ofw-mcp 2.26.1 → 2.27.1
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +47 -2
- package/dist/bundle.js +1724 -930
- package/dist/config.js +12 -0
- package/dist/tools/_shared.js +1 -1
- package/dist/tools/attachments.js +31 -2
- package/dist/tools/draft-freshness.js +17 -5
- package/dist/tools/held-attachments.js +50 -0
- package/dist/tools/lifecycle.js +7 -4
- package/dist/tools/messages.js +389 -107
- package/dist/tools/uploads.js +234 -0
- package/dist/version.js +1 -1
- package/mint.yaml +5 -0
- package/package.json +2 -2
- package/server.json +2 -2
- package/skills/ofw/SKILL.md +4 -4
package/dist/bundle.js
CHANGED
|
@@ -25,9 +25,9 @@ var __export = (target, all) => {
|
|
|
25
25
|
};
|
|
26
26
|
var __copyProps = (to, from, except, desc) => {
|
|
27
27
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
-
for (let
|
|
29
|
-
if (!__hasOwnProp.call(to,
|
|
30
|
-
__defProp(to,
|
|
28
|
+
for (let key2 of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
30
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
31
31
|
}
|
|
32
32
|
return to;
|
|
33
33
|
};
|
|
@@ -373,44 +373,44 @@ var require_permessage_deflate = __commonJS({
|
|
|
373
373
|
*/
|
|
374
374
|
normalizeParams(configurations) {
|
|
375
375
|
configurations.forEach((params) => {
|
|
376
|
-
Object.keys(params).forEach((
|
|
377
|
-
let value = params[
|
|
376
|
+
Object.keys(params).forEach((key2) => {
|
|
377
|
+
let value = params[key2];
|
|
378
378
|
if (value.length > 1) {
|
|
379
|
-
throw new Error(`Parameter "${
|
|
379
|
+
throw new Error(`Parameter "${key2}" must have only a single value`);
|
|
380
380
|
}
|
|
381
381
|
value = value[0];
|
|
382
|
-
if (
|
|
382
|
+
if (key2 === "client_max_window_bits") {
|
|
383
383
|
if (value !== true) {
|
|
384
384
|
const num = +value;
|
|
385
385
|
if (!Number.isInteger(num) || num < 8 || num > 15) {
|
|
386
386
|
throw new TypeError(
|
|
387
|
-
`Invalid value for parameter "${
|
|
387
|
+
`Invalid value for parameter "${key2}": ${value}`
|
|
388
388
|
);
|
|
389
389
|
}
|
|
390
390
|
value = num;
|
|
391
391
|
} else if (!this._isServer) {
|
|
392
392
|
throw new TypeError(
|
|
393
|
-
`Invalid value for parameter "${
|
|
393
|
+
`Invalid value for parameter "${key2}": ${value}`
|
|
394
394
|
);
|
|
395
395
|
}
|
|
396
|
-
} else if (
|
|
396
|
+
} else if (key2 === "server_max_window_bits") {
|
|
397
397
|
const num = +value;
|
|
398
398
|
if (!Number.isInteger(num) || num < 8 || num > 15) {
|
|
399
399
|
throw new TypeError(
|
|
400
|
-
`Invalid value for parameter "${
|
|
400
|
+
`Invalid value for parameter "${key2}": ${value}`
|
|
401
401
|
);
|
|
402
402
|
}
|
|
403
403
|
value = num;
|
|
404
|
-
} else if (
|
|
404
|
+
} else if (key2 === "client_no_context_takeover" || key2 === "server_no_context_takeover") {
|
|
405
405
|
if (value !== true) {
|
|
406
406
|
throw new TypeError(
|
|
407
|
-
`Invalid value for parameter "${
|
|
407
|
+
`Invalid value for parameter "${key2}": ${value}`
|
|
408
408
|
);
|
|
409
409
|
}
|
|
410
410
|
} else {
|
|
411
|
-
throw new Error(`Unknown parameter "${
|
|
411
|
+
throw new Error(`Unknown parameter "${key2}"`);
|
|
412
412
|
}
|
|
413
|
-
params[
|
|
413
|
+
params[key2] = value;
|
|
414
414
|
});
|
|
415
415
|
});
|
|
416
416
|
return configurations;
|
|
@@ -458,8 +458,8 @@ var require_permessage_deflate = __commonJS({
|
|
|
458
458
|
_decompress(data, fin, callback) {
|
|
459
459
|
const endpoint = this._isServer ? "client" : "server";
|
|
460
460
|
if (!this._inflate) {
|
|
461
|
-
const
|
|
462
|
-
const windowBits = typeof this.params[
|
|
461
|
+
const key2 = `${endpoint}_max_window_bits`;
|
|
462
|
+
const windowBits = typeof this.params[key2] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key2];
|
|
463
463
|
this._inflate = zlib.createInflateRaw({
|
|
464
464
|
...this._options.zlibInflateOptions,
|
|
465
465
|
windowBits
|
|
@@ -509,8 +509,8 @@ var require_permessage_deflate = __commonJS({
|
|
|
509
509
|
_compress(data, fin, callback) {
|
|
510
510
|
const endpoint = this._isServer ? "server" : "client";
|
|
511
511
|
if (!this._deflate) {
|
|
512
|
-
const
|
|
513
|
-
const windowBits = typeof this.params[
|
|
512
|
+
const key2 = `${endpoint}_max_window_bits`;
|
|
513
|
+
const windowBits = typeof this.params[key2] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key2];
|
|
514
514
|
this._deflate = zlib.createDeflateRaw({
|
|
515
515
|
...this._options.zlibDeflateOptions,
|
|
516
516
|
windowBits
|
|
@@ -2279,7 +2279,7 @@ var require_websocket = __commonJS({
|
|
|
2279
2279
|
var http = __require("http");
|
|
2280
2280
|
var net = __require("net");
|
|
2281
2281
|
var tls = __require("tls");
|
|
2282
|
-
var { randomBytes: randomBytes7, createHash:
|
|
2282
|
+
var { randomBytes: randomBytes7, createHash: createHash7 } = __require("crypto");
|
|
2283
2283
|
var { Duplex, Readable } = __require("stream");
|
|
2284
2284
|
var { URL: URL2 } = __require("url");
|
|
2285
2285
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -2830,7 +2830,7 @@ var require_websocket = __commonJS({
|
|
|
2830
2830
|
}
|
|
2831
2831
|
}
|
|
2832
2832
|
const defaultPort = isSecure ? 443 : 80;
|
|
2833
|
-
const
|
|
2833
|
+
const key2 = randomBytes7(16).toString("base64");
|
|
2834
2834
|
const request = isSecure ? https.request : http.request;
|
|
2835
2835
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
2836
2836
|
let perMessageDeflate;
|
|
@@ -2841,7 +2841,7 @@ var require_websocket = __commonJS({
|
|
|
2841
2841
|
opts.headers = {
|
|
2842
2842
|
...opts.headers,
|
|
2843
2843
|
"Sec-WebSocket-Version": opts.protocolVersion,
|
|
2844
|
-
"Sec-WebSocket-Key":
|
|
2844
|
+
"Sec-WebSocket-Key": key2,
|
|
2845
2845
|
Connection: "Upgrade",
|
|
2846
2846
|
Upgrade: "websocket"
|
|
2847
2847
|
};
|
|
@@ -2892,8 +2892,8 @@ var require_websocket = __commonJS({
|
|
|
2892
2892
|
const headers = options && options.headers;
|
|
2893
2893
|
options = { ...options, headers: {} };
|
|
2894
2894
|
if (headers) {
|
|
2895
|
-
for (const [
|
|
2896
|
-
options.headers[
|
|
2895
|
+
for (const [key3, value] of Object.entries(headers)) {
|
|
2896
|
+
options.headers[key3.toLowerCase()] = value;
|
|
2897
2897
|
}
|
|
2898
2898
|
}
|
|
2899
2899
|
} else if (websocket.listenerCount("redirect") === 0) {
|
|
@@ -2960,7 +2960,7 @@ var require_websocket = __commonJS({
|
|
|
2960
2960
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
2961
2961
|
return;
|
|
2962
2962
|
}
|
|
2963
|
-
const digest =
|
|
2963
|
+
const digest = createHash7("sha1").update(key2 + GUID).digest("base64");
|
|
2964
2964
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
2965
2965
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
2966
2966
|
return;
|
|
@@ -3329,7 +3329,7 @@ var require_websocket_server = __commonJS({
|
|
|
3329
3329
|
var EventEmitter = __require("events");
|
|
3330
3330
|
var http = __require("http");
|
|
3331
3331
|
var { Duplex } = __require("stream");
|
|
3332
|
-
var { createHash:
|
|
3332
|
+
var { createHash: createHash7 } = __require("crypto");
|
|
3333
3333
|
var extension2 = require_extension();
|
|
3334
3334
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
3335
3335
|
var subprotocol2 = require_subprotocol();
|
|
@@ -3528,7 +3528,7 @@ var require_websocket_server = __commonJS({
|
|
|
3528
3528
|
*/
|
|
3529
3529
|
handleUpgrade(req, socket, head, cb) {
|
|
3530
3530
|
socket.on("error", socketOnError);
|
|
3531
|
-
const
|
|
3531
|
+
const key2 = req.headers["sec-websocket-key"];
|
|
3532
3532
|
const upgrade = req.headers.upgrade;
|
|
3533
3533
|
const version2 = +req.headers["sec-websocket-version"];
|
|
3534
3534
|
if (req.method !== "GET") {
|
|
@@ -3541,7 +3541,7 @@ var require_websocket_server = __commonJS({
|
|
|
3541
3541
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
3542
3542
|
return;
|
|
3543
3543
|
}
|
|
3544
|
-
if (
|
|
3544
|
+
if (key2 === void 0 || !keyRegex.test(key2)) {
|
|
3545
3545
|
const message = "Missing or invalid Sec-WebSocket-Key header";
|
|
3546
3546
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
3547
3547
|
return;
|
|
@@ -3601,7 +3601,7 @@ var require_websocket_server = __commonJS({
|
|
|
3601
3601
|
}
|
|
3602
3602
|
this.completeUpgrade(
|
|
3603
3603
|
extensions,
|
|
3604
|
-
|
|
3604
|
+
key2,
|
|
3605
3605
|
protocols,
|
|
3606
3606
|
req,
|
|
3607
3607
|
socket,
|
|
@@ -3613,7 +3613,7 @@ var require_websocket_server = __commonJS({
|
|
|
3613
3613
|
}
|
|
3614
3614
|
if (!this.options.verifyClient(info)) return abortHandshake(socket, 401);
|
|
3615
3615
|
}
|
|
3616
|
-
this.completeUpgrade(extensions,
|
|
3616
|
+
this.completeUpgrade(extensions, key2, protocols, req, socket, head, cb);
|
|
3617
3617
|
}
|
|
3618
3618
|
/**
|
|
3619
3619
|
* Upgrade the connection to WebSocket.
|
|
@@ -3628,7 +3628,7 @@ var require_websocket_server = __commonJS({
|
|
|
3628
3628
|
* @throws {Error} If called more than once with the same socket
|
|
3629
3629
|
* @private
|
|
3630
3630
|
*/
|
|
3631
|
-
completeUpgrade(extensions,
|
|
3631
|
+
completeUpgrade(extensions, key2, protocols, req, socket, head, cb) {
|
|
3632
3632
|
if (!socket.readable || !socket.writable) return socket.destroy();
|
|
3633
3633
|
if (socket[kWebSocket]) {
|
|
3634
3634
|
throw new Error(
|
|
@@ -3636,7 +3636,7 @@ var require_websocket_server = __commonJS({
|
|
|
3636
3636
|
);
|
|
3637
3637
|
}
|
|
3638
3638
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
3639
|
-
const digest =
|
|
3639
|
+
const digest = createHash7("sha1").update(key2 + GUID).digest("base64");
|
|
3640
3640
|
const headers = [
|
|
3641
3641
|
"HTTP/1.1 101 Switching Protocols",
|
|
3642
3642
|
"Upgrade: websocket",
|
|
@@ -3798,12 +3798,12 @@ var __exportAll = (all, symbols) => {
|
|
|
3798
3798
|
};
|
|
3799
3799
|
var __copyProps2 = (to, from, except, desc) => {
|
|
3800
3800
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
3801
|
-
for (var keys = __getOwnPropNames2(from), i = 0, n = keys.length,
|
|
3802
|
-
|
|
3803
|
-
if (!__hasOwnProp2.call(to,
|
|
3804
|
-
__defProp2(to,
|
|
3805
|
-
get: ((k) => from[k]).bind(null,
|
|
3806
|
-
enumerable: !(desc = __getOwnPropDesc2(from,
|
|
3801
|
+
for (var keys = __getOwnPropNames2(from), i = 0, n = keys.length, key2; i < n; i++) {
|
|
3802
|
+
key2 = keys[i];
|
|
3803
|
+
if (!__hasOwnProp2.call(to, key2) && key2 !== except) {
|
|
3804
|
+
__defProp2(to, key2, {
|
|
3805
|
+
get: ((k) => from[k]).bind(null, key2),
|
|
3806
|
+
enumerable: !(desc = __getOwnPropDesc2(from, key2)) || desc.enumerable
|
|
3807
3807
|
});
|
|
3808
3808
|
}
|
|
3809
3809
|
}
|
|
@@ -4555,9 +4555,9 @@ function floatSafeRemainder(val, step) {
|
|
|
4555
4555
|
return ratio - roundedRatio;
|
|
4556
4556
|
}
|
|
4557
4557
|
var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
4558
|
-
function defineLazy(object2,
|
|
4558
|
+
function defineLazy(object2, key2, getter) {
|
|
4559
4559
|
let value = void 0;
|
|
4560
|
-
Object.defineProperty(object2,
|
|
4560
|
+
Object.defineProperty(object2, key2, {
|
|
4561
4561
|
get() {
|
|
4562
4562
|
if (value === EVALUATING) {
|
|
4563
4563
|
return void 0;
|
|
@@ -4569,7 +4569,7 @@ function defineLazy(object2, key, getter) {
|
|
|
4569
4569
|
return value;
|
|
4570
4570
|
},
|
|
4571
4571
|
set(v) {
|
|
4572
|
-
Object.defineProperty(object2,
|
|
4572
|
+
Object.defineProperty(object2, key2, {
|
|
4573
4573
|
value: v
|
|
4574
4574
|
// configurable: true,
|
|
4575
4575
|
});
|
|
@@ -4595,47 +4595,47 @@ function rawShape(def) {
|
|
|
4595
4595
|
function sourceShape(schema) {
|
|
4596
4596
|
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
4597
4597
|
}
|
|
4598
|
-
function deferProp(target,
|
|
4599
|
-
Object.defineProperty(target,
|
|
4598
|
+
function deferProp(target, key2, getter) {
|
|
4599
|
+
Object.defineProperty(target, key2, {
|
|
4600
4600
|
get() {
|
|
4601
4601
|
const value = getter();
|
|
4602
|
-
assignProp(this,
|
|
4602
|
+
assignProp(this, key2, value);
|
|
4603
4603
|
return value;
|
|
4604
4604
|
},
|
|
4605
4605
|
enumerable: true,
|
|
4606
4606
|
configurable: true
|
|
4607
4607
|
});
|
|
4608
4608
|
}
|
|
4609
|
-
function putProp(target,
|
|
4610
|
-
if (
|
|
4611
|
-
assignProp(target,
|
|
4609
|
+
function putProp(target, key2, value) {
|
|
4610
|
+
if (key2 in target)
|
|
4611
|
+
assignProp(target, key2, value);
|
|
4612
4612
|
else
|
|
4613
|
-
target[
|
|
4613
|
+
target[key2] = value;
|
|
4614
4614
|
}
|
|
4615
4615
|
function mirrorShape(target, source, keys, wrap) {
|
|
4616
4616
|
const raw = sourceShape(source);
|
|
4617
|
-
for (const
|
|
4618
|
-
const desc = Object.getOwnPropertyDescriptor(raw,
|
|
4617
|
+
for (const key2 of keys) {
|
|
4618
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key2);
|
|
4619
4619
|
if (!desc.enumerable)
|
|
4620
4620
|
continue;
|
|
4621
4621
|
if (desc.get) {
|
|
4622
|
-
deferProp(target,
|
|
4623
|
-
const value = source._zod.def.shape[
|
|
4624
|
-
return wrap ? wrap(value,
|
|
4622
|
+
deferProp(target, key2, () => {
|
|
4623
|
+
const value = source._zod.def.shape[key2];
|
|
4624
|
+
return wrap ? wrap(value, key2) : value;
|
|
4625
4625
|
});
|
|
4626
4626
|
} else
|
|
4627
|
-
putProp(target,
|
|
4627
|
+
putProp(target, key2, wrap ? wrap(desc.value, key2) : desc.value);
|
|
4628
4628
|
}
|
|
4629
4629
|
}
|
|
4630
4630
|
function mirrorProps(target, source) {
|
|
4631
|
-
for (const
|
|
4632
|
-
const desc = Object.getOwnPropertyDescriptor(source,
|
|
4631
|
+
for (const key2 of Reflect.ownKeys(source)) {
|
|
4632
|
+
const desc = Object.getOwnPropertyDescriptor(source, key2);
|
|
4633
4633
|
if (!desc.enumerable)
|
|
4634
4634
|
continue;
|
|
4635
4635
|
if (desc.get)
|
|
4636
|
-
deferProp(target,
|
|
4636
|
+
deferProp(target, key2, () => source[key2]);
|
|
4637
4637
|
else
|
|
4638
|
-
putProp(target,
|
|
4638
|
+
putProp(target, key2, desc.value);
|
|
4639
4639
|
}
|
|
4640
4640
|
}
|
|
4641
4641
|
function mergeDefs(...defs) {
|
|
@@ -4652,11 +4652,11 @@ function cloneDef(schema) {
|
|
|
4652
4652
|
function getElementAtPath(obj, path) {
|
|
4653
4653
|
if (!path)
|
|
4654
4654
|
return obj;
|
|
4655
|
-
return path.reduce((acc,
|
|
4655
|
+
return path.reduce((acc, key2) => acc?.[key2], obj);
|
|
4656
4656
|
}
|
|
4657
4657
|
function promiseAllObject(promisesObj) {
|
|
4658
4658
|
const keys = Object.keys(promisesObj);
|
|
4659
|
-
const promises = keys.map((
|
|
4659
|
+
const promises = keys.map((key2) => promisesObj[key2]);
|
|
4660
4660
|
return Promise.all(promises).then((results) => {
|
|
4661
4661
|
const resolvedObj = {};
|
|
4662
4662
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -4728,8 +4728,8 @@ function shallowClone(o) {
|
|
|
4728
4728
|
}
|
|
4729
4729
|
function numKeys(data) {
|
|
4730
4730
|
let keyCount = 0;
|
|
4731
|
-
for (const
|
|
4732
|
-
if (Object.prototype.hasOwnProperty.call(data,
|
|
4731
|
+
for (const key2 in data) {
|
|
4732
|
+
if (Object.prototype.hasOwnProperty.call(data, key2)) {
|
|
4733
4733
|
keyCount++;
|
|
4734
4734
|
}
|
|
4735
4735
|
}
|
|
@@ -4883,12 +4883,12 @@ function pick(schema, mask) {
|
|
|
4883
4883
|
function maskedKeys(schema, mask) {
|
|
4884
4884
|
const raw = sourceShape(schema);
|
|
4885
4885
|
const keys = [];
|
|
4886
|
-
for (const
|
|
4887
|
-
if (!Object.getOwnPropertyDescriptor(raw,
|
|
4888
|
-
throw new Error(`Unrecognized key: "${String(
|
|
4886
|
+
for (const key2 of Reflect.ownKeys(mask)) {
|
|
4887
|
+
if (!Object.getOwnPropertyDescriptor(raw, key2)?.enumerable) {
|
|
4888
|
+
throw new Error(`Unrecognized key: "${String(key2)}"`);
|
|
4889
4889
|
}
|
|
4890
|
-
if (mask[
|
|
4891
|
-
keys.push(
|
|
4890
|
+
if (mask[key2])
|
|
4891
|
+
keys.push(key2);
|
|
4892
4892
|
}
|
|
4893
4893
|
return keys;
|
|
4894
4894
|
}
|
|
@@ -4901,7 +4901,7 @@ function omit(schema, mask) {
|
|
|
4901
4901
|
}
|
|
4902
4902
|
const omitted = new Set(maskedKeys(schema, mask));
|
|
4903
4903
|
const newShape = {};
|
|
4904
|
-
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((
|
|
4904
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key2) => !omitted.has(key2)));
|
|
4905
4905
|
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
4906
4906
|
}
|
|
4907
4907
|
function extend(schema, shape) {
|
|
@@ -4912,8 +4912,8 @@ function extend(schema, shape) {
|
|
|
4912
4912
|
const hasChecks = checks && checks.length > 0;
|
|
4913
4913
|
if (hasChecks) {
|
|
4914
4914
|
const existingShape = sourceShape(schema);
|
|
4915
|
-
for (const
|
|
4916
|
-
if (Object.getOwnPropertyDescriptor(existingShape,
|
|
4915
|
+
for (const key2 of Reflect.ownKeys(shape)) {
|
|
4916
|
+
if (Object.getOwnPropertyDescriptor(existingShape, key2) !== void 0) {
|
|
4917
4917
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
4918
4918
|
}
|
|
4919
4919
|
}
|
|
@@ -4960,15 +4960,15 @@ function partial(Class2, schema, mask, name = "partial") {
|
|
|
4960
4960
|
}
|
|
4961
4961
|
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
4962
4962
|
const newShape = {};
|
|
4963
|
-
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class2 && ((value,
|
|
4963
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class2 && ((value, key2) => selected && !selected.has(key2) ? value : new Class2({ type: "optional", innerType: value })));
|
|
4964
4964
|
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
|
|
4965
4965
|
}
|
|
4966
4966
|
function required(Class2, schema, mask) {
|
|
4967
4967
|
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
4968
4968
|
const newShape = {};
|
|
4969
|
-
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value,
|
|
4969
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key2) => (
|
|
4970
4970
|
// overwrite with non-optional
|
|
4971
|
-
selected && !selected.has(
|
|
4971
|
+
selected && !selected.has(key2) ? value : new Class2({ type: "nonoptional", innerType: value })
|
|
4972
4972
|
));
|
|
4973
4973
|
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
|
|
4974
4974
|
}
|
|
@@ -5155,46 +5155,46 @@ var Class = class {
|
|
|
5155
5155
|
}
|
|
5156
5156
|
};
|
|
5157
5157
|
function members(proto, table) {
|
|
5158
|
-
for (const
|
|
5159
|
-
const desc = Object.getOwnPropertyDescriptor(table,
|
|
5158
|
+
for (const key2 in table) {
|
|
5159
|
+
const desc = Object.getOwnPropertyDescriptor(table, key2);
|
|
5160
5160
|
if (desc.get)
|
|
5161
|
-
Object.defineProperty(proto,
|
|
5161
|
+
Object.defineProperty(proto, key2, { ...desc, enumerable: false });
|
|
5162
5162
|
else
|
|
5163
|
-
defineBound(proto,
|
|
5163
|
+
defineBound(proto, key2, desc.value);
|
|
5164
5164
|
}
|
|
5165
5165
|
}
|
|
5166
|
-
function own(inst,
|
|
5167
|
-
Object.defineProperty(inst,
|
|
5166
|
+
function own(inst, key2, value, enumerable = true) {
|
|
5167
|
+
Object.defineProperty(inst, key2, { configurable: true, writable: true, enumerable, value });
|
|
5168
5168
|
return value;
|
|
5169
5169
|
}
|
|
5170
|
-
function hide(inst,
|
|
5171
|
-
return own(inst,
|
|
5170
|
+
function hide(inst, key2, value) {
|
|
5171
|
+
return own(inst, key2, value, false);
|
|
5172
5172
|
}
|
|
5173
5173
|
// @__NO_SIDE_EFFECTS__
|
|
5174
5174
|
function derived(computes, table) {
|
|
5175
|
-
for (const
|
|
5176
|
-
const compute = computes[
|
|
5177
|
-
Object.defineProperty(table,
|
|
5175
|
+
for (const key2 in computes) {
|
|
5176
|
+
const compute = computes[key2];
|
|
5177
|
+
Object.defineProperty(table, key2, {
|
|
5178
5178
|
configurable: true,
|
|
5179
5179
|
enumerable: true,
|
|
5180
5180
|
get() {
|
|
5181
|
-
return own(this,
|
|
5181
|
+
return own(this, key2, compute(this));
|
|
5182
5182
|
},
|
|
5183
5183
|
set(value) {
|
|
5184
|
-
own(this,
|
|
5184
|
+
own(this, key2, value);
|
|
5185
5185
|
}
|
|
5186
5186
|
});
|
|
5187
5187
|
}
|
|
5188
5188
|
return table;
|
|
5189
5189
|
}
|
|
5190
|
-
function defineBound(proto,
|
|
5191
|
-
Object.defineProperty(proto,
|
|
5190
|
+
function defineBound(proto, key2, fn) {
|
|
5191
|
+
Object.defineProperty(proto, key2, {
|
|
5192
5192
|
configurable: true,
|
|
5193
5193
|
get() {
|
|
5194
|
-
return this == null ? fn : own(this,
|
|
5194
|
+
return this == null ? fn : own(this, key2, fn.bind(this));
|
|
5195
5195
|
},
|
|
5196
5196
|
set(value) {
|
|
5197
|
-
own(this,
|
|
5197
|
+
own(this, key2, value);
|
|
5198
5198
|
}
|
|
5199
5199
|
});
|
|
5200
5200
|
}
|
|
@@ -5211,53 +5211,53 @@ var breaker = {
|
|
|
5211
5211
|
return void 0;
|
|
5212
5212
|
}
|
|
5213
5213
|
};
|
|
5214
|
-
function defineLazyInternal(inst,
|
|
5214
|
+
function defineLazyInternal(inst, key2, compute) {
|
|
5215
5215
|
const proto = Object.getPrototypeOf(inst._zod);
|
|
5216
|
-
if (
|
|
5216
|
+
if (key2 in proto && installing !== inst._zod) {
|
|
5217
5217
|
installing = void 0;
|
|
5218
5218
|
return;
|
|
5219
5219
|
}
|
|
5220
5220
|
installing = inst._zod;
|
|
5221
|
-
Object.defineProperty(proto,
|
|
5221
|
+
Object.defineProperty(proto, key2, {
|
|
5222
5222
|
configurable: true,
|
|
5223
5223
|
get() {
|
|
5224
|
-
Object.defineProperty(this,
|
|
5224
|
+
Object.defineProperty(this, key2, breaker);
|
|
5225
5225
|
const outer = broke;
|
|
5226
5226
|
broke = false;
|
|
5227
5227
|
try {
|
|
5228
5228
|
const value = compute(this);
|
|
5229
5229
|
if (broke)
|
|
5230
|
-
delete this[
|
|
5230
|
+
delete this[key2];
|
|
5231
5231
|
else
|
|
5232
|
-
Object.defineProperty(this,
|
|
5232
|
+
Object.defineProperty(this, key2, { configurable: true, writable: true, value });
|
|
5233
5233
|
broke = broke || outer;
|
|
5234
5234
|
return value;
|
|
5235
5235
|
} catch (err) {
|
|
5236
|
-
delete this[
|
|
5236
|
+
delete this[key2];
|
|
5237
5237
|
broke = broke || outer;
|
|
5238
5238
|
throw err;
|
|
5239
5239
|
}
|
|
5240
5240
|
},
|
|
5241
5241
|
set(value) {
|
|
5242
|
-
Object.defineProperty(this,
|
|
5242
|
+
Object.defineProperty(this, key2, { configurable: true, writable: true, value });
|
|
5243
5243
|
}
|
|
5244
5244
|
});
|
|
5245
5245
|
}
|
|
5246
|
-
function installLazyProp(inst,
|
|
5247
|
-
const proto = claim(inst,
|
|
5246
|
+
function installLazyProp(inst, key2, make, enumerable) {
|
|
5247
|
+
const proto = claim(inst, key2);
|
|
5248
5248
|
if (!proto)
|
|
5249
5249
|
return;
|
|
5250
|
-
Object.defineProperty(proto,
|
|
5250
|
+
Object.defineProperty(proto, key2, {
|
|
5251
5251
|
configurable: true,
|
|
5252
5252
|
get() {
|
|
5253
5253
|
const desc = { configurable: true, writable: true, enumerable, value: void 0 };
|
|
5254
|
-
Object.defineProperty(this,
|
|
5254
|
+
Object.defineProperty(this, key2, desc);
|
|
5255
5255
|
desc.value = make(this);
|
|
5256
|
-
Object.defineProperty(this,
|
|
5256
|
+
Object.defineProperty(this, key2, desc);
|
|
5257
5257
|
return desc.value;
|
|
5258
5258
|
},
|
|
5259
5259
|
set(value) {
|
|
5260
|
-
Object.defineProperty(this,
|
|
5260
|
+
Object.defineProperty(this, key2, { configurable: true, writable: true, enumerable, value });
|
|
5261
5261
|
}
|
|
5262
5262
|
});
|
|
5263
5263
|
}
|
|
@@ -5434,15 +5434,15 @@ var $ZodError = $constructor("$ZodError", initializer);
|
|
|
5434
5434
|
var $ZodRealError = $constructor("$ZodError", initializer, void 0, {
|
|
5435
5435
|
Parent: Error
|
|
5436
5436
|
});
|
|
5437
|
-
function node(obj,
|
|
5438
|
-
if (!Object.prototype.hasOwnProperty.call(obj,
|
|
5439
|
-
if (
|
|
5440
|
-
Object.defineProperty(obj,
|
|
5437
|
+
function node(obj, key2, make) {
|
|
5438
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key2)) {
|
|
5439
|
+
if (key2 === "__proto__") {
|
|
5440
|
+
Object.defineProperty(obj, key2, { value: make(), writable: true, enumerable: true, configurable: true });
|
|
5441
5441
|
} else {
|
|
5442
|
-
obj[
|
|
5442
|
+
obj[key2] = make();
|
|
5443
5443
|
}
|
|
5444
5444
|
}
|
|
5445
|
-
return obj[
|
|
5445
|
+
return obj[key2];
|
|
5446
5446
|
}
|
|
5447
5447
|
function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
5448
5448
|
const fieldErrors = {};
|
|
@@ -6351,16 +6351,16 @@ var $ZodCheckProperties = /* @__PURE__ */ $constructor("$ZodCheckProperties", (i
|
|
|
6351
6351
|
payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
|
|
6352
6352
|
return void 0;
|
|
6353
6353
|
}
|
|
6354
|
-
entries ?? (entries = Reflect.ownKeys(def.shape).map((
|
|
6354
|
+
entries ?? (entries = Reflect.ownKeys(def.shape).map((key2) => [key2, def.shape[key2]]));
|
|
6355
6355
|
const input2 = payload.value;
|
|
6356
6356
|
let proms;
|
|
6357
|
-
for (const [
|
|
6358
|
-
const result = schema._zod.run({ value: input2[
|
|
6357
|
+
for (const [key2, schema] of entries) {
|
|
6358
|
+
const result = schema._zod.run({ value: input2[key2], issues: [] }, {});
|
|
6359
6359
|
if (result instanceof Promise) {
|
|
6360
6360
|
proms ?? (proms = []);
|
|
6361
|
-
proms.push(result.then((result2) => handleCheckPropertyResult(result2, payload,
|
|
6361
|
+
proms.push(result.then((result2) => handleCheckPropertyResult(result2, payload, key2)));
|
|
6362
6362
|
} else {
|
|
6363
|
-
handleCheckPropertyResult(result, payload,
|
|
6363
|
+
handleCheckPropertyResult(result, payload, key2);
|
|
6364
6364
|
}
|
|
6365
6365
|
}
|
|
6366
6366
|
if (proms)
|
|
@@ -7261,8 +7261,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
7261
7261
|
};
|
|
7262
7262
|
capSize(inst, arraySize);
|
|
7263
7263
|
});
|
|
7264
|
-
function handlePropertyResult(result, final,
|
|
7265
|
-
const isPresent =
|
|
7264
|
+
function handlePropertyResult(result, final, key2, input2, optin, optout) {
|
|
7265
|
+
const isPresent = key2 in input2;
|
|
7266
7266
|
const isOptionalOut = optout === "optional";
|
|
7267
7267
|
if (!isPresent && isOptionalOut && optin === "optional") {
|
|
7268
7268
|
return;
|
|
@@ -7271,7 +7271,7 @@ function handlePropertyResult(result, final, key, input2, optin, optout) {
|
|
|
7271
7271
|
if (optin !== void 0 && isOptionalOut && !isPresent) {
|
|
7272
7272
|
return;
|
|
7273
7273
|
}
|
|
7274
|
-
final.issues.push(...prefixIssues(
|
|
7274
|
+
final.issues.push(...prefixIssues(key2, result.issues));
|
|
7275
7275
|
}
|
|
7276
7276
|
if (!isPresent && optin === void 0) {
|
|
7277
7277
|
if (!result.issues.length) {
|
|
@@ -7279,17 +7279,17 @@ function handlePropertyResult(result, final, key, input2, optin, optout) {
|
|
|
7279
7279
|
code: "invalid_type",
|
|
7280
7280
|
expected: "nonoptional",
|
|
7281
7281
|
input: void 0,
|
|
7282
|
-
path: [
|
|
7282
|
+
path: [key2]
|
|
7283
7283
|
});
|
|
7284
7284
|
}
|
|
7285
7285
|
return;
|
|
7286
7286
|
}
|
|
7287
7287
|
if (result.value === void 0) {
|
|
7288
7288
|
if (isPresent || optin === "defaulted" && !isOptionalOut) {
|
|
7289
|
-
final.value[
|
|
7289
|
+
final.value[key2] = void 0;
|
|
7290
7290
|
}
|
|
7291
7291
|
} else {
|
|
7292
|
-
final.value[
|
|
7292
|
+
final.value[key2] = result.value;
|
|
7293
7293
|
}
|
|
7294
7294
|
}
|
|
7295
7295
|
var NO_SYMBOL_KEYS = [];
|
|
@@ -7322,28 +7322,28 @@ function handleCatchall(proms, input2, payload, ctx, def, inst, abortEarly) {
|
|
|
7322
7322
|
const optin = _catchall.optin;
|
|
7323
7323
|
const optout = _catchall.optout;
|
|
7324
7324
|
let seen = 0;
|
|
7325
|
-
for (const
|
|
7325
|
+
for (const key2 in input2) {
|
|
7326
7326
|
if (abortEarly && payload.issues.length !== seen) {
|
|
7327
7327
|
if (aborted(payload, seen))
|
|
7328
7328
|
break;
|
|
7329
7329
|
seen = payload.issues.length;
|
|
7330
7330
|
}
|
|
7331
|
-
if (keySet.has(
|
|
7331
|
+
if (keySet.has(key2))
|
|
7332
7332
|
continue;
|
|
7333
|
-
if (
|
|
7333
|
+
if (key2 === "__proto__") {
|
|
7334
7334
|
if (t === "never")
|
|
7335
|
-
unrecognized.push(
|
|
7335
|
+
unrecognized.push(key2);
|
|
7336
7336
|
continue;
|
|
7337
7337
|
}
|
|
7338
7338
|
if (t === "never") {
|
|
7339
|
-
unrecognized.push(
|
|
7339
|
+
unrecognized.push(key2);
|
|
7340
7340
|
continue;
|
|
7341
7341
|
}
|
|
7342
|
-
const r = _catchall.run({ value: input2[
|
|
7342
|
+
const r = _catchall.run({ value: input2[key2], issues: [] }, ctx);
|
|
7343
7343
|
if (r instanceof Promise) {
|
|
7344
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload,
|
|
7344
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key2, input2, optin, optout)));
|
|
7345
7345
|
} else {
|
|
7346
|
-
handlePropertyResult(r, payload,
|
|
7346
|
+
handlePropertyResult(r, payload, key2, input2, optin, optout);
|
|
7347
7347
|
}
|
|
7348
7348
|
}
|
|
7349
7349
|
if (unrecognized.length) {
|
|
@@ -7380,16 +7380,16 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
7380
7380
|
defineLazyInternal(inst, "propValues", (zod) => {
|
|
7381
7381
|
const shape = zod.def.shape;
|
|
7382
7382
|
const propValues = {};
|
|
7383
|
-
for (const
|
|
7384
|
-
const field = shape[
|
|
7383
|
+
for (const key2 in shape) {
|
|
7384
|
+
const field = shape[key2]._zod;
|
|
7385
7385
|
if (field.values) {
|
|
7386
|
-
if (!Object.prototype.hasOwnProperty.call(propValues,
|
|
7387
|
-
assignProp(propValues,
|
|
7386
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key2)) {
|
|
7387
|
+
assignProp(propValues, key2, /* @__PURE__ */ new Set());
|
|
7388
7388
|
}
|
|
7389
7389
|
for (const v of field.values)
|
|
7390
|
-
propValues[
|
|
7390
|
+
propValues[key2].add(v);
|
|
7391
7391
|
if (field.optin !== void 0)
|
|
7392
|
-
propValues[
|
|
7392
|
+
propValues[key2].add(void 0);
|
|
7393
7393
|
}
|
|
7394
7394
|
}
|
|
7395
7395
|
return propValues;
|
|
@@ -7416,22 +7416,22 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
7416
7416
|
const shape = value.shape;
|
|
7417
7417
|
const abortEarly = ctx?.abortEarly;
|
|
7418
7418
|
let seen = payload.issues.length;
|
|
7419
|
-
for (const
|
|
7419
|
+
for (const key2 of value.allKeys) {
|
|
7420
7420
|
if (abortEarly && payload.issues.length !== seen) {
|
|
7421
7421
|
if (aborted(payload, seen))
|
|
7422
7422
|
break;
|
|
7423
7423
|
seen = payload.issues.length;
|
|
7424
7424
|
}
|
|
7425
|
-
if (
|
|
7425
|
+
if (key2 === "__proto__")
|
|
7426
7426
|
continue;
|
|
7427
|
-
const el = shape[
|
|
7427
|
+
const el = shape[key2];
|
|
7428
7428
|
const optin = el._zod.optin;
|
|
7429
7429
|
const optout = el._zod.optout;
|
|
7430
|
-
const r = el._zod.run({ value: input2[
|
|
7430
|
+
const r = el._zod.run({ value: input2[key2], issues: [] }, ctx);
|
|
7431
7431
|
if (r instanceof Promise) {
|
|
7432
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload,
|
|
7432
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key2, input2, optin, optout)));
|
|
7433
7433
|
} else {
|
|
7434
|
-
handlePropertyResult(r, payload,
|
|
7434
|
+
handlePropertyResult(r, payload, key2, input2, optin, optout);
|
|
7435
7435
|
}
|
|
7436
7436
|
}
|
|
7437
7437
|
if (!catchall) {
|
|
@@ -7465,17 +7465,17 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
7465
7465
|
doc.write(`const input = payload.value;`);
|
|
7466
7466
|
const ids = /* @__PURE__ */ Object.create(null);
|
|
7467
7467
|
let counter = 0;
|
|
7468
|
-
for (const
|
|
7469
|
-
ids[
|
|
7468
|
+
for (const key2 of normalized.allKeys) {
|
|
7469
|
+
ids[key2] = `key_${counter++}`;
|
|
7470
7470
|
}
|
|
7471
7471
|
doc.write(memo3 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
7472
|
-
for (const
|
|
7473
|
-
if (
|
|
7472
|
+
for (const key2 of normalized.allKeys) {
|
|
7473
|
+
if (key2 === "__proto__")
|
|
7474
7474
|
continue;
|
|
7475
|
-
const id2 = ids[
|
|
7476
|
-
const k = typeof
|
|
7475
|
+
const id2 = ids[key2];
|
|
7476
|
+
const k = typeof key2 === "symbol" ? `syms[${syms.indexOf(key2)}]` : esc(key2);
|
|
7477
7477
|
const isPresent = `${k} in input`;
|
|
7478
|
-
const schema = shape[
|
|
7478
|
+
const schema = shape[key2];
|
|
7479
7479
|
const optin = schema?._zod?.optin;
|
|
7480
7480
|
const isOptionalIn = optin !== void 0;
|
|
7481
7481
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
@@ -7809,21 +7809,21 @@ function mergeValues(a, b) {
|
|
|
7809
7809
|
}
|
|
7810
7810
|
if (isPlainObject(a) && isPlainObject(b)) {
|
|
7811
7811
|
const bKeys = Object.keys(b);
|
|
7812
|
-
const sharedKeys = Object.keys(a).filter((
|
|
7812
|
+
const sharedKeys = Object.keys(a).filter((key2) => bKeys.indexOf(key2) !== -1);
|
|
7813
7813
|
const newObj = { ...a, ...b };
|
|
7814
7814
|
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
|
|
7815
7815
|
delete newObj.__proto__;
|
|
7816
|
-
for (const
|
|
7817
|
-
if (
|
|
7816
|
+
for (const key2 of sharedKeys) {
|
|
7817
|
+
if (key2 === "__proto__")
|
|
7818
7818
|
continue;
|
|
7819
|
-
const sharedValue = mergeValues(a[
|
|
7819
|
+
const sharedValue = mergeValues(a[key2], b[key2]);
|
|
7820
7820
|
if (!sharedValue.valid) {
|
|
7821
7821
|
return {
|
|
7822
7822
|
valid: false,
|
|
7823
|
-
mergeErrorPath: [
|
|
7823
|
+
mergeErrorPath: [key2, ...sharedValue.mergeErrorPath]
|
|
7824
7824
|
};
|
|
7825
7825
|
}
|
|
7826
|
-
newObj[
|
|
7826
|
+
newObj[key2] = sharedValue.data;
|
|
7827
7827
|
}
|
|
7828
7828
|
return { valid: true, data: newObj };
|
|
7829
7829
|
}
|
|
@@ -7982,9 +7982,9 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
7982
7982
|
return handleTupleResults(itemResults, payload, items, input2, optoutStart);
|
|
7983
7983
|
};
|
|
7984
7984
|
});
|
|
7985
|
-
function getTupleOptStart(items,
|
|
7985
|
+
function getTupleOptStart(items, key2) {
|
|
7986
7986
|
for (let i = items.length - 1; i >= 0; i--) {
|
|
7987
|
-
const omittable =
|
|
7987
|
+
const omittable = key2 === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional";
|
|
7988
7988
|
if (!omittable)
|
|
7989
7989
|
return i + 1;
|
|
7990
7990
|
}
|
|
@@ -8042,12 +8042,12 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
8042
8042
|
if (values && !def.partial) {
|
|
8043
8043
|
payload.value = memo3 ? memo3.alloc(inst, payload, {}, ctx) : {};
|
|
8044
8044
|
const recordKeys = /* @__PURE__ */ new Set();
|
|
8045
|
-
for (const
|
|
8046
|
-
if (typeof
|
|
8047
|
-
recordKeys.add(typeof
|
|
8048
|
-
if (
|
|
8045
|
+
for (const key2 of values) {
|
|
8046
|
+
if (typeof key2 === "string" || typeof key2 === "number" || typeof key2 === "symbol") {
|
|
8047
|
+
recordKeys.add(typeof key2 === "number" ? key2.toString() : key2);
|
|
8048
|
+
if (key2 === "__proto__")
|
|
8049
8049
|
continue;
|
|
8050
|
-
const keyResult = def.keyType._zod.run({ value:
|
|
8050
|
+
const keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx);
|
|
8051
8051
|
if (keyResult instanceof Promise) {
|
|
8052
8052
|
throw new Error("Async schemas not supported in object keys currently");
|
|
8053
8053
|
}
|
|
@@ -8056,8 +8056,8 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
8056
8056
|
code: "invalid_key",
|
|
8057
8057
|
origin: "record",
|
|
8058
8058
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
8059
|
-
input:
|
|
8060
|
-
path: [
|
|
8059
|
+
input: key2,
|
|
8060
|
+
path: [key2],
|
|
8061
8061
|
inst
|
|
8062
8062
|
});
|
|
8063
8063
|
continue;
|
|
@@ -8065,32 +8065,32 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
8065
8065
|
const outKey = keyResult.value;
|
|
8066
8066
|
if (outKey === "__proto__")
|
|
8067
8067
|
continue;
|
|
8068
|
-
const result = def.valueType._zod.run({ value: input2[
|
|
8068
|
+
const result = def.valueType._zod.run({ value: input2[key2], issues: [] }, ctx);
|
|
8069
8069
|
if (result instanceof Promise) {
|
|
8070
8070
|
proms.push(result.then((result2) => {
|
|
8071
8071
|
if (result2.issues.length) {
|
|
8072
|
-
payload.issues.push(...prefixIssues(
|
|
8072
|
+
payload.issues.push(...prefixIssues(key2, result2.issues));
|
|
8073
8073
|
}
|
|
8074
8074
|
payload.value[outKey] = result2.value;
|
|
8075
8075
|
}));
|
|
8076
8076
|
} else {
|
|
8077
8077
|
if (result.issues.length) {
|
|
8078
|
-
payload.issues.push(...prefixIssues(
|
|
8078
|
+
payload.issues.push(...prefixIssues(key2, result.issues));
|
|
8079
8079
|
}
|
|
8080
8080
|
payload.value[outKey] = result.value;
|
|
8081
8081
|
}
|
|
8082
8082
|
}
|
|
8083
8083
|
}
|
|
8084
8084
|
let unrecognized;
|
|
8085
|
-
for (const
|
|
8086
|
-
if (!recordKeys.has(
|
|
8085
|
+
for (const key2 in input2) {
|
|
8086
|
+
if (!recordKeys.has(key2)) {
|
|
8087
8087
|
if (def.mode === "loose") {
|
|
8088
|
-
if (
|
|
8088
|
+
if (key2 === "__proto__")
|
|
8089
8089
|
continue;
|
|
8090
|
-
payload.value[
|
|
8090
|
+
payload.value[key2] = input2[key2];
|
|
8091
8091
|
} else {
|
|
8092
8092
|
unrecognized = unrecognized ?? [];
|
|
8093
|
-
unrecognized.push(
|
|
8093
|
+
unrecognized.push(key2);
|
|
8094
8094
|
}
|
|
8095
8095
|
}
|
|
8096
8096
|
}
|
|
@@ -8106,18 +8106,18 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
8106
8106
|
} else {
|
|
8107
8107
|
payload.value = memo3 ? memo3.alloc(inst, payload, {}, ctx) : {};
|
|
8108
8108
|
let unrecognized;
|
|
8109
|
-
for (const
|
|
8110
|
-
if (
|
|
8109
|
+
for (const key2 of Reflect.ownKeys(input2)) {
|
|
8110
|
+
if (key2 === "__proto__")
|
|
8111
8111
|
continue;
|
|
8112
|
-
if (!Object.prototype.propertyIsEnumerable.call(input2,
|
|
8112
|
+
if (!Object.prototype.propertyIsEnumerable.call(input2, key2))
|
|
8113
8113
|
continue;
|
|
8114
|
-
let keyResult = def.keyType._zod.run({ value:
|
|
8114
|
+
let keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx);
|
|
8115
8115
|
if (keyResult instanceof Promise) {
|
|
8116
8116
|
throw new Error("Async schemas not supported in object keys currently");
|
|
8117
8117
|
}
|
|
8118
|
-
const checkNumericKey = typeof
|
|
8118
|
+
const checkNumericKey = typeof key2 === "string" && number.test(key2) && keyResult.issues.length;
|
|
8119
8119
|
if (checkNumericKey) {
|
|
8120
|
-
const retryResult = def.keyType._zod.run({ value: Number(
|
|
8120
|
+
const retryResult = def.keyType._zod.run({ value: Number(key2), issues: [] }, ctx);
|
|
8121
8121
|
if (retryResult instanceof Promise) {
|
|
8122
8122
|
throw new Error("Async schemas not supported in object keys currently");
|
|
8123
8123
|
}
|
|
@@ -8127,17 +8127,17 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
8127
8127
|
}
|
|
8128
8128
|
if (keyResult.issues.length) {
|
|
8129
8129
|
if (def.mode === "loose") {
|
|
8130
|
-
payload.value[
|
|
8130
|
+
payload.value[key2] = input2[key2];
|
|
8131
8131
|
} else if (values) {
|
|
8132
8132
|
unrecognized = unrecognized ?? [];
|
|
8133
|
-
unrecognized.push(
|
|
8133
|
+
unrecognized.push(key2);
|
|
8134
8134
|
} else {
|
|
8135
8135
|
payload.issues.push({
|
|
8136
8136
|
code: "invalid_key",
|
|
8137
8137
|
origin: "record",
|
|
8138
8138
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
8139
|
-
input:
|
|
8140
|
-
path: [
|
|
8139
|
+
input: key2,
|
|
8140
|
+
path: [key2],
|
|
8141
8141
|
inst
|
|
8142
8142
|
});
|
|
8143
8143
|
}
|
|
@@ -8146,17 +8146,17 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
8146
8146
|
const outKey = keyResult.value;
|
|
8147
8147
|
if (outKey === "__proto__")
|
|
8148
8148
|
continue;
|
|
8149
|
-
const result = def.valueType._zod.run({ value: input2[
|
|
8149
|
+
const result = def.valueType._zod.run({ value: input2[key2], issues: [] }, ctx);
|
|
8150
8150
|
if (result instanceof Promise) {
|
|
8151
8151
|
proms.push(result.then((result2) => {
|
|
8152
8152
|
if (result2.issues.length) {
|
|
8153
|
-
payload.issues.push(...prefixIssues(
|
|
8153
|
+
payload.issues.push(...prefixIssues(key2, result2.issues));
|
|
8154
8154
|
}
|
|
8155
8155
|
payload.value[outKey] = result2.value;
|
|
8156
8156
|
}));
|
|
8157
8157
|
} else {
|
|
8158
8158
|
if (result.issues.length) {
|
|
8159
|
-
payload.issues.push(...prefixIssues(
|
|
8159
|
+
payload.issues.push(...prefixIssues(key2, result.issues));
|
|
8160
8160
|
}
|
|
8161
8161
|
payload.value[outKey] = result.value;
|
|
8162
8162
|
}
|
|
@@ -8196,20 +8196,20 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
|
8196
8196
|
payload.value = memo3 ? memo3.alloc(inst, payload, /* @__PURE__ */ new Map(), ctx) : /* @__PURE__ */ new Map();
|
|
8197
8197
|
const abortEarly = ctx?.abortEarly;
|
|
8198
8198
|
let seen = payload.issues.length;
|
|
8199
|
-
for (const [
|
|
8199
|
+
for (const [key2, value] of input2) {
|
|
8200
8200
|
if (abortEarly && payload.issues.length !== seen) {
|
|
8201
8201
|
if (aborted(payload, seen))
|
|
8202
8202
|
break;
|
|
8203
8203
|
seen = payload.issues.length;
|
|
8204
8204
|
}
|
|
8205
|
-
const keyResult = def.keyType._zod.run({ value:
|
|
8205
|
+
const keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx);
|
|
8206
8206
|
const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
|
|
8207
8207
|
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
|
8208
8208
|
proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
|
|
8209
|
-
handleMapResult(keyResult2, valueResult2, payload,
|
|
8209
|
+
handleMapResult(keyResult2, valueResult2, payload, key2, input2, inst, ctx);
|
|
8210
8210
|
}));
|
|
8211
8211
|
} else {
|
|
8212
|
-
handleMapResult(keyResult, valueResult, payload,
|
|
8212
|
+
handleMapResult(keyResult, valueResult, payload, key2, input2, inst, ctx);
|
|
8213
8213
|
}
|
|
8214
8214
|
}
|
|
8215
8215
|
if (proms.length)
|
|
@@ -8218,10 +8218,10 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
|
8218
8218
|
};
|
|
8219
8219
|
capSize(inst, mapSize);
|
|
8220
8220
|
});
|
|
8221
|
-
function handleMapResult(keyResult, valueResult, final,
|
|
8221
|
+
function handleMapResult(keyResult, valueResult, final, key2, input2, inst, ctx) {
|
|
8222
8222
|
if (keyResult.issues.length) {
|
|
8223
|
-
if (propertyKeyTypes.has(typeof
|
|
8224
|
-
final.issues.push(...prefixIssues(
|
|
8223
|
+
if (propertyKeyTypes.has(typeof key2)) {
|
|
8224
|
+
final.issues.push(...prefixIssues(key2, keyResult.issues));
|
|
8225
8225
|
} else {
|
|
8226
8226
|
final.issues.push({
|
|
8227
8227
|
code: "invalid_key",
|
|
@@ -8233,15 +8233,15 @@ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx)
|
|
|
8233
8233
|
}
|
|
8234
8234
|
}
|
|
8235
8235
|
if (valueResult.issues.length) {
|
|
8236
|
-
if (propertyKeyTypes.has(typeof
|
|
8237
|
-
final.issues.push(...prefixIssues(
|
|
8236
|
+
if (propertyKeyTypes.has(typeof key2)) {
|
|
8237
|
+
final.issues.push(...prefixIssues(key2, valueResult.issues));
|
|
8238
8238
|
} else {
|
|
8239
8239
|
final.issues.push({
|
|
8240
8240
|
origin: "map",
|
|
8241
8241
|
code: "invalid_element",
|
|
8242
8242
|
input: input2,
|
|
8243
8243
|
inst,
|
|
8244
|
-
key,
|
|
8244
|
+
key: key2,
|
|
8245
8245
|
issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
|
|
8246
8246
|
});
|
|
8247
8247
|
}
|
|
@@ -8916,8 +8916,8 @@ function isRecursive(inst, stack, resolve8) {
|
|
|
8916
8916
|
};
|
|
8917
8917
|
const shape = (sh, spread) => {
|
|
8918
8918
|
let answer = NONE;
|
|
8919
|
-
for (const
|
|
8920
|
-
const desc = Object.getOwnPropertyDescriptor(sh,
|
|
8919
|
+
for (const key2 of Reflect.ownKeys(sh)) {
|
|
8920
|
+
const desc = Object.getOwnPropertyDescriptor(sh, key2);
|
|
8921
8921
|
if (spread && !desc.enumerable)
|
|
8922
8922
|
continue;
|
|
8923
8923
|
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve8) : NONE;
|
|
@@ -9013,8 +9013,8 @@ function isRecursive(inst, stack, resolve8) {
|
|
|
9013
9013
|
break;
|
|
9014
9014
|
default: {
|
|
9015
9015
|
kind;
|
|
9016
|
-
for (const
|
|
9017
|
-
const desc = Object.getOwnPropertyDescriptor(def,
|
|
9016
|
+
for (const key2 in def) {
|
|
9017
|
+
const desc = Object.getOwnPropertyDescriptor(def, key2);
|
|
9018
9018
|
if (!desc || desc.get)
|
|
9019
9019
|
continue;
|
|
9020
9020
|
const value = desc.value;
|
|
@@ -17147,11 +17147,11 @@ function generatePropertiesChecks(doc, ctx, def, accessor) {
|
|
|
17147
17147
|
}
|
|
17148
17148
|
doc.write(`if (${accessor} == null) return INVALID;`);
|
|
17149
17149
|
const shape = def.shape;
|
|
17150
|
-
for (const
|
|
17151
|
-
const keyExpr = typeof
|
|
17150
|
+
for (const key2 of Reflect.ownKeys(shape)) {
|
|
17151
|
+
const keyExpr = typeof key2 === "symbol" ? addConstant(ctx, key2) : esc(key2);
|
|
17152
17152
|
const inputVar = newVar(ctx);
|
|
17153
17153
|
doc.write(`const ${inputVar} = ${accessor}[${keyExpr}];`);
|
|
17154
|
-
compileChild(doc, ctx, shape[
|
|
17154
|
+
compileChild(doc, ctx, shape[key2], inputVar, false);
|
|
17155
17155
|
}
|
|
17156
17156
|
}
|
|
17157
17157
|
function generatePropertyCheck(doc, ctx, def, accessor) {
|
|
@@ -17544,9 +17544,9 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
17544
17544
|
throw new ZodCompileUnsupportedError('object shape key "__proto__"');
|
|
17545
17545
|
}
|
|
17546
17546
|
const propOutputs = /* @__PURE__ */ new Map();
|
|
17547
|
-
for (const
|
|
17548
|
-
const propSchema = propShape[
|
|
17549
|
-
const kx = keyExpr(
|
|
17547
|
+
for (const key2 of allKeys) {
|
|
17548
|
+
const propSchema = propShape[key2];
|
|
17549
|
+
const kx = keyExpr(key2);
|
|
17550
17550
|
const inputVar = newVar(ctx);
|
|
17551
17551
|
doc.write(`const ${inputVar} = ${accessor}[${kx}];`);
|
|
17552
17552
|
if (propSchema._zod.optin !== void 0) {
|
|
@@ -17567,14 +17567,14 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
17567
17567
|
} else {
|
|
17568
17568
|
doc.write(`if (${outputVar2} === INVALID) return INVALID;`);
|
|
17569
17569
|
}
|
|
17570
|
-
propOutputs.set(
|
|
17570
|
+
propOutputs.set(key2, outputVar2);
|
|
17571
17571
|
} else {
|
|
17572
17572
|
if (requiresPresenceCheck(propSchema)) {
|
|
17573
17573
|
doc.write(`if (!(${kx} in ${accessor})) return INVALID;`);
|
|
17574
17574
|
}
|
|
17575
17575
|
const outputAccessor = compileChild(doc, ctx, propSchema, inputVar, buildsValue);
|
|
17576
17576
|
if (outputAccessor !== null)
|
|
17577
|
-
propOutputs.set(
|
|
17577
|
+
propOutputs.set(key2, outputAccessor);
|
|
17578
17578
|
}
|
|
17579
17579
|
}
|
|
17580
17580
|
const catchall = def.catchall;
|
|
@@ -17995,9 +17995,9 @@ function generateTupleCheck(doc, ctx, schema, accessor) {
|
|
|
17995
17995
|
}
|
|
17996
17996
|
return outputVar;
|
|
17997
17997
|
}
|
|
17998
|
-
function getTupleOptStart2(items,
|
|
17998
|
+
function getTupleOptStart2(items, key2) {
|
|
17999
17999
|
for (let i = items.length - 1; i >= 0; i--) {
|
|
18000
|
-
const omittable =
|
|
18000
|
+
const omittable = key2 === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional";
|
|
18001
18001
|
if (!omittable)
|
|
18002
18002
|
return i + 1;
|
|
18003
18003
|
}
|
|
@@ -18127,16 +18127,16 @@ function generateRecordCheck(doc, ctx, schema, accessor) {
|
|
|
18127
18127
|
const keyValues = recordDef.partial ? void 0 : def.keyType._zod.values;
|
|
18128
18128
|
if (keyValues) {
|
|
18129
18129
|
const inputKeys = [];
|
|
18130
|
-
for (const
|
|
18131
|
-
if (!(typeof
|
|
18132
|
-
throw new ZodCompileUnsupportedError(`record key value ${String(
|
|
18130
|
+
for (const key2 of keyValues) {
|
|
18131
|
+
if (!(typeof key2 === "string" || typeof key2 === "number" || typeof key2 === "symbol")) {
|
|
18132
|
+
throw new ZodCompileUnsupportedError(`record key value ${String(key2)}`);
|
|
18133
18133
|
}
|
|
18134
|
-
const inputKey = typeof
|
|
18134
|
+
const inputKey = typeof key2 === "number" ? key2.toString() : key2;
|
|
18135
18135
|
if (inputKey === "__proto__") {
|
|
18136
18136
|
throw new ZodCompileUnsupportedError('record key "__proto__"');
|
|
18137
18137
|
}
|
|
18138
18138
|
inputKeys.push(inputKey);
|
|
18139
|
-
const keyConst = addConstant(ctx,
|
|
18139
|
+
const keyConst = addConstant(ctx, key2);
|
|
18140
18140
|
const outKey = generateCheck(doc, ctx, def.keyType, keyConst);
|
|
18141
18141
|
const valueVar = newVar(ctx);
|
|
18142
18142
|
doc.write(`const ${valueVar} = ${accessor}[${literalPropertyKey(ctx, inputKey)}];`);
|
|
@@ -18214,10 +18214,10 @@ function emitOwnKeys(doc, ctx, accessor, kVar, body, onSymbol) {
|
|
|
18214
18214
|
});
|
|
18215
18215
|
doc.write(`}`);
|
|
18216
18216
|
}
|
|
18217
|
-
function literalPropertyKey(ctx,
|
|
18218
|
-
if (typeof
|
|
18219
|
-
return esc(
|
|
18220
|
-
return addConstant(ctx,
|
|
18217
|
+
function literalPropertyKey(ctx, key2) {
|
|
18218
|
+
if (typeof key2 === "string")
|
|
18219
|
+
return esc(key2);
|
|
18220
|
+
return addConstant(ctx, key2);
|
|
18221
18221
|
}
|
|
18222
18222
|
function generateMapCheck(doc, ctx, schema, accessor) {
|
|
18223
18223
|
const def = schema._zod.def;
|
|
@@ -19446,9 +19446,9 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
|
|
|
19446
19446
|
// node_modules/zod/v4/core/to-json-schema.js
|
|
19447
19447
|
function assignProps(target, ...sources) {
|
|
19448
19448
|
for (const source of sources) {
|
|
19449
|
-
for (const
|
|
19450
|
-
if (Object.prototype.propertyIsEnumerable.call(source,
|
|
19451
|
-
assignProp(target,
|
|
19449
|
+
for (const key2 of Reflect.ownKeys(source)) {
|
|
19450
|
+
if (Object.prototype.propertyIsEnumerable.call(source, key2)) {
|
|
19451
|
+
assignProp(target, key2, source[key2]);
|
|
19452
19452
|
}
|
|
19453
19453
|
}
|
|
19454
19454
|
}
|
|
@@ -19594,8 +19594,8 @@ function extractDefs(ctx, schema) {
|
|
|
19594
19594
|
if (defId)
|
|
19595
19595
|
seen.defId = defId;
|
|
19596
19596
|
const schema2 = seen.schema;
|
|
19597
|
-
for (const
|
|
19598
|
-
delete schema2[
|
|
19597
|
+
for (const key2 in schema2) {
|
|
19598
|
+
delete schema2[key2];
|
|
19599
19599
|
}
|
|
19600
19600
|
schema2.$ref = ref;
|
|
19601
19601
|
};
|
|
@@ -19676,8 +19676,8 @@ function foldObjects(members2) {
|
|
|
19676
19676
|
for (const member of members2) {
|
|
19677
19677
|
if (typeof member !== "object" || member.type !== "object")
|
|
19678
19678
|
return null;
|
|
19679
|
-
for (const
|
|
19680
|
-
if (!FOLDABLE_KEYS.has(
|
|
19679
|
+
for (const key2 in member) {
|
|
19680
|
+
if (!FOLDABLE_KEYS.has(key2))
|
|
19681
19681
|
return null;
|
|
19682
19682
|
}
|
|
19683
19683
|
objects.push(member);
|
|
@@ -19685,22 +19685,22 @@ function foldObjects(members2) {
|
|
|
19685
19685
|
const properties = {};
|
|
19686
19686
|
const required2 = /* @__PURE__ */ new Set();
|
|
19687
19687
|
for (const object2 of objects) {
|
|
19688
|
-
for (const
|
|
19689
|
-
if (Object.prototype.hasOwnProperty.call(properties,
|
|
19688
|
+
for (const key2 in object2.properties) {
|
|
19689
|
+
if (Object.prototype.hasOwnProperty.call(properties, key2))
|
|
19690
19690
|
continue;
|
|
19691
19691
|
const parts = [];
|
|
19692
19692
|
for (const other of objects) {
|
|
19693
|
-
const part = other.properties?.[
|
|
19693
|
+
const part = other.properties?.[key2] ?? undeclaredConstraint(other);
|
|
19694
19694
|
if (part === null || part === void 0)
|
|
19695
19695
|
continue;
|
|
19696
19696
|
if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part)))
|
|
19697
19697
|
parts.push(part);
|
|
19698
19698
|
}
|
|
19699
19699
|
const merged = parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts };
|
|
19700
|
-
assignProp(properties,
|
|
19700
|
+
assignProp(properties, key2, merged);
|
|
19701
19701
|
}
|
|
19702
|
-
for (const
|
|
19703
|
-
required2.add(
|
|
19702
|
+
for (const key2 of object2.required ?? [])
|
|
19703
|
+
required2.add(key2);
|
|
19704
19704
|
}
|
|
19705
19705
|
const folded = { type: "object", properties };
|
|
19706
19706
|
if (required2.size)
|
|
@@ -19725,8 +19725,8 @@ function foldIntersection(json2) {
|
|
|
19725
19725
|
const allOf = json2.allOf;
|
|
19726
19726
|
if (!Array.isArray(allOf) || allOf.length < 2)
|
|
19727
19727
|
return;
|
|
19728
|
-
for (const
|
|
19729
|
-
if (
|
|
19728
|
+
for (const key2 of FOLDABLE_KEYS)
|
|
19729
|
+
if (key2 in json2)
|
|
19730
19730
|
return;
|
|
19731
19731
|
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
19732
19732
|
let folded = null;
|
|
@@ -19773,20 +19773,20 @@ function finalize(ctx, schema) {
|
|
|
19773
19773
|
assignProps(schema2, _cached);
|
|
19774
19774
|
const isParentRef = zodSchema._zod.parent === ref;
|
|
19775
19775
|
if (isParentRef) {
|
|
19776
|
-
for (const
|
|
19777
|
-
if (
|
|
19776
|
+
for (const key2 in schema2) {
|
|
19777
|
+
if (key2 === "$ref" || key2 === "allOf")
|
|
19778
19778
|
continue;
|
|
19779
|
-
if (!(
|
|
19780
|
-
delete schema2[
|
|
19779
|
+
if (!(key2 in _cached)) {
|
|
19780
|
+
delete schema2[key2];
|
|
19781
19781
|
}
|
|
19782
19782
|
}
|
|
19783
19783
|
}
|
|
19784
19784
|
if (refSchema.$ref && refSeen.def) {
|
|
19785
|
-
for (const
|
|
19786
|
-
if (
|
|
19785
|
+
for (const key2 in schema2) {
|
|
19786
|
+
if (key2 === "$ref" || key2 === "allOf")
|
|
19787
19787
|
continue;
|
|
19788
|
-
if (
|
|
19789
|
-
delete schema2[
|
|
19788
|
+
if (key2 in refSeen.def && JSON.stringify(schema2[key2]) === JSON.stringify(refSeen.def[key2])) {
|
|
19789
|
+
delete schema2[key2];
|
|
19790
19790
|
}
|
|
19791
19791
|
}
|
|
19792
19792
|
}
|
|
@@ -19798,11 +19798,11 @@ function finalize(ctx, schema) {
|
|
|
19798
19798
|
if (parentSeen?.schema.$ref) {
|
|
19799
19799
|
schema2.$ref = parentSeen.schema.$ref;
|
|
19800
19800
|
if (parentSeen.def) {
|
|
19801
|
-
for (const
|
|
19802
|
-
if (
|
|
19801
|
+
for (const key2 in schema2) {
|
|
19802
|
+
if (key2 === "$ref" || key2 === "allOf")
|
|
19803
19803
|
continue;
|
|
19804
|
-
if (
|
|
19805
|
-
delete schema2[
|
|
19804
|
+
if (key2 in parentSeen.def && JSON.stringify(schema2[key2]) === JSON.stringify(parentSeen.def[key2])) {
|
|
19805
|
+
delete schema2[key2];
|
|
19806
19806
|
}
|
|
19807
19807
|
}
|
|
19808
19808
|
}
|
|
@@ -19935,8 +19935,8 @@ function isTransforming(_schema, _ctx) {
|
|
|
19935
19935
|
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
19936
19936
|
}
|
|
19937
19937
|
if (def.type === "object") {
|
|
19938
|
-
for (const
|
|
19939
|
-
if (isTransforming(def.shape[
|
|
19938
|
+
for (const key2 in def.shape) {
|
|
19939
|
+
if (isTransforming(def.shape[key2], ctx))
|
|
19940
19940
|
return true;
|
|
19941
19941
|
}
|
|
19942
19942
|
return false;
|
|
@@ -19974,13 +19974,13 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
|
|
|
19974
19974
|
};
|
|
19975
19975
|
|
|
19976
19976
|
// node_modules/zod/v4/core/json-schema-processors.js
|
|
19977
|
-
var narrowMin = (agg,
|
|
19978
|
-
if (agg[
|
|
19979
|
-
agg[
|
|
19977
|
+
var narrowMin = (agg, key2, value) => {
|
|
19978
|
+
if (agg[key2] === void 0 || value > agg[key2])
|
|
19979
|
+
agg[key2] = value;
|
|
19980
19980
|
};
|
|
19981
|
-
var narrowMax = (agg,
|
|
19982
|
-
if (agg[
|
|
19983
|
-
agg[
|
|
19981
|
+
var narrowMax = (agg, key2, value) => {
|
|
19982
|
+
if (agg[key2] === void 0 || value < agg[key2])
|
|
19983
|
+
agg[key2] = value;
|
|
19984
19984
|
};
|
|
19985
19985
|
var narrowBoth = (agg, value) => {
|
|
19986
19986
|
narrowMin(agg, "minimum", value);
|
|
@@ -20318,17 +20318,17 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
20318
20318
|
}
|
|
20319
20319
|
json2.type = "object";
|
|
20320
20320
|
json2.properties = {};
|
|
20321
|
-
for (const
|
|
20322
|
-
assignProp(json2.properties,
|
|
20321
|
+
for (const key2 in shape) {
|
|
20322
|
+
assignProp(json2.properties, key2, processSchema(shape[key2], ctx, {
|
|
20323
20323
|
...params,
|
|
20324
|
-
path: [...params.path, "properties",
|
|
20324
|
+
path: [...params.path, "properties", key2]
|
|
20325
20325
|
}));
|
|
20326
20326
|
}
|
|
20327
20327
|
const requiredKeys = [];
|
|
20328
|
-
for (const
|
|
20329
|
-
const field = def.shape[
|
|
20328
|
+
for (const key2 of Object.keys(shape)) {
|
|
20329
|
+
const field = def.shape[key2];
|
|
20330
20330
|
if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) {
|
|
20331
|
-
requiredKeys.push(
|
|
20331
|
+
requiredKeys.push(key2);
|
|
20332
20332
|
}
|
|
20333
20333
|
}
|
|
20334
20334
|
if (requiredKeys.length > 0) {
|
|
@@ -20703,9 +20703,9 @@ function toJSONSchema(input2, params) {
|
|
|
20703
20703
|
};
|
|
20704
20704
|
ctx2.external = external;
|
|
20705
20705
|
for (const entry of registry2._idmap.entries()) {
|
|
20706
|
-
const [
|
|
20706
|
+
const [key2, schema] = entry;
|
|
20707
20707
|
extractDefs(ctx2, schema);
|
|
20708
|
-
assignProp(schemas,
|
|
20708
|
+
assignProp(schemas, key2, finalize(ctx2, schema));
|
|
20709
20709
|
}
|
|
20710
20710
|
if (Object.keys(defs).length > 0) {
|
|
20711
20711
|
const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
@@ -21020,17 +21020,17 @@ __export(checks_exports2, {
|
|
|
21020
21020
|
|
|
21021
21021
|
// node_modules/zod/v4/classic/errors.js
|
|
21022
21022
|
var _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
21023
|
-
function _lazyMethod(proto,
|
|
21024
|
-
Object.defineProperty(proto,
|
|
21023
|
+
function _lazyMethod(proto, key2, make) {
|
|
21024
|
+
Object.defineProperty(proto, key2, {
|
|
21025
21025
|
configurable: true,
|
|
21026
21026
|
enumerable: false,
|
|
21027
21027
|
get() {
|
|
21028
21028
|
const value = make(this);
|
|
21029
|
-
Object.defineProperty(this,
|
|
21029
|
+
Object.defineProperty(this, key2, { value, configurable: true, writable: true });
|
|
21030
21030
|
return value;
|
|
21031
21031
|
},
|
|
21032
21032
|
set(value) {
|
|
21033
|
-
Object.defineProperty(this,
|
|
21033
|
+
Object.defineProperty(this, key2, { value, configurable: true, writable: true });
|
|
21034
21034
|
}
|
|
21035
21035
|
});
|
|
21036
21036
|
}
|
|
@@ -22700,11 +22700,11 @@ function resolveRef(ref, ctx) {
|
|
|
22700
22700
|
}
|
|
22701
22701
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
22702
22702
|
if (path[0] === defsKey) {
|
|
22703
|
-
const
|
|
22704
|
-
if (!
|
|
22703
|
+
const key2 = path[1] === void 0 ? void 0 : decodeJSONPointerSegment(path[1]);
|
|
22704
|
+
if (!key2 || !ctx.defs[key2]) {
|
|
22705
22705
|
throw new Error(`Reference not found: ${ref}`);
|
|
22706
22706
|
}
|
|
22707
|
-
return ctx.defs[
|
|
22707
|
+
return ctx.defs[key2];
|
|
22708
22708
|
}
|
|
22709
22709
|
throw new Error(`Reference not found: ${ref}`);
|
|
22710
22710
|
}
|
|
@@ -22739,16 +22739,16 @@ function checkObjectGuards(objectSchema, guards) {
|
|
|
22739
22739
|
});
|
|
22740
22740
|
}
|
|
22741
22741
|
if (guards.keySchema) {
|
|
22742
|
-
for (const
|
|
22743
|
-
const result = guards.keySchema.safeParse(
|
|
22742
|
+
for (const key2 of keys) {
|
|
22743
|
+
const result = guards.keySchema.safeParse(key2);
|
|
22744
22744
|
if (result.success)
|
|
22745
22745
|
continue;
|
|
22746
22746
|
payload.issues.push({
|
|
22747
22747
|
code: "invalid_key",
|
|
22748
22748
|
origin: "record",
|
|
22749
22749
|
issues: result.error.issues,
|
|
22750
|
-
input:
|
|
22751
|
-
path: [
|
|
22750
|
+
input: key2,
|
|
22751
|
+
path: [key2],
|
|
22752
22752
|
continue: true
|
|
22753
22753
|
});
|
|
22754
22754
|
}
|
|
@@ -22773,20 +22773,20 @@ function canonicalKey(value, seen) {
|
|
|
22773
22773
|
if (Array.isArray(value)) {
|
|
22774
22774
|
const parts2 = [];
|
|
22775
22775
|
for (const item of value) {
|
|
22776
|
-
const
|
|
22777
|
-
if (
|
|
22776
|
+
const key2 = canonicalKey(item, seen);
|
|
22777
|
+
if (key2 === null)
|
|
22778
22778
|
return null;
|
|
22779
|
-
parts2.push(
|
|
22779
|
+
parts2.push(key2);
|
|
22780
22780
|
}
|
|
22781
22781
|
return `a${parts2.length}:[${parts2.join(",")}]`;
|
|
22782
22782
|
}
|
|
22783
22783
|
const keys = Object.keys(value).sort();
|
|
22784
22784
|
const parts = [];
|
|
22785
22785
|
for (const k of keys) {
|
|
22786
|
-
const
|
|
22787
|
-
if (
|
|
22786
|
+
const key2 = canonicalKey(value[k], seen);
|
|
22787
|
+
if (key2 === null)
|
|
22788
22788
|
return null;
|
|
22789
|
-
parts.push(`${k.length}:${k}=${
|
|
22789
|
+
parts.push(`${k.length}:${k}=${key2}`);
|
|
22790
22790
|
}
|
|
22791
22791
|
return `o${parts.length}:{${parts.join(",")}}`;
|
|
22792
22792
|
} finally {
|
|
@@ -22826,10 +22826,10 @@ function containsRef(value) {
|
|
|
22826
22826
|
return value.some(containsRef);
|
|
22827
22827
|
if (typeof value.$ref === "string")
|
|
22828
22828
|
return true;
|
|
22829
|
-
return Object.entries(value).some(([
|
|
22830
|
-
if (SCHEMA_KEYWORDS.has(
|
|
22829
|
+
return Object.entries(value).some(([key2, sub]) => {
|
|
22830
|
+
if (SCHEMA_KEYWORDS.has(key2))
|
|
22831
22831
|
return containsRef(sub);
|
|
22832
|
-
if (!SCHEMA_MAP_KEYWORDS.has(
|
|
22832
|
+
if (!SCHEMA_MAP_KEYWORDS.has(key2) || typeof sub !== "object" || sub === null)
|
|
22833
22833
|
return false;
|
|
22834
22834
|
return Object.values(sub).some(containsRef);
|
|
22835
22835
|
});
|
|
@@ -22845,12 +22845,12 @@ function checkArrayGuards(arraySchema, guards) {
|
|
|
22845
22845
|
if (guards.uniqueItems === true) {
|
|
22846
22846
|
const firstSeen = /* @__PURE__ */ new Map();
|
|
22847
22847
|
for (let i = 0; i < items.length; i++) {
|
|
22848
|
-
const
|
|
22849
|
-
if (
|
|
22848
|
+
const key2 = canonicalKey(items[i], /* @__PURE__ */ new Set());
|
|
22849
|
+
if (key2 === null)
|
|
22850
22850
|
continue;
|
|
22851
|
-
const first = firstSeen.get(
|
|
22851
|
+
const first = firstSeen.get(key2);
|
|
22852
22852
|
if (first === void 0) {
|
|
22853
|
-
firstSeen.set(
|
|
22853
|
+
firstSeen.set(key2, i);
|
|
22854
22854
|
continue;
|
|
22855
22855
|
}
|
|
22856
22856
|
payload.issues.push({
|
|
@@ -23089,9 +23089,9 @@ function convertBaseSchema(schema, ctx) {
|
|
|
23089
23089
|
const properties = schema.properties || {};
|
|
23090
23090
|
const requiredSet = new Set(schema.required || []);
|
|
23091
23091
|
const additionalSchema = typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : void 0;
|
|
23092
|
-
for (const [
|
|
23092
|
+
for (const [key2, propSchema] of Object.entries(properties)) {
|
|
23093
23093
|
const propZodSchema = convertSchema(propSchema, ctx);
|
|
23094
|
-
assignProp(shape,
|
|
23094
|
+
assignProp(shape, key2, requiredSet.has(key2) ? propZodSchema : propZodSchema.optional());
|
|
23095
23095
|
}
|
|
23096
23096
|
if (schema.patternProperties) {
|
|
23097
23097
|
const patternProps = schema.patternProperties;
|
|
@@ -23126,12 +23126,12 @@ function convertBaseSchema(schema, ctx) {
|
|
|
23126
23126
|
if (!isPlainObject(payload.value))
|
|
23127
23127
|
return;
|
|
23128
23128
|
const unrecognized = [];
|
|
23129
|
-
for (const
|
|
23130
|
-
if (propertyKeys.includes(
|
|
23129
|
+
for (const key2 of Object.keys(payload.value)) {
|
|
23130
|
+
if (propertyKeys.includes(key2))
|
|
23131
23131
|
continue;
|
|
23132
|
-
if (patterns.some((regex) => regex.test(
|
|
23132
|
+
if (patterns.some((regex) => regex.test(key2)))
|
|
23133
23133
|
continue;
|
|
23134
|
-
unrecognized.push(
|
|
23134
|
+
unrecognized.push(key2);
|
|
23135
23135
|
}
|
|
23136
23136
|
if (unrecognized.length) {
|
|
23137
23137
|
payload.issues.push({
|
|
@@ -23262,38 +23262,38 @@ function convertSchema(schema, ctx) {
|
|
|
23262
23262
|
}
|
|
23263
23263
|
const extraMeta = {};
|
|
23264
23264
|
const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
|
|
23265
|
-
for (const
|
|
23266
|
-
if (
|
|
23267
|
-
extraMeta[
|
|
23265
|
+
for (const key2 of coreMetadataKeys) {
|
|
23266
|
+
if (key2 in schema) {
|
|
23267
|
+
extraMeta[key2] = schema[key2];
|
|
23268
23268
|
}
|
|
23269
23269
|
}
|
|
23270
23270
|
const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
|
|
23271
|
-
for (const
|
|
23272
|
-
if (
|
|
23273
|
-
extraMeta[
|
|
23271
|
+
for (const key2 of contentMetadataKeys) {
|
|
23272
|
+
if (key2 in schema) {
|
|
23273
|
+
extraMeta[key2] = schema[key2];
|
|
23274
23274
|
}
|
|
23275
23275
|
}
|
|
23276
23276
|
if (schema.type === "object" && schema.$ref === void 0) {
|
|
23277
23277
|
if (schema.propertyNames !== void 0 && !containsRef(schema.propertyNames)) {
|
|
23278
23278
|
extraMeta.propertyNames = schema.propertyNames;
|
|
23279
23279
|
}
|
|
23280
|
-
for (const
|
|
23281
|
-
if (schema[
|
|
23282
|
-
extraMeta[
|
|
23280
|
+
for (const key2 of ["minProperties", "maxProperties"]) {
|
|
23281
|
+
if (schema[key2] !== void 0)
|
|
23282
|
+
extraMeta[key2] = schema[key2];
|
|
23283
23283
|
}
|
|
23284
23284
|
}
|
|
23285
23285
|
if (schema.type === "array" && schema.$ref === void 0) {
|
|
23286
23286
|
if (schema.contains !== void 0 && !containsRef(schema.contains)) {
|
|
23287
23287
|
extraMeta.contains = schema.contains;
|
|
23288
23288
|
}
|
|
23289
|
-
for (const
|
|
23290
|
-
if (schema[
|
|
23291
|
-
extraMeta[
|
|
23289
|
+
for (const key2 of ["uniqueItems", "minContains", "maxContains"]) {
|
|
23290
|
+
if (schema[key2] !== void 0)
|
|
23291
|
+
extraMeta[key2] = schema[key2];
|
|
23292
23292
|
}
|
|
23293
23293
|
}
|
|
23294
|
-
for (const
|
|
23295
|
-
if (!RECOGNIZED_KEYS.has(
|
|
23296
|
-
assignProp(extraMeta,
|
|
23294
|
+
for (const key2 of Object.keys(schema)) {
|
|
23295
|
+
if (!RECOGNIZED_KEYS.has(key2)) {
|
|
23296
|
+
assignProp(extraMeta, key2, schema[key2]);
|
|
23297
23297
|
}
|
|
23298
23298
|
}
|
|
23299
23299
|
if (Object.keys(extraMeta).length > 0) {
|
|
@@ -24711,7 +24711,7 @@ var TOOL_RESULT_FOREIGN_FAMILY_KEYS = [
|
|
|
24711
24711
|
"requestState"
|
|
24712
24712
|
];
|
|
24713
24713
|
function normalizeContentlessToolResult(value) {
|
|
24714
|
-
if (value === null || typeof value !== "object" || Array.isArray(value) || value.content !== void 0 || TOOL_RESULT_FOREIGN_FAMILY_KEYS.some((
|
|
24714
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || value.content !== void 0 || TOOL_RESULT_FOREIGN_FAMILY_KEYS.some((key2) => key2 in value)) return value;
|
|
24715
24715
|
return {
|
|
24716
24716
|
...value,
|
|
24717
24717
|
content: []
|
|
@@ -25581,10 +25581,10 @@ function build$1() {
|
|
|
25581
25581
|
]),
|
|
25582
25582
|
CallToolResultWireSchema: unknown().superRefine((value, ctx) => {
|
|
25583
25583
|
if (typeof value !== "object" || value === null || Array.isArray(value) || value.content !== void 0) return;
|
|
25584
|
-
for (const
|
|
25584
|
+
for (const key2 of TOOL_RESULT_FOREIGN_FAMILY_KEYS) if (key2 in value) {
|
|
25585
25585
|
ctx.addIssue({
|
|
25586
25586
|
code: "custom",
|
|
25587
|
-
message: `content is required when the body carries '${
|
|
25587
|
+
message: `content is required when the body carries '${key2}' \u2014 another result family cannot default into an empty tools/call success`
|
|
25588
25588
|
});
|
|
25589
25589
|
return;
|
|
25590
25590
|
}
|
|
@@ -27122,17 +27122,17 @@ var rev2026Codec = {
|
|
|
27122
27122
|
},
|
|
27123
27123
|
validateEnvelopeMeta(meta3) {
|
|
27124
27124
|
const issues = [];
|
|
27125
|
-
for (const
|
|
27126
|
-
key,
|
|
27125
|
+
for (const key2 of REQUIRED_ENVELOPE_KEYS) if (!(key2 in meta3)) issues.push({
|
|
27126
|
+
key: key2,
|
|
27127
27127
|
problem: "missing"
|
|
27128
27128
|
});
|
|
27129
27129
|
const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(meta3);
|
|
27130
27130
|
if (!parsed.success) for (const issue2 of parsed.error.issues) {
|
|
27131
27131
|
const path = issue2.path.map(String);
|
|
27132
|
-
const
|
|
27133
|
-
if (path.length === 1 && issues.some((existing) => existing.key ===
|
|
27132
|
+
const key2 = path.length > 0 ? path.join(".") : "_meta";
|
|
27133
|
+
if (path.length === 1 && issues.some((existing) => existing.key === key2 && existing.problem === "missing")) continue;
|
|
27134
27134
|
issues.push({
|
|
27135
|
-
key,
|
|
27135
|
+
key: key2,
|
|
27136
27136
|
problem: issue2.message
|
|
27137
27137
|
});
|
|
27138
27138
|
}
|
|
@@ -27482,8 +27482,8 @@ function scanXMcpHeaderDeclarations(inputSchema) {
|
|
|
27482
27482
|
});
|
|
27483
27483
|
}
|
|
27484
27484
|
const properties = schema.properties;
|
|
27485
|
-
if (properties !== null && typeof properties === "object") for (const [
|
|
27486
|
-
const fault$1 = visit2(child, [...path,
|
|
27485
|
+
if (properties !== null && typeof properties === "object") for (const [key2, child] of Object.entries(properties)) {
|
|
27486
|
+
const fault$1 = visit2(child, [...path, key2], reachable);
|
|
27487
27487
|
if (fault$1 !== void 0) return fault$1;
|
|
27488
27488
|
}
|
|
27489
27489
|
for (const k of NON_REACHABLE_SUBSCHEMA_KEYWORDS) {
|
|
@@ -27713,12 +27713,12 @@ function isProvablyObjectShapedRoot(schema, root = schema) {
|
|
|
27713
27713
|
if ("properties" in schema || "patternProperties" in schema || "additionalProperties" in schema || "required" in schema) return true;
|
|
27714
27714
|
const ref = typeof schema.$ref === "string" && LOCAL_DEFINITION_REF.exec(schema.$ref);
|
|
27715
27715
|
if (ref && root[ref[1]]?.[ref[2]]?.type === "object") return true;
|
|
27716
|
-
for (const
|
|
27716
|
+
for (const key2 of [
|
|
27717
27717
|
"oneOf",
|
|
27718
27718
|
"anyOf",
|
|
27719
27719
|
"allOf"
|
|
27720
27720
|
]) {
|
|
27721
|
-
const members2 = schema[
|
|
27721
|
+
const members2 = schema[key2];
|
|
27722
27722
|
if (Array.isArray(members2) && members2.length > 0) return members2.every((m) => m !== null && typeof m === "object" && (m.type === "object" || isProvablyObjectShapedRoot(m, "$id" in m ? {} : root)));
|
|
27723
27723
|
}
|
|
27724
27724
|
return false;
|
|
@@ -27812,8 +27812,8 @@ var ANNOTATION_ONLY_JSON_SCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
27812
27812
|
"title",
|
|
27813
27813
|
"writeOnly"
|
|
27814
27814
|
]);
|
|
27815
|
-
function isAnnotationOnlyJsonSchemaKeyword(
|
|
27816
|
-
return ANNOTATION_ONLY_JSON_SCHEMA_KEYWORDS.has(
|
|
27815
|
+
function isAnnotationOnlyJsonSchemaKeyword(key2) {
|
|
27816
|
+
return ANNOTATION_ONLY_JSON_SCHEMA_KEYWORDS.has(key2) || key2.startsWith("x-");
|
|
27817
27817
|
}
|
|
27818
27818
|
var ROOT_KEYS = /* @__PURE__ */ new Set(["$schema", ...Object.keys(ElicitRequestFormParamsSchema.shape.requestedSchema.shape)]);
|
|
27819
27819
|
var PROPERTY_KEYS_BY_TYPE = {
|
|
@@ -27834,19 +27834,19 @@ function walkProperty(node2, path, vendor, unsupported) {
|
|
|
27834
27834
|
const allowedKeys = typeof node2.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node2.type) ? PROPERTY_KEYS_BY_TYPE[node2.type] : void 0;
|
|
27835
27835
|
if (allowedKeys === void 0) return node2;
|
|
27836
27836
|
const pruned = {};
|
|
27837
|
-
for (const [
|
|
27838
|
-
else if (
|
|
27839
|
-
if (!SUPPORTED_STRING_FORMATS.has(node2.format)) pruned[
|
|
27840
|
-
else if (typeof value !== "string" || !isLibraryFormatPattern(node2.format, value, vendor)) unsupported.push(`${path}.${
|
|
27841
|
-
} else unsupported.push(`${path}.${
|
|
27837
|
+
for (const [key2, value] of Object.entries(node2)) if (allowedKeys.has(key2) || isAnnotationOnlyJsonSchemaKeyword(key2)) pruned[key2] = value;
|
|
27838
|
+
else if (key2 === "pattern" && node2.type === "string" && typeof node2.format === "string") {
|
|
27839
|
+
if (!SUPPORTED_STRING_FORMATS.has(node2.format)) pruned[key2] = value;
|
|
27840
|
+
else if (typeof value !== "string" || !isLibraryFormatPattern(node2.format, value, vendor)) unsupported.push(`${path}.${key2}`);
|
|
27841
|
+
} else unsupported.push(`${path}.${key2}`);
|
|
27842
27842
|
return pruned;
|
|
27843
27843
|
}
|
|
27844
27844
|
function walkRequestedSchema(converted, vendor) {
|
|
27845
27845
|
const pruned = {};
|
|
27846
27846
|
const unsupported = [];
|
|
27847
|
-
for (const [
|
|
27848
|
-
else if (ROOT_KEYS.has(
|
|
27849
|
-
else if (!isAnnotationOnlyJsonSchemaKeyword(
|
|
27847
|
+
for (const [key2, value] of Object.entries(converted)) if (key2 === "properties" && isJsonObject(value)) pruned[key2] = Object.fromEntries(Object.entries(value).map(([name, node2]) => [name, walkProperty(node2, `properties.${name}`, vendor, unsupported)]));
|
|
27848
|
+
else if (ROOT_KEYS.has(key2)) pruned[key2] = value;
|
|
27849
|
+
else if (!isAnnotationOnlyJsonSchemaKeyword(key2)) unsupported.push(key2);
|
|
27850
27850
|
if (unsupported.length > 0) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${unsupported.join(", ")}`);
|
|
27851
27851
|
return pruned;
|
|
27852
27852
|
}
|
|
@@ -27858,10 +27858,10 @@ function describeUnsupportedProperties(pruned, fallback) {
|
|
|
27858
27858
|
function findDroppedConstraintPaths(original, parsed, path = "") {
|
|
27859
27859
|
if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${path}[${index}]`));
|
|
27860
27860
|
if (!isJsonObject(original) || !isJsonObject(parsed)) return [];
|
|
27861
|
-
return Object.entries(original).flatMap(([
|
|
27862
|
-
const childPath = path ? `${path}.${
|
|
27863
|
-
if (!Object.prototype.hasOwnProperty.call(parsed,
|
|
27864
|
-
return findDroppedConstraintPaths(value, parsed[
|
|
27861
|
+
return Object.entries(original).flatMap(([key2, value]) => {
|
|
27862
|
+
const childPath = path ? `${path}.${key2}` : key2;
|
|
27863
|
+
if (!Object.prototype.hasOwnProperty.call(parsed, key2)) return isAnnotationOnlyJsonSchemaKeyword(key2) ? [] : [childPath];
|
|
27864
|
+
return findDroppedConstraintPaths(value, parsed[key2], childPath);
|
|
27865
27865
|
});
|
|
27866
27866
|
}
|
|
27867
27867
|
function normalizeElicitInputParams(input2) {
|
|
@@ -27876,7 +27876,7 @@ function normalizeElicitInputParams(input2) {
|
|
|
27876
27876
|
if (!parsed.success) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${describeUnsupportedProperties(pruned, parsed.error.message)}`);
|
|
27877
27877
|
const droppedConstraints = findDroppedConstraintPaths(pruned, parsed.data);
|
|
27878
27878
|
if (droppedConstraints.length > 0) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${droppedConstraints.join(", ")}`);
|
|
27879
|
-
const danglingRequired = (parsed.data.required ?? []).filter((
|
|
27879
|
+
const danglingRequired = (parsed.data.required ?? []).filter((key2) => !Object.prototype.hasOwnProperty.call(parsed.data.properties, key2));
|
|
27880
27880
|
if (danglingRequired.length > 0) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema lists required properties that are not defined in properties: ${danglingRequired.join(", ")}`);
|
|
27881
27881
|
return {
|
|
27882
27882
|
...input2,
|
|
@@ -27924,17 +27924,17 @@ var inputRequired = Object.assign(buildInputRequired, {
|
|
|
27924
27924
|
return { method: "roots/list" };
|
|
27925
27925
|
}
|
|
27926
27926
|
});
|
|
27927
|
-
function acceptedContent(responses,
|
|
27928
|
-
const view = inputResponse(responses,
|
|
27927
|
+
function acceptedContent(responses, key2, schema) {
|
|
27928
|
+
const view = inputResponse(responses, key2);
|
|
27929
27929
|
if (view.kind !== "elicit" || view.action !== "accept" || view.content === void 0) return void 0;
|
|
27930
27930
|
if (schema === void 0) return view.content;
|
|
27931
27931
|
const outcome = schema["~standard"].validate(view.content);
|
|
27932
27932
|
if (outcome instanceof Promise) throw new TypeError("acceptedContent(responses, key, schema) requires a synchronously-validating schema");
|
|
27933
27933
|
return outcome.issues === void 0 ? outcome.value : void 0;
|
|
27934
27934
|
}
|
|
27935
|
-
function inputResponse(responses,
|
|
27935
|
+
function inputResponse(responses, key2) {
|
|
27936
27936
|
if (responses === void 0 || typeof responses !== "object" || responses === null) return { kind: "missing" };
|
|
27937
|
-
const entry = responses[
|
|
27937
|
+
const entry = responses[key2];
|
|
27938
27938
|
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return { kind: "missing" };
|
|
27939
27939
|
const candidate = entry;
|
|
27940
27940
|
if (candidate["action"] === "accept" || candidate["action"] === "decline" || candidate["action"] === "cancel") {
|
|
@@ -28166,13 +28166,13 @@ var authSchemas = {
|
|
|
28166
28166
|
};
|
|
28167
28167
|
var _specTypeSchemas = {};
|
|
28168
28168
|
var _isSpecType = {};
|
|
28169
|
-
function register(
|
|
28170
|
-
const name =
|
|
28169
|
+
function register(key2, schema) {
|
|
28170
|
+
const name = key2.slice(0, -6);
|
|
28171
28171
|
_specTypeSchemas[name] = schema;
|
|
28172
28172
|
_isSpecType[name] = (v) => schema.safeParse(v).success;
|
|
28173
28173
|
}
|
|
28174
|
-
for (const
|
|
28175
|
-
for (const [
|
|
28174
|
+
for (const key2 of SPEC_SCHEMA_KEYS) register(key2, schemas_exports3[key2]);
|
|
28175
|
+
for (const [key2, schema] of Object.entries(authSchemas)) register(key2, schema);
|
|
28176
28176
|
var specTypeSchemas = Object.freeze(_specTypeSchemas);
|
|
28177
28177
|
var isSpecType = Object.freeze(_isSpecType);
|
|
28178
28178
|
function bootstrapOutboundCodec(method) {
|
|
@@ -28201,8 +28201,8 @@ function liftWireOnlyMaterial(message, kind) {
|
|
|
28201
28201
|
lifted: {}
|
|
28202
28202
|
};
|
|
28203
28203
|
const meta3 = params._meta;
|
|
28204
|
-
const envelopeKeys = isPlainObject$1(meta3) ? RESERVED_ENVELOPE_META_KEYS.filter((
|
|
28205
|
-
const retryKeys = kind === "request" ? RETRY_PARAMS_KEYS.filter((
|
|
28204
|
+
const envelopeKeys = isPlainObject$1(meta3) ? RESERVED_ENVELOPE_META_KEYS.filter((key2) => key2 in meta3) : [];
|
|
28205
|
+
const retryKeys = kind === "request" ? RETRY_PARAMS_KEYS.filter((key2) => key2 in params) : [];
|
|
28206
28206
|
if (envelopeKeys.length === 0 && retryKeys.length === 0) return {
|
|
28207
28207
|
message,
|
|
28208
28208
|
lifted: {}
|
|
@@ -28212,18 +28212,18 @@ function liftWireOnlyMaterial(message, kind) {
|
|
|
28212
28212
|
if (envelopeKeys.length > 0 && isPlainObject$1(meta3)) {
|
|
28213
28213
|
const envelope = {};
|
|
28214
28214
|
const nextMeta = { ...meta3 };
|
|
28215
|
-
for (const
|
|
28216
|
-
envelope[
|
|
28217
|
-
delete nextMeta[
|
|
28215
|
+
for (const key2 of envelopeKeys) {
|
|
28216
|
+
envelope[key2] = meta3[key2];
|
|
28217
|
+
delete nextMeta[key2];
|
|
28218
28218
|
}
|
|
28219
28219
|
lifted.envelope = envelope;
|
|
28220
28220
|
if (Object.keys(nextMeta).length > 0) nextParams._meta = nextMeta;
|
|
28221
28221
|
else delete nextParams._meta;
|
|
28222
28222
|
}
|
|
28223
|
-
for (const
|
|
28224
|
-
if (
|
|
28225
|
-
if (
|
|
28226
|
-
delete nextParams[
|
|
28223
|
+
for (const key2 of retryKeys) {
|
|
28224
|
+
if (key2 === "inputResponses") lifted.inputResponses = nextParams[key2];
|
|
28225
|
+
if (key2 === "requestState") lifted.requestState = nextParams[key2];
|
|
28226
|
+
delete nextParams[key2];
|
|
28227
28227
|
}
|
|
28228
28228
|
return {
|
|
28229
28229
|
message: {
|
|
@@ -29004,8 +29004,8 @@ function isPlainObject$1(value) {
|
|
|
29004
29004
|
}
|
|
29005
29005
|
function mergeCapabilities(base, additional) {
|
|
29006
29006
|
const result = { ...base };
|
|
29007
|
-
for (const
|
|
29008
|
-
const k =
|
|
29007
|
+
for (const key2 in additional) {
|
|
29008
|
+
const k = key2;
|
|
29009
29009
|
const addValue = additional[k];
|
|
29010
29010
|
if (addValue === void 0) continue;
|
|
29011
29011
|
const baseValue = result[k];
|
|
@@ -29026,12 +29026,12 @@ function partitionInputResponses(inputResponses) {
|
|
|
29026
29026
|
accepted,
|
|
29027
29027
|
droppedKeys
|
|
29028
29028
|
};
|
|
29029
|
-
for (const [
|
|
29029
|
+
for (const [key2, entry] of Object.entries(inputResponses)) {
|
|
29030
29030
|
if (!isPlainObject2(entry) || "method" in entry || "result" in entry) {
|
|
29031
|
-
droppedKeys.push(
|
|
29031
|
+
droppedKeys.push(key2);
|
|
29032
29032
|
continue;
|
|
29033
29033
|
}
|
|
29034
|
-
accepted[
|
|
29034
|
+
accepted[key2] = entry;
|
|
29035
29035
|
}
|
|
29036
29036
|
return {
|
|
29037
29037
|
accepted,
|
|
@@ -29060,20 +29060,20 @@ var require_content_type = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29060
29060
|
if (!TYPE_REGEXP.test(type)) throw new TypeError("invalid media type");
|
|
29061
29061
|
var obj = new ContentType(type.toLowerCase());
|
|
29062
29062
|
if (index !== -1) {
|
|
29063
|
-
var
|
|
29063
|
+
var key2;
|
|
29064
29064
|
var match;
|
|
29065
29065
|
var value;
|
|
29066
29066
|
PARAM_REGEXP.lastIndex = index;
|
|
29067
29067
|
while (match = PARAM_REGEXP.exec(header)) {
|
|
29068
29068
|
if (match.index !== index) throw new TypeError("invalid parameter format");
|
|
29069
29069
|
index += match[0].length;
|
|
29070
|
-
|
|
29070
|
+
key2 = match[1].toLowerCase();
|
|
29071
29071
|
value = match[2];
|
|
29072
29072
|
if (value.charCodeAt(0) === 34) {
|
|
29073
29073
|
value = value.slice(1, -1);
|
|
29074
29074
|
if (value.indexOf("\\") !== -1) value = value.replace(QESC_REGEXP, "$1");
|
|
29075
29075
|
}
|
|
29076
|
-
obj.parameters[
|
|
29076
|
+
obj.parameters[key2] = value;
|
|
29077
29077
|
}
|
|
29078
29078
|
if (index !== header.length) throw new TypeError("invalid parameter format");
|
|
29079
29079
|
}
|
|
@@ -29315,13 +29315,13 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29315
29315
|
return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
29316
29316
|
}
|
|
29317
29317
|
exports.safeStringify = safeStringify;
|
|
29318
|
-
function getProperty(
|
|
29319
|
-
return typeof
|
|
29318
|
+
function getProperty(key2) {
|
|
29319
|
+
return typeof key2 == "string" && exports.IDENTIFIER.test(key2) ? new _Code(`.${key2}`) : _`[${key2}]`;
|
|
29320
29320
|
}
|
|
29321
29321
|
exports.getProperty = getProperty;
|
|
29322
|
-
function getEsmExportName(
|
|
29323
|
-
if (typeof
|
|
29324
|
-
throw new Error(`CodeGen: invalid export name: ${
|
|
29322
|
+
function getEsmExportName(key2) {
|
|
29323
|
+
if (typeof key2 == "string" && exports.IDENTIFIER.test(key2)) return new _Code(`${key2}`);
|
|
29324
|
+
throw new Error(`CodeGen: invalid export name: ${key2}, use explicit $id name mapping`);
|
|
29325
29325
|
}
|
|
29326
29326
|
exports.getEsmExportName = getEsmExportName;
|
|
29327
29327
|
function regexpCode(rx) {
|
|
@@ -29932,10 +29932,10 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29932
29932
|
}
|
|
29933
29933
|
object(...keyValues) {
|
|
29934
29934
|
const code2 = ["{"];
|
|
29935
|
-
for (const [
|
|
29935
|
+
for (const [key2, value] of keyValues) {
|
|
29936
29936
|
if (code2.length > 1) code2.push(",");
|
|
29937
|
-
code2.push(
|
|
29938
|
-
if (
|
|
29937
|
+
code2.push(key2);
|
|
29938
|
+
if (key2 !== value || this.opts.es5) {
|
|
29939
29939
|
code2.push(":");
|
|
29940
29940
|
(0, code_1.addCodeArg)(code2, value);
|
|
29941
29941
|
}
|
|
@@ -30157,18 +30157,18 @@ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
30157
30157
|
if (!opts.strictSchema) return;
|
|
30158
30158
|
if (typeof schema === "boolean") return;
|
|
30159
30159
|
const rules = self.RULES.keywords;
|
|
30160
|
-
for (const
|
|
30160
|
+
for (const key2 in schema) if (!rules[key2]) checkStrictMode(it, `unknown keyword: "${key2}"`);
|
|
30161
30161
|
}
|
|
30162
30162
|
exports.checkUnknownRules = checkUnknownRules;
|
|
30163
30163
|
function schemaHasRules(schema, rules) {
|
|
30164
30164
|
if (typeof schema == "boolean") return !schema;
|
|
30165
|
-
for (const
|
|
30165
|
+
for (const key2 in schema) if (rules[key2]) return true;
|
|
30166
30166
|
return false;
|
|
30167
30167
|
}
|
|
30168
30168
|
exports.schemaHasRules = schemaHasRules;
|
|
30169
30169
|
function schemaHasRulesButRef(schema, RULES) {
|
|
30170
30170
|
if (typeof schema == "boolean") return !schema;
|
|
30171
|
-
for (const
|
|
30171
|
+
for (const key2 in schema) if (key2 !== "$ref" && RULES.all[key2]) return true;
|
|
30172
30172
|
return false;
|
|
30173
30173
|
}
|
|
30174
30174
|
exports.schemaHasRulesButRef = schemaHasRulesButRef;
|
|
@@ -30675,7 +30675,7 @@ var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
30675
30675
|
const util_1 = require_util();
|
|
30676
30676
|
function assignDefaults(it, ty) {
|
|
30677
30677
|
const { properties, items } = it.schema;
|
|
30678
|
-
if (ty === "object" && properties) for (const
|
|
30678
|
+
if (ty === "object" && properties) for (const key2 in properties) assignDefault(it, key2, properties[key2].default);
|
|
30679
30679
|
else if (ty === "array" && Array.isArray(items)) items.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
30680
30680
|
}
|
|
30681
30681
|
exports.assignDefaults = assignDefaults;
|
|
@@ -31001,8 +31001,8 @@ var require_fast_deep_equal = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
31001
31001
|
if (length !== Object.keys(b).length) return false;
|
|
31002
31002
|
for (i = length; i-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
31003
31003
|
for (i = length; i-- !== 0; ) {
|
|
31004
|
-
var
|
|
31005
|
-
if (!equal(a[
|
|
31004
|
+
var key2 = keys[i];
|
|
31005
|
+
if (!equal(a[key2], b[key2])) return false;
|
|
31006
31006
|
}
|
|
31007
31007
|
return true;
|
|
31008
31008
|
}
|
|
@@ -31069,13 +31069,13 @@ var require_json_schema_traverse = /* @__PURE__ */ __commonJSMin(((exports, modu
|
|
|
31069
31069
|
function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
|
31070
31070
|
if (schema && typeof schema == "object" && !Array.isArray(schema)) {
|
|
31071
31071
|
pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
31072
|
-
for (var
|
|
31073
|
-
var sch = schema[
|
|
31072
|
+
for (var key2 in schema) {
|
|
31073
|
+
var sch = schema[key2];
|
|
31074
31074
|
if (Array.isArray(sch)) {
|
|
31075
|
-
if (
|
|
31076
|
-
} else if (
|
|
31077
|
-
if (sch && typeof sch == "object") for (var prop in sch) _traverse(opts, pre, post, sch[prop], jsonPtr + "/" +
|
|
31078
|
-
} else if (
|
|
31075
|
+
if (key2 in traverse.arrayKeywords) for (var i = 0; i < sch.length; i++) _traverse(opts, pre, post, sch[i], jsonPtr + "/" + key2 + "/" + i, rootSchema, jsonPtr, key2, schema, i);
|
|
31076
|
+
} else if (key2 in traverse.propsKeywords) {
|
|
31077
|
+
if (sch && typeof sch == "object") for (var prop in sch) _traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key2 + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key2, schema, prop);
|
|
31078
|
+
} else if (key2 in traverse.keywords || opts.allKeys && !(key2 in traverse.skipKeywords)) _traverse(opts, pre, post, sch, jsonPtr + "/" + key2, rootSchema, jsonPtr, key2, schema);
|
|
31079
31079
|
}
|
|
31080
31080
|
post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
31081
31081
|
}
|
|
@@ -31123,9 +31123,9 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
31123
31123
|
"$dynamicAnchor"
|
|
31124
31124
|
]);
|
|
31125
31125
|
function hasRef(schema) {
|
|
31126
|
-
for (const
|
|
31127
|
-
if (REF_KEYWORDS.has(
|
|
31128
|
-
const sch = schema[
|
|
31126
|
+
for (const key2 in schema) {
|
|
31127
|
+
if (REF_KEYWORDS.has(key2)) return true;
|
|
31128
|
+
const sch = schema[key2];
|
|
31129
31129
|
if (Array.isArray(sch) && sch.some(hasRef)) return true;
|
|
31130
31130
|
if (typeof sch == "object" && hasRef(sch)) return true;
|
|
31131
31131
|
}
|
|
@@ -31133,11 +31133,11 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
31133
31133
|
}
|
|
31134
31134
|
function countKeys(schema) {
|
|
31135
31135
|
let count = 0;
|
|
31136
|
-
for (const
|
|
31137
|
-
if (
|
|
31136
|
+
for (const key2 in schema) {
|
|
31137
|
+
if (key2 === "$ref") return Infinity;
|
|
31138
31138
|
count++;
|
|
31139
|
-
if (SIMPLE_INLINED.has(
|
|
31140
|
-
if (typeof schema[
|
|
31139
|
+
if (SIMPLE_INLINED.has(key2)) continue;
|
|
31140
|
+
if (typeof schema[key2] == "object") (0, util_1.eachItem)(schema[key2], (sch) => count += countKeys(sch));
|
|
31141
31141
|
if (count === Infinity) return Infinity;
|
|
31142
31142
|
}
|
|
31143
31143
|
return count;
|
|
@@ -31295,7 +31295,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
31295
31295
|
}
|
|
31296
31296
|
function schemaCxtHasRules({ schema, self }) {
|
|
31297
31297
|
if (typeof schema == "boolean") return !schema;
|
|
31298
|
-
for (const
|
|
31298
|
+
for (const key2 in schema) if (self.RULES.all[key2]) return true;
|
|
31299
31299
|
return false;
|
|
31300
31300
|
}
|
|
31301
31301
|
function isSchemaObj(it) {
|
|
@@ -33028,7 +33028,7 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
33028
33028
|
}
|
|
33029
33029
|
}
|
|
33030
33030
|
}
|
|
33031
|
-
addSchema(schema,
|
|
33031
|
+
addSchema(schema, key2, _meta, _validateSchema = this.opts.validateSchema) {
|
|
33032
33032
|
if (Array.isArray(schema)) {
|
|
33033
33033
|
for (const sch of schema) this.addSchema(sch, void 0, _meta, _validateSchema);
|
|
33034
33034
|
return this;
|
|
@@ -33039,13 +33039,13 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
33039
33039
|
id2 = schema[schemaId];
|
|
33040
33040
|
if (id2 !== void 0 && typeof id2 != "string") throw new Error(`schema ${schemaId} must be string`);
|
|
33041
33041
|
}
|
|
33042
|
-
|
|
33043
|
-
this._checkUnique(
|
|
33044
|
-
this.schemas[
|
|
33042
|
+
key2 = (0, resolve_1.normalizeId)(key2 || id2);
|
|
33043
|
+
this._checkUnique(key2);
|
|
33044
|
+
this.schemas[key2] = this._addSchema(schema, _meta, key2, _validateSchema, true);
|
|
33045
33045
|
return this;
|
|
33046
33046
|
}
|
|
33047
|
-
addMetaSchema(schema,
|
|
33048
|
-
this.addSchema(schema,
|
|
33047
|
+
addMetaSchema(schema, key2, _validateSchema = this.opts.validateSchema) {
|
|
33048
|
+
this.addSchema(schema, key2, true, _validateSchema);
|
|
33049
33049
|
return this;
|
|
33050
33050
|
}
|
|
33051
33051
|
validateSchema(schema, throwOrLogError) {
|
|
@@ -33177,12 +33177,12 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
33177
33177
|
const segments = jsonPointer.split("/").slice(1);
|
|
33178
33178
|
let keywords = metaSchema;
|
|
33179
33179
|
for (const seg of segments) keywords = keywords[seg];
|
|
33180
|
-
for (const
|
|
33181
|
-
const rule = rules[
|
|
33180
|
+
for (const key2 in rules) {
|
|
33181
|
+
const rule = rules[key2];
|
|
33182
33182
|
if (typeof rule != "object") continue;
|
|
33183
33183
|
const { $data } = rule.definition;
|
|
33184
|
-
const schema = keywords[
|
|
33185
|
-
if ($data && schema) keywords[
|
|
33184
|
+
const schema = keywords[key2];
|
|
33185
|
+
if ($data && schema) keywords[key2] = schemaOrData(schema);
|
|
33186
33186
|
}
|
|
33187
33187
|
}
|
|
33188
33188
|
return metaSchema;
|
|
@@ -33247,9 +33247,9 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
33247
33247
|
Ajv2.MissingRefError = ref_error_1.default;
|
|
33248
33248
|
exports.default = Ajv2;
|
|
33249
33249
|
function checkOptions(checkOpts, options, msg, log = "error") {
|
|
33250
|
-
for (const
|
|
33251
|
-
const opt =
|
|
33252
|
-
if (opt in options) this.logger[log](`${msg}: option ${
|
|
33250
|
+
for (const key2 in checkOpts) {
|
|
33251
|
+
const opt = key2;
|
|
33252
|
+
if (opt in options) this.logger[log](`${msg}: option ${key2}. ${checkOpts[opt]}`);
|
|
33253
33253
|
}
|
|
33254
33254
|
}
|
|
33255
33255
|
function getSchEnv(keyRef) {
|
|
@@ -33260,7 +33260,7 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
33260
33260
|
const optsSchemas = this.opts.schemas;
|
|
33261
33261
|
if (!optsSchemas) return;
|
|
33262
33262
|
if (Array.isArray(optsSchemas)) this.addSchema(optsSchemas);
|
|
33263
|
-
else for (const
|
|
33263
|
+
else for (const key2 in optsSchemas) this.addSchema(optsSchemas[key2], key2);
|
|
33264
33264
|
}
|
|
33265
33265
|
function addInitialFormats() {
|
|
33266
33266
|
for (const name in this.opts.formats) {
|
|
@@ -34150,10 +34150,10 @@ var require_dependencies = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
34150
34150
|
function splitDependencies({ schema }) {
|
|
34151
34151
|
const propertyDeps = {};
|
|
34152
34152
|
const schemaDeps = {};
|
|
34153
|
-
for (const
|
|
34154
|
-
if (
|
|
34155
|
-
const deps = Array.isArray(schema[
|
|
34156
|
-
deps[
|
|
34153
|
+
for (const key2 in schema) {
|
|
34154
|
+
if (key2 === "__proto__") continue;
|
|
34155
|
+
const deps = Array.isArray(schema[key2]) ? propertyDeps : schemaDeps;
|
|
34156
|
+
deps[key2] = schema[key2];
|
|
34157
34157
|
}
|
|
34158
34158
|
return [propertyDeps, schemaDeps];
|
|
34159
34159
|
}
|
|
@@ -34215,13 +34215,13 @@ var require_propertyNames = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
34215
34215
|
const { gen, schema, data, it } = cxt;
|
|
34216
34216
|
if ((0, util_1.alwaysValidSchema)(it, schema)) return;
|
|
34217
34217
|
const valid = gen.name("valid");
|
|
34218
|
-
gen.forIn("key", data, (
|
|
34219
|
-
cxt.setParams({ propertyName:
|
|
34218
|
+
gen.forIn("key", data, (key2) => {
|
|
34219
|
+
cxt.setParams({ propertyName: key2 });
|
|
34220
34220
|
cxt.subschema({
|
|
34221
34221
|
keyword: "propertyNames",
|
|
34222
|
-
data:
|
|
34222
|
+
data: key2,
|
|
34223
34223
|
dataTypes: ["string"],
|
|
34224
|
-
propertyName:
|
|
34224
|
+
propertyName: key2,
|
|
34225
34225
|
compositeRule: true
|
|
34226
34226
|
}, valid);
|
|
34227
34227
|
gen.if((0, codegen_1.not)(valid), () => {
|
|
@@ -34261,31 +34261,31 @@ var require_additionalProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
34261
34261
|
checkAdditionalProperties();
|
|
34262
34262
|
cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
34263
34263
|
function checkAdditionalProperties() {
|
|
34264
|
-
gen.forIn("key", data, (
|
|
34265
|
-
if (!props.length && !patProps.length) additionalPropertyCode(
|
|
34266
|
-
else gen.if(isAdditional(
|
|
34264
|
+
gen.forIn("key", data, (key2) => {
|
|
34265
|
+
if (!props.length && !patProps.length) additionalPropertyCode(key2);
|
|
34266
|
+
else gen.if(isAdditional(key2), () => additionalPropertyCode(key2));
|
|
34267
34267
|
});
|
|
34268
34268
|
}
|
|
34269
|
-
function isAdditional(
|
|
34269
|
+
function isAdditional(key2) {
|
|
34270
34270
|
let definedProp;
|
|
34271
34271
|
if (props.length > 8) {
|
|
34272
34272
|
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
|
|
34273
|
-
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema,
|
|
34274
|
-
} else if (props.length) definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${
|
|
34273
|
+
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key2);
|
|
34274
|
+
} else if (props.length) definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${key2} === ${p}`));
|
|
34275
34275
|
else definedProp = codegen_1.nil;
|
|
34276
|
-
if (patProps.length) definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${
|
|
34276
|
+
if (patProps.length) definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${key2})`));
|
|
34277
34277
|
return (0, codegen_1.not)(definedProp);
|
|
34278
34278
|
}
|
|
34279
|
-
function deleteAdditional(
|
|
34280
|
-
gen.code((0, codegen_1._)`delete ${data}[${
|
|
34279
|
+
function deleteAdditional(key2) {
|
|
34280
|
+
gen.code((0, codegen_1._)`delete ${data}[${key2}]`);
|
|
34281
34281
|
}
|
|
34282
|
-
function additionalPropertyCode(
|
|
34282
|
+
function additionalPropertyCode(key2) {
|
|
34283
34283
|
if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) {
|
|
34284
|
-
deleteAdditional(
|
|
34284
|
+
deleteAdditional(key2);
|
|
34285
34285
|
return;
|
|
34286
34286
|
}
|
|
34287
34287
|
if (schema === false) {
|
|
34288
|
-
cxt.setParams({ additionalProperty:
|
|
34288
|
+
cxt.setParams({ additionalProperty: key2 });
|
|
34289
34289
|
cxt.error();
|
|
34290
34290
|
if (!allErrors) gen.break();
|
|
34291
34291
|
return;
|
|
@@ -34293,21 +34293,21 @@ var require_additionalProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
34293
34293
|
if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
|
|
34294
34294
|
const valid = gen.name("valid");
|
|
34295
34295
|
if (opts.removeAdditional === "failing") {
|
|
34296
|
-
applyAdditionalSchema(
|
|
34296
|
+
applyAdditionalSchema(key2, valid, false);
|
|
34297
34297
|
gen.if((0, codegen_1.not)(valid), () => {
|
|
34298
34298
|
cxt.reset();
|
|
34299
|
-
deleteAdditional(
|
|
34299
|
+
deleteAdditional(key2);
|
|
34300
34300
|
});
|
|
34301
34301
|
} else {
|
|
34302
|
-
applyAdditionalSchema(
|
|
34302
|
+
applyAdditionalSchema(key2, valid);
|
|
34303
34303
|
if (!allErrors) gen.if((0, codegen_1.not)(valid), () => gen.break());
|
|
34304
34304
|
}
|
|
34305
34305
|
}
|
|
34306
34306
|
}
|
|
34307
|
-
function applyAdditionalSchema(
|
|
34307
|
+
function applyAdditionalSchema(key2, valid, errors) {
|
|
34308
34308
|
const subschema = {
|
|
34309
34309
|
keyword: "additionalProperties",
|
|
34310
|
-
dataProp:
|
|
34310
|
+
dataProp: key2,
|
|
34311
34311
|
dataPropType: util_1.Type.Str
|
|
34312
34312
|
};
|
|
34313
34313
|
if (errors === false) Object.assign(subschema, {
|
|
@@ -34401,16 +34401,16 @@ var require_patternProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
34401
34401
|
for (const prop in checkProperties) if (new RegExp(pat).test(prop)) (0, util_1.checkStrictMode)(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`);
|
|
34402
34402
|
}
|
|
34403
34403
|
function validateProperties(pat) {
|
|
34404
|
-
gen.forIn("key", data, (
|
|
34405
|
-
gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${
|
|
34404
|
+
gen.forIn("key", data, (key2) => {
|
|
34405
|
+
gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key2})`, () => {
|
|
34406
34406
|
const alwaysValid = alwaysValidPatterns.includes(pat);
|
|
34407
34407
|
if (!alwaysValid) cxt.subschema({
|
|
34408
34408
|
keyword: "patternProperties",
|
|
34409
34409
|
schemaProp: pat,
|
|
34410
|
-
dataProp:
|
|
34410
|
+
dataProp: key2,
|
|
34411
34411
|
dataPropType: util_2.Type.Str
|
|
34412
34412
|
}, valid);
|
|
34413
|
-
if (it.opts.unevaluated && props !== true) gen.assign((0, codegen_1._)`${props}[${
|
|
34413
|
+
if (it.opts.unevaluated && props !== true) gen.assign((0, codegen_1._)`${props}[${key2}]`, true);
|
|
34414
34414
|
else if (!alwaysValid && !it.allErrors) gen.if((0, codegen_1.not)(valid), () => gen.break());
|
|
34415
34415
|
});
|
|
34416
34416
|
});
|
|
@@ -35261,13 +35261,13 @@ var require_unevaluatedProperties = /* @__PURE__ */ __commonJSMin(((exports) =>
|
|
|
35261
35261
|
const { gen, schema, data, errsCount, it } = cxt;
|
|
35262
35262
|
if (!errsCount) throw new Error("ajv implementation error");
|
|
35263
35263
|
const { allErrors, props } = it;
|
|
35264
|
-
if (props instanceof codegen_1.Name) gen.if((0, codegen_1._)`${props} !== true`, () => gen.forIn("key", data, (
|
|
35265
|
-
else if (props !== true) gen.forIn("key", data, (
|
|
35264
|
+
if (props instanceof codegen_1.Name) gen.if((0, codegen_1._)`${props} !== true`, () => gen.forIn("key", data, (key2) => gen.if(unevaluatedDynamic(props, key2), () => unevaluatedPropCode(key2))));
|
|
35265
|
+
else if (props !== true) gen.forIn("key", data, (key2) => props === void 0 ? unevaluatedPropCode(key2) : gen.if(unevaluatedStatic(props, key2), () => unevaluatedPropCode(key2)));
|
|
35266
35266
|
it.props = true;
|
|
35267
35267
|
cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
35268
|
-
function unevaluatedPropCode(
|
|
35268
|
+
function unevaluatedPropCode(key2) {
|
|
35269
35269
|
if (schema === false) {
|
|
35270
|
-
cxt.setParams({ unevaluatedProperty:
|
|
35270
|
+
cxt.setParams({ unevaluatedProperty: key2 });
|
|
35271
35271
|
cxt.error();
|
|
35272
35272
|
if (!allErrors) gen.break();
|
|
35273
35273
|
return;
|
|
@@ -35276,18 +35276,18 @@ var require_unevaluatedProperties = /* @__PURE__ */ __commonJSMin(((exports) =>
|
|
|
35276
35276
|
const valid = gen.name("valid");
|
|
35277
35277
|
cxt.subschema({
|
|
35278
35278
|
keyword: "unevaluatedProperties",
|
|
35279
|
-
dataProp:
|
|
35279
|
+
dataProp: key2,
|
|
35280
35280
|
dataPropType: util_1.Type.Str
|
|
35281
35281
|
}, valid);
|
|
35282
35282
|
if (!allErrors) gen.if((0, codegen_1.not)(valid), () => gen.break());
|
|
35283
35283
|
}
|
|
35284
35284
|
}
|
|
35285
|
-
function unevaluatedDynamic(evaluatedProps,
|
|
35286
|
-
return (0, codegen_1._)`!${evaluatedProps} || !${evaluatedProps}[${
|
|
35285
|
+
function unevaluatedDynamic(evaluatedProps, key2) {
|
|
35286
|
+
return (0, codegen_1._)`!${evaluatedProps} || !${evaluatedProps}[${key2}]`;
|
|
35287
35287
|
}
|
|
35288
|
-
function unevaluatedStatic(evaluatedProps,
|
|
35288
|
+
function unevaluatedStatic(evaluatedProps, key2) {
|
|
35289
35289
|
const ps = [];
|
|
35290
|
-
for (const p in evaluatedProps) if (evaluatedProps[p] === true) ps.push((0, codegen_1._)`${
|
|
35290
|
+
for (const p in evaluatedProps) if (evaluatedProps[p] === true) ps.push((0, codegen_1._)`${key2} !== ${p}`);
|
|
35291
35291
|
return (0, codegen_1.and)(...ps);
|
|
35292
35292
|
}
|
|
35293
35293
|
}
|
|
@@ -36812,11 +36812,11 @@ function resolveLegacyShimOptions(options) {
|
|
|
36812
36812
|
legacyShim: options?.legacyShim ?? true
|
|
36813
36813
|
};
|
|
36814
36814
|
}
|
|
36815
|
-
function coerceEmbeddedInputRequest(method,
|
|
36816
|
-
if (entry === null || typeof entry !== "object" || typeof entry.method !== "string") throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an invalid input request '${
|
|
36815
|
+
function coerceEmbeddedInputRequest(method, key2, entry) {
|
|
36816
|
+
if (entry === null || typeof entry !== "object" || typeof entry.method !== "string") throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an invalid input request '${key2}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);
|
|
36817
36817
|
const embedded = entry;
|
|
36818
36818
|
const required2 = requiredClientCapabilitiesForInputRequest(embedded);
|
|
36819
|
-
if (required2 === void 0) throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${
|
|
36819
|
+
if (required2 === void 0) throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${key2}' of kind '${embedded.method}', which is not an embedded request the 2026-07-28 revision defines`);
|
|
36820
36820
|
return {
|
|
36821
36821
|
embedded,
|
|
36822
36822
|
required: required2
|
|
@@ -36862,11 +36862,11 @@ var LegacyInputRequiredShim = class {
|
|
|
36862
36862
|
if (hasInputRequests) {
|
|
36863
36863
|
const declared = this._host.resolvedClientCapabilities(ctx);
|
|
36864
36864
|
const coerced = [];
|
|
36865
|
-
for (const [
|
|
36866
|
-
const { embedded, required: required2 } = coerceEmbeddedInputRequest(method,
|
|
36867
|
-
if (embedded.method !== "roots/list" && embedded.params === void 0) throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${
|
|
36868
|
-
if (missingClientCapabilities(required2, declared) !== void 0) return legacyShimFailure(method, `Cannot request input '${
|
|
36869
|
-
coerced.push([
|
|
36865
|
+
for (const [key2, entry] of Object.entries(inputRequests)) {
|
|
36866
|
+
const { embedded, required: required2 } = coerceEmbeddedInputRequest(method, key2, entry);
|
|
36867
|
+
if (embedded.method !== "roots/list" && embedded.params === void 0) throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${key2}' of kind '${embedded.method}' without params`);
|
|
36868
|
+
if (missingClientCapabilities(required2, declared) !== void 0) return legacyShimFailure(method, `Cannot request input '${key2}' (${embedded.method}): the client on this 2025-era connection did not declare the required capability${declared === void 0 ? " (no client capabilities are available on this connection \u2014 per-request legacy serving cannot receive server-to-client requests)" : ""}`);
|
|
36869
|
+
coerced.push([key2, embedded]);
|
|
36870
36870
|
}
|
|
36871
36871
|
const roundAbort = linkedRoundAbort(outerSignal);
|
|
36872
36872
|
try {
|
|
@@ -36878,9 +36878,9 @@ var LegacyInputRequiredShim = class {
|
|
|
36878
36878
|
},
|
|
36879
36879
|
signal: roundAbort.signal
|
|
36880
36880
|
};
|
|
36881
|
-
const fulfilled = await Promise.all(coerced.map(async ([
|
|
36881
|
+
const fulfilled = await Promise.all(coerced.map(async ([key2, embedded]) => {
|
|
36882
36882
|
try {
|
|
36883
|
-
return [
|
|
36883
|
+
return [key2, await this._dispatchLeg(embedded, legOptions)];
|
|
36884
36884
|
} catch (error62) {
|
|
36885
36885
|
roundAbort.abort(error62);
|
|
36886
36886
|
throw error62;
|
|
@@ -37187,10 +37187,10 @@ var Server = class extends Protocol {
|
|
|
37187
37187
|
if (!hasInputRequests && !hasRequestState) throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);
|
|
37188
37188
|
if (hasInputRequests) {
|
|
37189
37189
|
const declared = this._inputRequestCapabilityView(ctx);
|
|
37190
|
-
for (const [
|
|
37191
|
-
const { embedded, required: required2 } = coerceEmbeddedInputRequest(method,
|
|
37190
|
+
for (const [key2, entry] of Object.entries(inputRequests)) {
|
|
37191
|
+
const { embedded, required: required2 } = coerceEmbeddedInputRequest(method, key2, entry);
|
|
37192
37192
|
const missing = missingClientCapabilities(required2, declared);
|
|
37193
|
-
if (missing !== void 0) throw new MissingRequiredClientCapabilityError({ requiredCapabilities: missing }, `Cannot request input '${
|
|
37193
|
+
if (missing !== void 0) throw new MissingRequiredClientCapabilityError({ requiredCapabilities: missing }, `Cannot request input '${key2}' (${embedded.method}): the request's client capabilities do not declare the required capability`);
|
|
37194
37194
|
}
|
|
37195
37195
|
}
|
|
37196
37196
|
return result;
|
|
@@ -37580,10 +37580,10 @@ function toolInputElementCount(value, max) {
|
|
|
37580
37580
|
if (++count > max) return count;
|
|
37581
37581
|
if (child !== null && typeof child === "object") stack.push(child);
|
|
37582
37582
|
}
|
|
37583
|
-
else for (const
|
|
37584
|
-
if (!Object.prototype.hasOwnProperty.call(node2,
|
|
37583
|
+
else for (const key2 in node2) {
|
|
37584
|
+
if (!Object.prototype.hasOwnProperty.call(node2, key2)) continue;
|
|
37585
37585
|
if (++count > max) return count;
|
|
37586
|
-
const child = node2[
|
|
37586
|
+
const child = node2[key2];
|
|
37587
37587
|
if (child !== null && typeof child === "object") stack.push(child);
|
|
37588
37588
|
}
|
|
37589
37589
|
}
|
|
@@ -39027,8 +39027,8 @@ var DQ_STRING_RE = /"((?:[^"\\]|\\.)*)"/g;
|
|
|
39027
39027
|
var SQ_STRING_RE = /'((?:[^'\\]|\\.)*)'/g;
|
|
39028
39028
|
function redactJsonCookie(quote) {
|
|
39029
39029
|
const stringRe = quote === '"' ? DQ_STRING_RE : SQ_STRING_RE;
|
|
39030
|
-
return (_m, prefix,
|
|
39031
|
-
const setCookie =
|
|
39030
|
+
return (_m, prefix, key2, value) => {
|
|
39031
|
+
const setCookie = key2.toLowerCase() === "set-cookie";
|
|
39032
39032
|
const redacted = value.replace(stringRe, (_s, body) => {
|
|
39033
39033
|
const out = setCookie ? body.replace(/^(\s*[^=;]+)=[^;]*/, "$1=[REDACTED]") : body.replace(/=[^;]*/g, "=[REDACTED]");
|
|
39034
39034
|
return `${quote}${out}${quote}`;
|
|
@@ -39164,9 +39164,9 @@ function errorResult(message) {
|
|
|
39164
39164
|
}
|
|
39165
39165
|
function pruneUndefined(obj) {
|
|
39166
39166
|
const out = {};
|
|
39167
|
-
for (const
|
|
39168
|
-
if (obj[
|
|
39169
|
-
out[
|
|
39167
|
+
for (const key2 of Object.keys(obj)) {
|
|
39168
|
+
if (obj[key2] !== void 0)
|
|
39169
|
+
out[key2] = obj[key2];
|
|
39170
39170
|
}
|
|
39171
39171
|
return out;
|
|
39172
39172
|
}
|
|
@@ -39212,8 +39212,8 @@ function canonicalJson(value) {
|
|
|
39212
39212
|
const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
39213
39213
|
return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
|
|
39214
39214
|
}
|
|
39215
|
-
function escapeKey(
|
|
39216
|
-
return
|
|
39215
|
+
function escapeKey(key2) {
|
|
39216
|
+
return key2.startsWith("$") ? `$${key2}` : key2;
|
|
39217
39217
|
}
|
|
39218
39218
|
|
|
39219
39219
|
// node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
|
|
@@ -39226,22 +39226,22 @@ function bindingKey(binding) {
|
|
|
39226
39226
|
if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
|
|
39227
39227
|
throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
|
|
39228
39228
|
}
|
|
39229
|
-
const
|
|
39230
|
-
if (
|
|
39229
|
+
const key2 = typeof binding.key === "string" ? Buffer.from(binding.key, "utf8") : Buffer.from(binding.key);
|
|
39230
|
+
if (key2.length < 32) {
|
|
39231
39231
|
throw new RangeError("requireConfirmation: binding.key must be at least 32 bytes.");
|
|
39232
39232
|
}
|
|
39233
|
-
return
|
|
39233
|
+
return key2;
|
|
39234
39234
|
}
|
|
39235
39235
|
function commitment(action, args) {
|
|
39236
39236
|
return createHash("sha256").update(`${action}\0${canonicalJson(args)}`).digest("base64url");
|
|
39237
39237
|
}
|
|
39238
|
-
function mintState(
|
|
39238
|
+
function mintState(key2, action, binding) {
|
|
39239
39239
|
const exp = Math.floor(Date.now() / 1e3) + (binding.ttlSeconds ?? 600);
|
|
39240
39240
|
const body = Buffer.from(JSON.stringify({ c: commitment(action, binding.args), exp })).toString("base64url");
|
|
39241
|
-
const mac3 = createHmac("sha256",
|
|
39241
|
+
const mac3 = createHmac("sha256", key2).update(`${STATE_PREFIX}${body}`).digest("base64url");
|
|
39242
39242
|
return `${STATE_PREFIX}${body}.${mac3}`;
|
|
39243
39243
|
}
|
|
39244
|
-
function verifyState(
|
|
39244
|
+
function verifyState(key2, action, binding, state) {
|
|
39245
39245
|
if (typeof state !== "string" || !state.startsWith(STATE_PREFIX))
|
|
39246
39246
|
return false;
|
|
39247
39247
|
const rest = state.slice(STATE_PREFIX.length);
|
|
@@ -39250,7 +39250,7 @@ function verifyState(key, action, binding, state) {
|
|
|
39250
39250
|
return false;
|
|
39251
39251
|
const body = rest.slice(0, dot);
|
|
39252
39252
|
const mac3 = Buffer.from(rest.slice(dot + 1), "base64url");
|
|
39253
|
-
const expected = createHmac("sha256",
|
|
39253
|
+
const expected = createHmac("sha256", key2).update(`${STATE_PREFIX}${body}`).digest();
|
|
39254
39254
|
if (mac3.length !== expected.length || !timingSafeEqual(mac3, expected))
|
|
39255
39255
|
return false;
|
|
39256
39256
|
let payload;
|
|
@@ -39271,7 +39271,7 @@ function echoedState(ctx) {
|
|
|
39271
39271
|
}
|
|
39272
39272
|
function requireConfirmation(ctx, options) {
|
|
39273
39273
|
const requestKey = options.requestKey ?? DEFAULT_REQUEST_KEY;
|
|
39274
|
-
const
|
|
39274
|
+
const key2 = options.binding ? bindingKey(options.binding) : void 0;
|
|
39275
39275
|
const confirmationSchema = external_exports.object({
|
|
39276
39276
|
confirmed: external_exports.boolean().describe(options.confirmationLabel ?? DEFAULT_CONFIRMATION_LABEL)
|
|
39277
39277
|
});
|
|
@@ -39288,7 +39288,7 @@ ${JSON.stringify(preview, null, 2)}`,
|
|
|
39288
39288
|
requestedSchema: confirmationSchema
|
|
39289
39289
|
})
|
|
39290
39290
|
},
|
|
39291
|
-
...
|
|
39291
|
+
...key2 && options.binding ? { requestState: mintState(key2, options.action, options.binding) } : {}
|
|
39292
39292
|
});
|
|
39293
39293
|
};
|
|
39294
39294
|
const response = inputResponse(ctx.mcpReq.inputResponses, requestKey);
|
|
@@ -39315,12 +39315,12 @@ ${JSON.stringify(preview, null, 2)}`,
|
|
|
39315
39315
|
return ask();
|
|
39316
39316
|
}
|
|
39317
39317
|
if (response.kind === "elicit" && response.action === "accept" && accepted?.confirmed === true) {
|
|
39318
|
-
if (
|
|
39318
|
+
if (key2 && options.binding) {
|
|
39319
39319
|
const state = echoedState(ctx);
|
|
39320
39320
|
if (state === void 0 || state === null) {
|
|
39321
39321
|
return errorResult(`Confirmation for ${options.action} was accepted, but the retry carried no requestState, so it cannot be checked against the prompt that was shown. Nothing was done. The likely cause is that the MCP client or host does not round-trip requestState (it must echo the requestState from the input_required result back on the retry); asking again would loop.`);
|
|
39322
39322
|
}
|
|
39323
|
-
if (!verifyState(
|
|
39323
|
+
if (!verifyState(key2, options.action, options.binding, state))
|
|
39324
39324
|
return ask();
|
|
39325
39325
|
}
|
|
39326
39326
|
return void 0;
|
|
@@ -39455,8 +39455,8 @@ function createSpentTokenStore() {
|
|
|
39455
39455
|
var PROCESS_SPENT = createSpentTokenStore();
|
|
39456
39456
|
var PREFIX = "mcpu.token.v1.";
|
|
39457
39457
|
var DEFAULT_TTL_SECONDS = 600;
|
|
39458
|
-
function tokenKey(
|
|
39459
|
-
const bytes = typeof
|
|
39458
|
+
function tokenKey(key2) {
|
|
39459
|
+
const bytes = typeof key2 === "string" ? Buffer.from(key2, "utf8") : Buffer.from(key2);
|
|
39460
39460
|
if (bytes.length < 32)
|
|
39461
39461
|
throw new RangeError("confirm token: key must be at least 32 bytes.");
|
|
39462
39462
|
return bytes;
|
|
@@ -39469,14 +39469,14 @@ function ttlOf(ttlSeconds) {
|
|
|
39469
39469
|
}
|
|
39470
39470
|
return ttlSeconds;
|
|
39471
39471
|
}
|
|
39472
|
-
function sign(
|
|
39473
|
-
return createHmac2("sha256",
|
|
39472
|
+
function sign(key2, body) {
|
|
39473
|
+
return createHmac2("sha256", key2).update(`${PREFIX}${body}`).digest();
|
|
39474
39474
|
}
|
|
39475
39475
|
function hashConfirmPayload(payload) {
|
|
39476
39476
|
return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
|
|
39477
39477
|
}
|
|
39478
|
-
function issueConfirmToken(
|
|
39479
|
-
const k = tokenKey(
|
|
39478
|
+
function issueConfirmToken(key2, binding, options = {}) {
|
|
39479
|
+
const k = tokenKey(key2);
|
|
39480
39480
|
const now = options.now ?? Date.now();
|
|
39481
39481
|
const exp = now + ttlOf(options.ttlSeconds) * 1e3;
|
|
39482
39482
|
const claims = {
|
|
@@ -39499,8 +39499,8 @@ function parseClaims(body) {
|
|
|
39499
39499
|
return void 0;
|
|
39500
39500
|
}
|
|
39501
39501
|
}
|
|
39502
|
-
function verifyConfirmToken(
|
|
39503
|
-
const k = tokenKey(
|
|
39502
|
+
function verifyConfirmToken(key2, token, binding, options = {}) {
|
|
39503
|
+
const k = tokenKey(key2);
|
|
39504
39504
|
const now = options.now ?? Date.now();
|
|
39505
39505
|
const spent = options.spent ?? PROCESS_SPENT;
|
|
39506
39506
|
spent.prune(now);
|
|
@@ -39614,9 +39614,9 @@ import { isAbsolute as isAbsolute2, join as join3 } from "node:path";
|
|
|
39614
39614
|
import { homedir } from "node:os";
|
|
39615
39615
|
import { isAbsolute, join, resolve } from "node:path";
|
|
39616
39616
|
var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
|
|
39617
|
-
function readEnvVar(
|
|
39617
|
+
function readEnvVar(key2, opts = {}) {
|
|
39618
39618
|
const env = opts.env ?? process.env;
|
|
39619
|
-
const raw = env[
|
|
39619
|
+
const raw = env[key2];
|
|
39620
39620
|
if (typeof raw === "string") {
|
|
39621
39621
|
const trimmed = raw.trim();
|
|
39622
39622
|
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
@@ -39627,9 +39627,9 @@ function readEnvVar(key, opts = {}) {
|
|
|
39627
39627
|
}
|
|
39628
39628
|
var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
|
|
39629
39629
|
var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
39630
|
-
function parseBoolEnv(
|
|
39630
|
+
function parseBoolEnv(key2, opts = {}) {
|
|
39631
39631
|
const fallback = opts.default ?? false;
|
|
39632
|
-
const raw = readEnvVar(
|
|
39632
|
+
const raw = readEnvVar(key2, { env: opts.env });
|
|
39633
39633
|
if (raw === void 0)
|
|
39634
39634
|
return fallback;
|
|
39635
39635
|
const token = raw.toLowerCase();
|
|
@@ -39768,9 +39768,9 @@ function readConfirmElicitation(env = process.env) {
|
|
|
39768
39768
|
return "on";
|
|
39769
39769
|
if (raw === "off")
|
|
39770
39770
|
return "off";
|
|
39771
|
-
const
|
|
39772
|
-
if (!warned.has(
|
|
39773
|
-
warned.add(
|
|
39771
|
+
const key2 = `elicitation:${raw}`;
|
|
39772
|
+
if (!warned.has(key2)) {
|
|
39773
|
+
warned.add(key2);
|
|
39774
39774
|
process.stderr.write(`MCP_CONFIRM_ELICITATION="${raw}" is not one of on, off; treating it as on.
|
|
39775
39775
|
`);
|
|
39776
39776
|
}
|
|
@@ -39782,9 +39782,9 @@ function readConfirmTtl(env) {
|
|
|
39782
39782
|
return DEFAULT_TTL_SECONDS2;
|
|
39783
39783
|
if (/^[1-9]\d*$/.test(raw))
|
|
39784
39784
|
return Number(raw);
|
|
39785
|
-
const
|
|
39786
|
-
if (!warned.has(
|
|
39787
|
-
warned.add(
|
|
39785
|
+
const key2 = `ttl:${raw}`;
|
|
39786
|
+
if (!warned.has(key2)) {
|
|
39787
|
+
warned.add(key2);
|
|
39788
39788
|
process.stderr.write(`MCP_CONFIRM_TTL_SECONDS="${raw}" is not a positive whole number of seconds; gated writes will refuse on clients that cannot show a confirmation prompt until it is fixed.
|
|
39789
39789
|
`);
|
|
39790
39790
|
}
|
|
@@ -40258,6 +40258,17 @@ async function fileBlob(path, opts = {}) {
|
|
|
40258
40258
|
return blob;
|
|
40259
40259
|
}
|
|
40260
40260
|
|
|
40261
|
+
// node_modules/@chrischall/mcp-utils/dist/internal/headers.js
|
|
40262
|
+
function responseHeader(res, name) {
|
|
40263
|
+
return getHeader(res?.headers, name);
|
|
40264
|
+
}
|
|
40265
|
+
function getHeader(headers, name) {
|
|
40266
|
+
if (!headers || typeof headers.get !== "function")
|
|
40267
|
+
return null;
|
|
40268
|
+
const value = headers.get.call(headers, name);
|
|
40269
|
+
return typeof value === "string" ? value : null;
|
|
40270
|
+
}
|
|
40271
|
+
|
|
40261
40272
|
// node_modules/@chrischall/mcp-utils/dist/internal/ascii.js
|
|
40262
40273
|
function asciiLower(s) {
|
|
40263
40274
|
return s.replace(/[A-Z]+/g, (m) => m.toLowerCase());
|
|
@@ -40366,6 +40377,144 @@ function parseContentDispositionFilename(header) {
|
|
|
40366
40377
|
return rawExt;
|
|
40367
40378
|
}
|
|
40368
40379
|
|
|
40380
|
+
// node_modules/@chrischall/mcp-utils/dist/http/body-limit.js
|
|
40381
|
+
var ResponseTooLargeError = class extends McpToolError {
|
|
40382
|
+
maxBytes;
|
|
40383
|
+
constructor(service, maxBytes) {
|
|
40384
|
+
super(`Response from ${service} is larger than the ${maxBytes}-byte limit.`, {
|
|
40385
|
+
hint: "Raise maxBytes (or the client's maxResponseBytes) if a response this large is expected.",
|
|
40386
|
+
kind: "too_large"
|
|
40387
|
+
});
|
|
40388
|
+
this.name = "ResponseTooLargeError";
|
|
40389
|
+
this.maxBytes = maxBytes;
|
|
40390
|
+
}
|
|
40391
|
+
};
|
|
40392
|
+
async function readBytesCapped(res, maxBytes, service, bounded) {
|
|
40393
|
+
if (maxBytes !== void 0) {
|
|
40394
|
+
const declared = Number(responseHeader(res, "content-length") ?? NaN);
|
|
40395
|
+
if (Number.isFinite(declared) && declared > maxBytes) {
|
|
40396
|
+
cancelStream(res.body);
|
|
40397
|
+
throw new ResponseTooLargeError(service, maxBytes);
|
|
40398
|
+
}
|
|
40399
|
+
}
|
|
40400
|
+
if (!res.body)
|
|
40401
|
+
return new Uint8Array(0);
|
|
40402
|
+
const reader = res.body.getReader();
|
|
40403
|
+
const chunks = [];
|
|
40404
|
+
let total = 0;
|
|
40405
|
+
try {
|
|
40406
|
+
for (; ; ) {
|
|
40407
|
+
const { done, value } = await bounded(reader.read());
|
|
40408
|
+
if (done)
|
|
40409
|
+
break;
|
|
40410
|
+
total += value.byteLength;
|
|
40411
|
+
if (maxBytes !== void 0 && total > maxBytes)
|
|
40412
|
+
throw new ResponseTooLargeError(service, maxBytes);
|
|
40413
|
+
chunks.push(value);
|
|
40414
|
+
}
|
|
40415
|
+
} catch (err) {
|
|
40416
|
+
reader.cancel().catch(() => {
|
|
40417
|
+
});
|
|
40418
|
+
throw err;
|
|
40419
|
+
}
|
|
40420
|
+
const out = new Uint8Array(total);
|
|
40421
|
+
let offset = 0;
|
|
40422
|
+
for (const c of chunks) {
|
|
40423
|
+
out.set(c, offset);
|
|
40424
|
+
offset += c.byteLength;
|
|
40425
|
+
}
|
|
40426
|
+
return out;
|
|
40427
|
+
}
|
|
40428
|
+
function cancelStream(body) {
|
|
40429
|
+
try {
|
|
40430
|
+
body?.cancel().catch(() => {
|
|
40431
|
+
});
|
|
40432
|
+
} catch {
|
|
40433
|
+
}
|
|
40434
|
+
}
|
|
40435
|
+
|
|
40436
|
+
// node_modules/@chrischall/mcp-utils/dist/http/fetch-bounded.js
|
|
40437
|
+
async function fetchBounded(url2, init, opts = {}) {
|
|
40438
|
+
const doFetch = opts.fetchImpl ?? fetch;
|
|
40439
|
+
const service = opts.service ?? hostOf(url2);
|
|
40440
|
+
const read = opts.read ?? "text";
|
|
40441
|
+
const timeoutMs = opts.timeoutMs === false ? 0 : opts.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
40442
|
+
const caller = withAmbientCancellation(init?.signal ?? void 0);
|
|
40443
|
+
if (caller?.aborted)
|
|
40444
|
+
throw reasonOf(caller);
|
|
40445
|
+
const timer = timeoutMs > 0 ? new AbortController() : void 0;
|
|
40446
|
+
const signal = combine(timer?.signal, caller);
|
|
40447
|
+
let handle;
|
|
40448
|
+
let detach = () => {
|
|
40449
|
+
};
|
|
40450
|
+
const stop = signal ? new Promise((_resolve, reject) => {
|
|
40451
|
+
const onAbort = () => reject(timer?.signal.aborted ? new RequestTimeoutError(service, timeoutMs) : reasonOf(caller));
|
|
40452
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
40453
|
+
detach = () => signal.removeEventListener("abort", onAbort);
|
|
40454
|
+
}) : void 0;
|
|
40455
|
+
stop?.catch(() => {
|
|
40456
|
+
});
|
|
40457
|
+
const bounded = (p) => stop ? Promise.race([p, stop]) : p;
|
|
40458
|
+
if (timer)
|
|
40459
|
+
handle = setTimeout(() => timer.abort(), timeoutMs);
|
|
40460
|
+
try {
|
|
40461
|
+
let res;
|
|
40462
|
+
try {
|
|
40463
|
+
res = await bounded(doFetch(url2, { ...init, ...signal ? { signal } : {} }));
|
|
40464
|
+
} catch (err) {
|
|
40465
|
+
if (timer?.signal.aborted)
|
|
40466
|
+
throw new RequestTimeoutError(service, timeoutMs);
|
|
40467
|
+
if (caller?.aborted)
|
|
40468
|
+
throw reasonOf(caller);
|
|
40469
|
+
throw err;
|
|
40470
|
+
}
|
|
40471
|
+
if (read === "none") {
|
|
40472
|
+
cancelStream(res.body);
|
|
40473
|
+
return done(res, void 0);
|
|
40474
|
+
}
|
|
40475
|
+
const bytes = await readBytesCapped(res, opts.maxBytes, service, bounded);
|
|
40476
|
+
if (read === "bytes")
|
|
40477
|
+
return done(res, bytes);
|
|
40478
|
+
const text = new TextDecoder().decode(bytes);
|
|
40479
|
+
if (read === "text")
|
|
40480
|
+
return done(res, text);
|
|
40481
|
+
if (text.length === 0)
|
|
40482
|
+
return done(res, void 0);
|
|
40483
|
+
try {
|
|
40484
|
+
return done(res, JSON.parse(text));
|
|
40485
|
+
} catch (cause) {
|
|
40486
|
+
const type = res.headers.get("content-type") ?? "no content-type";
|
|
40487
|
+
throw new McpToolError(`${service} returned a non-JSON response (HTTP ${res.status}, ${type}).`, {
|
|
40488
|
+
hint: "The upstream may have served an error or sign-in page instead of data.",
|
|
40489
|
+
cause,
|
|
40490
|
+
status: res.status
|
|
40491
|
+
});
|
|
40492
|
+
}
|
|
40493
|
+
} finally {
|
|
40494
|
+
clearTimeout(handle);
|
|
40495
|
+
detach();
|
|
40496
|
+
}
|
|
40497
|
+
function done(res, body) {
|
|
40498
|
+
return { res, status: res.status, ok: res.ok, headers: res.headers, body };
|
|
40499
|
+
}
|
|
40500
|
+
}
|
|
40501
|
+
function combine(a, b) {
|
|
40502
|
+
if (a && b)
|
|
40503
|
+
return AbortSignal.any([a, b]);
|
|
40504
|
+
return a ?? b;
|
|
40505
|
+
}
|
|
40506
|
+
function reasonOf(signal) {
|
|
40507
|
+
const reason = signal.reason;
|
|
40508
|
+
return reason instanceof Error ? reason : new Error(String(reason));
|
|
40509
|
+
}
|
|
40510
|
+
function hostOf(url2) {
|
|
40511
|
+
try {
|
|
40512
|
+
return new URL(url2).host;
|
|
40513
|
+
} catch {
|
|
40514
|
+
return String(url2);
|
|
40515
|
+
}
|
|
40516
|
+
}
|
|
40517
|
+
|
|
40369
40518
|
// node_modules/@chrischall/mcp-utils/dist/netguard/address.js
|
|
40370
40519
|
function parseIPv4(text) {
|
|
40371
40520
|
if (!/^(?:0|[1-9]\d{0,2})(?:\.(?:0|[1-9]\d{0,2})){3}$/.test(text))
|
|
@@ -40449,6 +40598,7 @@ var NAT64 = V6("64:ff9b::");
|
|
|
40449
40598
|
var SIX_TO_FOUR = V6("2002::");
|
|
40450
40599
|
|
|
40451
40600
|
// node_modules/@chrischall/mcp-utils/dist/http/index.js
|
|
40601
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
40452
40602
|
var RateLimitedError = class extends Error {
|
|
40453
40603
|
status = 429;
|
|
40454
40604
|
/** `'http'`: the far side answered, with a 429 (see `status`). */
|
|
@@ -40504,8 +40654,8 @@ function headerOf(headers, name) {
|
|
|
40504
40654
|
if (typeof headers.get === "function")
|
|
40505
40655
|
return headers.get(name) ?? void 0;
|
|
40506
40656
|
const wanted = name.toLowerCase();
|
|
40507
|
-
for (const [
|
|
40508
|
-
if (
|
|
40657
|
+
for (const [key2, value] of Object.entries(headers)) {
|
|
40658
|
+
if (key2.toLowerCase() === wanted)
|
|
40509
40659
|
return value;
|
|
40510
40660
|
}
|
|
40511
40661
|
return void 0;
|
|
@@ -41221,8 +41371,8 @@ import { fileURLToPath } from "url";
|
|
|
41221
41371
|
|
|
41222
41372
|
// node_modules/@fetchproxy/protocol/dist/crypto.js
|
|
41223
41373
|
var subtle = globalThis.crypto.subtle;
|
|
41224
|
-
async function exportRaw(
|
|
41225
|
-
const buf = await subtle.exportKey(format,
|
|
41374
|
+
async function exportRaw(key2, format) {
|
|
41375
|
+
const buf = await subtle.exportKey(format, key2);
|
|
41226
41376
|
return new Uint8Array(buf);
|
|
41227
41377
|
}
|
|
41228
41378
|
async function generateX25519() {
|
|
@@ -41325,15 +41475,15 @@ async function hkdfSha256(ikm, salt, info, lenBytes) {
|
|
|
41325
41475
|
}, baseKey, lenBytes * 8);
|
|
41326
41476
|
return new Uint8Array(bits);
|
|
41327
41477
|
}
|
|
41328
|
-
async function aesGcmSeal(
|
|
41329
|
-
const k = await subtle.importKey("raw",
|
|
41478
|
+
async function aesGcmSeal(key2, iv, plaintext, aad) {
|
|
41479
|
+
const k = await subtle.importKey("raw", key2, { name: "AES-GCM" }, false, [
|
|
41330
41480
|
"encrypt"
|
|
41331
41481
|
]);
|
|
41332
41482
|
const ct = await subtle.encrypt({ name: "AES-GCM", iv, additionalData: aad }, k, plaintext);
|
|
41333
41483
|
return new Uint8Array(ct);
|
|
41334
41484
|
}
|
|
41335
|
-
async function aesGcmOpen(
|
|
41336
|
-
const k = await subtle.importKey("raw",
|
|
41485
|
+
async function aesGcmOpen(key2, iv, ciphertext, aad) {
|
|
41486
|
+
const k = await subtle.importKey("raw", key2, { name: "AES-GCM" }, false, [
|
|
41337
41487
|
"decrypt"
|
|
41338
41488
|
]);
|
|
41339
41489
|
const pt = await subtle.decrypt({ name: "AES-GCM", iv, additionalData: aad }, k, ciphertext);
|
|
@@ -41837,11 +41987,11 @@ function assertCaptureHeadersArray(value, label) {
|
|
|
41837
41987
|
throw new ProtocolError3(`${label}[${i}].headerName: invalid name ${JSON.stringify(entry.headerName)}`);
|
|
41838
41988
|
}
|
|
41839
41989
|
const normalizedPath = entry.path ?? "/*";
|
|
41840
|
-
const
|
|
41841
|
-
if (seen.has(
|
|
41990
|
+
const key2 = `${entry.host}\0${normalizedPath}\0${entry.headerName}`;
|
|
41991
|
+
if (seen.has(key2)) {
|
|
41842
41992
|
throw new ProtocolError3(`${label}: duplicate ${JSON.stringify({ host: entry.host, path: normalizedPath, headerName: entry.headerName })}`);
|
|
41843
41993
|
}
|
|
41844
|
-
seen.add(
|
|
41994
|
+
seen.add(key2);
|
|
41845
41995
|
for (const k of Object.keys(entry)) {
|
|
41846
41996
|
if (k !== "host" && k !== "path" && k !== "headerName") {
|
|
41847
41997
|
throw new ProtocolError3(`${label}[${i}]: unexpected field ${JSON.stringify(k)}`);
|
|
@@ -44260,10 +44410,10 @@ async function startHost(opts) {
|
|
|
44260
44410
|
const extPub = fromB64(frame.extensionSessionPub);
|
|
44261
44411
|
const shared = await ecdhX25519(held.priv, extPub);
|
|
44262
44412
|
const salt = await transcriptHash(held.nonce, extNonce, held.pub, extPub);
|
|
44263
|
-
const
|
|
44413
|
+
const key2 = await hkdfSha256(shared, salt, enc5.encode(HKDF_SESSION_INFO), 32);
|
|
44264
44414
|
if (extensionWs !== ws)
|
|
44265
44415
|
return;
|
|
44266
|
-
ownSession = new SessionState(
|
|
44416
|
+
ownSession = new SessionState(key2);
|
|
44267
44417
|
ownSessionInfo = sessionInfoFromHello(verifiedHello);
|
|
44268
44418
|
ownDecryptFailures = 0;
|
|
44269
44419
|
ownPendingPairCode = null;
|
|
@@ -46828,8 +46978,8 @@ var FetchproxyServer = class {
|
|
|
46828
46978
|
return { ...opts, expectStatus: [...DEFAULT_JSON_OK_STATUSES] };
|
|
46829
46979
|
}
|
|
46830
46980
|
hasContentType(headers) {
|
|
46831
|
-
for (const
|
|
46832
|
-
if (
|
|
46981
|
+
for (const key2 of Object.keys(headers)) {
|
|
46982
|
+
if (key2.toLowerCase() === "content-type")
|
|
46833
46983
|
return true;
|
|
46834
46984
|
}
|
|
46835
46985
|
return false;
|
|
@@ -47702,7 +47852,7 @@ function describeTokenlessLogin(record2) {
|
|
|
47702
47852
|
|
|
47703
47853
|
// src/version.ts
|
|
47704
47854
|
var SERVER_NAME = "ofw-mcp";
|
|
47705
|
-
var VERSION = "2.
|
|
47855
|
+
var VERSION = "2.27.1";
|
|
47706
47856
|
|
|
47707
47857
|
// src/auth.ts
|
|
47708
47858
|
function fetchproxyDisabled() {
|
|
@@ -48206,7 +48356,7 @@ function isRealCalendarDate(p) {
|
|
|
48206
48356
|
const utc = new Date(Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute, p.second));
|
|
48207
48357
|
return utc.getUTCFullYear() === p.year && utc.getUTCMonth() === p.month - 1 && utc.getUTCDate() === p.day && utc.getUTCHours() === p.hour && utc.getUTCMinutes() === p.minute && utc.getUTCSeconds() === p.second;
|
|
48208
48358
|
}
|
|
48209
|
-
function parseTimestampValue(
|
|
48359
|
+
function parseTimestampValue(key2, value, assumeNaiveIn) {
|
|
48210
48360
|
if (typeof value !== "string") return null;
|
|
48211
48361
|
const raw = value.trim();
|
|
48212
48362
|
if (raw === "" || DATE_ONLY.test(raw)) return null;
|
|
@@ -48275,18 +48425,18 @@ function walk(node2, tz) {
|
|
|
48275
48425
|
}
|
|
48276
48426
|
if (node2 === null || typeof node2 !== "object") return node2;
|
|
48277
48427
|
const obj = node2;
|
|
48278
|
-
for (const
|
|
48279
|
-
const value = obj[
|
|
48428
|
+
for (const key2 of Object.keys(obj)) {
|
|
48429
|
+
const value = obj[key2];
|
|
48280
48430
|
if (value !== null && typeof value === "object") {
|
|
48281
48431
|
walk(value, tz);
|
|
48282
48432
|
continue;
|
|
48283
48433
|
}
|
|
48284
|
-
if (ZONE_NAME_KEYS.has(
|
|
48285
|
-
const instant = parseTimestampValue(
|
|
48434
|
+
if (ZONE_NAME_KEYS.has(key2) || !TIMESTAMP_KEYS.has(key2)) continue;
|
|
48435
|
+
const instant = parseTimestampValue(key2, value, tz);
|
|
48286
48436
|
if (!instant) continue;
|
|
48287
48437
|
const { iso, display } = formatInstant(instant, tz);
|
|
48288
|
-
obj[
|
|
48289
|
-
obj[`${
|
|
48438
|
+
obj[key2] = iso;
|
|
48439
|
+
obj[`${key2}Display`] = display;
|
|
48290
48440
|
}
|
|
48291
48441
|
return obj;
|
|
48292
48442
|
}
|
|
@@ -48315,7 +48465,7 @@ function jsonErrorResponse(data) {
|
|
|
48315
48465
|
}
|
|
48316
48466
|
var ApiRecipientSchema = external_exports.looseObject({
|
|
48317
48467
|
// Live OFW payloads key the recipient's id as `userId` (verified against a
|
|
48318
|
-
// real /pub/v3/messages record: `recipients[].user.userId ===
|
|
48468
|
+
// real /pub/v3/messages record: `recipients[].user.userId === 2000001`). An
|
|
48319
48469
|
// earlier guess read `id`, which is absent — so every normalized recipient
|
|
48320
48470
|
// came out with `userId: 0`, breaking any "find my own recipient" match. Both
|
|
48321
48471
|
// are accepted (userId first, id fallback) so a backend that ever returns `id`
|
|
@@ -49098,6 +49248,12 @@ function getAttachmentsDir() {
|
|
|
49098
49248
|
function getDefaultAttachmentsDir() {
|
|
49099
49249
|
return join10(homedir4(), "Downloads", "ofw-mcp");
|
|
49100
49250
|
}
|
|
49251
|
+
function isHostedDeployment(env = process.env) {
|
|
49252
|
+
return readEnvVar("MCP_DATA_DIR", { env }) !== void 0 || readEnvVar("MCP_BLOB_BASE_URL", { env }) !== void 0;
|
|
49253
|
+
}
|
|
49254
|
+
function hasBlobStoreEnv(env = process.env) {
|
|
49255
|
+
return readEnvVar("MCP_BLOB_BASE_URL", { env }) !== void 0 && readEnvVar("MCP_BLOB_SIGNING_KEY", { env }) !== void 0;
|
|
49256
|
+
}
|
|
49101
49257
|
function getUploadDir() {
|
|
49102
49258
|
const override = process.env.OFW_UPLOAD_DIR;
|
|
49103
49259
|
if (override && override.trim().length > 0) return override.trim();
|
|
@@ -49299,9 +49455,11 @@ function fnv1a64(s) {
|
|
|
49299
49455
|
}
|
|
49300
49456
|
return h.toString(16).padStart(16, "0");
|
|
49301
49457
|
}
|
|
49302
|
-
function draftRevision(d) {
|
|
49458
|
+
function draftRevision(d, heldFiles = []) {
|
|
49303
49459
|
const ids = [...new Set(d.recipients.map((r) => r.userId))].sort((a, b) => a - b);
|
|
49304
49460
|
const parts = [d.subject, d.body, String(d.replyToId ?? ""), ids.join(",")];
|
|
49461
|
+
const held = [...new Set(heldFiles)].sort((a, b) => a - b);
|
|
49462
|
+
if (held.length > 0) parts.push(`files:${held.join(",")}`);
|
|
49305
49463
|
return `r1:${fnv1a64(parts.map((p) => `${p.length}:${p}`).join("|"))}`;
|
|
49306
49464
|
}
|
|
49307
49465
|
var ServerDraftSchema = external_exports.looseObject({
|
|
@@ -49388,6 +49546,7 @@ function diffFields(a, b) {
|
|
|
49388
49546
|
}
|
|
49389
49547
|
function checkDraftFreshness(input2) {
|
|
49390
49548
|
const { server, cached: cached2, expectedRevision } = input2;
|
|
49549
|
+
const held = input2.heldFiles ?? [];
|
|
49391
49550
|
if (server === null) {
|
|
49392
49551
|
return {
|
|
49393
49552
|
verdict: "MISSING",
|
|
@@ -49396,11 +49555,11 @@ function checkDraftFreshness(input2) {
|
|
|
49396
49555
|
};
|
|
49397
49556
|
}
|
|
49398
49557
|
if (expectedRevision !== void 0) {
|
|
49399
|
-
const actual = draftRevision(server);
|
|
49400
|
-
if (expectedRevision === actual) {
|
|
49558
|
+
const actual = draftRevision(server, held);
|
|
49559
|
+
if (expectedRevision === actual || expectedRevision === draftRevision(server)) {
|
|
49401
49560
|
return { verdict: "FRESH", reason: "expectedRevision matches the live server draft.", changedFields: [] };
|
|
49402
49561
|
}
|
|
49403
|
-
if (cached2 !== null && draftRevision(cached2) === expectedRevision) {
|
|
49562
|
+
if (cached2 !== null && (draftRevision(cached2, held) === expectedRevision || draftRevision(cached2) === expectedRevision)) {
|
|
49404
49563
|
const changedFields2 = diffFields(server, cached2);
|
|
49405
49564
|
if (substantiveChanges(changedFields2).length === 0) {
|
|
49406
49565
|
return {
|
|
@@ -49450,12 +49609,40 @@ function staleDraftPayload(input2) {
|
|
|
49450
49609
|
verdict: verdict.verdict,
|
|
49451
49610
|
reason: verdict.reason,
|
|
49452
49611
|
...verdict.changedFields.length > 0 ? { changedFields: verdict.changedFields } : {},
|
|
49453
|
-
...server !== null ? { serverBody: server.body, serverSubject: server.subject, serverRevision: draftRevision(server) } : {},
|
|
49612
|
+
...server !== null ? { serverBody: server.body, serverSubject: server.subject, serverRevision: draftRevision(server, input2.heldFiles ?? []) } : {},
|
|
49454
49613
|
...cached2 !== null ? { cachedBody: cached2.body } : {},
|
|
49455
49614
|
recovery: server === null ? "The draft is gone from OurFamilyWizard. Nothing was changed. If you still want this content saved, call ofw_save_draft WITHOUT messageId to create a new draft." : "Nothing was changed. Merge your edit into serverBody above, then retry with expectedRevision set to serverRevision. Pass force:true only if you intend to discard the server copy shown here."
|
|
49456
49615
|
};
|
|
49457
49616
|
}
|
|
49458
49617
|
|
|
49618
|
+
// src/tools/held-attachments.ts
|
|
49619
|
+
var key = (draftId) => `draft_held_files:${draftId}`;
|
|
49620
|
+
function uniqueIds(ids) {
|
|
49621
|
+
return [...new Set(ids)];
|
|
49622
|
+
}
|
|
49623
|
+
async function getHeldFiles(cache, draftId) {
|
|
49624
|
+
const raw = await cache.getMeta(key(draftId));
|
|
49625
|
+
if (!raw) return [];
|
|
49626
|
+
try {
|
|
49627
|
+
const parsed = JSON.parse(raw);
|
|
49628
|
+
return Array.isArray(parsed) ? parsed.filter((v) => Number.isInteger(v)) : [];
|
|
49629
|
+
} catch {
|
|
49630
|
+
return [];
|
|
49631
|
+
}
|
|
49632
|
+
}
|
|
49633
|
+
async function setHeldFiles(cache, draftId, ids) {
|
|
49634
|
+
await cache.setMeta(key(draftId), JSON.stringify(uniqueIds(ids)));
|
|
49635
|
+
}
|
|
49636
|
+
async function clearHeldFiles(cache, draftId) {
|
|
49637
|
+
await cache.setMeta(key(draftId), "[]");
|
|
49638
|
+
}
|
|
49639
|
+
async function heldFilesFor(cache, draftIds) {
|
|
49640
|
+
const out = /* @__PURE__ */ new Map();
|
|
49641
|
+
for (const id2 of draftIds) out.set(id2, await getHeldFiles(cache, id2));
|
|
49642
|
+
return out;
|
|
49643
|
+
}
|
|
49644
|
+
var HELD_NOTE = "OurFamilyWizard drafts do not store attachments, so these files are held with this draft by this server and attached when you send it with ofw_send_message (draftId). They are not visible on the draft in the OurFamilyWizard web app.";
|
|
49645
|
+
|
|
49459
49646
|
// src/tools/lifecycle.ts
|
|
49460
49647
|
var FOLDER_TYPE = {
|
|
49461
49648
|
inbox: "INBOX",
|
|
@@ -49564,13 +49751,13 @@ async function probeIds(client2, store, ids, opts) {
|
|
|
49564
49751
|
items.push({ id: p.id, skipped: true, reason: "WOULD_MARK_READ", note: SKIP_NOTE });
|
|
49565
49752
|
continue;
|
|
49566
49753
|
}
|
|
49567
|
-
const probe = await probeOne(client2, p, map2, keyById.get(p.id) ?? null);
|
|
49754
|
+
const probe = await probeOne(client2, p, map2, keyById.get(p.id) ?? null, await getHeldFiles(store, p.id));
|
|
49568
49755
|
requests += probe.requests;
|
|
49569
49756
|
items.push(probe.item);
|
|
49570
49757
|
}
|
|
49571
49758
|
return { items, requests };
|
|
49572
49759
|
}
|
|
49573
|
-
async function probeOne(client2, prepared, map2, draftKey) {
|
|
49760
|
+
async function probeOne(client2, prepared, map2, draftKey, heldFiles) {
|
|
49574
49761
|
const { id: id2, cachedDraft } = prepared;
|
|
49575
49762
|
let snapshot;
|
|
49576
49763
|
try {
|
|
@@ -49588,8 +49775,8 @@ async function probeOne(client2, prepared, map2, draftKey) {
|
|
|
49588
49775
|
};
|
|
49589
49776
|
}
|
|
49590
49777
|
const state = classifyState(snapshot, map2);
|
|
49591
|
-
const cacheRevision = cachedDraft === null ? null : draftRevision(cachedDraft);
|
|
49592
|
-
const serverRevision = snapshot === null ? null : draftRevision(snapshot.content);
|
|
49778
|
+
const cacheRevision = cachedDraft === null ? null : draftRevision(cachedDraft, heldFiles);
|
|
49779
|
+
const serverRevision = snapshot === null ? null : draftRevision(snapshot.content, heldFiles);
|
|
49593
49780
|
const viewedAt = snapshot?.content.recipients.find((r) => r.viewedAt !== null)?.viewedAt ?? null;
|
|
49594
49781
|
let inSync;
|
|
49595
49782
|
if (cachedDraft === null) inSync = null;
|
|
@@ -49663,6 +49850,644 @@ function stateRevision(value) {
|
|
|
49663
49850
|
return `s1:${fnv1a64(JSON.stringify(value))}`;
|
|
49664
49851
|
}
|
|
49665
49852
|
|
|
49853
|
+
// src/tools/attachments.ts
|
|
49854
|
+
import { chmodSync as chmodSync3, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync3, mkdirSync as mkdirSync5, unlinkSync as unlinkSync5 } from "node:fs";
|
|
49855
|
+
import { basename as basename2, dirname as dirname6, extname, isAbsolute as isAbsolute6, join as join11, relative as relative2, resolve as resolve5, sep as sep2 } from "node:path";
|
|
49856
|
+
function isWithin(root, candidate) {
|
|
49857
|
+
const rel = relative2(root, candidate);
|
|
49858
|
+
return rel !== "" && !rel.startsWith("..") && !isAbsolute6(rel);
|
|
49859
|
+
}
|
|
49860
|
+
function resolveSaveDest(root, saveTo, defaultName) {
|
|
49861
|
+
if (!saveTo) return join11(root, defaultName);
|
|
49862
|
+
const isDirArg = saveTo.endsWith("/") || saveTo.endsWith("\\");
|
|
49863
|
+
const abs = resolve5(root, saveTo.startsWith("~") ? expandPath(saveTo) : saveTo);
|
|
49864
|
+
const dest = isDirArg ? join11(abs, defaultName) : abs;
|
|
49865
|
+
if (!isWithin(root, dest)) {
|
|
49866
|
+
throw new Error(`Refusing to save to ${dest}: it is outside the attachments directory (${root}). Files can only be written inside it \u2014 pass a path or subdirectory under it, or set OFW_ATTACHMENTS_DIR to move it.`);
|
|
49867
|
+
}
|
|
49868
|
+
return dest;
|
|
49869
|
+
}
|
|
49870
|
+
var MIME_BY_EXT = {
|
|
49871
|
+
".pdf": "application/pdf",
|
|
49872
|
+
".png": "image/png",
|
|
49873
|
+
".jpg": "image/jpeg",
|
|
49874
|
+
".jpeg": "image/jpeg",
|
|
49875
|
+
".gif": "image/gif",
|
|
49876
|
+
".webp": "image/webp",
|
|
49877
|
+
".heic": "image/heic",
|
|
49878
|
+
".txt": "text/plain",
|
|
49879
|
+
".md": "text/markdown",
|
|
49880
|
+
".csv": "text/csv",
|
|
49881
|
+
".html": "text/html",
|
|
49882
|
+
".htm": "text/html",
|
|
49883
|
+
".json": "application/json",
|
|
49884
|
+
".xml": "application/xml",
|
|
49885
|
+
".doc": "application/msword",
|
|
49886
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
49887
|
+
".xls": "application/vnd.ms-excel",
|
|
49888
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
49889
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
49890
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
49891
|
+
".zip": "application/zip",
|
|
49892
|
+
".ics": "text/calendar"
|
|
49893
|
+
};
|
|
49894
|
+
function mimeFromName(name) {
|
|
49895
|
+
return MIME_BY_EXT[extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
49896
|
+
}
|
|
49897
|
+
var OCTET_STREAM = "application/octet-stream";
|
|
49898
|
+
var HOST_RENDERABLE_IMAGE_MIMES = /* @__PURE__ */ new Set([
|
|
49899
|
+
"image/png",
|
|
49900
|
+
"image/jpeg",
|
|
49901
|
+
"image/gif",
|
|
49902
|
+
"image/webp"
|
|
49903
|
+
]);
|
|
49904
|
+
function normalizeMimeType(raw) {
|
|
49905
|
+
if (!raw) return OCTET_STREAM;
|
|
49906
|
+
const bare = raw.split(";", 1)[0].trim().toLowerCase();
|
|
49907
|
+
return bare || OCTET_STREAM;
|
|
49908
|
+
}
|
|
49909
|
+
function sniffImageMime(bytes) {
|
|
49910
|
+
const sniffed = sniffMimeBytes(bytes);
|
|
49911
|
+
return sniffed !== void 0 && HOST_RENDERABLE_IMAGE_MIMES.has(sniffed) ? sniffed : null;
|
|
49912
|
+
}
|
|
49913
|
+
function resolveDownloadMime(bytes, headerMime, fileName) {
|
|
49914
|
+
const sniffed = sniffImageMime(bytes);
|
|
49915
|
+
if (sniffed) return sniffed;
|
|
49916
|
+
const fromHeader = normalizeMimeType(headerMime);
|
|
49917
|
+
if (fromHeader !== OCTET_STREAM) return fromHeader;
|
|
49918
|
+
return mimeFromName(fileName);
|
|
49919
|
+
}
|
|
49920
|
+
function isHostRenderableImage(mime) {
|
|
49921
|
+
return HOST_RENDERABLE_IMAGE_MIMES.has(mime);
|
|
49922
|
+
}
|
|
49923
|
+
var MAX_UPLOAD_BYTES = 25 * 1024 * 1024;
|
|
49924
|
+
function hostedPathRefusal(hasBlobStore) {
|
|
49925
|
+
return new Error(
|
|
49926
|
+
"This server is remote and can't read files on your machine, so `path` cannot work here. " + (hasBlobStore ? "Upload the bytes instead: call ofw_upload_attachment with uploadSlots:[{filename}] to get a signed upload URL, PUT the file to it (the response includes a ready curl command), then call it again with blobKeys. For a small file you can instead pass `inline` with base64 content." : "Pass the bytes with `inline` ({filename, contentBase64}) instead.")
|
|
49927
|
+
);
|
|
49928
|
+
}
|
|
49929
|
+
var NodeAttachmentIO = class {
|
|
49930
|
+
supportsDisk = true;
|
|
49931
|
+
async resolveUpload(path) {
|
|
49932
|
+
if (isHostedDeployment()) throw hostedPathRefusal(hasBlobStoreEnv());
|
|
49933
|
+
const root = resolve5(getUploadDir());
|
|
49934
|
+
mkdirSync5(root, { recursive: true, mode: 448 });
|
|
49935
|
+
const abs = resolve5(root, path.startsWith("~") ? expandPath(path) : path);
|
|
49936
|
+
const outside = new Error(`Refusing to upload ${abs}: it is outside the upload directory (${root}). Only files placed in that directory can be uploaded \u2014 ask the user to copy the file there, or set OFW_UPLOAD_DIR.`);
|
|
49937
|
+
if (!isWithin(root, abs)) throw outside;
|
|
49938
|
+
let real;
|
|
49939
|
+
try {
|
|
49940
|
+
real = realpathSync3(abs);
|
|
49941
|
+
} catch (e) {
|
|
49942
|
+
if (e.code !== "ENOENT") throw e;
|
|
49943
|
+
throw new Error(`File not found in the upload directory (${root}): ${abs}. Copy the file there first, or pass its bytes with \`inline\`.`);
|
|
49944
|
+
}
|
|
49945
|
+
const realRoot = realpathSync3(root);
|
|
49946
|
+
try {
|
|
49947
|
+
assertPathWithinRoots(real, [realRoot]);
|
|
49948
|
+
} catch {
|
|
49949
|
+
throw outside;
|
|
49950
|
+
}
|
|
49951
|
+
if (relative2(realRoot, real).split(sep2).some((segment) => segment.startsWith("."))) {
|
|
49952
|
+
throw new Error(`Refusing to upload ${abs}: hidden files and files in hidden directories (dotfiles, credential stores) are never uploaded.`);
|
|
49953
|
+
}
|
|
49954
|
+
const stat = statSync3(real);
|
|
49955
|
+
if (!stat.isFile()) throw new Error(`Not a file: ${abs}`);
|
|
49956
|
+
if (stat.size > MAX_UPLOAD_BYTES) {
|
|
49957
|
+
throw new Error(`Refusing to upload ${abs}: it is too large (${stat.size} bytes; the limit is ${MAX_UPLOAD_BYTES}).`);
|
|
49958
|
+
}
|
|
49959
|
+
const fileName = basename2(abs);
|
|
49960
|
+
const mimeType = mimeFromName(fileName);
|
|
49961
|
+
const blob = await fileBlob(real, { type: mimeType, allowedRoots: [realRoot] });
|
|
49962
|
+
return { blob, fileName, mimeType, sizeBytes: stat.size };
|
|
49963
|
+
}
|
|
49964
|
+
readDownloaded(path) {
|
|
49965
|
+
try {
|
|
49966
|
+
return readFileSync4(path);
|
|
49967
|
+
} catch {
|
|
49968
|
+
return null;
|
|
49969
|
+
}
|
|
49970
|
+
}
|
|
49971
|
+
async writeDownload(dest, bytes, { root, overwrite }) {
|
|
49972
|
+
mkdirSync5(root, { recursive: true, mode: 448 });
|
|
49973
|
+
if (resolve5(root) === resolve5(getDefaultAttachmentsDir())) chmodSync3(root, 448);
|
|
49974
|
+
const realRoot = realpathSync3(root);
|
|
49975
|
+
const parent = dirname6(dest);
|
|
49976
|
+
const outside = () => new Error(`Refusing to write ${dest}: it resolves outside the attachments directory (${root}).`);
|
|
49977
|
+
try {
|
|
49978
|
+
assertPathWithinRoots(parent, [realRoot]);
|
|
49979
|
+
} catch {
|
|
49980
|
+
throw outside();
|
|
49981
|
+
}
|
|
49982
|
+
mkdirSync5(parent, { recursive: true, mode: 448 });
|
|
49983
|
+
if (overwrite) {
|
|
49984
|
+
try {
|
|
49985
|
+
unlinkSync5(dest);
|
|
49986
|
+
} catch {
|
|
49987
|
+
}
|
|
49988
|
+
}
|
|
49989
|
+
try {
|
|
49990
|
+
await writeFileSafe(dest, bytes, { mode: 384, allowedRoots: [realRoot] });
|
|
49991
|
+
} catch (e) {
|
|
49992
|
+
if (e instanceof FileWriteRefusedError) {
|
|
49993
|
+
if (e.reason === "outside-roots") throw outside();
|
|
49994
|
+
throw new Error(`Refusing to overwrite ${dest}: a file already exists there. Pass force:true to replace it, or choose another saveTo.`);
|
|
49995
|
+
}
|
|
49996
|
+
throw e;
|
|
49997
|
+
}
|
|
49998
|
+
}
|
|
49999
|
+
};
|
|
50000
|
+
|
|
50001
|
+
// node_modules/@chrischall/mcp-utils/dist/export/blob.js
|
|
50002
|
+
import { createHmac as createHmac4 } from "node:crypto";
|
|
50003
|
+
var BLOB_DEFAULT_TTL_MS = 60 * 60 * 1e3;
|
|
50004
|
+
var BLOB_MAX_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
50005
|
+
var BLOB_MAX_OBJECT_BYTES = 100 * 1024 * 1024;
|
|
50006
|
+
var MAX_KEY_LENGTH = 1024;
|
|
50007
|
+
var SAFE_SEGMENT = /^[A-Za-z0-9._~-]+$/;
|
|
50008
|
+
function configError(reason) {
|
|
50009
|
+
return new McpToolError(`MCP_BLOB_BASE_URL is not usable: ${reason}.`, {
|
|
50010
|
+
hint: "It should look like https://<host>/b/<registrationId> \u2014 check the deployment's environment.",
|
|
50011
|
+
kind: "unknown"
|
|
50012
|
+
});
|
|
50013
|
+
}
|
|
50014
|
+
function parseBase(baseUrl) {
|
|
50015
|
+
let parsed;
|
|
50016
|
+
try {
|
|
50017
|
+
parsed = new URL(baseUrl);
|
|
50018
|
+
} catch {
|
|
50019
|
+
throw configError("not a valid URL");
|
|
50020
|
+
}
|
|
50021
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:")
|
|
50022
|
+
throw configError("scheme must be http(s)");
|
|
50023
|
+
if (parsed.username || parsed.password)
|
|
50024
|
+
throw configError("must not contain credentials");
|
|
50025
|
+
if (parsed.search || parsed.hash)
|
|
50026
|
+
throw configError("must not contain a query or fragment");
|
|
50027
|
+
const path = parsed.pathname.replace(/^\/+|\/+$/g, "");
|
|
50028
|
+
const prefix = path.startsWith("b/") ? path.slice(2) : path;
|
|
50029
|
+
if (!prefix || prefix === "b")
|
|
50030
|
+
throw configError("has no registration path");
|
|
50031
|
+
return { base: `${parsed.origin}/${path}`, prefix };
|
|
50032
|
+
}
|
|
50033
|
+
function badInput(message) {
|
|
50034
|
+
return new McpToolError(message, { kind: "unknown" });
|
|
50035
|
+
}
|
|
50036
|
+
function encodeKey(key2) {
|
|
50037
|
+
if (typeof key2 !== "string" || key2.length === 0)
|
|
50038
|
+
throw badInput("Blob key must be a non-empty string.");
|
|
50039
|
+
if (key2.length > MAX_KEY_LENGTH)
|
|
50040
|
+
throw badInput(`Blob key is longer than ${MAX_KEY_LENGTH} characters.`);
|
|
50041
|
+
const segments = key2.split("/");
|
|
50042
|
+
for (const seg of segments) {
|
|
50043
|
+
if (seg === "" || seg === "." || seg === ".." || !SAFE_SEGMENT.test(seg)) {
|
|
50044
|
+
throw badInput('Blob key must be relative, slash-separated segments of [A-Za-z0-9._~-] with no empty, "." or ".." segment.');
|
|
50045
|
+
}
|
|
50046
|
+
}
|
|
50047
|
+
return segments.map(encodeURIComponent).join("/");
|
|
50048
|
+
}
|
|
50049
|
+
function checkContentType(contentType) {
|
|
50050
|
+
if (typeof contentType !== "string" || contentType.length === 0 || /[\x00-\x1f\x7f]/.test(contentType)) {
|
|
50051
|
+
throw badInput("Blob content type must be a non-empty string without control characters.");
|
|
50052
|
+
}
|
|
50053
|
+
}
|
|
50054
|
+
function expiry(opts) {
|
|
50055
|
+
const ttl = opts?.ttlMs ?? BLOB_DEFAULT_TTL_MS;
|
|
50056
|
+
if (!Number.isFinite(ttl) || ttl <= 0 || ttl > BLOB_MAX_TTL_MS) {
|
|
50057
|
+
throw badInput(`Blob link TTL must be between 1 ms and ${BLOB_MAX_TTL_MS} ms (24h); the gateway refuses longer.`);
|
|
50058
|
+
}
|
|
50059
|
+
return Math.floor((opts?.now ?? Date.now()) + ttl);
|
|
50060
|
+
}
|
|
50061
|
+
function toArrayBuffer(view) {
|
|
50062
|
+
const buf = view.buffer;
|
|
50063
|
+
if (buf instanceof ArrayBuffer && view.byteOffset === 0 && view.byteLength === buf.byteLength)
|
|
50064
|
+
return buf;
|
|
50065
|
+
return view.slice().buffer;
|
|
50066
|
+
}
|
|
50067
|
+
function createBlobStore(opts) {
|
|
50068
|
+
const { base, prefix } = parseBase(opts.baseUrl);
|
|
50069
|
+
const signingKey = opts.signingKey;
|
|
50070
|
+
const sign2 = (payload) => createHmac4("sha256", signingKey).update(payload).digest("base64url");
|
|
50071
|
+
const link2 = (encodedKey, exp, sig) => `${base}/${encodedKey}?exp=${exp}&sig=${encodeURIComponent(sig)}`;
|
|
50072
|
+
const signGetUrl = (key2, o) => {
|
|
50073
|
+
const encoded = encodeKey(key2);
|
|
50074
|
+
const exp = expiry(o);
|
|
50075
|
+
return { url: link2(encoded, exp, sign2(`${prefix}/${key2}
|
|
50076
|
+
${exp}`)), expiresAtMs: exp };
|
|
50077
|
+
};
|
|
50078
|
+
const signPutUrl = (key2, contentType, o) => {
|
|
50079
|
+
const encoded = encodeKey(key2);
|
|
50080
|
+
checkContentType(contentType);
|
|
50081
|
+
const exp = expiry(o);
|
|
50082
|
+
return { url: link2(encoded, exp, sign2(`put\0${prefix}/${key2}\0${contentType}\0${exp}`)), expiresAtMs: exp };
|
|
50083
|
+
};
|
|
50084
|
+
const put = async (key2, body, contentType, o = {}) => {
|
|
50085
|
+
const { url: url2 } = signPutUrl(key2, contentType, o);
|
|
50086
|
+
const bytes = typeof body === "string" ? new TextEncoder().encode(body) : body;
|
|
50087
|
+
const doFetch = o.fetchImpl ?? fetch;
|
|
50088
|
+
let res;
|
|
50089
|
+
try {
|
|
50090
|
+
res = await doFetch(url2, {
|
|
50091
|
+
method: "PUT",
|
|
50092
|
+
headers: { "content-type": contentType },
|
|
50093
|
+
body: toArrayBuffer(bytes),
|
|
50094
|
+
...o.signal ? { signal: o.signal } : {}
|
|
50095
|
+
});
|
|
50096
|
+
} catch (cause) {
|
|
50097
|
+
if (o.signal?.aborted)
|
|
50098
|
+
throw cause;
|
|
50099
|
+
throw new McpToolError(`Blob store upload of ${key2} did not complete (network error).`, {
|
|
50100
|
+
kind: "transport"
|
|
50101
|
+
});
|
|
50102
|
+
}
|
|
50103
|
+
if (!res.ok) {
|
|
50104
|
+
throw new McpToolError(`Blob store upload of ${key2} failed (HTTP ${res.status}).`, {
|
|
50105
|
+
kind: "http",
|
|
50106
|
+
status: res.status
|
|
50107
|
+
});
|
|
50108
|
+
}
|
|
50109
|
+
return { key: key2, bytes: bytes.byteLength };
|
|
50110
|
+
};
|
|
50111
|
+
const signDeleteUrl = (key2, o) => {
|
|
50112
|
+
const encoded = encodeKey(key2);
|
|
50113
|
+
const exp = expiry(o);
|
|
50114
|
+
return { url: link2(encoded, exp, sign2(`del\0${prefix}/${key2}\0${exp}`)), expiresAtMs: exp };
|
|
50115
|
+
};
|
|
50116
|
+
const exchange = async (what, url2, method, read, o) => {
|
|
50117
|
+
try {
|
|
50118
|
+
return await fetchBounded(url2, { method, ...o.signal ? { signal: o.signal } : {} }, {
|
|
50119
|
+
read,
|
|
50120
|
+
service: "the blob store",
|
|
50121
|
+
...read === "bytes" ? { maxBytes: o.maxBytes ?? BLOB_MAX_OBJECT_BYTES } : {},
|
|
50122
|
+
...o.timeoutMs !== void 0 ? { timeoutMs: o.timeoutMs } : {},
|
|
50123
|
+
...o.fetchImpl ? { fetchImpl: o.fetchImpl } : {}
|
|
50124
|
+
});
|
|
50125
|
+
} catch (cause) {
|
|
50126
|
+
if (o.signal?.aborted || cause instanceof McpToolError || cause instanceof RequestTimeoutError)
|
|
50127
|
+
throw cause;
|
|
50128
|
+
throw new McpToolError(`Blob store ${what} did not complete (network error).`, { kind: "transport" });
|
|
50129
|
+
}
|
|
50130
|
+
};
|
|
50131
|
+
const get = async (key2, o = {}) => {
|
|
50132
|
+
const { url: url2 } = signGetUrl(key2, o);
|
|
50133
|
+
const res = await exchange(`read of ${key2}`, url2, "GET", "bytes", o);
|
|
50134
|
+
if (!res.ok) {
|
|
50135
|
+
const why = res.status === 404 ? " \u2014 not found (never uploaded, expired, or already consumed)" : "";
|
|
50136
|
+
throw new McpToolError(`Blob store read of ${key2} failed (HTTP ${res.status})${why}.`, {
|
|
50137
|
+
kind: "http",
|
|
50138
|
+
status: res.status
|
|
50139
|
+
});
|
|
50140
|
+
}
|
|
50141
|
+
const contentType = res.headers.get("content-type") ?? void 0;
|
|
50142
|
+
return { key: key2, bytes: res.body, ...contentType !== void 0 ? { contentType } : {} };
|
|
50143
|
+
};
|
|
50144
|
+
const del = async (key2, o = {}) => {
|
|
50145
|
+
const { url: url2 } = signDeleteUrl(key2, o);
|
|
50146
|
+
const res = await exchange(`delete of ${key2}`, url2, "DELETE", "none", o);
|
|
50147
|
+
if (!res.ok) {
|
|
50148
|
+
throw new McpToolError(`Blob store delete of ${key2} failed (HTTP ${res.status}).`, {
|
|
50149
|
+
kind: "http",
|
|
50150
|
+
status: res.status
|
|
50151
|
+
});
|
|
50152
|
+
}
|
|
50153
|
+
};
|
|
50154
|
+
const consume = async (key2, use, o = {}) => {
|
|
50155
|
+
const object2 = await get(key2, o);
|
|
50156
|
+
const result = await use(object2);
|
|
50157
|
+
try {
|
|
50158
|
+
await del(key2, o);
|
|
50159
|
+
return { result, deleted: true };
|
|
50160
|
+
} catch (e) {
|
|
50161
|
+
return { result, deleted: false, deleteError: e instanceof Error ? e.message : String(e) };
|
|
50162
|
+
}
|
|
50163
|
+
};
|
|
50164
|
+
return { baseUrl: base, prefix, signGetUrl, signPutUrl, put, signDeleteUrl, get, delete: del, consume };
|
|
50165
|
+
}
|
|
50166
|
+
function blobStoreFromEnv(env = process.env) {
|
|
50167
|
+
const baseUrl = readEnvVar("MCP_BLOB_BASE_URL", { env });
|
|
50168
|
+
const signingKey = readEnvVar("MCP_BLOB_SIGNING_KEY", { env });
|
|
50169
|
+
if (!baseUrl || !signingKey)
|
|
50170
|
+
return void 0;
|
|
50171
|
+
return createBlobStore({ baseUrl, signingKey });
|
|
50172
|
+
}
|
|
50173
|
+
|
|
50174
|
+
// node_modules/@chrischall/mcp-utils/dist/export/zip.js
|
|
50175
|
+
var CRC_TABLE = (() => {
|
|
50176
|
+
const table = new Uint32Array(256);
|
|
50177
|
+
for (let n = 0; n < 256; n++) {
|
|
50178
|
+
let c = n;
|
|
50179
|
+
for (let k = 0; k < 8; k++)
|
|
50180
|
+
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
50181
|
+
table[n] = c >>> 0;
|
|
50182
|
+
}
|
|
50183
|
+
return table;
|
|
50184
|
+
})();
|
|
50185
|
+
|
|
50186
|
+
// node_modules/@chrischall/mcp-utils/dist/export/sink.js
|
|
50187
|
+
var EXPORT_BLOB_MAX_BYTES = 256 * 1024 * 1024;
|
|
50188
|
+
|
|
50189
|
+
// node_modules/@chrischall/mcp-utils/dist/export/upload.js
|
|
50190
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
50191
|
+
var MAX_UPLOAD_FILES = 10;
|
|
50192
|
+
var UPLOAD_KEY_PREFIX = "uploads";
|
|
50193
|
+
var UPLOAD_SLOT_DEFAULT_TTL_MS = 30 * 60 * 1e3;
|
|
50194
|
+
var MIB = 1024 * 1024;
|
|
50195
|
+
var OCTET_STREAM2 = "application/octet-stream";
|
|
50196
|
+
var inlineFileSchema = external_exports.object({
|
|
50197
|
+
filename: external_exports.string().describe("Filename the upstream will show \u2014 a bare name, no path, not starting with a dot. Its extension sets the MIME type when mimeType is omitted."),
|
|
50198
|
+
contentBase64: external_exports.string().describe(`The file's bytes, standard base64 (line breaks and a "data:<type>;base64," prefix are tolerated).`),
|
|
50199
|
+
mimeType: external_exports.string().describe('MIME type, e.g. "image/jpeg". Default: inferred from the filename extension.').optional()
|
|
50200
|
+
});
|
|
50201
|
+
var uploadSlotRequestSchema = external_exports.object({
|
|
50202
|
+
filename: external_exports.string().describe("Filename the upstream will show \u2014 a bare name, no path, not starting with a dot."),
|
|
50203
|
+
mimeType: external_exports.string().describe("MIME type. Default: inferred from the filename extension. The PUT must send exactly this Content-Type.").optional()
|
|
50204
|
+
});
|
|
50205
|
+
function sanitizeUploadFilename(raw) {
|
|
50206
|
+
const name = raw.trim();
|
|
50207
|
+
if (name.length === 0)
|
|
50208
|
+
throw new Error("filename is empty.");
|
|
50209
|
+
if (/[/\\]/.test(name)) {
|
|
50210
|
+
throw new Error(`filename ${JSON.stringify(name)} must be a bare filename, not a path \u2014 pass just the name to show, e.g. "photo.jpg".`);
|
|
50211
|
+
}
|
|
50212
|
+
if (/[\x00-\x1f\x7f]/.test(name))
|
|
50213
|
+
throw new Error(`filename ${JSON.stringify(name)} contains control characters.`);
|
|
50214
|
+
if (name.startsWith(".")) {
|
|
50215
|
+
throw new Error(`filename ${JSON.stringify(name)} must not start with a dot (hidden files are never uploaded).`);
|
|
50216
|
+
}
|
|
50217
|
+
if (name.length > 200)
|
|
50218
|
+
throw new Error("filename is longer than 200 characters.");
|
|
50219
|
+
return name;
|
|
50220
|
+
}
|
|
50221
|
+
var MIME_BY_EXT2 = {
|
|
50222
|
+
pdf: "application/pdf",
|
|
50223
|
+
png: "image/png",
|
|
50224
|
+
jpg: "image/jpeg",
|
|
50225
|
+
jpeg: "image/jpeg",
|
|
50226
|
+
gif: "image/gif",
|
|
50227
|
+
webp: "image/webp",
|
|
50228
|
+
heic: "image/heic",
|
|
50229
|
+
heif: "image/heif",
|
|
50230
|
+
tif: "image/tiff",
|
|
50231
|
+
tiff: "image/tiff",
|
|
50232
|
+
svg: "image/svg+xml",
|
|
50233
|
+
txt: "text/plain",
|
|
50234
|
+
md: "text/markdown",
|
|
50235
|
+
csv: "text/csv",
|
|
50236
|
+
html: "text/html",
|
|
50237
|
+
htm: "text/html",
|
|
50238
|
+
json: "application/json",
|
|
50239
|
+
xml: "application/xml",
|
|
50240
|
+
ics: "text/calendar",
|
|
50241
|
+
doc: "application/msword",
|
|
50242
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
50243
|
+
xls: "application/vnd.ms-excel",
|
|
50244
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
50245
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
50246
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
50247
|
+
zip: "application/zip",
|
|
50248
|
+
mp3: "audio/mpeg",
|
|
50249
|
+
m4a: "audio/mp4",
|
|
50250
|
+
wav: "audio/wav",
|
|
50251
|
+
mp4: "video/mp4",
|
|
50252
|
+
mov: "video/quicktime",
|
|
50253
|
+
webm: "video/webm"
|
|
50254
|
+
};
|
|
50255
|
+
function mimeFromFileName(name) {
|
|
50256
|
+
const dot = name.lastIndexOf(".");
|
|
50257
|
+
if (dot <= 0)
|
|
50258
|
+
return OCTET_STREAM2;
|
|
50259
|
+
return MIME_BY_EXT2[name.slice(dot + 1).toLowerCase()] ?? OCTET_STREAM2;
|
|
50260
|
+
}
|
|
50261
|
+
var MEDIA_TYPE = /^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/;
|
|
50262
|
+
function resolveUploadMime(fileName, mimeType) {
|
|
50263
|
+
if (mimeType === void 0)
|
|
50264
|
+
return mimeFromFileName(fileName);
|
|
50265
|
+
const bare = (mimeType.split(";", 1)[0] ?? "").trim().toLowerCase();
|
|
50266
|
+
if (!MEDIA_TYPE.test(bare)) {
|
|
50267
|
+
throw new Error(`mimeType ${JSON.stringify(mimeType)} is not a type/subtype media type such as "image/jpeg".`);
|
|
50268
|
+
}
|
|
50269
|
+
return bare;
|
|
50270
|
+
}
|
|
50271
|
+
function limitText(maxBytes) {
|
|
50272
|
+
return `${Math.floor(maxBytes / MIB)} MiB (${maxBytes} bytes)`;
|
|
50273
|
+
}
|
|
50274
|
+
function checkUploadSize(fileName, size, maxBytes) {
|
|
50275
|
+
if (size === 0)
|
|
50276
|
+
throw new Error(`${fileName} is empty (0 bytes); nothing to upload.`);
|
|
50277
|
+
if (size > maxBytes)
|
|
50278
|
+
throw new Error(`${fileName} is too large (${size} bytes); the upload limit is ${limitText(maxBytes)}.`);
|
|
50279
|
+
}
|
|
50280
|
+
var BASE64 = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
50281
|
+
function decodeBase64Strict(content, opts) {
|
|
50282
|
+
const { fileName, maxBytes } = opts;
|
|
50283
|
+
const compact = content.replace(/^data:[^,]*;base64,/i, "").replace(/\s+/g, "");
|
|
50284
|
+
if (compact.length === 0)
|
|
50285
|
+
throw new Error(`${fileName} is empty (0 bytes); nothing to upload.`);
|
|
50286
|
+
const invalid = () => new Error(`${fileName}: contentBase64 is not valid base64 (standard alphabet A-Z a-z 0-9 + /, padded with = to a multiple of 4 characters). It may have been truncated.`);
|
|
50287
|
+
if (compact.length % 4 !== 0 || !BASE64.test(compact))
|
|
50288
|
+
throw invalid();
|
|
50289
|
+
const padding = compact.endsWith("==") ? 2 : compact.endsWith("=") ? 1 : 0;
|
|
50290
|
+
checkUploadSize(fileName, compact.length / 4 * 3 - padding, maxBytes);
|
|
50291
|
+
const bytes = Buffer.from(compact, "base64");
|
|
50292
|
+
if (bytes.toString("base64") !== compact)
|
|
50293
|
+
throw invalid();
|
|
50294
|
+
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
50295
|
+
}
|
|
50296
|
+
var PREFIX2 = /^[A-Za-z0-9._~-]+$/;
|
|
50297
|
+
function checkPrefix(prefix) {
|
|
50298
|
+
if (!PREFIX2.test(prefix) || prefix === "." || prefix === "..") {
|
|
50299
|
+
throw new Error(`Upload key prefix ${JSON.stringify(prefix)} must be one key segment of [A-Za-z0-9._~-].`);
|
|
50300
|
+
}
|
|
50301
|
+
}
|
|
50302
|
+
function mintUploadSlot(store, req, opts = {}) {
|
|
50303
|
+
const prefix = opts.prefix ?? UPLOAD_KEY_PREFIX;
|
|
50304
|
+
checkPrefix(prefix);
|
|
50305
|
+
const filename = sanitizeUploadFilename(req.filename);
|
|
50306
|
+
const mimeType = resolveUploadMime(filename, req.mimeType);
|
|
50307
|
+
const blobKey = `${prefix}/${randomUUID2()}/${Buffer.from(filename, "utf8").toString("base64url")}`;
|
|
50308
|
+
const { url: url2, expiresAtMs } = store.signPutUrl(blobKey, mimeType, {
|
|
50309
|
+
ttlMs: opts.ttlMs ?? UPLOAD_SLOT_DEFAULT_TTL_MS,
|
|
50310
|
+
...opts.now !== void 0 ? { now: opts.now } : {}
|
|
50311
|
+
});
|
|
50312
|
+
const shellName = filename.replace(/'/g, `'\\''`);
|
|
50313
|
+
return {
|
|
50314
|
+
filename,
|
|
50315
|
+
mimeType,
|
|
50316
|
+
blobKey,
|
|
50317
|
+
method: "PUT",
|
|
50318
|
+
uploadUrl: url2,
|
|
50319
|
+
expiresAtMs,
|
|
50320
|
+
expiresAt: new Date(expiresAtMs).toISOString(),
|
|
50321
|
+
// --fail turns a refused PUT (expired, wrong Content-Type) into a non-zero exit.
|
|
50322
|
+
curl: `curl -sS --fail -X PUT -H 'Content-Type: ${mimeType}' --data-binary @'<path to ${shellName}>' '${url2}'`
|
|
50323
|
+
};
|
|
50324
|
+
}
|
|
50325
|
+
var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
50326
|
+
function uploadFileNameFromKey(key2, opts = {}) {
|
|
50327
|
+
const prefix = opts.prefix ?? UPLOAD_KEY_PREFIX;
|
|
50328
|
+
checkPrefix(prefix);
|
|
50329
|
+
const escaped = prefix.replace(/[.~-]/g, "\\$&");
|
|
50330
|
+
const match = new RegExp(`^${escaped}/${UUID}/([A-Za-z0-9_-]+)$`).exec(key2);
|
|
50331
|
+
if (!match) {
|
|
50332
|
+
throw new Error(`blobKey ${JSON.stringify(key2)} is not an upload key. Pass the blobKey exactly as the upload slot returned it.`);
|
|
50333
|
+
}
|
|
50334
|
+
return sanitizeUploadFilename(Buffer.from(match[1], "base64url").toString("utf8"));
|
|
50335
|
+
}
|
|
50336
|
+
|
|
50337
|
+
// src/tools/uploads.ts
|
|
50338
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
50339
|
+
var MAX_FILES_PER_CALL = MAX_UPLOAD_FILES;
|
|
50340
|
+
var UPLOAD_SLOT_TTL_MS = UPLOAD_SLOT_DEFAULT_TTL_MS;
|
|
50341
|
+
var UPLOAD_BLOB_PREFIX = UPLOAD_KEY_PREFIX;
|
|
50342
|
+
function checkUploadSize2(fileName, size) {
|
|
50343
|
+
checkUploadSize(fileName, size, MAX_UPLOAD_BYTES);
|
|
50344
|
+
}
|
|
50345
|
+
function decodeBase64Content(content, fileName) {
|
|
50346
|
+
const bytes = decodeBase64Strict(content, { fileName, maxBytes: MAX_UPLOAD_BYTES });
|
|
50347
|
+
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
50348
|
+
}
|
|
50349
|
+
function resolveInlineUpload(file2) {
|
|
50350
|
+
const fileName = sanitizeUploadFilename(file2.filename);
|
|
50351
|
+
const mimeType = resolveUploadMime(fileName, file2.mimeType);
|
|
50352
|
+
const bytes = decodeBase64Content(file2.contentBase64, fileName);
|
|
50353
|
+
return { blob: new Blob([new Uint8Array(bytes)], { type: mimeType }), fileName, mimeType, sizeBytes: bytes.length };
|
|
50354
|
+
}
|
|
50355
|
+
function fileNameFromBlobKey(key2) {
|
|
50356
|
+
try {
|
|
50357
|
+
return uploadFileNameFromKey(key2, { prefix: UPLOAD_BLOB_PREFIX });
|
|
50358
|
+
} catch (e) {
|
|
50359
|
+
const message = e.message;
|
|
50360
|
+
if (!message.includes("is not an upload key")) throw e;
|
|
50361
|
+
throw new Error(`blobKey ${JSON.stringify(key2)} is not an upload key. Pass the blobKey exactly as ofw_upload_attachment's uploadSlots returned it.`);
|
|
50362
|
+
}
|
|
50363
|
+
}
|
|
50364
|
+
function mintUploadSlot2(store, req) {
|
|
50365
|
+
const { expiresAtMs, ...slot } = mintUploadSlot(store, req, { prefix: UPLOAD_BLOB_PREFIX, ttlMs: UPLOAD_SLOT_TTL_MS });
|
|
50366
|
+
return { ...slot, expiresAt: formatInstant(new Date(expiresAtMs)).iso };
|
|
50367
|
+
}
|
|
50368
|
+
function blobObjectToUpload(key2, object2) {
|
|
50369
|
+
const fileName = fileNameFromBlobKey(key2);
|
|
50370
|
+
checkUploadSize2(fileName, object2.bytes.length);
|
|
50371
|
+
const mimeType = normalizeMimeType(object2.contentType ?? mimeFromName(fileName));
|
|
50372
|
+
return {
|
|
50373
|
+
blob: new Blob([object2.bytes], { type: mimeType }),
|
|
50374
|
+
fileName,
|
|
50375
|
+
mimeType,
|
|
50376
|
+
sizeBytes: object2.bytes.length
|
|
50377
|
+
};
|
|
50378
|
+
}
|
|
50379
|
+
var UploadedFileSchema = external_exports.looseObject({
|
|
50380
|
+
fileId: external_exports.number(),
|
|
50381
|
+
fileName: external_exports.string().optional(),
|
|
50382
|
+
label: external_exports.string().optional(),
|
|
50383
|
+
fileType: external_exports.string().optional(),
|
|
50384
|
+
sizeInBytes: external_exports.number().optional(),
|
|
50385
|
+
shareClass: external_exports.string().optional()
|
|
50386
|
+
});
|
|
50387
|
+
async function uploadToMyFiles(client2, cache, upload, opts) {
|
|
50388
|
+
const { blob, fileName, mimeType, sizeBytes } = upload;
|
|
50389
|
+
const form = new FormData();
|
|
50390
|
+
form.append("file", blob, fileName);
|
|
50391
|
+
form.append("source", "message");
|
|
50392
|
+
form.append("description", opts.description ?? fileName);
|
|
50393
|
+
form.append("label", opts.label ?? fileName);
|
|
50394
|
+
form.append("fileName", fileName);
|
|
50395
|
+
form.append("shareClass", opts.shareClass);
|
|
50396
|
+
const meta3 = parseLenient(
|
|
50397
|
+
UploadedFileSchema,
|
|
50398
|
+
await client2.request("POST", "/pub/v3/myfiles/multipart", form),
|
|
50399
|
+
{ label: "ofw-mcp", context: "POST /pub/v3/myfiles/multipart (ofw_upload_attachment)", mode: "strict" }
|
|
50400
|
+
);
|
|
50401
|
+
const stored = {
|
|
50402
|
+
fileName: meta3.fileName ?? fileName,
|
|
50403
|
+
mimeType: meta3.fileType ?? mimeType,
|
|
50404
|
+
sizeBytes: typeof meta3.sizeInBytes === "number" ? meta3.sizeInBytes : sizeBytes
|
|
50405
|
+
};
|
|
50406
|
+
await cache.upsertAttachmentForMessage({
|
|
50407
|
+
fileId: meta3.fileId,
|
|
50408
|
+
fileName: stored.fileName,
|
|
50409
|
+
label: meta3.label ?? opts.label ?? fileName,
|
|
50410
|
+
mimeType: stored.mimeType,
|
|
50411
|
+
sizeBytes: stored.sizeBytes,
|
|
50412
|
+
metadata: meta3,
|
|
50413
|
+
messageId: 0
|
|
50414
|
+
});
|
|
50415
|
+
return { fileId: meta3.fileId, ...stored, bytes: sizeBytes, shareClass: meta3.shareClass ?? opts.shareClass };
|
|
50416
|
+
}
|
|
50417
|
+
async function sha256Hex(blob) {
|
|
50418
|
+
return createHash6("sha256").update(new Uint8Array(await blob.arrayBuffer())).digest("hex");
|
|
50419
|
+
}
|
|
50420
|
+
function checkFileCount(count, what) {
|
|
50421
|
+
if (count > MAX_FILES_PER_CALL) {
|
|
50422
|
+
throw new Error(`${what}: at most ${MAX_FILES_PER_CALL} files per call (got ${count}). Split them across calls.`);
|
|
50423
|
+
}
|
|
50424
|
+
}
|
|
50425
|
+
function requireBlobStore(store, what) {
|
|
50426
|
+
if (store) return store;
|
|
50427
|
+
throw new Error(`${what} needs the blob store an mcp-host deployment provides, and this server has no blob store (it is a local install). Pass a \`path\` inside the upload directory, or the bytes with \`inline\`.`);
|
|
50428
|
+
}
|
|
50429
|
+
var inlineAttachmentsParam = external_exports.array(inlineFileSchema).max(MAX_FILES_PER_CALL).describe(
|
|
50430
|
+
"Files to attach, supplied as base64 BYTES ({filename, contentBase64, mimeType?}). Each is uploaded to My Files (PRIVATE when a draft holds it; SHARED when sent, as the web app attaches files) and attached alongside any myFileIDs. Use for small files; on a hosted deployment, larger files (phone photos) go faster through ofw_upload_attachment uploadSlots + blobKeys here. Every entry is validated before anything is uploaded."
|
|
50431
|
+
).optional();
|
|
50432
|
+
var blobKeysParam = external_exports.array(external_exports.string()).max(MAX_FILES_PER_CALL).describe(
|
|
50433
|
+
"Hosted deployments: blobKeys from ofw_upload_attachment uploadSlots whose files you have already PUT. Each is uploaded to My Files (PRIVATE when a draft holds it; SHARED when sent), attached alongside any myFileIDs, and deleted from the upload store."
|
|
50434
|
+
).optional();
|
|
50435
|
+
async function planAttachments(input2, opts) {
|
|
50436
|
+
const inline = input2.inline ?? [];
|
|
50437
|
+
const keys = input2.blobKeys ?? [];
|
|
50438
|
+
checkFileCount(inline.length + keys.length, "inlineAttachments + blobKeys");
|
|
50439
|
+
const pending = [];
|
|
50440
|
+
for (const file2 of inline) {
|
|
50441
|
+
const upload = resolveInlineUpload(file2);
|
|
50442
|
+
pending.push({ fileName: upload.fileName, mimeType: upload.mimeType, sizeBytes: upload.sizeBytes, sha256: await sha256Hex(upload.blob), inline: upload });
|
|
50443
|
+
}
|
|
50444
|
+
if (keys.length > 0) {
|
|
50445
|
+
const store = requireBlobStore(opts.store, "blobKeys");
|
|
50446
|
+
for (const blobKey of keys) {
|
|
50447
|
+
const fileName = fileNameFromBlobKey(blobKey);
|
|
50448
|
+
if (!opts.readBlobs) {
|
|
50449
|
+
pending.push({ fileName, mimeType: null, sizeBytes: null, sha256: null, blobKey });
|
|
50450
|
+
continue;
|
|
50451
|
+
}
|
|
50452
|
+
const upload = blobObjectToUpload(blobKey, await store.get(blobKey, { maxBytes: MAX_UPLOAD_BYTES }));
|
|
50453
|
+
pending.push({ fileName, mimeType: upload.mimeType, sizeBytes: upload.sizeBytes, sha256: await sha256Hex(upload.blob), blobKey });
|
|
50454
|
+
}
|
|
50455
|
+
}
|
|
50456
|
+
return pending;
|
|
50457
|
+
}
|
|
50458
|
+
function describePending(pending) {
|
|
50459
|
+
return pending.map((p) => ({ fileName: p.fileName, mimeType: p.mimeType, sizeBytes: p.sizeBytes, sha256: p.sha256, upload: "PRIVATE, on approval" }));
|
|
50460
|
+
}
|
|
50461
|
+
async function uploadPending(pending, ctx) {
|
|
50462
|
+
const uploaded = [];
|
|
50463
|
+
const warnings = [];
|
|
50464
|
+
for (const p of pending) {
|
|
50465
|
+
try {
|
|
50466
|
+
if (p.inline) {
|
|
50467
|
+
uploaded.push(await uploadToMyFiles(ctx.client, ctx.cache, p.inline, { shareClass: ctx.shareClass }));
|
|
50468
|
+
continue;
|
|
50469
|
+
}
|
|
50470
|
+
const out = await ctx.store.consume(p.blobKey, async (object2) => {
|
|
50471
|
+
const upload = blobObjectToUpload(p.blobKey, object2);
|
|
50472
|
+
if (p.sha256 !== null && await sha256Hex(upload.blob) !== p.sha256) {
|
|
50473
|
+
throw new Error(`${p.fileName} changed in the upload store after it was previewed`);
|
|
50474
|
+
}
|
|
50475
|
+
return uploadToMyFiles(ctx.client, ctx.cache, upload, { shareClass: ctx.shareClass });
|
|
50476
|
+
}, { maxBytes: MAX_UPLOAD_BYTES });
|
|
50477
|
+
uploaded.push(out.result);
|
|
50478
|
+
if (!out.deleted) {
|
|
50479
|
+
warnings.push(`${p.fileName} was uploaded (fileId ${out.result.fileId}) but its copy in the upload store could not be deleted (${out.deleteError}); it expires with the store's retention.`);
|
|
50480
|
+
}
|
|
50481
|
+
} catch (e) {
|
|
50482
|
+
const done = uploaded.map((u) => `${u.fileName} (fileId ${u.fileId})`);
|
|
50483
|
+
throw new Error(
|
|
50484
|
+
`Attachment ${p.fileName} could not be uploaded: ${e.message}. Nothing was ${ctx.nothingWas}.` + (done.length > 0 ? ` Already uploaded to My Files (${ctx.shareClass}): ${done.join(", ")} \u2014 pass those fileIds in myFileIDs when you retry instead of uploading them again.` : "")
|
|
50485
|
+
);
|
|
50486
|
+
}
|
|
50487
|
+
}
|
|
50488
|
+
return { uploaded, warnings };
|
|
50489
|
+
}
|
|
50490
|
+
|
|
49666
50491
|
// src/extract/inflate.ts
|
|
49667
50492
|
var MAX_DECOMPRESSED_BYTES = 32 * 1024 * 1024;
|
|
49668
50493
|
var MAX_TOTAL_DECOMPRESSED_BYTES = 64 * 1024 * 1024;
|
|
@@ -50568,141 +51393,6 @@ async function extractAttachment(bytes, mimeType, fileName, opts = {}) {
|
|
|
50568
51393
|
return applyCharBudget(extracted, opts.maxChars ?? DEFAULT_MAX_CHARS);
|
|
50569
51394
|
}
|
|
50570
51395
|
|
|
50571
|
-
// src/tools/attachments.ts
|
|
50572
|
-
import { chmodSync as chmodSync3, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync3, mkdirSync as mkdirSync5, unlinkSync as unlinkSync5 } from "node:fs";
|
|
50573
|
-
import { basename as basename2, dirname as dirname6, extname, isAbsolute as isAbsolute6, join as join11, relative as relative2, resolve as resolve5, sep as sep2 } from "node:path";
|
|
50574
|
-
function isWithin(root, candidate) {
|
|
50575
|
-
const rel = relative2(root, candidate);
|
|
50576
|
-
return rel !== "" && !rel.startsWith("..") && !isAbsolute6(rel);
|
|
50577
|
-
}
|
|
50578
|
-
function resolveSaveDest(root, saveTo, defaultName) {
|
|
50579
|
-
if (!saveTo) return join11(root, defaultName);
|
|
50580
|
-
const isDirArg = saveTo.endsWith("/") || saveTo.endsWith("\\");
|
|
50581
|
-
const abs = resolve5(root, saveTo.startsWith("~") ? expandPath(saveTo) : saveTo);
|
|
50582
|
-
const dest = isDirArg ? join11(abs, defaultName) : abs;
|
|
50583
|
-
if (!isWithin(root, dest)) {
|
|
50584
|
-
throw new Error(`Refusing to save to ${dest}: it is outside the attachments directory (${root}). Files can only be written inside it \u2014 pass a path or subdirectory under it, or set OFW_ATTACHMENTS_DIR to move it.`);
|
|
50585
|
-
}
|
|
50586
|
-
return dest;
|
|
50587
|
-
}
|
|
50588
|
-
var MIME_BY_EXT = {
|
|
50589
|
-
".pdf": "application/pdf",
|
|
50590
|
-
".png": "image/png",
|
|
50591
|
-
".jpg": "image/jpeg",
|
|
50592
|
-
".jpeg": "image/jpeg",
|
|
50593
|
-
".gif": "image/gif",
|
|
50594
|
-
".webp": "image/webp",
|
|
50595
|
-
".heic": "image/heic",
|
|
50596
|
-
".txt": "text/plain",
|
|
50597
|
-
".md": "text/markdown",
|
|
50598
|
-
".csv": "text/csv",
|
|
50599
|
-
".html": "text/html",
|
|
50600
|
-
".htm": "text/html",
|
|
50601
|
-
".json": "application/json",
|
|
50602
|
-
".xml": "application/xml",
|
|
50603
|
-
".doc": "application/msword",
|
|
50604
|
-
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
50605
|
-
".xls": "application/vnd.ms-excel",
|
|
50606
|
-
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
50607
|
-
".ppt": "application/vnd.ms-powerpoint",
|
|
50608
|
-
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
50609
|
-
".zip": "application/zip",
|
|
50610
|
-
".ics": "text/calendar"
|
|
50611
|
-
};
|
|
50612
|
-
function mimeFromName(name) {
|
|
50613
|
-
return MIME_BY_EXT[extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
50614
|
-
}
|
|
50615
|
-
var OCTET_STREAM = "application/octet-stream";
|
|
50616
|
-
var HOST_RENDERABLE_IMAGE_MIMES = /* @__PURE__ */ new Set([
|
|
50617
|
-
"image/png",
|
|
50618
|
-
"image/jpeg",
|
|
50619
|
-
"image/gif",
|
|
50620
|
-
"image/webp"
|
|
50621
|
-
]);
|
|
50622
|
-
function normalizeMimeType(raw) {
|
|
50623
|
-
if (!raw) return OCTET_STREAM;
|
|
50624
|
-
const bare = raw.split(";", 1)[0].trim().toLowerCase();
|
|
50625
|
-
return bare || OCTET_STREAM;
|
|
50626
|
-
}
|
|
50627
|
-
function sniffImageMime(bytes) {
|
|
50628
|
-
const sniffed = sniffMimeBytes(bytes);
|
|
50629
|
-
return sniffed !== void 0 && HOST_RENDERABLE_IMAGE_MIMES.has(sniffed) ? sniffed : null;
|
|
50630
|
-
}
|
|
50631
|
-
function resolveDownloadMime(bytes, headerMime, fileName) {
|
|
50632
|
-
const sniffed = sniffImageMime(bytes);
|
|
50633
|
-
if (sniffed) return sniffed;
|
|
50634
|
-
const fromHeader = normalizeMimeType(headerMime);
|
|
50635
|
-
if (fromHeader !== OCTET_STREAM) return fromHeader;
|
|
50636
|
-
return mimeFromName(fileName);
|
|
50637
|
-
}
|
|
50638
|
-
function isHostRenderableImage(mime) {
|
|
50639
|
-
return HOST_RENDERABLE_IMAGE_MIMES.has(mime);
|
|
50640
|
-
}
|
|
50641
|
-
var MAX_UPLOAD_BYTES = 25 * 1024 * 1024;
|
|
50642
|
-
var NodeAttachmentIO = class {
|
|
50643
|
-
supportsDisk = true;
|
|
50644
|
-
async resolveUpload(path) {
|
|
50645
|
-
const root = resolve5(getUploadDir());
|
|
50646
|
-
const abs = resolve5(root, path.startsWith("~") ? expandPath(path) : path);
|
|
50647
|
-
const outside = new Error(`Refusing to upload ${abs}: it is outside the upload directory (${root}). Only files placed in that directory can be uploaded \u2014 ask the user to copy the file there, or set OFW_UPLOAD_DIR.`);
|
|
50648
|
-
if (!isWithin(root, abs)) throw outside;
|
|
50649
|
-
const real = realpathSync3(abs);
|
|
50650
|
-
const realRoot = realpathSync3(root);
|
|
50651
|
-
try {
|
|
50652
|
-
assertPathWithinRoots(real, [realRoot]);
|
|
50653
|
-
} catch {
|
|
50654
|
-
throw outside;
|
|
50655
|
-
}
|
|
50656
|
-
if (relative2(realRoot, real).split(sep2).some((segment) => segment.startsWith("."))) {
|
|
50657
|
-
throw new Error(`Refusing to upload ${abs}: hidden files and files in hidden directories (dotfiles, credential stores) are never uploaded.`);
|
|
50658
|
-
}
|
|
50659
|
-
const stat = statSync3(real);
|
|
50660
|
-
if (!stat.isFile()) throw new Error(`Not a file: ${abs}`);
|
|
50661
|
-
if (stat.size > MAX_UPLOAD_BYTES) {
|
|
50662
|
-
throw new Error(`Refusing to upload ${abs}: it is too large (${stat.size} bytes; the limit is ${MAX_UPLOAD_BYTES}).`);
|
|
50663
|
-
}
|
|
50664
|
-
const fileName = basename2(abs);
|
|
50665
|
-
const mimeType = mimeFromName(fileName);
|
|
50666
|
-
const blob = await fileBlob(real, { type: mimeType, allowedRoots: [realRoot] });
|
|
50667
|
-
return { blob, fileName, mimeType, sizeBytes: stat.size };
|
|
50668
|
-
}
|
|
50669
|
-
readDownloaded(path) {
|
|
50670
|
-
try {
|
|
50671
|
-
return readFileSync4(path);
|
|
50672
|
-
} catch {
|
|
50673
|
-
return null;
|
|
50674
|
-
}
|
|
50675
|
-
}
|
|
50676
|
-
async writeDownload(dest, bytes, { root, overwrite }) {
|
|
50677
|
-
mkdirSync5(root, { recursive: true, mode: 448 });
|
|
50678
|
-
if (resolve5(root) === resolve5(getDefaultAttachmentsDir())) chmodSync3(root, 448);
|
|
50679
|
-
const realRoot = realpathSync3(root);
|
|
50680
|
-
const parent = dirname6(dest);
|
|
50681
|
-
const outside = () => new Error(`Refusing to write ${dest}: it resolves outside the attachments directory (${root}).`);
|
|
50682
|
-
try {
|
|
50683
|
-
assertPathWithinRoots(parent, [realRoot]);
|
|
50684
|
-
} catch {
|
|
50685
|
-
throw outside();
|
|
50686
|
-
}
|
|
50687
|
-
mkdirSync5(parent, { recursive: true, mode: 448 });
|
|
50688
|
-
if (overwrite) {
|
|
50689
|
-
try {
|
|
50690
|
-
unlinkSync5(dest);
|
|
50691
|
-
} catch {
|
|
50692
|
-
}
|
|
50693
|
-
}
|
|
50694
|
-
try {
|
|
50695
|
-
await writeFileSafe(dest, bytes, { mode: 384, allowedRoots: [realRoot] });
|
|
50696
|
-
} catch (e) {
|
|
50697
|
-
if (e instanceof FileWriteRefusedError) {
|
|
50698
|
-
if (e.reason === "outside-roots") throw outside();
|
|
50699
|
-
throw new Error(`Refusing to overwrite ${dest}: a file already exists there. Pass force:true to replace it, or choose another saveTo.`);
|
|
50700
|
-
}
|
|
50701
|
-
throw e;
|
|
50702
|
-
}
|
|
50703
|
-
}
|
|
50704
|
-
};
|
|
50705
|
-
|
|
50706
51396
|
// src/tools/delivery.ts
|
|
50707
51397
|
var MAX_INLINE_BYTES = 10 * 1024 * 1024;
|
|
50708
51398
|
async function tryExtract(bytes, mimeType, fileName, opts) {
|
|
@@ -50778,6 +51468,7 @@ async function buildInlineDelivery(input2) {
|
|
|
50778
51468
|
|
|
50779
51469
|
// src/tools/messages.ts
|
|
50780
51470
|
import { basename as basename3, resolve as resolve6 } from "node:path";
|
|
51471
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
50781
51472
|
|
|
50782
51473
|
// src/tools/pagination.ts
|
|
50783
51474
|
function pageState(input2) {
|
|
@@ -50885,7 +51576,7 @@ var MESSAGE_ROW_KEYS = /* @__PURE__ */ new Set([
|
|
|
50885
51576
|
var DRAFT_ROW_KEYS = /* @__PURE__ */ new Set(["id", "subject", "recipients", "replyToId", "modifiedAt", "body"]);
|
|
50886
51577
|
function omitKnown(rest, own2) {
|
|
50887
51578
|
const out = {};
|
|
50888
|
-
for (const [
|
|
51579
|
+
for (const [key2, value] of Object.entries(rest)) if (!own2.has(key2)) out[key2] = value;
|
|
50889
51580
|
return out;
|
|
50890
51581
|
}
|
|
50891
51582
|
function compactDraft(row) {
|
|
@@ -50920,6 +51611,16 @@ function viewOne(view, row) {
|
|
|
50920
51611
|
}
|
|
50921
51612
|
|
|
50922
51613
|
// src/tools/messages.ts
|
|
51614
|
+
async function describeHeld(cache, ids) {
|
|
51615
|
+
return Promise.all(ids.map(async (fileId) => ({ fileId, fileName: (await cache.getAttachment(fileId))?.fileName ?? null, held: true })));
|
|
51616
|
+
}
|
|
51617
|
+
var GateHalt = class extends Error {
|
|
51618
|
+
constructor(response) {
|
|
51619
|
+
super("confirmation required");
|
|
51620
|
+
this.response = response;
|
|
51621
|
+
}
|
|
51622
|
+
response;
|
|
51623
|
+
};
|
|
50923
51624
|
var DateSchema = external_exports.looseObject({ dateTime: external_exports.string() });
|
|
50924
51625
|
var SentDetailSchema = external_exports.looseObject({
|
|
50925
51626
|
subject: external_exports.string().optional(),
|
|
@@ -50932,7 +51633,9 @@ var SentDetailSchema = external_exports.looseObject({
|
|
|
50932
51633
|
// _shared.ts). Backs the `threaded` verdict on ofw_send_message.
|
|
50933
51634
|
replyToId: external_exports.number().nullable().optional(),
|
|
50934
51635
|
inReplyTo: external_exports.number().nullable().optional(),
|
|
50935
|
-
showContext: external_exports.boolean().optional()
|
|
51636
|
+
showContext: external_exports.boolean().optional(),
|
|
51637
|
+
// What OFW actually attached — checked against what was sent.
|
|
51638
|
+
files: external_exports.array(external_exports.number()).optional()
|
|
50936
51639
|
});
|
|
50937
51640
|
var SavedDraftDetailSchema = external_exports.looseObject({
|
|
50938
51641
|
subject: external_exports.string().optional(),
|
|
@@ -50976,14 +51679,6 @@ var FolderCountsSchema = external_exports.looseObject({
|
|
|
50976
51679
|
})).optional()
|
|
50977
51680
|
});
|
|
50978
51681
|
var MAX_FRESHNESS_IDS = 25;
|
|
50979
|
-
var UploadedFileSchema = external_exports.looseObject({
|
|
50980
|
-
fileId: external_exports.number(),
|
|
50981
|
-
fileName: external_exports.string().optional(),
|
|
50982
|
-
label: external_exports.string().optional(),
|
|
50983
|
-
fileType: external_exports.string().optional(),
|
|
50984
|
-
sizeInBytes: external_exports.number().optional(),
|
|
50985
|
-
shareClass: external_exports.string().optional()
|
|
50986
|
-
});
|
|
50987
51682
|
function listDataHintsAtFiles(listData) {
|
|
50988
51683
|
if (typeof listData !== "object" || listData === null) return false;
|
|
50989
51684
|
const ld = listData;
|
|
@@ -51202,20 +51897,20 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51202
51897
|
});
|
|
51203
51898
|
}
|
|
51204
51899
|
const bounds = {};
|
|
51205
|
-
for (const
|
|
51206
|
-
const value2 = args[
|
|
51900
|
+
for (const key2 of ["since", "until"]) {
|
|
51901
|
+
const value2 = args[key2];
|
|
51207
51902
|
if (value2 === void 0) continue;
|
|
51208
51903
|
const converted = toNaiveWallClock(value2);
|
|
51209
51904
|
if (converted === null) {
|
|
51210
51905
|
return jsonErrorResponse({
|
|
51211
51906
|
result: "INVALID_DATE",
|
|
51212
|
-
reason: `${
|
|
51213
|
-
remedy: `Re-call with ${
|
|
51907
|
+
reason: `${key2} must be an ISO date (YYYY-MM-DD) or datetime, optionally with an offset or Z (got ${JSON.stringify(value2)}).`,
|
|
51908
|
+
remedy: `Re-call with ${key2} as e.g. "2026-07-27" or "2026-07-27T22:00:00-04:00".`,
|
|
51214
51909
|
complete: false,
|
|
51215
51910
|
note: 'No lookup was performed. This says NOTHING about what is in the cache \u2014 do not read it as "no messages".'
|
|
51216
51911
|
});
|
|
51217
51912
|
}
|
|
51218
|
-
bounds[
|
|
51913
|
+
bounds[key2] = converted;
|
|
51219
51914
|
}
|
|
51220
51915
|
const cache = cacheProvider();
|
|
51221
51916
|
const folders = folder === void 0 ? ["inbox", "sent"] : [folder];
|
|
@@ -51306,6 +52001,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51306
52001
|
const draftRow = await cache.getDraft(id2);
|
|
51307
52002
|
if (draftRow !== null) {
|
|
51308
52003
|
const { freshness: freshness2, serverConfirmed, cacheStatus } = await draftsFreshness(cache);
|
|
52004
|
+
const held = await getHeldFiles(cache, draftRow.id);
|
|
51309
52005
|
return jsonResponse({
|
|
51310
52006
|
// Stable identity FIRST — the id below changes on every edit
|
|
51311
52007
|
// (create-then-delete), so callers should key off draftKey. Null when
|
|
@@ -51335,11 +52031,14 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51335
52031
|
// the DRAFTS table, which is the source of truth for a draft id — the
|
|
51336
52032
|
// echo duplicates it and adds a stale copy of nothing else.
|
|
51337
52033
|
...view === "compact" ? {} : { listData: draftRow.listData },
|
|
51338
|
-
|
|
52034
|
+
// OFW keeps no files on a draft; these are the ones HELD for it here
|
|
52035
|
+
// and attached when it is sent (held-attachments.ts).
|
|
52036
|
+
attachments: await describeHeld(cache, held),
|
|
52037
|
+
...held.length > 0 ? { attachmentsNote: HELD_NOTE } : {},
|
|
51339
52038
|
// Concurrency token — pass as expectedRevision to ofw_save_draft /
|
|
51340
52039
|
// ofw_delete_draft / ofw_send_message to assert you are acting on
|
|
51341
52040
|
// THIS version.
|
|
51342
|
-
revision: draftRevision(draftRow),
|
|
52041
|
+
revision: draftRevision(draftRow, held),
|
|
51343
52042
|
cacheStatus,
|
|
51344
52043
|
// False = this draft's existence and unsent status are remembered from
|
|
51345
52044
|
// a cache, not confirmed on OFW. Call ofw_check_freshness before
|
|
@@ -51443,7 +52142,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51443
52142
|
});
|
|
51444
52143
|
if (allowSend) server.registerTool("ofw_send_message", {
|
|
51445
52144
|
_meta: familyMeta("send", { aliases: ["message", "co-parent", "reply", "ofw"] }),
|
|
51446
|
-
description: "Send a message via OurFamilyWizard \u2014 the ONE irreversible operation here, so it carries the strongest guard. TO SEND AN EXISTING DRAFT (the safe default): pass draftId (or messageId \u2014 same thing). The tool re-reads the draft from OFW and sends the SERVER'S version, so what goes out is what is on OurFamilyWizard, not what this session remembers \u2014 subject/body act only as explicit overrides. It is guarded exactly like ofw_save_draft: pass expectedRevision to assert which version you are sending; if the draft changed on OFW since you read it \u2014 or no longer exists (it may already have been SENT) \u2014 the send is REFUSED with the current server content echoed back, and nothing goes out. RECIPIENTS: OurFamilyWizard does not persist recipients on drafts, so recipientIds is usually still required at send time (ids from ofw_get_profile). After the send is CONFIRMED (OFW returned the new message id and the re-fetched sent record matches what was posted), the source draft is deleted automatically; pass deleteDraftOnSuccess:false to keep it. On ANY failure or ambiguity the draft is never deleted \u2014 the response carries draftRetained:true with the reason. If the send request times out or drops without a definitive answer, the result is SEND_UNCONFIRMED: the message may already have been delivered, so do NOT retry until a sent-folder sync (or ourfamilywizard.com) shows it did not go out. TO COMPOSE FROM SCRATCH: supply subject/body/recipientIds with no draftId. If replyToId is provided (or inherited from the draft), the cache may rewrite it to the latest reply in the same thread (a note is included when this happens). ATTACHMENTS: when sending by draftId
|
|
52145
|
+
description: "Send a message via OurFamilyWizard \u2014 the ONE irreversible operation here, so it carries the strongest guard. TO SEND AN EXISTING DRAFT (the safe default): pass draftId (or messageId \u2014 same thing). The tool re-reads the draft from OFW and sends the SERVER'S version, so what goes out is what is on OurFamilyWizard, not what this session remembers \u2014 subject/body act only as explicit overrides. It is guarded exactly like ofw_save_draft: pass expectedRevision to assert which version you are sending; if the draft changed on OFW since you read it \u2014 or no longer exists (it may already have been SENT) \u2014 the send is REFUSED with the current server content echoed back, and nothing goes out. RECIPIENTS: OurFamilyWizard does not persist recipients on drafts, so recipientIds is usually still required at send time (ids from ofw_get_profile). After the send is CONFIRMED (OFW returned the new message id and the re-fetched sent record matches what was posted), the source draft is deleted automatically; pass deleteDraftOnSuccess:false to keep it. On ANY failure or ambiguity the draft is never deleted \u2014 the response carries draftRetained:true with the reason. If the send request times out or drops without a definitive answer, the result is SEND_UNCONFIRMED: the message may already have been delivered, so do NOT retry until a sent-folder sync (or ourfamilywizard.com) shows it did not go out. TO COMPOSE FROM SCRATCH: supply subject/body/recipientIds with no draftId. If replyToId is provided (or inherited from the draft), the cache may rewrite it to the latest reply in the same thread (a note is included when this happens). ATTACHMENTS: OurFamilyWizard keeps no files on drafts, so when sending by draftId the files ofw_save_draft HELD for it are attached automatically; myFileIDs (from ofw_upload_attachment) overrides them, or attaches files on a fresh compose; inlineAttachments/blobKeys upload new ones. Every attachment goes out SHARED, as the web app sends them: new files are uploaded SHARED and files known to be PRIVATE are re-shared as SHARED, both only after the send is approved. The response verifies them against the sent message (attachments.verified/missing). The response leads with sentMessageId and the stable draftKey, and reports threaded (whether OFW actually linked the reply) and draftDeleted. " + CONFIRM_NOTE,
|
|
51447
52146
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
51448
52147
|
inputSchema: external_exports.object({
|
|
51449
52148
|
subject: external_exports.string().describe("Message subject. Required unless draftId/messageId is given (then it overrides the server draft's subject).").optional(),
|
|
@@ -51456,6 +52155,8 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51456
52155
|
deleteDraftOnSuccess: external_exports.boolean().describe("Default true. Delete the source draft after \u2014 and ONLY after \u2014 the send is confirmed (new message id returned and the re-fetched sent record checks out). Set false to keep the draft. On a failed or unverifiable send the draft is ALWAYS kept, regardless of this flag.").optional(),
|
|
51457
52156
|
force: external_exports.boolean().describe("Default false. Send even when the draft changed on OurFamilyWizard since you read it, or its current state could not be read. Only use after showing the user the conflict.").optional(),
|
|
51458
52157
|
myFileIDs: external_exports.array(external_exports.number()).describe("Attachment file ids (from ofw_upload_attachment) to attach to the message. When sending by draftId, omit it to carry the server draft's own attachments over; passing it overrides them.").optional(),
|
|
52158
|
+
inlineAttachments: inlineAttachmentsParam,
|
|
52159
|
+
blobKeys: blobKeysParam,
|
|
51459
52160
|
confirmToken: confirmTokenParam
|
|
51460
52161
|
})
|
|
51461
52162
|
}, async (args, ctx) => {
|
|
@@ -51465,6 +52166,11 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51465
52166
|
const draftRef = args.messageId ?? args.draftId;
|
|
51466
52167
|
const cache = cacheProvider();
|
|
51467
52168
|
const deleteOnSuccess = args.deleteDraftOnSuccess ?? true;
|
|
52169
|
+
const blobStore = args.blobKeys?.length ? blobStoreFromEnv() : void 0;
|
|
52170
|
+
const pending = await planAttachments(
|
|
52171
|
+
{ inline: args.inlineAttachments, blobKeys: args.blobKeys },
|
|
52172
|
+
{ store: blobStore, readBlobs: true }
|
|
52173
|
+
);
|
|
51468
52174
|
let subject = args.subject;
|
|
51469
52175
|
let body = args.body;
|
|
51470
52176
|
let recipientIds = args.recipientIds;
|
|
@@ -51524,7 +52230,8 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51524
52230
|
replyParent = await cache.getMessage(resolvedReplyTo);
|
|
51525
52231
|
chainRootId = replyParent?.chainRootId ?? replyParent?.id ?? requestedReplyTo;
|
|
51526
52232
|
}
|
|
51527
|
-
const
|
|
52233
|
+
const heldForDraft = draftRef !== void 0 ? await getHeldFiles(cache, draftRef) : [];
|
|
52234
|
+
let myFileIDs = args.myFileIDs ?? uniqueIds([...serverDraft?.files ?? [], ...heldForDraft]);
|
|
51528
52235
|
const to = await describeRecipients(cache, recipientIds, [
|
|
51529
52236
|
serverDraft?.recipients,
|
|
51530
52237
|
cachedDraft?.recipients,
|
|
@@ -51533,8 +52240,14 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51533
52240
|
const unresolved = to.filter((r) => r.name === null).map((r) => r.userId);
|
|
51534
52241
|
const attachments = await Promise.all(myFileIDs.map(async (fileId) => {
|
|
51535
52242
|
const known = await cache.getAttachment(fileId);
|
|
51536
|
-
|
|
52243
|
+
const shareClass = known?.metadata?.shareClass;
|
|
52244
|
+
return {
|
|
52245
|
+
fileId,
|
|
52246
|
+
fileName: known?.fileName ?? null,
|
|
52247
|
+
...shareClass === "PRIVATE" ? { reshare: true } : {}
|
|
52248
|
+
};
|
|
51537
52249
|
}));
|
|
52250
|
+
const reshare = attachments.filter((a) => a.reshare).map((a) => a.fileId);
|
|
51538
52251
|
const preview = {
|
|
51539
52252
|
action: "Send OurFamilyWizard message",
|
|
51540
52253
|
warning: "Irreversible: once sent, the message is delivered to the recipient(s) and becomes part of the court-visible record. It cannot be recalled or edited.",
|
|
@@ -51544,6 +52257,8 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51544
52257
|
body,
|
|
51545
52258
|
replyTo: resolvedReplyTo === null ? null : { messageId: resolvedReplyTo, subject: replyParent?.subject ?? null, from: replyParent?.fromUser || null },
|
|
51546
52259
|
attachments,
|
|
52260
|
+
...reshare.length > 0 ? { reshareNote: `${reshare.length} PRIVATE file(s) will be re-shared as SHARED on approval so OurFamilyWizard attaches them \u2014 the web app attaches every message file as SHARED.` } : {},
|
|
52261
|
+
...pending.length > 0 ? { newAttachments: describePending(pending) } : {},
|
|
51547
52262
|
source: draftRef !== void 0 ? { draftId: draftRef, deleteDraftAfterSend: deleteOnSuccess } : "composed from the call arguments"
|
|
51548
52263
|
};
|
|
51549
52264
|
const gate = await confirmWrite2(ctx, {
|
|
@@ -51552,12 +52267,43 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51552
52267
|
action: "ofw.message.send",
|
|
51553
52268
|
message: "Review and confirm this OurFamilyWizard message. Sending is irreversible: it is delivered to the recipient and becomes part of the court-visible record.",
|
|
51554
52269
|
target: draftRef !== void 0 ? `draft:${draftRef}` : "compose",
|
|
51555
|
-
...serverDraft != null ? { revision: draftRevision(serverDraft) } : {},
|
|
51556
|
-
payload: {
|
|
52270
|
+
...serverDraft != null ? { revision: draftRevision(serverDraft, heldForDraft) } : {},
|
|
52271
|
+
payload: {
|
|
52272
|
+
subject,
|
|
52273
|
+
body,
|
|
52274
|
+
recipientIds,
|
|
52275
|
+
myFileIDs,
|
|
52276
|
+
replyToId: resolvedReplyTo,
|
|
52277
|
+
deleteDraftOnSuccess: deleteOnSuccess,
|
|
52278
|
+
...reshare.length > 0 ? { reshare } : {},
|
|
52279
|
+
...pending.length > 0 ? { newAttachments: pending.map((p) => ({ fileName: p.fileName, sizeBytes: p.sizeBytes, sha256: p.sha256 })) } : {}
|
|
52280
|
+
},
|
|
51557
52281
|
preview,
|
|
51558
52282
|
confirmToken: args.confirmToken
|
|
51559
52283
|
});
|
|
51560
52284
|
if (gate) return gate;
|
|
52285
|
+
const reshared = await reshareAsShared(reshare, "sent");
|
|
52286
|
+
const resharedNote = reshared.length > 0 ? ` These files were already re-shared as SHARED: ${reshared.map((r) => `${r.fileName} (fileId ${r.from} \u2192 ${r.to})`).join(", ")}; a retry reuses them.` : "";
|
|
52287
|
+
const withReshared = (e) => {
|
|
52288
|
+
const err = e;
|
|
52289
|
+
if (resharedNote) err.message += resharedNote;
|
|
52290
|
+
return err;
|
|
52291
|
+
};
|
|
52292
|
+
let uploadedNew;
|
|
52293
|
+
try {
|
|
52294
|
+
uploadedNew = await uploadPending(pending, {
|
|
52295
|
+
client: client2,
|
|
52296
|
+
cache,
|
|
52297
|
+
store: blobStore,
|
|
52298
|
+
nothingWas: "sent",
|
|
52299
|
+
shareClass: "SHARED"
|
|
52300
|
+
});
|
|
52301
|
+
} catch (e) {
|
|
52302
|
+
throw withReshared(e);
|
|
52303
|
+
}
|
|
52304
|
+
const { uploaded: newFiles, warnings: uploadWarnings } = uploadedNew;
|
|
52305
|
+
const swapped = new Map(reshared.map((r) => [r.from, r.to]));
|
|
52306
|
+
myFileIDs = [...myFileIDs.map((id2) => swapped.get(id2) ?? id2), ...newFiles.map((f) => f.fileId)];
|
|
51561
52307
|
let posted;
|
|
51562
52308
|
try {
|
|
51563
52309
|
posted = await postMessageAndRefetch(client2, {
|
|
@@ -51570,12 +52316,13 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51570
52316
|
replyToId: resolvedReplyTo
|
|
51571
52317
|
}, SentDetailSchema, "ofw_send_message");
|
|
51572
52318
|
} catch (e) {
|
|
51573
|
-
if (!(e instanceof UnconfirmedWriteError)) throw e;
|
|
52319
|
+
if (!(e instanceof UnconfirmedWriteError)) throw withReshared(e);
|
|
51574
52320
|
const reason = e.postedId !== null ? `OFW accepted the send (message id ${e.postedId}) but re-reading it to confirm failed: ${e.message}. The message WAS very likely delivered.` : `The send request failed without a definitive answer from OFW: ${e.message}. The message MAY HAVE BEEN DELIVERED to the recipient.`;
|
|
51575
52321
|
return jsonErrorResponse({
|
|
51576
52322
|
result: "SEND_UNCONFIRMED",
|
|
51577
52323
|
mayHaveBeenDelivered: true,
|
|
51578
52324
|
sentMessageId: e.postedId,
|
|
52325
|
+
...reshared.length > 0 ? { reshared } : {},
|
|
51579
52326
|
reason,
|
|
51580
52327
|
remedy: 'Do NOT retry the send blindly. First run ofw_sync_messages with folders:["sent"] and look for this subject/body among the newest sent messages (or check ourfamilywizard.com). Retry only once you have confirmed it did not go out.',
|
|
51581
52328
|
...draftRef !== void 0 ? { draftRetained: true, draftId: draftRef } : {}
|
|
@@ -51587,7 +52334,25 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51587
52334
|
let sentDraftKey = null;
|
|
51588
52335
|
let threaded = false;
|
|
51589
52336
|
let threadNote = null;
|
|
52337
|
+
let attachmentCheck = null;
|
|
52338
|
+
let attachmentNote = null;
|
|
52339
|
+
if (newId !== null && myFileIDs.length > 0) {
|
|
52340
|
+
const onMessage = Array.isArray(detail.files) ? detail.files : null;
|
|
52341
|
+
const missing = onMessage === null ? [] : myFileIDs.filter((id2) => !onMessage.includes(id2));
|
|
52342
|
+
attachmentCheck = {
|
|
52343
|
+
onMessage,
|
|
52344
|
+
verified: onMessage === null ? null : missing.length === 0,
|
|
52345
|
+
...missing.length > 0 ? { missing } : {},
|
|
52346
|
+
...reshared.length > 0 ? { reshared } : {}
|
|
52347
|
+
};
|
|
52348
|
+
if (missing.length > 0) {
|
|
52349
|
+
attachmentNote = `WARNING: the message was SENT, but OurFamilyWizard did not attach fileId(s) ${missing.join(", ")}. It cannot be edited; send the missing file(s) in a follow-up message.`;
|
|
52350
|
+
} else if (onMessage === null) {
|
|
52351
|
+
attachmentNote = "NOTE: OurFamilyWizard did not report the sent message's attachments, so they could not be verified. Check the sent message on ourfamilywizard.com.";
|
|
52352
|
+
}
|
|
52353
|
+
}
|
|
51590
52354
|
if (newId !== null) {
|
|
52355
|
+
if (draftRef !== void 0) await clearHeldFiles(cache, draftRef);
|
|
51591
52356
|
verifyNote = verifyWriteLanded("message", { subject, body }, detail);
|
|
51592
52357
|
const echoed = threadedReplyTo(detail);
|
|
51593
52358
|
if (resolvedReplyTo === null) {
|
|
@@ -51636,12 +52401,12 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51636
52401
|
if (draftRef !== void 0) {
|
|
51637
52402
|
const prior = await cache.getDraftLineageById(draftRef);
|
|
51638
52403
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
51639
|
-
const
|
|
52404
|
+
const key2 = prior?.draftKey ?? newDraftKey();
|
|
51640
52405
|
if (prior === null) {
|
|
51641
|
-
await cache.recordDraftLineage({ id: draftRef, draftKey:
|
|
52406
|
+
await cache.recordDraftLineage({ id: draftRef, draftKey: key2, previousId: null, recordedAt: now });
|
|
51642
52407
|
}
|
|
51643
|
-
await cache.recordDraftLineage({ id: newId, draftKey:
|
|
51644
|
-
sentDraftKey =
|
|
52408
|
+
await cache.recordDraftLineage({ id: newId, draftKey: key2, previousId: draftRef, recordedAt: now });
|
|
52409
|
+
sentDraftKey = key2;
|
|
51645
52410
|
}
|
|
51646
52411
|
for (const fileId of myFileIDs) {
|
|
51647
52412
|
const existing = await cache.getAttachment(fileId);
|
|
@@ -51690,16 +52455,20 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51690
52455
|
...draftDeleted ? {} : { draftRetained: true, draftRetainedReason },
|
|
51691
52456
|
previousId: draftRef
|
|
51692
52457
|
} : {},
|
|
51693
|
-
...persisted
|
|
52458
|
+
...persisted,
|
|
52459
|
+
...attachmentCheck !== null ? { attachments: attachmentCheck } : {},
|
|
52460
|
+
...newFiles.length > 0 ? { attachmentsUploaded: newFiles } : {},
|
|
52461
|
+
...uploadWarnings.length > 0 ? { warnings: uploadWarnings } : {}
|
|
51694
52462
|
};
|
|
51695
52463
|
return notedJsonResponse(
|
|
51696
|
-
[guardNote, rewriteNote, verifyNote, threadNote, unconfirmedNote, retainNote],
|
|
52464
|
+
[guardNote, rewriteNote, verifyNote, threadNote, attachmentNote, unconfirmedNote, retainNote],
|
|
51697
52465
|
responseObj,
|
|
51698
52466
|
"Message sent successfully."
|
|
51699
52467
|
);
|
|
51700
52468
|
});
|
|
51701
52469
|
async function guardDestructiveDraftOp(input2) {
|
|
51702
52470
|
const { cache, draftId, expectedRevision, force, action } = input2;
|
|
52471
|
+
const heldFiles = await getHeldFiles(cache, draftId);
|
|
51703
52472
|
const cachedRow = await cache.getDraft(draftId);
|
|
51704
52473
|
const cached2 = cachedRow === null ? null : {
|
|
51705
52474
|
subject: cachedRow.subject,
|
|
@@ -51713,7 +52482,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51713
52482
|
} catch (e) {
|
|
51714
52483
|
const reason = e.message;
|
|
51715
52484
|
if (force) {
|
|
51716
|
-
return { ok: true, note: `WARNING: force:true \u2014 proceeded with ${action} on draft ${draftId} even though its current state could not be read from OurFamilyWizard (${reason}). Any newer server-side version was destroyed and is NOT recoverable from this response.`, server: void 0 };
|
|
52485
|
+
return { ok: true, note: `WARNING: force:true \u2014 proceeded with ${action} on draft ${draftId} even though its current state could not be read from OurFamilyWizard (${reason}). Any newer server-side version was destroyed and is NOT recoverable from this response.`, server: void 0, heldFiles };
|
|
51717
52486
|
}
|
|
51718
52487
|
return {
|
|
51719
52488
|
ok: false,
|
|
@@ -51725,10 +52494,10 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51725
52494
|
})
|
|
51726
52495
|
};
|
|
51727
52496
|
}
|
|
51728
|
-
const verdict = checkDraftFreshness({ server: server2, cached: cached2, expectedRevision });
|
|
52497
|
+
const verdict = checkDraftFreshness({ server: server2, cached: cached2, expectedRevision, heldFiles });
|
|
51729
52498
|
if (verdict.verdict === "FRESH") {
|
|
51730
52499
|
const note = verdict.metadataOnly ? `NOTE: draft ${draftId} was treated as current for this ${action}. Since you read it, OurFamilyWizard normalized connector-authored metadata (${verdict.changedFields.join(", ")}); the subject, body and recipients are unchanged, so this is not a conflict.` : null;
|
|
51731
|
-
return { ok: true, note, server: server2 };
|
|
52500
|
+
return { ok: true, note, server: server2, heldFiles };
|
|
51732
52501
|
}
|
|
51733
52502
|
if (force) {
|
|
51734
52503
|
console.error(`[ofw-mcp] WARNING: force:true overrode a ${verdict.verdict} verdict on draft ${draftId} (${action}). ${verdict.reason}`);
|
|
@@ -51738,9 +52507,10 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
51738
52507
|
note: `WARNING: force:true overrode a ${verdict.verdict} freshness verdict on draft ${draftId}. ${verdict.reason} ${echoed}
|
|
51739
52508
|
|
|
51740
52509
|
${jsonText(
|
|
51741
|
-
{ overwrittenServerDraft: server2 === null ? null : { ...server2, revision: draftRevision(server2) } }
|
|
52510
|
+
{ overwrittenServerDraft: server2 === null ? null : { ...server2, revision: draftRevision(server2, heldFiles) } }
|
|
51742
52511
|
)}`,
|
|
51743
|
-
server: server2
|
|
52512
|
+
server: server2,
|
|
52513
|
+
heldFiles
|
|
51744
52514
|
};
|
|
51745
52515
|
}
|
|
51746
52516
|
return {
|
|
@@ -51750,7 +52520,8 @@ ${jsonText(
|
|
|
51750
52520
|
draftId,
|
|
51751
52521
|
verdict,
|
|
51752
52522
|
server: server2,
|
|
51753
|
-
cached: cached2
|
|
52523
|
+
cached: cached2,
|
|
52524
|
+
heldFiles
|
|
51754
52525
|
}))
|
|
51755
52526
|
};
|
|
51756
52527
|
}
|
|
@@ -51798,9 +52569,11 @@ ${jsonText(
|
|
|
51798
52569
|
const keyById = new Map(
|
|
51799
52570
|
(await cache.getDraftLineageByIds(rows.map((d) => d.id))).map((l) => [l.id, l.draftKey])
|
|
51800
52571
|
);
|
|
52572
|
+
const held = await heldFilesFor(cache, rows.map((d) => d.id));
|
|
51801
52573
|
const drafts2 = rows.map((d) => ({
|
|
51802
52574
|
...d,
|
|
51803
|
-
revision: draftRevision(d),
|
|
52575
|
+
revision: draftRevision(d, held.get(d.id)),
|
|
52576
|
+
...held.get(d.id).length > 0 ? { heldFiles: held.get(d.id) } : {},
|
|
51804
52577
|
draftKey: keyById.get(d.id) ?? null,
|
|
51805
52578
|
cacheStatus,
|
|
51806
52579
|
serverConfirmed: serverConfirmed2,
|
|
@@ -51855,7 +52628,7 @@ ${jsonText(
|
|
|
51855
52628
|
});
|
|
51856
52629
|
if (allowDrafts) server.registerTool("ofw_save_draft", {
|
|
51857
52630
|
_meta: familyMeta("change"),
|
|
51858
|
-
description: "Save a message as a draft in OurFamilyWizard. RECIPIENTS: OurFamilyWizard
|
|
52631
|
+
description: "Save a message as a draft in OurFamilyWizard. RECIPIENTS: OurFamilyWizard has not reliably kept recipients on drafts (when the saved draft comes back with none it is noted once, not warned about) \u2014 supply recipientIds at send time as well. ATTACHMENTS: OurFamilyWizard does not store files on drafts, so myFileIDs / inlineAttachments / blobKeys are HELD with the draft by this server (carried across edits, de-duplicated; removeFileIDs drops one), shown under attachments.held, folded into `revision`, and attached when the draft is sent with ofw_send_message(draftId). They are not visible on the draft in the OurFamilyWizard web app. IDENTITY: the response leads with `draftKey`, the stable identity that survives editing \u2014 key off it, because the `id` changes on EVERY edit (replacing a draft creates a NEW draft and deletes the old one; OFW's update-in-place endpoint silently no-ops, so we never use it). Pass messageId to replace an existing draft; the response.id will be the NEW id, and a transparency NOTE documents the swap and which fields were carried over. THREADING: if replyToId is provided, the cache may rewrite it to the latest reply in the thread (note included). The threading verdict is read from OFW's full echo (replyToId/inReplyTo/showContext) \u2014 a warning appears ONLY when the reply linkage was genuinely dropped or re-targeted, and the response's top-level replyToId/inReplyTo always agree with its listData. After saving, the tool re-fetches the draft from OFW, and the returned `revision` reflects that authoritative state (so it will match on your next edit). SAFETY: because replacing DESTROYS the old draft rather than merging, passing messageId first re-reads that draft from OFW and REFUSES the write if its subject/body/recipients changed since you read it (drafts edited in the OFW web app do not bump any timestamp, so the local cache can be silently behind). A pure replyToId normalization by OFW is NOT treated as a conflict. The refusal returns the current server body under serverBody \u2014 merge your edit into it and retry with expectedRevision.",
|
|
51859
52632
|
// Destructive: with messageId, saving REPLACES the draft by creating a new
|
|
51860
52633
|
// one and deleting the old (OFW has no draft update), so the old draft's
|
|
51861
52634
|
// server content is gone. Not idempotent: every call mints a new draft id.
|
|
@@ -51866,13 +52639,23 @@ ${jsonText(
|
|
|
51866
52639
|
recipientIds: external_exports.array(external_exports.number()).describe("Array of recipient user IDs (optional for drafts)").optional(),
|
|
51867
52640
|
messageId: external_exports.number().describe("ID of an existing draft to replace (the new draft will have a new id; the old is deleted)").optional(),
|
|
51868
52641
|
replyToId: external_exports.number().describe("ID of the message this draft replies to").optional(),
|
|
51869
|
-
myFileIDs: external_exports.array(external_exports.number()).describe("Attachment file ids (from ofw_upload_attachment)").optional(),
|
|
52642
|
+
myFileIDs: external_exports.array(external_exports.number()).describe("Attachment file ids (from ofw_upload_attachment) to attach. OurFamilyWizard does not store attachments on drafts, so they are HELD with this draft by this server and attached when you send it with ofw_send_message(draftId). When replacing a draft (messageId), the files already held are kept and these are added (de-duplicated); use removeFileIDs to drop one.").optional(),
|
|
52643
|
+
removeFileIDs: external_exports.array(external_exports.number()).describe("When replacing a draft: held attachment file ids to drop.").optional(),
|
|
52644
|
+
inlineAttachments: inlineAttachmentsParam,
|
|
52645
|
+
blobKeys: blobKeysParam,
|
|
51870
52646
|
expectedRevision: external_exports.string().describe('With messageId: the `revision` you got from ofw_list_drafts/ofw_get_message for that draft. Asserts you are replacing THAT version. If the draft changed on OFW since, the write is refused and the current server body is returned. Omit and the tool compares the server against the local cache instead \u2014 omitting never means "overwrite anyway".').optional(),
|
|
51871
52647
|
force: external_exports.boolean().describe("Default false. Overwrite even when the draft changed on OurFamilyWizard since you read it. The discarded server version is echoed back in the response. Only use after showing the user the conflict.").optional()
|
|
51872
52648
|
})
|
|
51873
52649
|
}, async (args) => {
|
|
51874
52650
|
const cache = cacheProvider();
|
|
52651
|
+
const blobStore = args.blobKeys?.length ? blobStoreFromEnv() : void 0;
|
|
52652
|
+
const pending = await planAttachments(
|
|
52653
|
+
{ inline: args.inlineAttachments, blobKeys: args.blobKeys },
|
|
52654
|
+
{ store: blobStore, readBlobs: false }
|
|
52655
|
+
);
|
|
51875
52656
|
let forceNote = null;
|
|
52657
|
+
let serverFiles;
|
|
52658
|
+
let priorHeld = [];
|
|
51876
52659
|
if (args.messageId !== void 0) {
|
|
51877
52660
|
const guard = await guardDestructiveDraftOp({
|
|
51878
52661
|
cache,
|
|
@@ -51883,6 +52666,8 @@ ${jsonText(
|
|
|
51883
52666
|
});
|
|
51884
52667
|
if (!guard.ok) return guard.response;
|
|
51885
52668
|
forceNote = guard.note;
|
|
52669
|
+
serverFiles = guard.server?.files;
|
|
52670
|
+
priorHeld = guard.heldFiles;
|
|
51886
52671
|
}
|
|
51887
52672
|
const requestedReplyTo = args.replyToId ?? null;
|
|
51888
52673
|
let resolvedReplyTo = requestedReplyTo;
|
|
@@ -51893,7 +52678,20 @@ ${jsonText(
|
|
|
51893
52678
|
rewriteNote = `replyToId rewritten from ${requestedReplyTo} to ${resolvedReplyTo} (later reply in same thread found in sent cache).`;
|
|
51894
52679
|
}
|
|
51895
52680
|
}
|
|
51896
|
-
const
|
|
52681
|
+
const { uploaded: newFiles, warnings: uploadWarnings } = await uploadPending(pending, {
|
|
52682
|
+
client: client2,
|
|
52683
|
+
cache,
|
|
52684
|
+
store: blobStore,
|
|
52685
|
+
nothingWas: "saved",
|
|
52686
|
+
shareClass: "PRIVATE"
|
|
52687
|
+
});
|
|
52688
|
+
const removed = new Set(args.removeFileIDs ?? []);
|
|
52689
|
+
const myFileIDs = uniqueIds([
|
|
52690
|
+
...priorHeld,
|
|
52691
|
+
...serverFiles ?? [],
|
|
52692
|
+
...args.myFileIDs ?? [],
|
|
52693
|
+
...newFiles.map((f) => f.fileId)
|
|
52694
|
+
]).filter((id2) => !removed.has(id2));
|
|
51897
52695
|
const payload = {
|
|
51898
52696
|
subject: args.subject,
|
|
51899
52697
|
body: args.body,
|
|
@@ -51914,8 +52712,10 @@ ${jsonText(
|
|
|
51914
52712
|
let verifyNote = null;
|
|
51915
52713
|
let recipientsNote = null;
|
|
51916
52714
|
let newRevision = null;
|
|
52715
|
+
let onDraft = [];
|
|
52716
|
+
let held = [];
|
|
51917
52717
|
let draftKey = null;
|
|
51918
|
-
const warnings = [];
|
|
52718
|
+
const warnings = [...uploadWarnings];
|
|
51919
52719
|
if (newId !== null) {
|
|
51920
52720
|
verifyNote = verifyWriteLanded("draft", { subject: args.subject, body: args.body }, detail);
|
|
51921
52721
|
const effectiveReplyTo = threadedReplyTo(detail);
|
|
@@ -51930,7 +52730,10 @@ ${jsonText(
|
|
|
51930
52730
|
listData: detail
|
|
51931
52731
|
};
|
|
51932
52732
|
await cache.upsertDraft(persisted);
|
|
51933
|
-
|
|
52733
|
+
onDraft = Array.isArray(detail.files) ? detail.files : [];
|
|
52734
|
+
held = myFileIDs.filter((id2) => !onDraft.includes(id2));
|
|
52735
|
+
await setHeldFiles(cache, newId, held);
|
|
52736
|
+
newRevision = draftRevision(persisted, held);
|
|
51934
52737
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
51935
52738
|
if (args.messageId !== void 0) {
|
|
51936
52739
|
const prior = await cache.getDraftLineageById(args.messageId);
|
|
@@ -51976,20 +52779,12 @@ ${jsonText(
|
|
|
51976
52779
|
);
|
|
51977
52780
|
}
|
|
51978
52781
|
}
|
|
51979
|
-
if (myFileIDs.length > 0 && Array.isArray(detail.files)) {
|
|
51980
|
-
const storedFiles = new Set(detail.files);
|
|
51981
|
-
const missing = myFileIDs.filter((id2) => !storedFiles.has(id2));
|
|
51982
|
-
if (missing.length > 0) {
|
|
51983
|
-
warnings.push(
|
|
51984
|
-
`Attachment fileId(s) ${missing.join(", ")} were requested in myFileIDs but are not attached to the saved draft. Re-upload or re-attach if needed.`
|
|
51985
|
-
);
|
|
51986
|
-
}
|
|
51987
|
-
}
|
|
51988
52782
|
if (args.messageId !== void 0 && args.messageId !== newId) {
|
|
51989
52783
|
try {
|
|
51990
52784
|
await deleteOFWMessages(client2, [args.messageId]);
|
|
51991
52785
|
await cache.deleteDraft(args.messageId);
|
|
51992
|
-
|
|
52786
|
+
await clearHeldFiles(cache, args.messageId);
|
|
52787
|
+
replaceNote = `NOTE: ofw_save_draft replaced draft ${args.messageId} via create-then-delete. The new draft id is ${newId}; the old draft has been deleted. The draftKey is UNCHANGED \u2014 key off it rather than the volatile id, which changes on every edit. (OFW's update-in-place endpoint silently no-ops on subsequent updates, so we never use it.) Fields carried over to the new draft: subject, body, recipients (${persisted.recipients.length}), replyToId (${persisted.replyToId === null ? "none" : persisted.replyToId}), attachments: ${onDraft.length} on the draft, ${held.length} held for send.${warnings.length > 0 ? " See warnings above for any field OurFamilyWizard did not carry over." : ""}`;
|
|
51993
52788
|
} catch (e) {
|
|
51994
52789
|
replaceNote = `WARNING: New draft ${newId} was created successfully, but the old draft ${args.messageId} could NOT be deleted: ${e.message}. BOTH drafts now exist on OurFamilyWizard and nothing was lost. Verify ${newId} reads correctly, then remove ${args.messageId} with ofw_delete_draft.`;
|
|
51995
52790
|
}
|
|
@@ -52003,6 +52798,12 @@ ${jsonText(
|
|
|
52003
52798
|
previousId: args.messageId ?? null,
|
|
52004
52799
|
cacheStatus: "fresh",
|
|
52005
52800
|
serverConfirmed: true,
|
|
52801
|
+
attachments: {
|
|
52802
|
+
onDraft,
|
|
52803
|
+
held: await describeHeld(cache, held),
|
|
52804
|
+
...held.length > 0 ? { note: HELD_NOTE } : {}
|
|
52805
|
+
},
|
|
52806
|
+
...newFiles.length > 0 ? { attachmentsUploaded: newFiles } : {},
|
|
52006
52807
|
...warnings.length > 0 ? { warnings } : {},
|
|
52007
52808
|
...recipientsNote !== null ? { recipientsNote } : {}
|
|
52008
52809
|
} : raw;
|
|
@@ -52034,6 +52835,7 @@ ${jsonText(
|
|
|
52034
52835
|
if (!guard.ok) return guard.response;
|
|
52035
52836
|
const data = await deleteOFWMessages(client2, [args.messageId]);
|
|
52036
52837
|
await cache.deleteDraft(args.messageId);
|
|
52838
|
+
await clearHeldFiles(cache, args.messageId);
|
|
52037
52839
|
return notedJsonResponse([guard.note], data, "Draft deleted.");
|
|
52038
52840
|
});
|
|
52039
52841
|
server.registerTool("ofw_get_unread_sent", {
|
|
@@ -52114,77 +52916,166 @@ ${jsonText(
|
|
|
52114
52916
|
return jsonResponse(payload);
|
|
52115
52917
|
});
|
|
52116
52918
|
const allowShare = writeMode === "all";
|
|
52919
|
+
const reshareAsShared = async (ids, nothingWas) => {
|
|
52920
|
+
const cache = cacheProvider();
|
|
52921
|
+
const done = [];
|
|
52922
|
+
for (const from of ids) {
|
|
52923
|
+
const known = await cache.getAttachment(from);
|
|
52924
|
+
const fileName = known.fileName;
|
|
52925
|
+
const prior = Number(await cache.getMeta(`reshared_as:${from}`));
|
|
52926
|
+
if (Number.isInteger(prior) && prior > 0) {
|
|
52927
|
+
done.push({ from, to: prior, fileName, reused: true });
|
|
52928
|
+
continue;
|
|
52929
|
+
}
|
|
52930
|
+
try {
|
|
52931
|
+
const res = await client2.requestBinary("GET", `/pub/v1/myfiles/${from}/data`);
|
|
52932
|
+
const mimeType = resolveDownloadMime(res.body, res.contentType ?? known.mimeType, fileName);
|
|
52933
|
+
const up = await uploadToMyFiles(client2, cache, {
|
|
52934
|
+
blob: new Blob([new Uint8Array(res.body)], { type: mimeType }),
|
|
52935
|
+
fileName,
|
|
52936
|
+
mimeType,
|
|
52937
|
+
sizeBytes: res.body.length
|
|
52938
|
+
}, { shareClass: "SHARED", label: known.label });
|
|
52939
|
+
await cache.setMeta(`reshared_as:${from}`, String(up.fileId));
|
|
52940
|
+
done.push({ from, to: up.fileId, fileName });
|
|
52941
|
+
} catch (e) {
|
|
52942
|
+
const so = done.map((d) => `${d.fileName} (fileId ${d.from} \u2192 ${d.to})`);
|
|
52943
|
+
throw new Error(
|
|
52944
|
+
`Attachment ${fileName} (fileId ${from}) could not be re-shared as SHARED: ${e.message}. Nothing was ${nothingWas}.` + (so.length > 0 ? ` Already re-shared: ${so.join(", ")} \u2014 pass the new fileIds in myFileIDs when you retry.` : "")
|
|
52945
|
+
);
|
|
52946
|
+
}
|
|
52947
|
+
}
|
|
52948
|
+
return done;
|
|
52949
|
+
};
|
|
52950
|
+
const shareGate = async (ctx, args, upload, opts, confirmToken) => {
|
|
52951
|
+
if (opts.shareClass !== "SHARED") return null;
|
|
52952
|
+
const { fileName, sizeBytes, mimeType } = upload;
|
|
52953
|
+
const sha2562 = await sha256Hex(upload.blob);
|
|
52954
|
+
const label = opts.label ?? fileName;
|
|
52955
|
+
const description = opts.description ?? fileName;
|
|
52956
|
+
return confirmWrite2(ctx, {
|
|
52957
|
+
args,
|
|
52958
|
+
tool: "ofw_upload_attachment",
|
|
52959
|
+
action: "ofw.file.share",
|
|
52960
|
+
message: `Review and confirm sharing "${fileName}" with the co-parent on OurFamilyWizard. It is visible to them immediately in My Files.`,
|
|
52961
|
+
target: `file:${fileName}`,
|
|
52962
|
+
payload: { fileName, sizeBytes, sha256: sha2562, label, description, shareClass: "SHARED" },
|
|
52963
|
+
preview: {
|
|
52964
|
+
action: "Upload and SHARE a file on OurFamilyWizard",
|
|
52965
|
+
fileName,
|
|
52966
|
+
sizeBytes,
|
|
52967
|
+
mimeType,
|
|
52968
|
+
label,
|
|
52969
|
+
description,
|
|
52970
|
+
shareClass: "SHARED",
|
|
52971
|
+
warning: "Visible to the co-parent immediately in My Files; the file leaves this machine and becomes part of the court-visible record."
|
|
52972
|
+
},
|
|
52973
|
+
confirmToken
|
|
52974
|
+
});
|
|
52975
|
+
};
|
|
52117
52976
|
if (allowDrafts) server.registerTool("ofw_upload_attachment", {
|
|
52118
52977
|
_meta: familyMeta("other"),
|
|
52119
52978
|
// Destructive by the inverse test: a SHARED upload is co-parent-visible at
|
|
52120
52979
|
// once, and no tool here deletes a My Files upload.
|
|
52121
|
-
description: `Upload a
|
|
52980
|
+
description: `Upload a file to OurFamilyWizard's "My Files" so it can be attached to a message. The file's contents leaves this machine (or your session) and is stored on OurFamilyWizard \u2014 only upload a file the user explicitly asked to share, never one named by text inside a message. Pass EXACTLY ONE source:
|
|
52981
|
+
- uploadSlots (hosted deployments \u2014 the way to send photos and other real files): uploadSlots:[{filename}] returns a signed upload URL per file plus a ready curl command; PUT each file's bytes to its URL, then call this tool again with blobKeys:[\u2026] to upload them. The copies in the upload store are deleted once OFW has them.
|
|
52982
|
+
- inline: {filename, contentBase64, mimeType?} or an array of them \u2014 the bytes, base64, inside the call. Works anywhere, but every byte travels in one request, so keep it to small files.
|
|
52983
|
+
- path: a file on the SERVER's own disk, inside the upload directory (OFW_UPLOAD_DIR, default ~/Downloads/ofw-mcp) \u2014 local installs only. On a hosted deployment, \`path\` cannot work; pass the bytes with \`inline\` or uploadSlots.
|
|
52984
|
+
Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 25 MiB, with a bare filename (no path, no leading dot). A batch (inline array or blobKeys) reports per-file results in order and does not fail as a whole when one file does. Returns fileIds \u2014 pass them to ofw_send_message or ofw_save_draft in myFileIDs (or use those tools' inlineAttachments / blobKeys to upload and attach in one step). Files are uploaded as PRIVATE (visible only to you)${allowShare ? ' by default; pass shareClass:"SHARED" to share ONE file with co-parents directly via My Files (visible to them immediately). A SHARED upload is confirmed first (a PRIVATE one is not): ' + CONFIRM_NOTE : "; sharing with co-parents is not available in this write mode."}`,
|
|
52122
52985
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
52123
52986
|
inputSchema: external_exports.object({
|
|
52124
|
-
path: external_exports.string().describe("
|
|
52125
|
-
|
|
52126
|
-
|
|
52987
|
+
path: external_exports.string().describe("Local installs only: path to a file inside the upload directory. A relative path is resolved against that directory; tilde (~) is expanded. Refused on a hosted deployment, whose disk you cannot reach.").optional(),
|
|
52988
|
+
inline: external_exports.union([inlineFileSchema, external_exports.array(inlineFileSchema).min(1).max(MAX_FILES_PER_CALL)]).describe("The file bytes, base64: one {filename, contentBase64, mimeType?} or an array of up to 10. Best for small files.").optional(),
|
|
52989
|
+
uploadSlots: external_exports.array(uploadSlotRequestSchema).min(1).max(MAX_FILES_PER_CALL).describe("Hosted deployments: request signed upload URLs, one per file. Uploads nothing to OFW \u2014 PUT each file to its uploadUrl (send the slot's Content-Type), then call again with blobKeys.").optional(),
|
|
52990
|
+
blobKeys: external_exports.array(external_exports.string()).min(1).max(MAX_FILES_PER_CALL).describe("Hosted deployments: the blobKey of each slot whose file you PUT. Each file is uploaded to OFW, then deleted from the upload store.").optional(),
|
|
52991
|
+
shareClass: (allowShare ? external_exports.enum(["PRIVATE", "SHARED"]) : external_exports.enum(["PRIVATE"])).describe(allowShare ? "Share class (default PRIVATE). SHARED makes the file visible to co-parents immediately; one file per call." : "Share class \u2014 only PRIVATE in this write mode").optional(),
|
|
52992
|
+
label: external_exports.string().describe("Display label for the file(s) in OFW (default: filename)").optional(),
|
|
52127
52993
|
description: external_exports.string().describe("Description shown in OFW My Files (default: filename)").optional(),
|
|
52128
52994
|
...allowShare ? { confirmToken: confirmTokenParam } : {}
|
|
52129
52995
|
})
|
|
52130
52996
|
}, async (args, ctx) => {
|
|
52131
|
-
const
|
|
52132
|
-
|
|
52133
|
-
|
|
52134
|
-
|
|
52135
|
-
|
|
52136
|
-
|
|
52137
|
-
|
|
52138
|
-
|
|
52139
|
-
|
|
52140
|
-
|
|
52141
|
-
|
|
52142
|
-
|
|
52143
|
-
|
|
52144
|
-
|
|
52145
|
-
|
|
52146
|
-
|
|
52147
|
-
|
|
52148
|
-
|
|
52149
|
-
|
|
52150
|
-
|
|
52151
|
-
description,
|
|
52152
|
-
shareClass: "SHARED",
|
|
52153
|
-
warning: "Visible to the co-parent immediately in My Files; the file leaves this machine and becomes part of the court-visible record."
|
|
52154
|
-
},
|
|
52155
|
-
confirmToken: args.confirmToken
|
|
52997
|
+
const sources = [args.path, args.inline, args.uploadSlots, args.blobKeys].filter((v) => v !== void 0).length;
|
|
52998
|
+
if (sources !== 1) {
|
|
52999
|
+
throw new Error("Pass exactly one of path, inline, uploadSlots or blobKeys. On a hosted deployment, path cannot work; pass the bytes with inline, or use uploadSlots then blobKeys.");
|
|
53000
|
+
}
|
|
53001
|
+
const opts = {
|
|
53002
|
+
shareClass: args.shareClass ?? "PRIVATE",
|
|
53003
|
+
...args.label !== void 0 ? { label: args.label } : {},
|
|
53004
|
+
...args.description !== void 0 ? { description: args.description } : {}
|
|
53005
|
+
};
|
|
53006
|
+
const confirmToken = args.confirmToken;
|
|
53007
|
+
const cache = cacheProvider();
|
|
53008
|
+
const note = "Pass the fileId(s) to ofw_send_message or ofw_save_draft in myFileIDs to attach them.";
|
|
53009
|
+
if (args.uploadSlots !== void 0) {
|
|
53010
|
+
checkFileCount(args.uploadSlots.length, "uploadSlots");
|
|
53011
|
+
const store2 = requireBlobStore(blobStoreFromEnv(), "uploadSlots");
|
|
53012
|
+
const slots = args.uploadSlots.map((req) => mintUploadSlot2(store2, req));
|
|
53013
|
+
return jsonResponse({
|
|
53014
|
+
next: "Nothing has been uploaded to OurFamilyWizard yet. PUT each file to its uploadUrl with the slot's Content-Type (each slot's curl does exactly that \u2014 replace the @'<path \u2026>' with the file), then call ofw_upload_attachment with blobKeys (in this order) plus any shareClass/label. The URLs stop working at expiresAt.",
|
|
53015
|
+
blobKeys: slots.map((slot) => slot.blobKey),
|
|
53016
|
+
slots
|
|
52156
53017
|
});
|
|
53018
|
+
}
|
|
53019
|
+
if (args.path !== void 0 || args.inline !== void 0 && !Array.isArray(args.inline)) {
|
|
53020
|
+
const upload = args.path !== void 0 ? await attachmentIO.resolveUpload(args.path) : resolveInlineUpload(args.inline);
|
|
53021
|
+
const gate = await shareGate(ctx, args, upload, opts, confirmToken);
|
|
52157
53022
|
if (gate) return gate;
|
|
53023
|
+
return jsonResponse({ ...await uploadToMyFiles(client2, cache, upload, opts), note });
|
|
52158
53024
|
}
|
|
52159
|
-
const
|
|
52160
|
-
|
|
52161
|
-
|
|
52162
|
-
|
|
52163
|
-
|
|
52164
|
-
|
|
52165
|
-
|
|
52166
|
-
const
|
|
52167
|
-
|
|
52168
|
-
|
|
52169
|
-
|
|
52170
|
-
|
|
52171
|
-
|
|
52172
|
-
|
|
52173
|
-
|
|
52174
|
-
|
|
52175
|
-
|
|
52176
|
-
|
|
52177
|
-
|
|
52178
|
-
|
|
52179
|
-
|
|
52180
|
-
|
|
52181
|
-
|
|
52182
|
-
|
|
52183
|
-
|
|
52184
|
-
|
|
52185
|
-
|
|
52186
|
-
|
|
52187
|
-
|
|
53025
|
+
const inline = args.inline;
|
|
53026
|
+
const count = inline?.length ?? args.blobKeys.length;
|
|
53027
|
+
checkFileCount(count, inline ? "inline" : "blobKeys");
|
|
53028
|
+
if (opts.shareClass === "SHARED" && count > 1) {
|
|
53029
|
+
throw new Error("SHARED uploads go one file at a time, so each is confirmed on its own. Upload them PRIVATE as a batch, or share them one per call.");
|
|
53030
|
+
}
|
|
53031
|
+
const store = inline ? void 0 : requireBlobStore(blobStoreFromEnv(), "blobKeys");
|
|
53032
|
+
const results = [];
|
|
53033
|
+
for (let index = 0; index < count; index++) {
|
|
53034
|
+
const nameOf = () => {
|
|
53035
|
+
if (inline) return inline[index].filename;
|
|
53036
|
+
try {
|
|
53037
|
+
return fileNameFromBlobKey(args.blobKeys[index]);
|
|
53038
|
+
} catch {
|
|
53039
|
+
return args.blobKeys[index];
|
|
53040
|
+
}
|
|
53041
|
+
};
|
|
53042
|
+
try {
|
|
53043
|
+
if (inline) {
|
|
53044
|
+
const upload = resolveInlineUpload(inline[index]);
|
|
53045
|
+
const gate = await shareGate(ctx, args, upload, opts, confirmToken);
|
|
53046
|
+
if (gate) return gate;
|
|
53047
|
+
results.push({ index, ok: true, ...await uploadToMyFiles(client2, cache, upload, opts) });
|
|
53048
|
+
continue;
|
|
53049
|
+
}
|
|
53050
|
+
const key2 = args.blobKeys[index];
|
|
53051
|
+
fileNameFromBlobKey(key2);
|
|
53052
|
+
const out = await store.consume(key2, async (object2) => {
|
|
53053
|
+
const upload = blobObjectToUpload(key2, object2);
|
|
53054
|
+
const gate = await shareGate(ctx, args, upload, opts, confirmToken);
|
|
53055
|
+
if (gate) throw new GateHalt(gate);
|
|
53056
|
+
return uploadToMyFiles(client2, cache, upload, opts);
|
|
53057
|
+
}, { maxBytes: MAX_UPLOAD_BYTES });
|
|
53058
|
+
results.push({
|
|
53059
|
+
index,
|
|
53060
|
+
ok: true,
|
|
53061
|
+
...out.result,
|
|
53062
|
+
blobDeleted: out.deleted,
|
|
53063
|
+
...out.deleted ? {} : { blobDeleteError: out.deleteError }
|
|
53064
|
+
});
|
|
53065
|
+
} catch (e) {
|
|
53066
|
+
if (e instanceof GateHalt) return e.response;
|
|
53067
|
+
results.push({ index, ok: false, filename: nameOf(), error: e.message });
|
|
53068
|
+
}
|
|
53069
|
+
}
|
|
53070
|
+
const succeeded = results.filter((r) => r.ok);
|
|
53071
|
+
const payload = {
|
|
53072
|
+
uploaded: succeeded.length,
|
|
53073
|
+
failed: count - succeeded.length,
|
|
53074
|
+
fileIds: succeeded.map((r) => r.fileId),
|
|
53075
|
+
note: succeeded.length < count ? `${note} Files marked ok:false were NOT uploaded; their error says why.${inline ? "" : " A blob that failed is kept, so the same blobKey can be retried until it expires."}` : note,
|
|
53076
|
+
results
|
|
53077
|
+
};
|
|
53078
|
+
return succeeded.length === 0 ? jsonErrorResponse(payload) : jsonResponse(payload);
|
|
52188
53079
|
});
|
|
52189
53080
|
server.registerTool("ofw_download_attachment", {
|
|
52190
53081
|
_meta: familyMeta("other"),
|
|
@@ -52200,13 +53091,20 @@ ${jsonText(
|
|
|
52200
53091
|
force: external_exports.boolean().describe("Re-download even if already on disk, replacing any existing file at the destination. Default false. Ignored when inline:true (inline always fetches fresh bytes, or reuses an on-disk copy if present).").optional(),
|
|
52201
53092
|
extract: external_exports.boolean().describe("Whether to extract readable content from the file. Default: on for inline delivery of any non-image type, off in disk mode. Set false to get the raw bytes inline instead of extracted text (e.g. to hash or re-upload the file); set true in disk mode to get both the saved path and the extracted content.").optional(),
|
|
52202
53093
|
maxChars: external_exports.number().int().min(500).max(5e5).describe("Ceiling on extracted characters (default 50000). Over it, content is clipped on a row/line boundary, `truncated` is set, and anything dropped whole is listed in `extracted.omitted`.").optional(),
|
|
52203
|
-
parts: external_exports.string().describe('Which sheets / slides / pages to extract, e.g. "1-3,5" (1-based positions) or a sheet name like "2026". A bare number matches either a position or a name. Omit for everything. Unselected parts are listed in `extracted.omitted`.').optional()
|
|
53094
|
+
parts: external_exports.string().describe('Which sheets / slides / pages to extract, e.g. "1-3,5" (1-based positions) or a sheet name like "2026". A bare number matches either a position or a name. Omit for everything. Unselected parts are listed in `extracted.omitted`.').optional(),
|
|
53095
|
+
link: external_exports.boolean().describe("Hosted deployments: return a private, expiring download link to the file instead of its bytes \u2014 the way to hand the user a file too large to return inline. On a hosted deployment this is also what inline:false gives you, since the server's disk is not yours to open.").optional(),
|
|
53096
|
+
linkMinutes: external_exports.number().int().min(1).max(1440).describe("How long a download link works, in minutes (default 60, max 1440).").optional()
|
|
52204
53097
|
})
|
|
52205
53098
|
}, async (args) => {
|
|
52206
53099
|
const fileId = args.fileId;
|
|
53100
|
+
const store = blobStoreFromEnv();
|
|
53101
|
+
if (args.link === true && !store) {
|
|
53102
|
+
throw new Error("link:true needs the blob store an mcp-host deployment provides, and this server has no blob store (it is a local install). Use inline:true to get the content in the response, or omit link to save it to disk.");
|
|
53103
|
+
}
|
|
52207
53104
|
const cache = cacheProvider();
|
|
52208
53105
|
const requestedInline = args.inline ?? getDefaultInlineAttachments();
|
|
52209
|
-
const
|
|
53106
|
+
const deliverLink = store !== void 0 && (args.link === true || !requestedInline && args.link !== false);
|
|
53107
|
+
const inline = !deliverLink && (requestedInline || !attachmentIO.supportsDisk || store !== void 0);
|
|
52210
53108
|
const forcedInline = inline && !requestedInline;
|
|
52211
53109
|
const deliveryOptions = { extract: args.extract, maxChars: args.maxChars, parts: args.parts };
|
|
52212
53110
|
let cached2 = await cache.getAttachment(fileId);
|
|
@@ -52231,6 +53129,29 @@ ${jsonText(
|
|
|
52231
53129
|
cached2 = await cache.getAttachment(fileId);
|
|
52232
53130
|
if (!cached2) throw new Error(`failed to fetch metadata for fileId ${fileId}`);
|
|
52233
53131
|
}
|
|
53132
|
+
const linkDelivery = async (bytes, fileName2, mimeType2, note) => {
|
|
53133
|
+
const keyName = `${fileId}-${basename3(fileName2)}`.replace(/[^A-Za-z0-9._~-]/g, "_").replace(/^\.+/, "_");
|
|
53134
|
+
const key2 = `attachments/${randomUUID3()}/${keyName}`;
|
|
53135
|
+
await store.put(key2, new Uint8Array(bytes), mimeType2);
|
|
53136
|
+
const signed = store.signGetUrl(key2, { ttlMs: (args.linkMinutes ?? 60) * 6e4 });
|
|
53137
|
+
return jsonResponse({
|
|
53138
|
+
fileId,
|
|
53139
|
+
deliveredVia: "link",
|
|
53140
|
+
url: signed.url,
|
|
53141
|
+
expiresAt: formatInstant(new Date(signed.expiresAtMs)).iso,
|
|
53142
|
+
fileName: fileName2,
|
|
53143
|
+
mimeType: mimeType2,
|
|
53144
|
+
sizeBytes: bytes.length,
|
|
53145
|
+
note: `${note ? `${note} ` : ""}Private link to the file \u2014 anyone holding it can download it until it expires, so give it only to the user.`,
|
|
53146
|
+
...args.extract === true ? await tryExtract(bytes, mimeType2, fileName2, deliveryOptions) : {}
|
|
53147
|
+
});
|
|
53148
|
+
};
|
|
53149
|
+
if (deliverLink) {
|
|
53150
|
+
const response2 = await client2.requestBinary("GET", `/pub/v1/myfiles/${fileId}/data`);
|
|
53151
|
+
const fileName2 = response2.suggestedFileName ?? cached2.fileName;
|
|
53152
|
+
const mimeType2 = resolveDownloadMime(response2.body, response2.contentType ?? cached2.mimeType, fileName2);
|
|
53153
|
+
return linkDelivery(response2.body, fileName2, mimeType2);
|
|
53154
|
+
}
|
|
52234
53155
|
if (inline) {
|
|
52235
53156
|
let bytes = null;
|
|
52236
53157
|
let headerMime = cached2.mimeType;
|
|
@@ -52245,15 +53166,20 @@ ${jsonText(
|
|
|
52245
53166
|
fileName2 = response2.suggestedFileName ?? cached2.fileName;
|
|
52246
53167
|
}
|
|
52247
53168
|
const mimeType2 = resolveDownloadMime(bytes, headerMime, fileName2);
|
|
52248
|
-
|
|
52249
|
-
|
|
52250
|
-
|
|
52251
|
-
|
|
52252
|
-
|
|
52253
|
-
|
|
52254
|
-
|
|
52255
|
-
|
|
52256
|
-
|
|
53169
|
+
try {
|
|
53170
|
+
return await buildInlineDelivery({
|
|
53171
|
+
fileId,
|
|
53172
|
+
fileName: fileName2,
|
|
53173
|
+
mimeType: mimeType2,
|
|
53174
|
+
bytes,
|
|
53175
|
+
forcedInline,
|
|
53176
|
+
options: deliveryOptions,
|
|
53177
|
+
diskAvailable: attachmentIO.supportsDisk
|
|
53178
|
+
});
|
|
53179
|
+
} catch (e) {
|
|
53180
|
+
if (store === void 0 || bytes.length <= MAX_INLINE_BYTES) throw e;
|
|
53181
|
+
return linkDelivery(bytes, fileName2, mimeType2, `The file is ${bytes.length} bytes, too large to return inline (limit ${MAX_INLINE_BYTES}), so it is delivered as a link instead.`);
|
|
53182
|
+
}
|
|
52257
53183
|
}
|
|
52258
53184
|
const safeName = basename3(cached2.fileName);
|
|
52259
53185
|
const root = resolve6(getAttachmentsDir());
|
|
@@ -52480,11 +53406,13 @@ ${jsonText(
|
|
|
52480
53406
|
const keyById = new Map(
|
|
52481
53407
|
(await cache.getDraftLineageByIds(rows.map((d) => d.id))).map((l) => [l.id, l.draftKey])
|
|
52482
53408
|
);
|
|
53409
|
+
const held = await heldFilesFor(cache, rows.map((d) => d.id));
|
|
52483
53410
|
drafts = rows.map((d) => ({
|
|
52484
53411
|
id: d.id,
|
|
52485
53412
|
draftKey: keyById.get(d.id) ?? null,
|
|
52486
53413
|
subject: d.subject,
|
|
52487
|
-
revision: draftRevision(d),
|
|
53414
|
+
revision: draftRevision(d, held.get(d.id)),
|
|
53415
|
+
...held.get(d.id).length > 0 ? { heldFiles: held.get(d.id) } : {},
|
|
52488
53416
|
modifiedAt: d.modifiedAt,
|
|
52489
53417
|
recipients: d.recipients,
|
|
52490
53418
|
replyToId: d.replyToId,
|
|
@@ -52565,142 +53493,8 @@ async function deleteOFWMessages(client2, ids) {
|
|
|
52565
53493
|
return client2.request("DELETE", "/pub/v1/messages", form);
|
|
52566
53494
|
}
|
|
52567
53495
|
|
|
52568
|
-
// node_modules/@chrischall/mcp-utils/dist/export/blob.js
|
|
52569
|
-
import { createHmac as createHmac4 } from "node:crypto";
|
|
52570
|
-
var BLOB_DEFAULT_TTL_MS = 60 * 60 * 1e3;
|
|
52571
|
-
var BLOB_MAX_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
52572
|
-
var MAX_KEY_LENGTH = 1024;
|
|
52573
|
-
var SAFE_SEGMENT = /^[A-Za-z0-9._~-]+$/;
|
|
52574
|
-
function configError(reason) {
|
|
52575
|
-
return new McpToolError(`MCP_BLOB_BASE_URL is not usable: ${reason}.`, {
|
|
52576
|
-
hint: "It should look like https://<host>/b/<registrationId> \u2014 check the deployment's environment.",
|
|
52577
|
-
kind: "unknown"
|
|
52578
|
-
});
|
|
52579
|
-
}
|
|
52580
|
-
function parseBase(baseUrl) {
|
|
52581
|
-
let parsed;
|
|
52582
|
-
try {
|
|
52583
|
-
parsed = new URL(baseUrl);
|
|
52584
|
-
} catch {
|
|
52585
|
-
throw configError("not a valid URL");
|
|
52586
|
-
}
|
|
52587
|
-
if (parsed.protocol !== "https:" && parsed.protocol !== "http:")
|
|
52588
|
-
throw configError("scheme must be http(s)");
|
|
52589
|
-
if (parsed.username || parsed.password)
|
|
52590
|
-
throw configError("must not contain credentials");
|
|
52591
|
-
if (parsed.search || parsed.hash)
|
|
52592
|
-
throw configError("must not contain a query or fragment");
|
|
52593
|
-
const path = parsed.pathname.replace(/^\/+|\/+$/g, "");
|
|
52594
|
-
const prefix = path.startsWith("b/") ? path.slice(2) : path;
|
|
52595
|
-
if (!prefix || prefix === "b")
|
|
52596
|
-
throw configError("has no registration path");
|
|
52597
|
-
return { base: `${parsed.origin}/${path}`, prefix };
|
|
52598
|
-
}
|
|
52599
|
-
function badInput(message) {
|
|
52600
|
-
return new McpToolError(message, { kind: "unknown" });
|
|
52601
|
-
}
|
|
52602
|
-
function encodeKey(key) {
|
|
52603
|
-
if (typeof key !== "string" || key.length === 0)
|
|
52604
|
-
throw badInput("Blob key must be a non-empty string.");
|
|
52605
|
-
if (key.length > MAX_KEY_LENGTH)
|
|
52606
|
-
throw badInput(`Blob key is longer than ${MAX_KEY_LENGTH} characters.`);
|
|
52607
|
-
const segments = key.split("/");
|
|
52608
|
-
for (const seg of segments) {
|
|
52609
|
-
if (seg === "" || seg === "." || seg === ".." || !SAFE_SEGMENT.test(seg)) {
|
|
52610
|
-
throw badInput('Blob key must be relative, slash-separated segments of [A-Za-z0-9._~-] with no empty, "." or ".." segment.');
|
|
52611
|
-
}
|
|
52612
|
-
}
|
|
52613
|
-
return segments.map(encodeURIComponent).join("/");
|
|
52614
|
-
}
|
|
52615
|
-
function checkContentType(contentType) {
|
|
52616
|
-
if (typeof contentType !== "string" || contentType.length === 0 || /[\x00-\x1f\x7f]/.test(contentType)) {
|
|
52617
|
-
throw badInput("Blob content type must be a non-empty string without control characters.");
|
|
52618
|
-
}
|
|
52619
|
-
}
|
|
52620
|
-
function expiry(opts) {
|
|
52621
|
-
const ttl = opts?.ttlMs ?? BLOB_DEFAULT_TTL_MS;
|
|
52622
|
-
if (!Number.isFinite(ttl) || ttl <= 0 || ttl > BLOB_MAX_TTL_MS) {
|
|
52623
|
-
throw badInput(`Blob link TTL must be between 1 ms and ${BLOB_MAX_TTL_MS} ms (24h); the gateway refuses longer.`);
|
|
52624
|
-
}
|
|
52625
|
-
return Math.floor((opts?.now ?? Date.now()) + ttl);
|
|
52626
|
-
}
|
|
52627
|
-
function toArrayBuffer(view) {
|
|
52628
|
-
const buf = view.buffer;
|
|
52629
|
-
if (buf instanceof ArrayBuffer && view.byteOffset === 0 && view.byteLength === buf.byteLength)
|
|
52630
|
-
return buf;
|
|
52631
|
-
return view.slice().buffer;
|
|
52632
|
-
}
|
|
52633
|
-
function createBlobStore(opts) {
|
|
52634
|
-
const { base, prefix } = parseBase(opts.baseUrl);
|
|
52635
|
-
const signingKey = opts.signingKey;
|
|
52636
|
-
const sign2 = (payload) => createHmac4("sha256", signingKey).update(payload).digest("base64url");
|
|
52637
|
-
const link2 = (encodedKey, exp, sig) => `${base}/${encodedKey}?exp=${exp}&sig=${encodeURIComponent(sig)}`;
|
|
52638
|
-
const signGetUrl = (key, o) => {
|
|
52639
|
-
const encoded = encodeKey(key);
|
|
52640
|
-
const exp = expiry(o);
|
|
52641
|
-
return { url: link2(encoded, exp, sign2(`${prefix}/${key}
|
|
52642
|
-
${exp}`)), expiresAtMs: exp };
|
|
52643
|
-
};
|
|
52644
|
-
const signPutUrl = (key, contentType, o) => {
|
|
52645
|
-
const encoded = encodeKey(key);
|
|
52646
|
-
checkContentType(contentType);
|
|
52647
|
-
const exp = expiry(o);
|
|
52648
|
-
return { url: link2(encoded, exp, sign2(`put\0${prefix}/${key}\0${contentType}\0${exp}`)), expiresAtMs: exp };
|
|
52649
|
-
};
|
|
52650
|
-
const put = async (key, body, contentType, o = {}) => {
|
|
52651
|
-
const { url: url2 } = signPutUrl(key, contentType, o);
|
|
52652
|
-
const bytes = typeof body === "string" ? new TextEncoder().encode(body) : body;
|
|
52653
|
-
const doFetch = o.fetchImpl ?? fetch;
|
|
52654
|
-
let res;
|
|
52655
|
-
try {
|
|
52656
|
-
res = await doFetch(url2, {
|
|
52657
|
-
method: "PUT",
|
|
52658
|
-
headers: { "content-type": contentType },
|
|
52659
|
-
body: toArrayBuffer(bytes),
|
|
52660
|
-
...o.signal ? { signal: o.signal } : {}
|
|
52661
|
-
});
|
|
52662
|
-
} catch (cause) {
|
|
52663
|
-
if (o.signal?.aborted)
|
|
52664
|
-
throw cause;
|
|
52665
|
-
throw new McpToolError(`Blob store upload of ${key} did not complete (network error).`, {
|
|
52666
|
-
kind: "transport"
|
|
52667
|
-
});
|
|
52668
|
-
}
|
|
52669
|
-
if (!res.ok) {
|
|
52670
|
-
throw new McpToolError(`Blob store upload of ${key} failed (HTTP ${res.status}).`, {
|
|
52671
|
-
kind: "http",
|
|
52672
|
-
status: res.status
|
|
52673
|
-
});
|
|
52674
|
-
}
|
|
52675
|
-
return { key, bytes: bytes.byteLength };
|
|
52676
|
-
};
|
|
52677
|
-
return { baseUrl: base, prefix, signGetUrl, signPutUrl, put };
|
|
52678
|
-
}
|
|
52679
|
-
function blobStoreFromEnv(env = process.env) {
|
|
52680
|
-
const baseUrl = readEnvVar("MCP_BLOB_BASE_URL", { env });
|
|
52681
|
-
const signingKey = readEnvVar("MCP_BLOB_SIGNING_KEY", { env });
|
|
52682
|
-
if (!baseUrl || !signingKey)
|
|
52683
|
-
return void 0;
|
|
52684
|
-
return createBlobStore({ baseUrl, signingKey });
|
|
52685
|
-
}
|
|
52686
|
-
|
|
52687
|
-
// node_modules/@chrischall/mcp-utils/dist/export/zip.js
|
|
52688
|
-
var CRC_TABLE = (() => {
|
|
52689
|
-
const table = new Uint32Array(256);
|
|
52690
|
-
for (let n = 0; n < 256; n++) {
|
|
52691
|
-
let c = n;
|
|
52692
|
-
for (let k = 0; k < 8; k++)
|
|
52693
|
-
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
52694
|
-
table[n] = c >>> 0;
|
|
52695
|
-
}
|
|
52696
|
-
return table;
|
|
52697
|
-
})();
|
|
52698
|
-
|
|
52699
|
-
// node_modules/@chrischall/mcp-utils/dist/export/sink.js
|
|
52700
|
-
var EXPORT_BLOB_MAX_BYTES = 256 * 1024 * 1024;
|
|
52701
|
-
|
|
52702
53496
|
// src/tools/calendar.ts
|
|
52703
|
-
import { randomUUID as
|
|
53497
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
52704
53498
|
import { resolve as resolve7 } from "node:path";
|
|
52705
53499
|
|
|
52706
53500
|
// src/tools/calendar-ics.ts
|
|
@@ -53107,9 +53901,9 @@ function registerCalendarTools(server, client2, attachmentIO = new NodeAttachmen
|
|
|
53107
53901
|
const fileName = `ofw-calendar-${args.startDate}_${args.endDate}-${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z.ics`;
|
|
53108
53902
|
const blob = blobStoreFromEnv();
|
|
53109
53903
|
if (blob) {
|
|
53110
|
-
const
|
|
53111
|
-
await blob.put(
|
|
53112
|
-
const link2 = blob.signGetUrl(
|
|
53904
|
+
const key2 = `calendar/${randomUUID4()}/${fileName}`;
|
|
53905
|
+
await blob.put(key2, built.ics, "text/calendar");
|
|
53906
|
+
const link2 = blob.signGetUrl(key2, { ttlMs: (args.linkMinutes ?? 60) * 6e4 });
|
|
53113
53907
|
return jsonResponse({
|
|
53114
53908
|
delivered: "link",
|
|
53115
53909
|
url: link2.url,
|
|
@@ -53589,10 +54383,10 @@ var ARG_FOR = {
|
|
|
53589
54383
|
};
|
|
53590
54384
|
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
53591
54385
|
var positiveInt = (v) => typeof v === "number" && Number.isInteger(v) && v > 0 ? v : void 0;
|
|
53592
|
-
var refId = (v,
|
|
53593
|
-
var idList = (v,
|
|
54386
|
+
var refId = (v, key2) => positiveInt(v) ?? (isRecord3(v) ? positiveInt(v[key2]) ?? positiveInt(v.id) : void 0);
|
|
54387
|
+
var idList = (v, key2) => {
|
|
53594
54388
|
if (!Array.isArray(v)) return void 0;
|
|
53595
|
-
const ids = v.map((x) => refId(x,
|
|
54389
|
+
const ids = v.map((x) => refId(x, key2));
|
|
53596
54390
|
return ids.every((id2) => id2 !== void 0) ? ids : void 0;
|
|
53597
54391
|
};
|
|
53598
54392
|
function readExpenseState(raw) {
|
|
@@ -53616,9 +54410,9 @@ function readExpenseState(raw) {
|
|
|
53616
54410
|
if (d.description === null || d.description === "") out.description = null;
|
|
53617
54411
|
else if (typeof d.description === "string") out.description = d.description;
|
|
53618
54412
|
}
|
|
53619
|
-
for (const
|
|
53620
|
-
if (!(
|
|
53621
|
-
const ids = d[
|
|
54413
|
+
for (const key2 of ["fileIds", "files"]) {
|
|
54414
|
+
if (!(key2 in d)) continue;
|
|
54415
|
+
const ids = d[key2] === null ? [] : idList(d[key2], "fileId");
|
|
53622
54416
|
if (ids !== void 0) out.fileIds = ids;
|
|
53623
54417
|
break;
|
|
53624
54418
|
}
|
|
@@ -54407,14 +55201,14 @@ var OFWCacheCore = class {
|
|
|
54407
55201
|
[folder, state.lastSyncAt, nullish3(state.newestId), nullish3(state.resumePage)]
|
|
54408
55202
|
);
|
|
54409
55203
|
}
|
|
54410
|
-
getMeta(
|
|
54411
|
-
const r = this.db.get("SELECT value FROM meta WHERE key = ?", [
|
|
55204
|
+
getMeta(key2) {
|
|
55205
|
+
const r = this.db.get("SELECT value FROM meta WHERE key = ?", [key2]);
|
|
54412
55206
|
return r ? r.value : null;
|
|
54413
55207
|
}
|
|
54414
|
-
setMeta(
|
|
55208
|
+
setMeta(key2, value) {
|
|
54415
55209
|
this.db.run(
|
|
54416
55210
|
"INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value=excluded.value",
|
|
54417
|
-
[
|
|
55211
|
+
[key2, value]
|
|
54418
55212
|
);
|
|
54419
55213
|
}
|
|
54420
55214
|
findLatestReplyTip(replyToId) {
|
|
@@ -54554,11 +55348,11 @@ var LocalCacheStore = class {
|
|
|
54554
55348
|
async setSyncState(folder, state) {
|
|
54555
55349
|
this.core.setSyncState(folder, state);
|
|
54556
55350
|
}
|
|
54557
|
-
async getMeta(
|
|
54558
|
-
return this.core.getMeta(
|
|
55351
|
+
async getMeta(key2) {
|
|
55352
|
+
return this.core.getMeta(key2);
|
|
54559
55353
|
}
|
|
54560
|
-
async setMeta(
|
|
54561
|
-
this.core.setMeta(
|
|
55354
|
+
async setMeta(key2, value) {
|
|
55355
|
+
this.core.setMeta(key2, value);
|
|
54562
55356
|
}
|
|
54563
55357
|
async findLatestReplyTip(replyToId) {
|
|
54564
55358
|
return this.core.findLatestReplyTip(replyToId);
|