@chrischall/microsoft-teams-mcp 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +110 -15
- package/dist/bridge-scope.js +13 -3
- package/dist/bundle.js +1728 -273
- package/dist/chatsvc.js +30 -0
- package/dist/compose.js +150 -51
- package/dist/index.js +10 -1
- package/dist/model.js +12 -91
- package/dist/recap-auth.js +44 -0
- package/dist/recap-token-cache.js +50 -0
- package/dist/recap.js +325 -0
- package/dist/rich.js +108 -0
- package/dist/tools/conversation.js +4 -1
- package/dist/tools/delete.js +72 -0
- package/dist/tools/edit.js +131 -0
- package/dist/tools/export-format.js +4 -1
- package/dist/tools/own-message.js +78 -0
- package/dist/tools/recap.js +122 -0
- package/dist/tools/send.js +24 -8
- package/dist/version.js +1 -1
- package/mint.yaml +9 -0
- package/package.json +2 -2
- package/server.json +17 -3
- package/skills/teams-fpx/SKILL.md +9 -7
package/dist/bundle.js
CHANGED
|
@@ -347,8 +347,8 @@ function defineLazy(object2, key, getter) {
|
|
|
347
347
|
configurable: true
|
|
348
348
|
});
|
|
349
349
|
}
|
|
350
|
-
function objectClone(
|
|
351
|
-
return Object.create(Object.getPrototypeOf(
|
|
350
|
+
function objectClone(obj3) {
|
|
351
|
+
return Object.create(Object.getPrototypeOf(obj3), Object.getOwnPropertyDescriptors(obj3));
|
|
352
352
|
}
|
|
353
353
|
function assignProp(target, prop, value) {
|
|
354
354
|
Object.defineProperty(target, prop, {
|
|
@@ -382,7 +382,7 @@ function putProp(target, key, value) {
|
|
|
382
382
|
else
|
|
383
383
|
target[key] = value;
|
|
384
384
|
}
|
|
385
|
-
function mirrorShape(target, source, keys,
|
|
385
|
+
function mirrorShape(target, source, keys, wrap2) {
|
|
386
386
|
const raw = sourceShape(source);
|
|
387
387
|
for (const key of keys) {
|
|
388
388
|
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
@@ -391,10 +391,10 @@ function mirrorShape(target, source, keys, wrap) {
|
|
|
391
391
|
if (desc.get) {
|
|
392
392
|
deferProp(target, key, () => {
|
|
393
393
|
const value = source._zod.def.shape[key];
|
|
394
|
-
return
|
|
394
|
+
return wrap2 ? wrap2(value, key) : value;
|
|
395
395
|
});
|
|
396
396
|
} else
|
|
397
|
-
putProp(target, key,
|
|
397
|
+
putProp(target, key, wrap2 ? wrap2(desc.value, key) : desc.value);
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
function mirrorProps(target, source) {
|
|
@@ -419,10 +419,10 @@ function mergeDefs(...defs) {
|
|
|
419
419
|
function cloneDef(schema) {
|
|
420
420
|
return mergeDefs(schema._zod.def);
|
|
421
421
|
}
|
|
422
|
-
function getElementAtPath(
|
|
422
|
+
function getElementAtPath(obj3, path) {
|
|
423
423
|
if (!path)
|
|
424
|
-
return
|
|
425
|
-
return path.reduce((acc, key) => acc?.[key],
|
|
424
|
+
return obj3;
|
|
425
|
+
return path.reduce((acc, key) => acc?.[key], obj3);
|
|
426
426
|
}
|
|
427
427
|
function promiseAllObject(promisesObj) {
|
|
428
428
|
const keys = Object.keys(promisesObj);
|
|
@@ -437,14 +437,14 @@ function promiseAllObject(promisesObj) {
|
|
|
437
437
|
}
|
|
438
438
|
function randomString(length = 10) {
|
|
439
439
|
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
440
|
-
let
|
|
440
|
+
let str4 = "";
|
|
441
441
|
for (let i = 0; i < length; i++) {
|
|
442
|
-
|
|
442
|
+
str4 += chars[Math.floor(Math.random() * chars.length)];
|
|
443
443
|
}
|
|
444
|
-
return
|
|
444
|
+
return str4;
|
|
445
445
|
}
|
|
446
|
-
function esc(
|
|
447
|
-
return JSON.stringify(
|
|
446
|
+
function esc(str4) {
|
|
447
|
+
return JSON.stringify(str4);
|
|
448
448
|
}
|
|
449
449
|
function slugify(input2) {
|
|
450
450
|
return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -488,8 +488,8 @@ function numKeys(data) {
|
|
|
488
488
|
}
|
|
489
489
|
return keyCount;
|
|
490
490
|
}
|
|
491
|
-
function escapeRegex(
|
|
492
|
-
return
|
|
491
|
+
function escapeRegex(str4) {
|
|
492
|
+
return str4.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
493
493
|
}
|
|
494
494
|
function clone(inst, def, params) {
|
|
495
495
|
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
@@ -743,13 +743,13 @@ function getSizableOrigin(input2) {
|
|
|
743
743
|
return "file";
|
|
744
744
|
return "unknown";
|
|
745
745
|
}
|
|
746
|
-
function codePointLength(
|
|
747
|
-
const units =
|
|
748
|
-
if (!highSurrogate.test(
|
|
746
|
+
function codePointLength(str4) {
|
|
747
|
+
const units = str4.length;
|
|
748
|
+
if (!highSurrogate.test(str4))
|
|
749
749
|
return units;
|
|
750
750
|
let count = units;
|
|
751
751
|
for (let i = 0; i < units - 1; i++) {
|
|
752
|
-
if ((
|
|
752
|
+
if ((str4.charCodeAt(i) & 64512) === 55296 && (str4.charCodeAt(i + 1) & 64512) === 56320) {
|
|
753
753
|
count--;
|
|
754
754
|
i++;
|
|
755
755
|
}
|
|
@@ -776,9 +776,9 @@ function parsedType(data) {
|
|
|
776
776
|
if (Array.isArray(data)) {
|
|
777
777
|
return "array";
|
|
778
778
|
}
|
|
779
|
-
const
|
|
780
|
-
if (
|
|
781
|
-
return
|
|
779
|
+
const obj3 = data;
|
|
780
|
+
if (obj3 && Object.getPrototypeOf(obj3) !== Object.prototype && "constructor" in obj3 && obj3.constructor) {
|
|
781
|
+
return obj3.constructor.name;
|
|
782
782
|
}
|
|
783
783
|
}
|
|
784
784
|
}
|
|
@@ -796,8 +796,8 @@ function issue(...args) {
|
|
|
796
796
|
}
|
|
797
797
|
return { ...iss };
|
|
798
798
|
}
|
|
799
|
-
function cleanEnum(
|
|
800
|
-
return Object.entries(
|
|
799
|
+
function cleanEnum(obj3) {
|
|
800
|
+
return Object.entries(obj3).filter(([k, _]) => {
|
|
801
801
|
return Number.isNaN(Number.parseInt(k, 10));
|
|
802
802
|
}).map((el) => el[1]);
|
|
803
803
|
}
|
|
@@ -838,9 +838,9 @@ function hexToUint8Array(hex3) {
|
|
|
838
838
|
function uint8ArrayToHex(bytes) {
|
|
839
839
|
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
840
840
|
}
|
|
841
|
-
function members(proto,
|
|
842
|
-
for (const key in
|
|
843
|
-
const desc = Object.getOwnPropertyDescriptor(
|
|
841
|
+
function members(proto, table2) {
|
|
842
|
+
for (const key in table2) {
|
|
843
|
+
const desc = Object.getOwnPropertyDescriptor(table2, key);
|
|
844
844
|
if (desc.get)
|
|
845
845
|
Object.defineProperty(proto, key, { ...desc, enumerable: false });
|
|
846
846
|
else
|
|
@@ -855,10 +855,10 @@ function hide(inst, key, value) {
|
|
|
855
855
|
return own(inst, key, value, false);
|
|
856
856
|
}
|
|
857
857
|
// @__NO_SIDE_EFFECTS__
|
|
858
|
-
function derived(computes,
|
|
858
|
+
function derived(computes, table2) {
|
|
859
859
|
for (const key in computes) {
|
|
860
860
|
const compute = computes[key];
|
|
861
|
-
Object.defineProperty(
|
|
861
|
+
Object.defineProperty(table2, key, {
|
|
862
862
|
configurable: true,
|
|
863
863
|
enumerable: true,
|
|
864
864
|
get() {
|
|
@@ -869,7 +869,7 @@ function derived(computes, table) {
|
|
|
869
869
|
}
|
|
870
870
|
});
|
|
871
871
|
}
|
|
872
|
-
return
|
|
872
|
+
return table2;
|
|
873
873
|
}
|
|
874
874
|
function defineBound(proto, key, fn) {
|
|
875
875
|
Object.defineProperty(proto, key, {
|
|
@@ -1194,15 +1194,15 @@ function _getMessage() {
|
|
|
1194
1194
|
function _setMessage(value) {
|
|
1195
1195
|
this._zod.message = value;
|
|
1196
1196
|
}
|
|
1197
|
-
function node(
|
|
1198
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
1197
|
+
function node(obj3, key, make) {
|
|
1198
|
+
if (!Object.prototype.hasOwnProperty.call(obj3, key)) {
|
|
1199
1199
|
if (key === "__proto__") {
|
|
1200
|
-
Object.defineProperty(
|
|
1200
|
+
Object.defineProperty(obj3, key, { value: make(), writable: true, enumerable: true, configurable: true });
|
|
1201
1201
|
} else {
|
|
1202
|
-
|
|
1202
|
+
obj3[key] = make();
|
|
1203
1203
|
}
|
|
1204
1204
|
}
|
|
1205
|
-
return
|
|
1205
|
+
return obj3[key];
|
|
1206
1206
|
}
|
|
1207
1207
|
function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
1208
1208
|
const fieldErrors = {};
|
|
@@ -16303,8 +16303,8 @@ var init_to_json_schema = __esm({
|
|
|
16303
16303
|
function aggregateChecks(schema) {
|
|
16304
16304
|
const agg = {};
|
|
16305
16305
|
const def = schema._zod.def;
|
|
16306
|
-
const
|
|
16307
|
-
for (const ch of
|
|
16306
|
+
const list2 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
16307
|
+
for (const ch of list2)
|
|
16308
16308
|
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
16309
16309
|
const bag = schema._zod.bag;
|
|
16310
16310
|
if (bag.minimum !== void 0)
|
|
@@ -24348,12 +24348,12 @@ function isZodV4Schema(v) {
|
|
|
24348
24348
|
function looksLikeZodV3(v) {
|
|
24349
24349
|
return typeof v === "object" && v !== null && !("_zod" in v) && "_def" in v && typeof v._def?.typeName === "string";
|
|
24350
24350
|
}
|
|
24351
|
-
function isZodRawShape(
|
|
24352
|
-
if (typeof
|
|
24353
|
-
if (isStandardSchema(
|
|
24354
|
-
const proto = Object.getPrototypeOf(
|
|
24351
|
+
function isZodRawShape(obj3) {
|
|
24352
|
+
if (typeof obj3 !== "object" || obj3 === null) return false;
|
|
24353
|
+
if (isStandardSchema(obj3)) return false;
|
|
24354
|
+
const proto = Object.getPrototypeOf(obj3);
|
|
24355
24355
|
if (proto !== Object.prototype && proto !== null) return false;
|
|
24356
|
-
return Object.values(
|
|
24356
|
+
return Object.values(obj3).every((v) => isZodV4Schema(v));
|
|
24357
24357
|
}
|
|
24358
24358
|
function normalizeRawShapeSchema(schema) {
|
|
24359
24359
|
if (schema === void 0) return void 0;
|
|
@@ -26208,7 +26208,7 @@ var init_src_DdvbAHrR = __esm({
|
|
|
26208
26208
|
var index = header.indexOf(";");
|
|
26209
26209
|
var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
|
|
26210
26210
|
if (!TYPE_REGEXP.test(type)) throw new TypeError("invalid media type");
|
|
26211
|
-
var
|
|
26211
|
+
var obj3 = new ContentType(type.toLowerCase());
|
|
26212
26212
|
if (index !== -1) {
|
|
26213
26213
|
var key;
|
|
26214
26214
|
var match;
|
|
@@ -26223,16 +26223,16 @@ var init_src_DdvbAHrR = __esm({
|
|
|
26223
26223
|
value = value.slice(1, -1);
|
|
26224
26224
|
if (value.indexOf("\\") !== -1) value = value.replace(QESC_REGEXP, "$1");
|
|
26225
26225
|
}
|
|
26226
|
-
|
|
26226
|
+
obj3.parameters[key] = value;
|
|
26227
26227
|
}
|
|
26228
26228
|
if (index !== header.length) throw new TypeError("invalid parameter format");
|
|
26229
26229
|
}
|
|
26230
|
-
return
|
|
26230
|
+
return obj3;
|
|
26231
26231
|
}
|
|
26232
|
-
function getcontenttype(
|
|
26232
|
+
function getcontenttype(obj3) {
|
|
26233
26233
|
var header;
|
|
26234
|
-
if (typeof
|
|
26235
|
-
else if (typeof
|
|
26234
|
+
if (typeof obj3.getHeader === "function") header = obj3.getHeader("content-type");
|
|
26235
|
+
else if (typeof obj3.headers === "object") header = obj3.headers && obj3.headers["content-type"];
|
|
26236
26236
|
if (typeof header !== "string") throw new TypeError("content-type header is missing from object");
|
|
26237
26237
|
return header;
|
|
26238
26238
|
}
|
|
@@ -26357,7 +26357,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
26357
26357
|
}
|
|
26358
26358
|
exports._ = _;
|
|
26359
26359
|
const plus = new _Code("+");
|
|
26360
|
-
function
|
|
26360
|
+
function str4(strs, ...args) {
|
|
26361
26361
|
const expr = [safeStringify(strs[0])];
|
|
26362
26362
|
let i = 0;
|
|
26363
26363
|
while (i < args.length) {
|
|
@@ -26368,7 +26368,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
26368
26368
|
optimize(expr);
|
|
26369
26369
|
return new _Code(expr);
|
|
26370
26370
|
}
|
|
26371
|
-
exports.str =
|
|
26371
|
+
exports.str = str4;
|
|
26372
26372
|
function addCodeArg(code2, arg) {
|
|
26373
26373
|
if (arg instanceof _Code) code2.push(...arg._items);
|
|
26374
26374
|
else if (arg instanceof Name) code2.push(arg);
|
|
@@ -26401,7 +26401,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
26401
26401
|
if (typeof b == "string" && b[0] === '"' && !(a instanceof Name)) return `"${a}${b.slice(1)}`;
|
|
26402
26402
|
}
|
|
26403
26403
|
function strConcat(c1, c2) {
|
|
26404
|
-
return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 :
|
|
26404
|
+
return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str4`${c1}${c2}`;
|
|
26405
26405
|
}
|
|
26406
26406
|
exports.strConcat = strConcat;
|
|
26407
26407
|
function interpolate(x) {
|
|
@@ -27082,10 +27082,10 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
27082
27082
|
}
|
|
27083
27083
|
return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name));
|
|
27084
27084
|
}
|
|
27085
|
-
forIn(nameOrPrefix,
|
|
27086
|
-
if (this.opts.ownProperties) return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${
|
|
27085
|
+
forIn(nameOrPrefix, obj3, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
|
|
27086
|
+
if (this.opts.ownProperties) return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj3})`, forBody);
|
|
27087
27087
|
const name = this._scope.toName(nameOrPrefix);
|
|
27088
|
-
return this._for(new ForIter("in", varKind, name,
|
|
27088
|
+
return this._for(new ForIter("in", varKind, name, obj3), () => forBody(name));
|
|
27089
27089
|
}
|
|
27090
27090
|
endFor() {
|
|
27091
27091
|
return this._endBlockNode(For);
|
|
@@ -27280,21 +27280,21 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
27280
27280
|
return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
|
|
27281
27281
|
}
|
|
27282
27282
|
exports.schemaRefOrVal = schemaRefOrVal;
|
|
27283
|
-
function unescapeFragment(
|
|
27284
|
-
return unescapeJsonPointer(decodeURIComponent(
|
|
27283
|
+
function unescapeFragment(str4) {
|
|
27284
|
+
return unescapeJsonPointer(decodeURIComponent(str4));
|
|
27285
27285
|
}
|
|
27286
27286
|
exports.unescapeFragment = unescapeFragment;
|
|
27287
|
-
function escapeFragment(
|
|
27288
|
-
return encodeURIComponent(escapeJsonPointer(
|
|
27287
|
+
function escapeFragment(str4) {
|
|
27288
|
+
return encodeURIComponent(escapeJsonPointer(str4));
|
|
27289
27289
|
}
|
|
27290
27290
|
exports.escapeFragment = escapeFragment;
|
|
27291
|
-
function escapeJsonPointer(
|
|
27292
|
-
if (typeof
|
|
27293
|
-
return
|
|
27291
|
+
function escapeJsonPointer(str4) {
|
|
27292
|
+
if (typeof str4 == "number") return `${str4}`;
|
|
27293
|
+
return str4.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
27294
27294
|
}
|
|
27295
27295
|
exports.escapeJsonPointer = escapeJsonPointer;
|
|
27296
|
-
function unescapeJsonPointer(
|
|
27297
|
-
return
|
|
27296
|
+
function unescapeJsonPointer(str4) {
|
|
27297
|
+
return str4.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
27298
27298
|
}
|
|
27299
27299
|
exports.unescapeJsonPointer = unescapeJsonPointer;
|
|
27300
27300
|
function eachItem(xs, f) {
|
|
@@ -28180,8 +28180,8 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
28180
28180
|
post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
28181
28181
|
}
|
|
28182
28182
|
}
|
|
28183
|
-
function escapeJsonPtr(
|
|
28184
|
-
return
|
|
28183
|
+
function escapeJsonPtr(str4) {
|
|
28184
|
+
return str4.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
28185
28185
|
}
|
|
28186
28186
|
}));
|
|
28187
28187
|
require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
@@ -28613,9 +28613,9 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
28613
28613
|
ok(cond) {
|
|
28614
28614
|
if (!this.allErrors) this.gen.if(cond);
|
|
28615
28615
|
}
|
|
28616
|
-
setParams(
|
|
28617
|
-
if (assign) Object.assign(this.params,
|
|
28618
|
-
else this.params =
|
|
28616
|
+
setParams(obj3, assign) {
|
|
28617
|
+
if (assign) Object.assign(this.params, obj3);
|
|
28618
|
+
else this.params = obj3;
|
|
28619
28619
|
}
|
|
28620
28620
|
block$data(valid, codeBlock, $dataValid = codegen_1.nil) {
|
|
28621
28621
|
this.gen.block(() => {
|
|
@@ -29126,9 +29126,9 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
29126
29126
|
isIPV6: true
|
|
29127
29127
|
};
|
|
29128
29128
|
}
|
|
29129
|
-
function findToken(
|
|
29129
|
+
function findToken(str4, token) {
|
|
29130
29130
|
let ind = 0;
|
|
29131
|
-
for (let i = 0; i <
|
|
29131
|
+
for (let i = 0; i < str4.length; i++) if (str4[i] === token) ind++;
|
|
29132
29132
|
return ind;
|
|
29133
29133
|
}
|
|
29134
29134
|
function removeDotSegments(path) {
|
|
@@ -29943,7 +29943,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
29943
29943
|
const util_1 = require_util();
|
|
29944
29944
|
const $dataRefSchema = require_data();
|
|
29945
29945
|
const uri_1 = require_uri();
|
|
29946
|
-
const defaultRegExp = (
|
|
29946
|
+
const defaultRegExp = (str4, flags) => new RegExp(str4, flags);
|
|
29947
29947
|
defaultRegExp.code = "new RegExp";
|
|
29948
29948
|
const META_IGNORE_OPTIONS = [
|
|
29949
29949
|
"removeAdditional",
|
|
@@ -30649,16 +30649,16 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
30649
30649
|
}));
|
|
30650
30650
|
require_ucs2length = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
30651
30651
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30652
|
-
function ucs2length(
|
|
30653
|
-
const len =
|
|
30652
|
+
function ucs2length(str4) {
|
|
30653
|
+
const len = str4.length;
|
|
30654
30654
|
let length = 0;
|
|
30655
30655
|
let pos = 0;
|
|
30656
30656
|
let value;
|
|
30657
30657
|
while (pos < len) {
|
|
30658
30658
|
length++;
|
|
30659
|
-
value =
|
|
30659
|
+
value = str4.charCodeAt(pos++);
|
|
30660
30660
|
if (value >= 55296 && value <= 56319 && pos < len) {
|
|
30661
|
-
value =
|
|
30661
|
+
value = str4.charCodeAt(pos);
|
|
30662
30662
|
if ((value & 64512) === 56320) pos++;
|
|
30663
30663
|
}
|
|
30664
30664
|
}
|
|
@@ -31196,7 +31196,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
31196
31196
|
const count = gen.let("count", 0);
|
|
31197
31197
|
validateItems(schValid, () => gen.if(schValid, () => checkLimits(count)));
|
|
31198
31198
|
}
|
|
31199
|
-
function validateItems(_valid,
|
|
31199
|
+
function validateItems(_valid, block2) {
|
|
31200
31200
|
gen.forRange("i", 0, len, (i) => {
|
|
31201
31201
|
cxt.subschema({
|
|
31202
31202
|
keyword: "contains",
|
|
@@ -31204,7 +31204,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
31204
31204
|
dataPropType: util_1.Type.Num,
|
|
31205
31205
|
compositeRule: true
|
|
31206
31206
|
}, _valid);
|
|
31207
|
-
|
|
31207
|
+
block2();
|
|
31208
31208
|
});
|
|
31209
31209
|
}
|
|
31210
31210
|
function checkLimits(count) {
|
|
@@ -33353,7 +33353,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
33353
33353
|
function isLeapYear(year) {
|
|
33354
33354
|
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
33355
33355
|
}
|
|
33356
|
-
const
|
|
33356
|
+
const DATE2 = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
33357
33357
|
const DAYS = [
|
|
33358
33358
|
0,
|
|
33359
33359
|
31,
|
|
@@ -33369,8 +33369,8 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
33369
33369
|
30,
|
|
33370
33370
|
31
|
|
33371
33371
|
];
|
|
33372
|
-
function date5(
|
|
33373
|
-
const matches =
|
|
33372
|
+
function date5(str4) {
|
|
33373
|
+
const matches = DATE2.exec(str4);
|
|
33374
33374
|
if (!matches) return false;
|
|
33375
33375
|
const year = +matches[1];
|
|
33376
33376
|
const month = +matches[2];
|
|
@@ -33385,8 +33385,8 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
33385
33385
|
}
|
|
33386
33386
|
const TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
|
|
33387
33387
|
function getTime(strictTimeZone) {
|
|
33388
|
-
return function time3(
|
|
33389
|
-
const matches = TIME.exec(
|
|
33388
|
+
return function time3(str4) {
|
|
33389
|
+
const matches = TIME.exec(str4);
|
|
33390
33390
|
if (!matches) return false;
|
|
33391
33391
|
const hr = +matches[1];
|
|
33392
33392
|
const min = +matches[2];
|
|
@@ -33423,8 +33423,8 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
33423
33423
|
const DATE_TIME_SEPARATOR = /t|\s/i;
|
|
33424
33424
|
function getDateTime(strictTimeZone) {
|
|
33425
33425
|
const time3 = getTime(strictTimeZone);
|
|
33426
|
-
return function date_time(
|
|
33427
|
-
const dateTime =
|
|
33426
|
+
return function date_time(str4) {
|
|
33427
|
+
const dateTime = str4.split(DATE_TIME_SEPARATOR);
|
|
33428
33428
|
return dateTime.length === 2 && date5(dateTime[0]) && time3(dateTime[1]);
|
|
33429
33429
|
};
|
|
33430
33430
|
}
|
|
@@ -33445,13 +33445,13 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
33445
33445
|
}
|
|
33446
33446
|
const NOT_URI_FRAGMENT = /\/|:/;
|
|
33447
33447
|
const URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
33448
|
-
function uri(
|
|
33449
|
-
return NOT_URI_FRAGMENT.test(
|
|
33448
|
+
function uri(str4) {
|
|
33449
|
+
return NOT_URI_FRAGMENT.test(str4) && URI.test(str4);
|
|
33450
33450
|
}
|
|
33451
33451
|
const BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;
|
|
33452
|
-
function byte(
|
|
33452
|
+
function byte(str4) {
|
|
33453
33453
|
BYTE.lastIndex = 0;
|
|
33454
|
-
return BYTE.test(
|
|
33454
|
+
return BYTE.test(str4);
|
|
33455
33455
|
}
|
|
33456
33456
|
const MIN_INT32 = -(2 ** 31);
|
|
33457
33457
|
const MAX_INT32 = 2 ** 31 - 1;
|
|
@@ -33465,10 +33465,10 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
33465
33465
|
return true;
|
|
33466
33466
|
}
|
|
33467
33467
|
const Z_ANCHOR = /[^\\]\\Z/;
|
|
33468
|
-
function regex(
|
|
33469
|
-
if (Z_ANCHOR.test(
|
|
33468
|
+
function regex(str4) {
|
|
33469
|
+
if (Z_ANCHOR.test(str4)) return false;
|
|
33470
33470
|
try {
|
|
33471
|
-
new RegExp(
|
|
33471
|
+
new RegExp(str4);
|
|
33472
33472
|
return true;
|
|
33473
33473
|
} catch (e) {
|
|
33474
33474
|
return false;
|
|
@@ -33574,11 +33574,11 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
33574
33574
|
if (!f) throw new Error(`Unknown format "${name}"`);
|
|
33575
33575
|
return f;
|
|
33576
33576
|
};
|
|
33577
|
-
function addFormats2(ajv,
|
|
33577
|
+
function addFormats2(ajv, list2, fs, exportName) {
|
|
33578
33578
|
var _a3;
|
|
33579
33579
|
var _b;
|
|
33580
33580
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 || (_b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`);
|
|
33581
|
-
for (const f of
|
|
33581
|
+
for (const f of list2) ajv.addFormat(f, fs[f]);
|
|
33582
33582
|
}
|
|
33583
33583
|
module.exports = exports = formatsPlugin;
|
|
33584
33584
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -36098,9 +36098,9 @@ function redactValues(text, values, opts = {}) {
|
|
|
36098
36098
|
return out;
|
|
36099
36099
|
}
|
|
36100
36100
|
function truncateErrorMessage(text, max = DEFAULT_ERROR_MESSAGE_MAX, opts = {}) {
|
|
36101
|
-
const
|
|
36101
|
+
const str4 = text === null || text === void 0 ? "" : String(text);
|
|
36102
36102
|
const cap = Math.max(ERROR_REDACTION_INPUT_MAX, max);
|
|
36103
|
-
const capped =
|
|
36103
|
+
const capped = str4.length > cap ? str4.slice(0, cap) : str4;
|
|
36104
36104
|
const scrubbed = opts.values !== void 0 ? redactValues(capped, opts.values, opts.placeholder !== void 0 ? { placeholder: opts.placeholder } : {}) : capped;
|
|
36105
36105
|
const redacted = redactSecrets(scrubbed);
|
|
36106
36106
|
if (redacted.length <= max)
|
|
@@ -38523,7 +38523,7 @@ var init_version = __esm({
|
|
|
38523
38523
|
"src/version.ts"() {
|
|
38524
38524
|
"use strict";
|
|
38525
38525
|
PACKAGE_NAME = "microsoft-teams-mcp";
|
|
38526
|
-
VERSION = "0.
|
|
38526
|
+
VERSION = "0.12.0";
|
|
38527
38527
|
}
|
|
38528
38528
|
});
|
|
38529
38529
|
|
|
@@ -38894,13 +38894,13 @@ function capturedBearerTokens(accessToken, opts = {}) {
|
|
|
38894
38894
|
}
|
|
38895
38895
|
function createCapturedTokenManager(opts) {
|
|
38896
38896
|
const { direct } = opts;
|
|
38897
|
-
const
|
|
38897
|
+
const wrap2 = (token) => capturedBearerTokens(token, {
|
|
38898
38898
|
...opts.unknownTtlMs !== void 0 ? { unknownTtlMs: opts.unknownTtlMs } : {},
|
|
38899
38899
|
...opts.now !== void 0 ? { now: opts.now } : {}
|
|
38900
38900
|
});
|
|
38901
38901
|
const persistence = direct === void 0 ? opts.persistence ?? void 0 : void 0;
|
|
38902
38902
|
return new TokenManager({
|
|
38903
|
-
initial: async () =>
|
|
38903
|
+
initial: async () => wrap2(direct ?? await opts.capture()),
|
|
38904
38904
|
refresh: async () => {
|
|
38905
38905
|
if (direct !== void 0) {
|
|
38906
38906
|
throw opts.onDirectRejected ? opts.onDirectRejected() : new McpToolError("The directly supplied access token was rejected (401).", {
|
|
@@ -38909,7 +38909,7 @@ function createCapturedTokenManager(opts) {
|
|
|
38909
38909
|
hint: "A directly supplied token cannot be refreshed automatically. Replace it with a current one, or unset it to capture from a signed-in browser tab instead."
|
|
38910
38910
|
});
|
|
38911
38911
|
}
|
|
38912
|
-
return
|
|
38912
|
+
return wrap2(await opts.capture());
|
|
38913
38913
|
},
|
|
38914
38914
|
...persistence !== void 0 ? { persistence } : {},
|
|
38915
38915
|
// Never fatal: the token is in hand and re-capturable.
|
|
@@ -40403,14 +40403,14 @@ function assertAcceptsList(accepts) {
|
|
|
40403
40403
|
}
|
|
40404
40404
|
}
|
|
40405
40405
|
}
|
|
40406
|
-
function assertExtensionFeatures(
|
|
40406
|
+
function assertExtensionFeatures(list2) {
|
|
40407
40407
|
const label = "hello.features";
|
|
40408
|
-
if (!Array.isArray(
|
|
40408
|
+
if (!Array.isArray(list2))
|
|
40409
40409
|
throw new ProtocolError3(`${label}: expected array`);
|
|
40410
|
-
if (
|
|
40411
|
-
throw new ProtocolError3(`${label}: at most ${MAX_EXTENSION_FEATURES} entries, got ${
|
|
40410
|
+
if (list2.length > MAX_EXTENSION_FEATURES) {
|
|
40411
|
+
throw new ProtocolError3(`${label}: at most ${MAX_EXTENSION_FEATURES} entries, got ${list2.length}`);
|
|
40412
40412
|
}
|
|
40413
|
-
for (const f of
|
|
40413
|
+
for (const f of list2) {
|
|
40414
40414
|
if (typeof f !== "string") {
|
|
40415
40415
|
throw new ProtocolError3(`${label}: entry must be string, got ${typeof f}`);
|
|
40416
40416
|
}
|
|
@@ -40419,14 +40419,14 @@ function assertExtensionFeatures(list) {
|
|
|
40419
40419
|
}
|
|
40420
40420
|
}
|
|
40421
40421
|
}
|
|
40422
|
-
function assertUnavailableCapabilities(
|
|
40422
|
+
function assertUnavailableCapabilities(list2) {
|
|
40423
40423
|
const label = "hello.unavailableCapabilities";
|
|
40424
|
-
if (!Array.isArray(
|
|
40424
|
+
if (!Array.isArray(list2))
|
|
40425
40425
|
throw new ProtocolError3(`${label}: expected array`);
|
|
40426
|
-
if (
|
|
40427
|
-
throw new ProtocolError3(`${label}: at most ${MAX_UNAVAILABLE_CAPABILITIES} entries, got ${
|
|
40426
|
+
if (list2.length > MAX_UNAVAILABLE_CAPABILITIES) {
|
|
40427
|
+
throw new ProtocolError3(`${label}: at most ${MAX_UNAVAILABLE_CAPABILITIES} entries, got ${list2.length}`);
|
|
40428
40428
|
}
|
|
40429
|
-
for (const c of
|
|
40429
|
+
for (const c of list2) {
|
|
40430
40430
|
if (typeof c !== "string") {
|
|
40431
40431
|
throw new ProtocolError3(`${label}: entry must be string, got ${typeof c}`);
|
|
40432
40432
|
}
|
|
@@ -41401,13 +41401,13 @@ var require_buffer_util = __commonJS({
|
|
|
41401
41401
|
var { websocketMask, websocketUnmask } = __require("http");
|
|
41402
41402
|
var { EMPTY_BUFFER } = require_constants();
|
|
41403
41403
|
var FastBuffer = Buffer[Symbol.species];
|
|
41404
|
-
function concat(
|
|
41405
|
-
if (
|
|
41406
|
-
if (
|
|
41404
|
+
function concat(list2, totalLength) {
|
|
41405
|
+
if (list2.length === 0) return EMPTY_BUFFER;
|
|
41406
|
+
if (list2.length === 1) return list2[0];
|
|
41407
41407
|
const target = Buffer.allocUnsafe(totalLength);
|
|
41408
41408
|
let offset = 0;
|
|
41409
|
-
for (let i = 0; i <
|
|
41410
|
-
const buf =
|
|
41409
|
+
for (let i = 0; i < list2.length; i++) {
|
|
41410
|
+
const buf = list2[i];
|
|
41411
41411
|
target.set(buf, offset);
|
|
41412
41412
|
offset += buf.length;
|
|
41413
41413
|
}
|
|
@@ -43206,14 +43206,14 @@ var require_sender = __commonJS({
|
|
|
43206
43206
|
* @param {Function} [cb] Callback
|
|
43207
43207
|
* @private
|
|
43208
43208
|
*/
|
|
43209
|
-
sendFrame(
|
|
43210
|
-
if (
|
|
43209
|
+
sendFrame(list2, cb) {
|
|
43210
|
+
if (list2.length === 2) {
|
|
43211
43211
|
this._socket.cork();
|
|
43212
|
-
this._socket.write(
|
|
43213
|
-
this._socket.write(
|
|
43212
|
+
this._socket.write(list2[0]);
|
|
43213
|
+
this._socket.write(list2[1], cb);
|
|
43214
43214
|
this._socket.uncork();
|
|
43215
43215
|
} else {
|
|
43216
|
-
this._socket.write(
|
|
43216
|
+
this._socket.write(list2[0], cb);
|
|
43217
43217
|
}
|
|
43218
43218
|
}
|
|
43219
43219
|
};
|
|
@@ -43636,7 +43636,7 @@ var require_websocket = __commonJS({
|
|
|
43636
43636
|
BINARY_TYPES,
|
|
43637
43637
|
CLOSE_TIMEOUT,
|
|
43638
43638
|
EMPTY_BUFFER,
|
|
43639
|
-
GUID:
|
|
43639
|
+
GUID: GUID4,
|
|
43640
43640
|
kForOnEventAttribute,
|
|
43641
43641
|
kListener,
|
|
43642
43642
|
kStatusCode,
|
|
@@ -44312,7 +44312,7 @@ var require_websocket = __commonJS({
|
|
|
44312
44312
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
44313
44313
|
return;
|
|
44314
44314
|
}
|
|
44315
|
-
const digest = createHash5("sha1").update(key +
|
|
44315
|
+
const digest = createHash5("sha1").update(key + GUID4).digest("base64");
|
|
44316
44316
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
44317
44317
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
44318
44318
|
return;
|
|
@@ -44691,7 +44691,7 @@ var require_websocket_server = __commonJS({
|
|
|
44691
44691
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
44692
44692
|
var subprotocol2 = require_subprotocol();
|
|
44693
44693
|
var WebSocket2 = require_websocket();
|
|
44694
|
-
var { CLOSE_TIMEOUT, GUID:
|
|
44694
|
+
var { CLOSE_TIMEOUT, GUID: GUID4, kWebSocket } = require_constants();
|
|
44695
44695
|
var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
44696
44696
|
var RUNNING = 0;
|
|
44697
44697
|
var CLOSING = 1;
|
|
@@ -44993,7 +44993,7 @@ var require_websocket_server = __commonJS({
|
|
|
44993
44993
|
);
|
|
44994
44994
|
}
|
|
44995
44995
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
44996
|
-
const digest = createHash5("sha1").update(key +
|
|
44996
|
+
const digest = createHash5("sha1").update(key + GUID4).digest("base64");
|
|
44997
44997
|
const headers = [
|
|
44998
44998
|
"HTTP/1.1 101 Switching Protocols",
|
|
44999
44999
|
"Upgrade: websocket",
|
|
@@ -48626,8 +48626,8 @@ var init_ws_server = __esm({
|
|
|
48626
48626
|
throw new Error("FetchproxyServer.captureRequestHeader: no captureHeaders declared on this server \u2014 declare at least one entry in FetchproxyServerOpts.captureHeaders, or pass {host, headerName} explicitly");
|
|
48627
48627
|
}
|
|
48628
48628
|
if (decls.length > 1) {
|
|
48629
|
-
const
|
|
48630
|
-
throw new Error(`FetchproxyServer.captureRequestHeader: multiple captureHeaders declared (${decls.length}: ${
|
|
48629
|
+
const list2 = decls.map((d) => `${JSON.stringify(d.host)}${JSON.stringify(normPath(d.path))}/${JSON.stringify(d.headerName)}`).join(", ");
|
|
48630
|
+
throw new Error(`FetchproxyServer.captureRequestHeader: multiple captureHeaders declared (${decls.length}: ${list2}); pass {host, headerName} to disambiguate`);
|
|
48631
48631
|
}
|
|
48632
48632
|
resolved = decls[0];
|
|
48633
48633
|
} else {
|
|
@@ -49964,7 +49964,7 @@ function sharePointCaptureDecl(host) {
|
|
|
49964
49964
|
}
|
|
49965
49965
|
function bridgeCaptureDecls(sharePointHosts) {
|
|
49966
49966
|
const hosts = [...new Set([...sharePointHosts].map((h) => h.toLowerCase()).filter(isSharePointHost))].sort();
|
|
49967
|
-
return [{ ...CAPTURE_DECL }, { ...SUBSTRATE_CAPTURE_DECL }, ...hosts.map(sharePointCaptureDecl)];
|
|
49967
|
+
return [{ ...CAPTURE_DECL }, { ...SUBSTRATE_CAPTURE_DECL }, { ...RECAP_CAPTURE_DECL }, ...hosts.map(sharePointCaptureDecl)];
|
|
49968
49968
|
}
|
|
49969
49969
|
function bridgeScopePath(env = process.env) {
|
|
49970
49970
|
return join10(dirname5(sharePointTokenCachePath(env)), "bridge-scope.json");
|
|
@@ -50008,7 +50008,7 @@ function withBridgeScope(opts, env, extraSharePointHosts = []) {
|
|
|
50008
50008
|
captureHeaders: bridgeCaptureDecls(hosts)
|
|
50009
50009
|
};
|
|
50010
50010
|
}
|
|
50011
|
-
var CAPTURE_DECL, SUBSTRATE_CAPTURE_DECL, BRIDGE_TRUST_DOMAINS;
|
|
50011
|
+
var CAPTURE_DECL, SUBSTRATE_CAPTURE_DECL, RECAP_CAPTURE_DECL, BRIDGE_TRUST_DOMAINS;
|
|
50012
50012
|
var init_bridge_scope = __esm({
|
|
50013
50013
|
"src/bridge-scope.ts"() {
|
|
50014
50014
|
"use strict";
|
|
@@ -50026,6 +50026,11 @@ var init_bridge_scope = __esm({
|
|
|
50026
50026
|
path: "/searchservice/*",
|
|
50027
50027
|
headerName: "authorization"
|
|
50028
50028
|
};
|
|
50029
|
+
RECAP_CAPTURE_DECL = {
|
|
50030
|
+
host: "teams.cloud.microsoft",
|
|
50031
|
+
path: "/api/mcps/*",
|
|
50032
|
+
headerName: "authorization"
|
|
50033
|
+
};
|
|
50029
50034
|
BRIDGE_TRUST_DOMAINS = [CAPTURE_DECL.host, "sharepoint.com", SUBSTRATE_CAPTURE_DECL.host];
|
|
50030
50035
|
}
|
|
50031
50036
|
});
|
|
@@ -50091,22 +50096,22 @@ function captureHostFor(fileHost) {
|
|
|
50091
50096
|
return m ? `${m[1]}-my.sharepoint.com` : h;
|
|
50092
50097
|
}
|
|
50093
50098
|
async function captureSharePointTokenViaFetchproxy(hosts, env = process.env) {
|
|
50094
|
-
const
|
|
50095
|
-
const bad =
|
|
50096
|
-
if (
|
|
50099
|
+
const list2 = [...new Set((typeof hosts === "string" ? [hosts] : [...hosts]).map((h) => h.toLowerCase()))];
|
|
50100
|
+
const bad = list2.find((h) => !isSharePointHost(h));
|
|
50101
|
+
if (list2.length === 0 || bad !== void 0) {
|
|
50097
50102
|
throw new Error(
|
|
50098
50103
|
`refusing to capture a SharePoint token for ${JSON.stringify(bad ?? "")}: not a *.sharepoint.com host`
|
|
50099
50104
|
);
|
|
50100
50105
|
}
|
|
50101
|
-
const label =
|
|
50106
|
+
const label = list2.join(" or ");
|
|
50102
50107
|
let refused = false;
|
|
50103
|
-
const scoped = bridgeScopedTransport(env,
|
|
50108
|
+
const scoped = bridgeScopedTransport(env, list2);
|
|
50104
50109
|
let token;
|
|
50105
50110
|
try {
|
|
50106
50111
|
token = await captureBearerHeader({
|
|
50107
50112
|
// Any call the browser makes to one of these hosts. Concrete hosts, never
|
|
50108
50113
|
// a wildcard — see the module note.
|
|
50109
|
-
captures:
|
|
50114
|
+
captures: list2.map(sharePointCaptureDecl),
|
|
50110
50115
|
// The one bridge scope (`bridge-scope.ts`), with these hosts' captures
|
|
50111
50116
|
// added to the remembered ones so the hello asks for exactly what it is
|
|
50112
50117
|
// about to read.
|
|
@@ -50127,7 +50132,7 @@ async function captureSharePointTokenViaFetchproxy(hosts, env = process.env) {
|
|
|
50127
50132
|
cause: err
|
|
50128
50133
|
});
|
|
50129
50134
|
}
|
|
50130
|
-
for (const h of
|
|
50135
|
+
for (const h of list2) rememberSharePointHost(h, env);
|
|
50131
50136
|
return token;
|
|
50132
50137
|
}
|
|
50133
50138
|
function noteScopeRefusal(transport, onRefused) {
|
|
@@ -50200,6 +50205,38 @@ var init_substrate_auth = __esm({
|
|
|
50200
50205
|
}
|
|
50201
50206
|
});
|
|
50202
50207
|
|
|
50208
|
+
// src/recap-auth.ts
|
|
50209
|
+
var recap_auth_exports = {};
|
|
50210
|
+
__export(recap_auth_exports, {
|
|
50211
|
+
RECAP_CAPTURE_DECL: () => RECAP_CAPTURE_DECL,
|
|
50212
|
+
captureRecapTokenViaFetchproxy: () => captureRecapTokenViaFetchproxy
|
|
50213
|
+
});
|
|
50214
|
+
async function captureRecapTokenViaFetchproxy(env = process.env) {
|
|
50215
|
+
return captureBearerHeader({
|
|
50216
|
+
// The one bridge scope every capture of this server declares (`bridge-scope.ts`).
|
|
50217
|
+
captures: [{ ...RECAP_CAPTURE_DECL }],
|
|
50218
|
+
domains: [...BRIDGE_TRUST_DOMAINS],
|
|
50219
|
+
windowMs: captureWindowMs(env),
|
|
50220
|
+
port: getWsPort(),
|
|
50221
|
+
serverName: PACKAGE_NAME,
|
|
50222
|
+
version: VERSION,
|
|
50223
|
+
what: "a Teams meeting-recap token",
|
|
50224
|
+
guidance: "In a signed-in teams.cloud.microsoft tab, open any meeting chat and click its Recap tab \u2014 that is what makes Teams call its meeting-recap service, where the token is read from \u2014 then retry. If the ContextMint Bridge asks to re-pair microsoft-teams-mcp, approve it once: the recap capture is new to its scope.",
|
|
50225
|
+
createTransport: bridgeScopedTransport(env)
|
|
50226
|
+
});
|
|
50227
|
+
}
|
|
50228
|
+
var init_recap_auth = __esm({
|
|
50229
|
+
"src/recap-auth.ts"() {
|
|
50230
|
+
"use strict";
|
|
50231
|
+
init_fetchproxy();
|
|
50232
|
+
init_capture_window();
|
|
50233
|
+
init_auth_fetchproxy();
|
|
50234
|
+
init_bridge_scope();
|
|
50235
|
+
init_version();
|
|
50236
|
+
init_bridge_scope();
|
|
50237
|
+
}
|
|
50238
|
+
});
|
|
50239
|
+
|
|
50203
50240
|
// src/index.ts
|
|
50204
50241
|
init_dist2();
|
|
50205
50242
|
init_version();
|
|
@@ -50209,6 +50246,758 @@ init_dist2();
|
|
|
50209
50246
|
init_session();
|
|
50210
50247
|
init_token_cache();
|
|
50211
50248
|
|
|
50249
|
+
// node_modules/@chrischall/mcp-utils/dist/rich/html.js
|
|
50250
|
+
var NAMED_ENTITIES = {
|
|
50251
|
+
amp: "&",
|
|
50252
|
+
lt: "<",
|
|
50253
|
+
gt: ">",
|
|
50254
|
+
quot: '"',
|
|
50255
|
+
apos: "'",
|
|
50256
|
+
nbsp: " "
|
|
50257
|
+
};
|
|
50258
|
+
function decodeEntities(s) {
|
|
50259
|
+
return s.replace(/&(?:#(\d{1,8})|#x([0-9a-f]{1,8})|([a-z]{1,10}));|&(amp|lt|gt|quot|nbsp)(?![a-z0-9=])/gi, (whole, dec2, hex3, name, legacy) => {
|
|
50260
|
+
if (legacy !== void 0)
|
|
50261
|
+
return NAMED_ENTITIES[legacy.toLowerCase()];
|
|
50262
|
+
if (name !== void 0)
|
|
50263
|
+
return NAMED_ENTITIES[name.toLowerCase()] ?? whole;
|
|
50264
|
+
const code2 = dec2 !== void 0 ? Number(dec2) : parseInt(hex3, 16);
|
|
50265
|
+
if (!Number.isFinite(code2) || code2 > 1114111)
|
|
50266
|
+
return whole;
|
|
50267
|
+
if (code2 < 32 && code2 !== 9 && code2 !== 10)
|
|
50268
|
+
return "";
|
|
50269
|
+
return String.fromCodePoint(code2);
|
|
50270
|
+
});
|
|
50271
|
+
}
|
|
50272
|
+
var HTML_ESCAPES = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
50273
|
+
function escapeHtml(s) {
|
|
50274
|
+
return s.replace(/[&<>"']/g, (c) => HTML_ESCAPES[c]);
|
|
50275
|
+
}
|
|
50276
|
+
function attr(attrs, name) {
|
|
50277
|
+
const m = new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'>]+))`, "i").exec(attrs);
|
|
50278
|
+
return m ? m[1] ?? m[2] ?? m[3] : void 0;
|
|
50279
|
+
}
|
|
50280
|
+
var INVISIBLE = /[\u200b\u200c\u2060\ufeff]/g;
|
|
50281
|
+
var visible = (s) => s.replace(INVISIBLE, "");
|
|
50282
|
+
var MAX_DEPTH = 200;
|
|
50283
|
+
var VOID = /* @__PURE__ */ new Set(["br", "img", "hr", "wbr", "input", "meta", "link", "col", "source", "area", "base", "embed", "param", "track"]);
|
|
50284
|
+
var DROPPED_WITH_CONTENT = "script|style|head|title|template|noscript|iframe|object|svg|math|xml";
|
|
50285
|
+
var BLOCK = /* @__PURE__ */ new Set(["p", "div", "ul", "ol", "pre", "blockquote", "table", "h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
50286
|
+
var TAG = /<(\/?)([a-z][a-z0-9]*)\b((?:[^<>"']|"[^"<]*"|'[^'<]*')*)>/gi;
|
|
50287
|
+
var HIDDEN_STYLE = /(?:^|[;\s])(?:display\s*:\s*none|visibility\s*:\s*hidden|mso-hide\s*:\s*all)\b/i;
|
|
50288
|
+
function isHidden(attrs) {
|
|
50289
|
+
const names = attrs.replace(/"[^"]*"|'[^']*'/g, '""');
|
|
50290
|
+
if (/(?:^|\s)hidden(?:\s|=|\/|$)/i.test(names))
|
|
50291
|
+
return true;
|
|
50292
|
+
const style = attr(attrs, "style");
|
|
50293
|
+
return style !== void 0 && HIDDEN_STYLE.test(decodeEntities(style));
|
|
50294
|
+
}
|
|
50295
|
+
function parseHtml(html, opts = {}) {
|
|
50296
|
+
const root = { tag: "#root", attrs: "", children: [] };
|
|
50297
|
+
const stack = [root];
|
|
50298
|
+
const top = () => stack[stack.length - 1];
|
|
50299
|
+
const src = html.replace(/[\u0001-\u0005]/g, "").replace(/<!--[\s\S]*?(?:-->|$)/g, "").replace(/<!\[CDATA\[[\s\S]*?(?:\]\]>|$)/g, "").replace(/<![^>]*>/g, "").replace(new RegExp(`<(${DROPPED_WITH_CONTENT})\\b[\\s\\S]*?(?:<\\/\\1\\s*>|$)`, "gi"), "");
|
|
50300
|
+
let at = 0;
|
|
50301
|
+
for (const m of src.matchAll(TAG)) {
|
|
50302
|
+
if (m.index > at)
|
|
50303
|
+
top().children.push(src.slice(at, m.index));
|
|
50304
|
+
at = m.index + m[0].length;
|
|
50305
|
+
const tag = m[2].toLowerCase();
|
|
50306
|
+
if (m[1] === "/") {
|
|
50307
|
+
let i = stack.length - 1;
|
|
50308
|
+
while (i > 0 && stack[i].tag !== tag)
|
|
50309
|
+
i--;
|
|
50310
|
+
if (i > 0)
|
|
50311
|
+
stack.length = i;
|
|
50312
|
+
continue;
|
|
50313
|
+
}
|
|
50314
|
+
if (tag === "li" && top().tag === "li" || BLOCK.has(tag) && top().tag === "p")
|
|
50315
|
+
stack.pop();
|
|
50316
|
+
if ((tag === "td" || tag === "th" || tag === "tr") && (top().tag === "td" || top().tag === "th"))
|
|
50317
|
+
stack.pop();
|
|
50318
|
+
if (tag === "tr" && top().tag === "tr")
|
|
50319
|
+
stack.pop();
|
|
50320
|
+
const attrs = m[3];
|
|
50321
|
+
const el = { tag, attrs, children: [] };
|
|
50322
|
+
const hidden = opts.keepHidden !== true && isHidden(attrs);
|
|
50323
|
+
if (!hidden)
|
|
50324
|
+
top().children.push(el);
|
|
50325
|
+
const opens = !VOID.has(tag) && !attrs.trimEnd().endsWith("/");
|
|
50326
|
+
if (opens && (hidden || stack.length <= MAX_DEPTH))
|
|
50327
|
+
stack.push(el);
|
|
50328
|
+
}
|
|
50329
|
+
if (at < src.length)
|
|
50330
|
+
top().children.push(src.slice(at));
|
|
50331
|
+
return root;
|
|
50332
|
+
}
|
|
50333
|
+
function safeHref(attrs) {
|
|
50334
|
+
const raw = attr(attrs, "href");
|
|
50335
|
+
if (raw === void 0)
|
|
50336
|
+
return void 0;
|
|
50337
|
+
const href = decodeEntities(raw).trim();
|
|
50338
|
+
return /^(https?:\/\/|mailto:)/i.test(href) ? href : void 0;
|
|
50339
|
+
}
|
|
50340
|
+
function defaultImageText(el) {
|
|
50341
|
+
const alt = decodeEntities(attr(el.attrs, "alt") ?? "").replace(/\s+/g, " ").trim();
|
|
50342
|
+
return alt === "" ? "" : `[${alt}]`;
|
|
50343
|
+
}
|
|
50344
|
+
var PLAIN_TAGS = /* @__PURE__ */ new Set([
|
|
50345
|
+
"p",
|
|
50346
|
+
"div",
|
|
50347
|
+
"br",
|
|
50348
|
+
"b",
|
|
50349
|
+
"strong",
|
|
50350
|
+
"i",
|
|
50351
|
+
"em",
|
|
50352
|
+
"u",
|
|
50353
|
+
"s",
|
|
50354
|
+
"strike",
|
|
50355
|
+
"del",
|
|
50356
|
+
"ul",
|
|
50357
|
+
"li",
|
|
50358
|
+
"code",
|
|
50359
|
+
"pre",
|
|
50360
|
+
"blockquote",
|
|
50361
|
+
"h1",
|
|
50362
|
+
"h2",
|
|
50363
|
+
"h3",
|
|
50364
|
+
"h4",
|
|
50365
|
+
"h5",
|
|
50366
|
+
"h6",
|
|
50367
|
+
"table",
|
|
50368
|
+
"thead",
|
|
50369
|
+
"tbody",
|
|
50370
|
+
"tr",
|
|
50371
|
+
"td",
|
|
50372
|
+
"th",
|
|
50373
|
+
"hr"
|
|
50374
|
+
]);
|
|
50375
|
+
function serialise(nodes, o, allow) {
|
|
50376
|
+
let out = "";
|
|
50377
|
+
for (const n of nodes) {
|
|
50378
|
+
if (typeof n === "string") {
|
|
50379
|
+
out += n.replace(/\r\n?/g, "\n").replace(/</g, "<").replace(/>/g, ">");
|
|
50380
|
+
continue;
|
|
50381
|
+
}
|
|
50382
|
+
const inner = n.tag === "img" ? "" : serialise(n.children, o, allow);
|
|
50383
|
+
const hooked = o.element?.(n, "html", inner);
|
|
50384
|
+
if (hooked !== void 0)
|
|
50385
|
+
out += hooked;
|
|
50386
|
+
else if (n.tag === "img")
|
|
50387
|
+
out += escapeHtml(defaultImageText(n));
|
|
50388
|
+
else if (allow !== void 0 && !allow.has(n.tag))
|
|
50389
|
+
out += outsideSubset(n, inner, o, allow);
|
|
50390
|
+
else if (n.tag === "br" || n.tag === "hr")
|
|
50391
|
+
out += `<${n.tag}>`;
|
|
50392
|
+
else if (PLAIN_TAGS.has(n.tag))
|
|
50393
|
+
out += `<${n.tag}>${inner}</${n.tag}>`;
|
|
50394
|
+
else if (n.tag === "ol") {
|
|
50395
|
+
const start = attr(n.attrs, "start");
|
|
50396
|
+
out += `<ol${start !== void 0 && /^\d{1,9}$/.test(start) ? ` start="${start}"` : ""}>${inner}</ol>`;
|
|
50397
|
+
} else if (n.tag === "a") {
|
|
50398
|
+
const href = safeHref(n.attrs);
|
|
50399
|
+
out += href !== void 0 ? `<a href="${escapeHtml(href)}">${inner}</a>` : inner;
|
|
50400
|
+
} else
|
|
50401
|
+
out += inner;
|
|
50402
|
+
}
|
|
50403
|
+
return out;
|
|
50404
|
+
}
|
|
50405
|
+
var EQUIVALENT = {
|
|
50406
|
+
b: ["strong"],
|
|
50407
|
+
strong: ["b"],
|
|
50408
|
+
i: ["em"],
|
|
50409
|
+
em: ["i"],
|
|
50410
|
+
s: ["strike", "del"],
|
|
50411
|
+
strike: ["s", "del"],
|
|
50412
|
+
del: ["s", "strike"]
|
|
50413
|
+
};
|
|
50414
|
+
var para = (inner, allow) => allow.has("p") ? `<p>${inner}</p>` : inner;
|
|
50415
|
+
var lineBreak = (allow) => allow.has("br") ? "<br>" : " ";
|
|
50416
|
+
function listLines(el, o, allow) {
|
|
50417
|
+
const ordered = el.tag === "ol";
|
|
50418
|
+
const startAttr = Number(attr(el.attrs, "start"));
|
|
50419
|
+
let n = ordered && Number.isInteger(startAttr) && startAttr >= 0 ? startAttr : 1;
|
|
50420
|
+
let out = "";
|
|
50421
|
+
let lines = [];
|
|
50422
|
+
const flush = () => {
|
|
50423
|
+
if (lines.length > 0)
|
|
50424
|
+
out += para(lines.join(lineBreak(allow)), allow);
|
|
50425
|
+
lines = [];
|
|
50426
|
+
};
|
|
50427
|
+
for (const li of el.children) {
|
|
50428
|
+
if (typeof li === "string" || li.tag !== "li")
|
|
50429
|
+
continue;
|
|
50430
|
+
const marker = ordered ? `${n++}. ` : "- ";
|
|
50431
|
+
const text = [];
|
|
50432
|
+
const nested = [];
|
|
50433
|
+
for (const c of li.children) {
|
|
50434
|
+
if (typeof c !== "string" && (c.tag === "ul" || c.tag === "ol"))
|
|
50435
|
+
nested.push(c);
|
|
50436
|
+
else
|
|
50437
|
+
text.push(c);
|
|
50438
|
+
}
|
|
50439
|
+
lines.push(marker + serialise(text, o, allow).trim());
|
|
50440
|
+
const blocks = nested.map((c) => serialise([c], o, allow)).join("");
|
|
50441
|
+
if (/^<(ul|ol|p)\b/.test(blocks)) {
|
|
50442
|
+
flush();
|
|
50443
|
+
out += blocks;
|
|
50444
|
+
} else if (blocks !== "")
|
|
50445
|
+
lines.push(blocks);
|
|
50446
|
+
}
|
|
50447
|
+
flush();
|
|
50448
|
+
return allow.has("p") ? out : out.replace(/<br>$/, "");
|
|
50449
|
+
}
|
|
50450
|
+
function outsideSubset(n, inner, o, allow) {
|
|
50451
|
+
const same = EQUIVALENT[n.tag]?.find((t) => allow.has(t));
|
|
50452
|
+
if (same !== void 0)
|
|
50453
|
+
return `<${same}>${inner}</${same}>`;
|
|
50454
|
+
switch (n.tag) {
|
|
50455
|
+
case "a": {
|
|
50456
|
+
const href = safeHref(n.attrs);
|
|
50457
|
+
if (href === void 0)
|
|
50458
|
+
return inner;
|
|
50459
|
+
const shown3 = escapeHtml(href);
|
|
50460
|
+
const label = inner.trim();
|
|
50461
|
+
return label === "" || label === shown3 || LOOKS_LIKE_ADDRESS.test(label) ? shown3 : `${inner} (${shown3})`;
|
|
50462
|
+
}
|
|
50463
|
+
case "ol":
|
|
50464
|
+
case "ul":
|
|
50465
|
+
return listLines(n, o, allow);
|
|
50466
|
+
case "li":
|
|
50467
|
+
return inner;
|
|
50468
|
+
case "pre":
|
|
50469
|
+
return para(inner.replace(/^\n+|\n+$/g, "").replace(/\n/g, lineBreak(allow)), allow);
|
|
50470
|
+
case "br":
|
|
50471
|
+
return " ";
|
|
50472
|
+
case "h1":
|
|
50473
|
+
case "h2":
|
|
50474
|
+
case "h3":
|
|
50475
|
+
case "h4":
|
|
50476
|
+
case "h5":
|
|
50477
|
+
case "h6": {
|
|
50478
|
+
const bold = ["b", "strong"].find((t) => allow.has(t));
|
|
50479
|
+
return para(bold === void 0 ? inner : `<${bold}>${inner}</${bold}>`, allow);
|
|
50480
|
+
}
|
|
50481
|
+
default:
|
|
50482
|
+
return inner;
|
|
50483
|
+
}
|
|
50484
|
+
}
|
|
50485
|
+
function sanitiseHtml(html, opts = {}) {
|
|
50486
|
+
const allow = opts.tags === void 0 ? void 0 : new Set([...opts.tags].map((t) => t.toLowerCase()));
|
|
50487
|
+
return serialise(parseHtml(html, opts).children, opts, allow);
|
|
50488
|
+
}
|
|
50489
|
+
var FORMATTING = /<(?!\/?(?:p|div|br)>)[a-z]/i;
|
|
50490
|
+
function walk(nodes, visit2) {
|
|
50491
|
+
for (const n of nodes) {
|
|
50492
|
+
if (typeof n === "string")
|
|
50493
|
+
continue;
|
|
50494
|
+
visit2(n);
|
|
50495
|
+
walk(n.children, visit2);
|
|
50496
|
+
}
|
|
50497
|
+
}
|
|
50498
|
+
function textOf(nodes, o) {
|
|
50499
|
+
return toText(nodes, o).replace(/[\u0001-\u0005]/g, " ").replace(/\s+/g, " ").trim();
|
|
50500
|
+
}
|
|
50501
|
+
function links(root, o) {
|
|
50502
|
+
const out = [];
|
|
50503
|
+
const seen = /* @__PURE__ */ new Set();
|
|
50504
|
+
walk(root.children, (el) => {
|
|
50505
|
+
if (el.tag !== "a")
|
|
50506
|
+
return;
|
|
50507
|
+
const href = safeHref(el.attrs);
|
|
50508
|
+
if (href === void 0)
|
|
50509
|
+
return;
|
|
50510
|
+
const text = textOf(el.children, o);
|
|
50511
|
+
const key = `${href}
|
|
50512
|
+
${text}`;
|
|
50513
|
+
if (seen.has(key))
|
|
50514
|
+
return;
|
|
50515
|
+
seen.add(key);
|
|
50516
|
+
out.push({ href, text });
|
|
50517
|
+
});
|
|
50518
|
+
return out;
|
|
50519
|
+
}
|
|
50520
|
+
function bodyStructure(html, opts = {}) {
|
|
50521
|
+
const root = parseHtml(html, opts);
|
|
50522
|
+
const sanitised = serialise(root.children, opts);
|
|
50523
|
+
return { ...FORMATTING.test(sanitised) ? { contentHtml: sanitised } : {}, links: links(root, { ...opts }) };
|
|
50524
|
+
}
|
|
50525
|
+
var QUOTE_OPEN = "";
|
|
50526
|
+
var QUOTE_CLOSE = "";
|
|
50527
|
+
var PARA = "";
|
|
50528
|
+
var BR = "";
|
|
50529
|
+
var MARKS = /[\u0004\u0005]/g;
|
|
50530
|
+
var paraBlock = (inner) => `
|
|
50531
|
+
${PARA}
|
|
50532
|
+
${inner}
|
|
50533
|
+
${PARA}
|
|
50534
|
+
`;
|
|
50535
|
+
var TEXT_BLOCK = /* @__PURE__ */ new Set(["p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "table", "hr"]);
|
|
50536
|
+
var LOOKS_LIKE_ADDRESS = /^(https?:\/\/|www\.)/i;
|
|
50537
|
+
function linkText(el, label) {
|
|
50538
|
+
const url2 = safeHref(el.attrs);
|
|
50539
|
+
if (url2 === void 0)
|
|
50540
|
+
return label;
|
|
50541
|
+
const shown3 = label.trim();
|
|
50542
|
+
if (shown3 === "" || shown3 === url2 || LOOKS_LIKE_ADDRESS.test(shown3))
|
|
50543
|
+
return url2;
|
|
50544
|
+
return `${label} (${url2})`;
|
|
50545
|
+
}
|
|
50546
|
+
function rowText(tr, o) {
|
|
50547
|
+
const cells = tr.children.filter((n) => typeof n !== "string" && (n.tag === "td" || n.tag === "th"));
|
|
50548
|
+
if (cells.length === 0)
|
|
50549
|
+
return toText(tr.children, o);
|
|
50550
|
+
const raw = cells.map((c) => toText(c.children, o));
|
|
50551
|
+
const filled = raw.filter((t) => t.replace(/[\s\u0001-\u0005]+/g, "") !== "");
|
|
50552
|
+
if (filled.length === 1)
|
|
50553
|
+
return filled[0];
|
|
50554
|
+
const texts = raw.map((t) => t.replace(/[\n\u0001-\u0005]+/g, " ").trim());
|
|
50555
|
+
while (texts.length > 0 && texts[texts.length - 1] === "")
|
|
50556
|
+
texts.pop();
|
|
50557
|
+
return texts.join(" | ");
|
|
50558
|
+
}
|
|
50559
|
+
function toText(nodes, o) {
|
|
50560
|
+
const memo3 = o.textMemo ??= /* @__PURE__ */ new WeakMap();
|
|
50561
|
+
const hit = memo3.get(nodes);
|
|
50562
|
+
if (hit !== void 0)
|
|
50563
|
+
return hit;
|
|
50564
|
+
let out = "";
|
|
50565
|
+
for (const n of nodes) {
|
|
50566
|
+
if (typeof n === "string") {
|
|
50567
|
+
out += visible(decodeEntities(n));
|
|
50568
|
+
continue;
|
|
50569
|
+
}
|
|
50570
|
+
if (n.tag === "br") {
|
|
50571
|
+
out += `
|
|
50572
|
+
${BR}`;
|
|
50573
|
+
continue;
|
|
50574
|
+
}
|
|
50575
|
+
const code2 = n.tag === "code" || n.tag === "pre";
|
|
50576
|
+
const inner = n.tag === "img" ? "" : code2 ? codeText(n.children) : toText(n.children, o);
|
|
50577
|
+
const hooked = o.element?.(n, "text", inner);
|
|
50578
|
+
if (hooked !== void 0)
|
|
50579
|
+
out += hooked;
|
|
50580
|
+
else if (n.tag === "img")
|
|
50581
|
+
out += defaultImageText(n);
|
|
50582
|
+
else if (n.tag === "a")
|
|
50583
|
+
out += linkText(n, inner);
|
|
50584
|
+
else if (n.tag === "tr")
|
|
50585
|
+
out += `
|
|
50586
|
+
${rowText(n, o)}
|
|
50587
|
+
`;
|
|
50588
|
+
else if (n.tag === "blockquote")
|
|
50589
|
+
out += paraBlock(`${QUOTE_OPEN}
|
|
50590
|
+
${inner}
|
|
50591
|
+
${QUOTE_CLOSE}`);
|
|
50592
|
+
else if (n.tag === "ol" || n.tag === "ul") {
|
|
50593
|
+
const start = Number(attr(n.attrs, "start"));
|
|
50594
|
+
let i = n.tag === "ol" && Number.isInteger(start) && start >= 0 ? start : 1;
|
|
50595
|
+
let items = "";
|
|
50596
|
+
for (const c of n.children) {
|
|
50597
|
+
if (typeof c !== "string" && c.tag === "li") {
|
|
50598
|
+
const text = toText(c.children, o).replace(/^[\s\u0004\u0005]+|[\s\u0004\u0005]+$/g, "");
|
|
50599
|
+
items += `
|
|
50600
|
+
${n.tag === "ol" ? `${i++}. ` : "- "}${text}
|
|
50601
|
+
`;
|
|
50602
|
+
} else
|
|
50603
|
+
items += toText([c], o);
|
|
50604
|
+
}
|
|
50605
|
+
out += paraBlock(items);
|
|
50606
|
+
} else if (n.tag === "pre" || TEXT_BLOCK.has(n.tag))
|
|
50607
|
+
out += paraBlock(inner);
|
|
50608
|
+
else if (n.tag === "li")
|
|
50609
|
+
out += `
|
|
50610
|
+
${inner}
|
|
50611
|
+
`;
|
|
50612
|
+
else
|
|
50613
|
+
out += inner;
|
|
50614
|
+
}
|
|
50615
|
+
memo3.set(nodes, out);
|
|
50616
|
+
return out;
|
|
50617
|
+
}
|
|
50618
|
+
function htmlToText(html, opts = {}) {
|
|
50619
|
+
const out = [];
|
|
50620
|
+
const paragraphs = opts.paragraphs === true;
|
|
50621
|
+
let depth = 0;
|
|
50622
|
+
let lastDepth = 0;
|
|
50623
|
+
let pendingBreak = false;
|
|
50624
|
+
for (const raw of toText(parseHtml(html, opts).children, { ...opts }).split(/\r?\n/)) {
|
|
50625
|
+
const line = raw.replace(/[ \t\u00a0]+/g, " ").trim();
|
|
50626
|
+
if (line === QUOTE_OPEN)
|
|
50627
|
+
depth++;
|
|
50628
|
+
else if (line === QUOTE_CLOSE)
|
|
50629
|
+
depth = Math.max(0, depth - 1);
|
|
50630
|
+
else if (line === PARA || line === BR)
|
|
50631
|
+
pendingBreak = paragraphs && out.length > 0;
|
|
50632
|
+
else {
|
|
50633
|
+
const text = line.replace(MARKS, "").trim();
|
|
50634
|
+
if (text === "")
|
|
50635
|
+
continue;
|
|
50636
|
+
if (pendingBreak)
|
|
50637
|
+
out.push("> ".repeat(Math.min(depth, lastDepth)).trimEnd());
|
|
50638
|
+
pendingBreak = false;
|
|
50639
|
+
out.push(`${"> ".repeat(depth)}${text}`);
|
|
50640
|
+
lastDepth = depth;
|
|
50641
|
+
}
|
|
50642
|
+
}
|
|
50643
|
+
return out.join("\n");
|
|
50644
|
+
}
|
|
50645
|
+
var CODE_HOLE = "";
|
|
50646
|
+
var block = (s) => `
|
|
50647
|
+
|
|
50648
|
+
${s}
|
|
50649
|
+
|
|
50650
|
+
`;
|
|
50651
|
+
function wrap(marker, inner) {
|
|
50652
|
+
const m = /^(\s*)([\s\S]*?)(\s*)$/.exec(inner);
|
|
50653
|
+
return m[2] === "" ? inner : `${m[1]}${marker}${m[2]}${marker}${m[3]}`;
|
|
50654
|
+
}
|
|
50655
|
+
function codeText(nodes) {
|
|
50656
|
+
return nodes.map((n) => typeof n === "string" ? decodeEntities(n) : n.tag === "br" ? "\n" : codeText(n.children)).join("");
|
|
50657
|
+
}
|
|
50658
|
+
function inlineCode(text) {
|
|
50659
|
+
const longest = Math.max(0, ...[...text.matchAll(/`+/g)].map((m) => m[0].length));
|
|
50660
|
+
const fence = "`".repeat(longest + 1);
|
|
50661
|
+
const pad2 = text.startsWith("`") || text.endsWith("`") ? " " : "";
|
|
50662
|
+
return `${fence}${pad2}${text}${pad2}${fence}`;
|
|
50663
|
+
}
|
|
50664
|
+
var tidyInner = (s) => s.replace(/\n{3,}/g, "\n\n").trim();
|
|
50665
|
+
function list(el, codes, o) {
|
|
50666
|
+
const ordered = el.tag === "ol";
|
|
50667
|
+
const startAttr = Number(attr(el.attrs, "start"));
|
|
50668
|
+
const start = ordered && Number.isInteger(startAttr) && startAttr >= 0 ? startAttr : 1;
|
|
50669
|
+
const items = el.children.filter((n) => typeof n !== "string" && n.tag === "li");
|
|
50670
|
+
return items.map((li, i) => {
|
|
50671
|
+
const marker = ordered ? `${start + i}. ` : "- ";
|
|
50672
|
+
const lines = md(li.children, codes, o).replace(/\n{2,}/g, "\n").trim().split("\n");
|
|
50673
|
+
return lines.map((l, n) => n === 0 ? marker + l : l === "" ? "" : " ".repeat(marker.length) + l).join("\n");
|
|
50674
|
+
}).join("\n");
|
|
50675
|
+
}
|
|
50676
|
+
function rowsOf(el) {
|
|
50677
|
+
const out = [];
|
|
50678
|
+
for (const n of el.children) {
|
|
50679
|
+
if (typeof n === "string")
|
|
50680
|
+
continue;
|
|
50681
|
+
if (n.tag === "tr")
|
|
50682
|
+
out.push(n);
|
|
50683
|
+
else if (n.tag === "thead" || n.tag === "tbody" || n.tag === "tfoot")
|
|
50684
|
+
out.push(...rowsOf(n));
|
|
50685
|
+
}
|
|
50686
|
+
return out;
|
|
50687
|
+
}
|
|
50688
|
+
function table(el, codes, o) {
|
|
50689
|
+
const cellsOf = (tr) => tr.children.filter((n) => typeof n !== "string" && (n.tag === "td" || n.tag === "th")).map((c) => tidyInner(md(c.children, codes, o)));
|
|
50690
|
+
const raw = rowsOf(el).map(cellsOf).filter((cells) => cells.some((c) => c !== ""));
|
|
50691
|
+
if (raw.length === 0)
|
|
50692
|
+
return "";
|
|
50693
|
+
if (raw.every((cells) => cells.filter((c) => c !== "").length <= 1)) {
|
|
50694
|
+
return raw.map((cells) => cells.find((c) => c !== "") ?? "").join("\n\n");
|
|
50695
|
+
}
|
|
50696
|
+
if (raw.length === 1)
|
|
50697
|
+
return raw[0].filter((c) => c !== "").join(" ");
|
|
50698
|
+
const lines = raw.map((cells) => cells.map((c) => c.replace(/\s*\n\s*/g, " ").replace(/\|/g, "\\|")));
|
|
50699
|
+
const width = Math.max(...lines.map((cells) => cells.length));
|
|
50700
|
+
const row = (cells) => `| ${[...cells, ...Array(width - cells.length).fill("")].join(" | ")} |`;
|
|
50701
|
+
const sep2 = `| ${Array.from({ length: width }, () => "---").join(" | ")} |`;
|
|
50702
|
+
return [row(lines[0]), sep2, ...lines.slice(1).map(row)].join("\n");
|
|
50703
|
+
}
|
|
50704
|
+
function md(nodes, codes, o) {
|
|
50705
|
+
const memo3 = o.mdMemo ??= /* @__PURE__ */ new WeakMap();
|
|
50706
|
+
const hit = memo3.get(nodes);
|
|
50707
|
+
if (hit !== void 0)
|
|
50708
|
+
return hit;
|
|
50709
|
+
let out = "";
|
|
50710
|
+
for (const n of nodes) {
|
|
50711
|
+
if (typeof n === "string") {
|
|
50712
|
+
out += visible(decodeEntities(n)).replace(/[\s\u00a0]+/g, " ");
|
|
50713
|
+
continue;
|
|
50714
|
+
}
|
|
50715
|
+
const inner = () => md(n.children, codes, o);
|
|
50716
|
+
if (o.element !== void 0 && n.tag !== "br") {
|
|
50717
|
+
const hooked = o.element(n, "markdown", n.tag === "img" ? "" : inner());
|
|
50718
|
+
if (hooked !== void 0) {
|
|
50719
|
+
out += hooked;
|
|
50720
|
+
continue;
|
|
50721
|
+
}
|
|
50722
|
+
}
|
|
50723
|
+
switch (n.tag) {
|
|
50724
|
+
case "br":
|
|
50725
|
+
out += "\n";
|
|
50726
|
+
break;
|
|
50727
|
+
case "p":
|
|
50728
|
+
case "div":
|
|
50729
|
+
out += block(inner().trim());
|
|
50730
|
+
break;
|
|
50731
|
+
case "hr":
|
|
50732
|
+
out += block("---");
|
|
50733
|
+
break;
|
|
50734
|
+
case "h1":
|
|
50735
|
+
case "h2":
|
|
50736
|
+
case "h3":
|
|
50737
|
+
case "h4":
|
|
50738
|
+
case "h5":
|
|
50739
|
+
case "h6": {
|
|
50740
|
+
const text = inner().replace(/\s+/g, " ").trim();
|
|
50741
|
+
out += text === "" ? "" : block(`${"#".repeat(Number(n.tag[1]))} ${text}`);
|
|
50742
|
+
break;
|
|
50743
|
+
}
|
|
50744
|
+
case "b":
|
|
50745
|
+
case "strong":
|
|
50746
|
+
out += wrap("**", inner());
|
|
50747
|
+
break;
|
|
50748
|
+
case "i":
|
|
50749
|
+
case "em":
|
|
50750
|
+
out += wrap("_", inner());
|
|
50751
|
+
break;
|
|
50752
|
+
case "s":
|
|
50753
|
+
case "strike":
|
|
50754
|
+
case "del":
|
|
50755
|
+
out += wrap("~~", inner());
|
|
50756
|
+
break;
|
|
50757
|
+
case "code":
|
|
50758
|
+
out += inlineCode(codeText(n.children));
|
|
50759
|
+
break;
|
|
50760
|
+
case "pre": {
|
|
50761
|
+
codes.push("```\n" + codeText(n.children).replace(/\n+$/, "") + "\n```");
|
|
50762
|
+
out += block(`${CODE_HOLE}${codes.length - 1}${CODE_HOLE}`);
|
|
50763
|
+
break;
|
|
50764
|
+
}
|
|
50765
|
+
case "a": {
|
|
50766
|
+
const label = inner().trim().replace(/^\[([^\[\]]*)\]$/, "$1");
|
|
50767
|
+
const href = safeHref(n.attrs);
|
|
50768
|
+
if (href === void 0)
|
|
50769
|
+
out += label;
|
|
50770
|
+
else if (label === "" || label === href || LOOKS_LIKE_ADDRESS.test(label))
|
|
50771
|
+
out += href;
|
|
50772
|
+
else
|
|
50773
|
+
out += `[${label}](${href.replace(/[()\s]/g, (c) => encodeURIComponent(c))})`;
|
|
50774
|
+
break;
|
|
50775
|
+
}
|
|
50776
|
+
case "blockquote":
|
|
50777
|
+
out += block(tidyInner(inner()).split("\n").map((l) => l === "" ? ">" : `> ${l}`).join("\n"));
|
|
50778
|
+
break;
|
|
50779
|
+
case "ul":
|
|
50780
|
+
case "ol":
|
|
50781
|
+
out += block(list(n, codes, o));
|
|
50782
|
+
break;
|
|
50783
|
+
case "table":
|
|
50784
|
+
out += block(table(n, codes, o));
|
|
50785
|
+
break;
|
|
50786
|
+
case "img":
|
|
50787
|
+
out += defaultImageText(n);
|
|
50788
|
+
break;
|
|
50789
|
+
default:
|
|
50790
|
+
out += inner();
|
|
50791
|
+
}
|
|
50792
|
+
}
|
|
50793
|
+
memo3.set(nodes, out);
|
|
50794
|
+
return out;
|
|
50795
|
+
}
|
|
50796
|
+
function htmlToMarkdown(html, opts = {}) {
|
|
50797
|
+
const codes = [];
|
|
50798
|
+
const lines = md(parseHtml(html, opts).children, codes, { ...opts }).split("\n");
|
|
50799
|
+
const tidy = [];
|
|
50800
|
+
for (const raw of lines) {
|
|
50801
|
+
const line = raw.trimEnd();
|
|
50802
|
+
tidy.push(tidy.length === 0 || tidy[tidy.length - 1] === "" ? line.trimStart() : line);
|
|
50803
|
+
}
|
|
50804
|
+
return tidy.join("\n").replace(/\n{3,}/g, "\n\n").trim().replace(new RegExp(`${CODE_HOLE}(\\d+)${CODE_HOLE}`, "g"), (_w, i) => codes[Number(i)]);
|
|
50805
|
+
}
|
|
50806
|
+
|
|
50807
|
+
// node_modules/@chrischall/mcp-utils/dist/rich/markdown.js
|
|
50808
|
+
var HOLE_OPEN = "\uE000";
|
|
50809
|
+
var HOLE_CLOSE = "\uE001";
|
|
50810
|
+
var RESERVED2 = /[-]/g;
|
|
50811
|
+
var SAFE_HREF = /^(https?:\/\/|mailto:)/i;
|
|
50812
|
+
function renderInline(src, o) {
|
|
50813
|
+
const holes = [];
|
|
50814
|
+
const hole = (html) => `${HOLE_OPEN}${holes.push(html) - 1}${HOLE_CLOSE}`;
|
|
50815
|
+
const token = /(`+)([\s\S]*?[^`])\1(?!`)|\[([^\]\n]+)\]\(\s*([^\s()]+(?:\([^\s()]*\)[^\s()]*)*)\s*\)|\\([\\`*_{}[\]()#+\-.!~>|:])/g;
|
|
50816
|
+
let s = src.replace(token, (whole, _ticks, code2, label, href, escaped) => {
|
|
50817
|
+
if (code2 !== void 0)
|
|
50818
|
+
return hole(`<code>${escapeHtml(code2.replace(/^ (.*[^ ].*) $/s, "$1"))}</code>`);
|
|
50819
|
+
if (escaped !== void 0)
|
|
50820
|
+
return hole(escapeHtml(escaped));
|
|
50821
|
+
if (!SAFE_HREF.test(href))
|
|
50822
|
+
return whole;
|
|
50823
|
+
return hole(`<a href="${escapeHtml(href)}">${renderInline(label, o)}</a>`);
|
|
50824
|
+
});
|
|
50825
|
+
if (o.shortcode !== void 0) {
|
|
50826
|
+
const render2 = o.shortcode;
|
|
50827
|
+
s = s.replace(/:([a-z0-9_+-]+):/g, (whole, key) => {
|
|
50828
|
+
const html = render2(key);
|
|
50829
|
+
return html === void 0 ? whole : hole(html);
|
|
50830
|
+
});
|
|
50831
|
+
}
|
|
50832
|
+
s = escapeHtml(s).replace(/\*\*(?=\S)([\s\S]*?\S)\*\*/g, "<strong>$1</strong>").replace(/(^|[^\w])__(?=\S)([\s\S]*?\S)__(?!\w)/g, "$1<strong>$2</strong>").replace(/~~(?=\S)([\s\S]*?\S)~~/g, "<s>$1</s>").replace(/(^|[^\w*])\*(?=[^\s*])([\s\S]*?[^\s*])\*(?![\w*])/g, "$1<em>$2</em>").replace(/(^|[^\w])_(?=[^\s_])([\s\S]*?[^\s_])_(?!\w)/g, "$1<em>$2</em>").replace(/\n/g, "<br>");
|
|
50833
|
+
const fill = new RegExp(`${HOLE_OPEN}(\\d+)${HOLE_CLOSE}`, "g");
|
|
50834
|
+
return s.replace(fill, (_w, n) => holes[Number(n)]);
|
|
50835
|
+
}
|
|
50836
|
+
var LIST_ITEM = /^( *)([-*+]|\d{1,9}[.)])[ \t]+(.*)$/;
|
|
50837
|
+
var HEADING = /^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*#*[ \t]*$/;
|
|
50838
|
+
var QUOTE = /^ {0,3}> ?(.*)$/;
|
|
50839
|
+
function renderList(list2, o) {
|
|
50840
|
+
const tag = list2.ordered ? "ol" : "ul";
|
|
50841
|
+
const start = list2.ordered && list2.start !== 1 ? ` start="${list2.start}"` : "";
|
|
50842
|
+
const items = list2.items.map((i) => `<li>${renderInline(i.lines.join("\n"), o)}${i.children.map((c) => renderList(c, o)).join("")}</li>`);
|
|
50843
|
+
return `<${tag}${start}>${items.join("")}</${tag}>`;
|
|
50844
|
+
}
|
|
50845
|
+
function parseList(lines, from, o) {
|
|
50846
|
+
const roots = [];
|
|
50847
|
+
const stack = [];
|
|
50848
|
+
let i = from;
|
|
50849
|
+
for (; i < lines.length; i++) {
|
|
50850
|
+
const line = lines[i];
|
|
50851
|
+
const m = LIST_ITEM.exec(line);
|
|
50852
|
+
if (m === null) {
|
|
50853
|
+
const last = stack.at(-1)?.items.at(-1);
|
|
50854
|
+
if (line.trim() !== "" && /^\s/.test(line) && last !== void 0) {
|
|
50855
|
+
last.lines.push(line.trim());
|
|
50856
|
+
continue;
|
|
50857
|
+
}
|
|
50858
|
+
break;
|
|
50859
|
+
}
|
|
50860
|
+
const indent = m[1].length;
|
|
50861
|
+
const ordered = /\d/.test(m[2]);
|
|
50862
|
+
while (stack.length > 0 && indent < stack[stack.length - 1].indent)
|
|
50863
|
+
stack.pop();
|
|
50864
|
+
let top = stack.at(-1);
|
|
50865
|
+
if (top !== void 0 && indent >= top.indent + 2 && top.items.length > 0) {
|
|
50866
|
+
const nested = { indent, ordered, start: ordered ? Number.parseInt(m[2], 10) : 1, items: [] };
|
|
50867
|
+
top.items[top.items.length - 1].children.push(nested);
|
|
50868
|
+
stack.push(nested);
|
|
50869
|
+
top = nested;
|
|
50870
|
+
} else if (top === void 0 || top.ordered !== ordered) {
|
|
50871
|
+
const fresh = { indent, ordered, start: ordered ? Number.parseInt(m[2], 10) : 1, items: [] };
|
|
50872
|
+
if (top !== void 0 && stack.length > 1) {
|
|
50873
|
+
stack.pop();
|
|
50874
|
+
stack[stack.length - 1].items.at(-1).children.push(fresh);
|
|
50875
|
+
} else {
|
|
50876
|
+
roots.push(fresh);
|
|
50877
|
+
stack.length = 0;
|
|
50878
|
+
}
|
|
50879
|
+
stack.push(fresh);
|
|
50880
|
+
top = fresh;
|
|
50881
|
+
}
|
|
50882
|
+
top.items.push({ lines: [m[3]], children: [] });
|
|
50883
|
+
}
|
|
50884
|
+
return { html: roots.map((r) => renderList(r, o)).join(""), next: i };
|
|
50885
|
+
}
|
|
50886
|
+
function render(src, o, depth) {
|
|
50887
|
+
const lines = src.split("\n");
|
|
50888
|
+
const out = [];
|
|
50889
|
+
let para2 = [];
|
|
50890
|
+
const flush = () => {
|
|
50891
|
+
if (para2.length > 0)
|
|
50892
|
+
out.push(`<p>${renderInline(para2.join("\n"), o)}</p>`);
|
|
50893
|
+
para2 = [];
|
|
50894
|
+
};
|
|
50895
|
+
for (let i = 0; i < lines.length; ) {
|
|
50896
|
+
const line = lines[i];
|
|
50897
|
+
const fence = /^ {0,3}(`{3,}|~{3,})/.exec(line);
|
|
50898
|
+
if (fence !== null) {
|
|
50899
|
+
flush();
|
|
50900
|
+
const close = new RegExp(`^ {0,3}${fence[1][0] === "`" ? "`" : "~"}{${fence[1].length},}\\s*$`);
|
|
50901
|
+
const code2 = [];
|
|
50902
|
+
for (i++; i < lines.length && !close.test(lines[i]); i++)
|
|
50903
|
+
code2.push(lines[i]);
|
|
50904
|
+
i++;
|
|
50905
|
+
out.push(`<pre><code>${escapeHtml(code2.join("\n"))}</code></pre>`);
|
|
50906
|
+
continue;
|
|
50907
|
+
}
|
|
50908
|
+
if (LIST_ITEM.test(line)) {
|
|
50909
|
+
flush();
|
|
50910
|
+
const { html, next } = parseList(lines, i, o);
|
|
50911
|
+
out.push(html);
|
|
50912
|
+
i = next;
|
|
50913
|
+
continue;
|
|
50914
|
+
}
|
|
50915
|
+
const heading = o.headings === true ? HEADING.exec(line) : null;
|
|
50916
|
+
if (heading !== null) {
|
|
50917
|
+
flush();
|
|
50918
|
+
const level = heading[1].length;
|
|
50919
|
+
out.push(`<h${level}>${renderInline(heading[2], o)}</h${level}>`);
|
|
50920
|
+
i++;
|
|
50921
|
+
continue;
|
|
50922
|
+
}
|
|
50923
|
+
if (o.quotes === true && depth < 20 && QUOTE.test(line)) {
|
|
50924
|
+
flush();
|
|
50925
|
+
const quoted2 = [];
|
|
50926
|
+
for (; i < lines.length; i++) {
|
|
50927
|
+
const q = QUOTE.exec(lines[i]);
|
|
50928
|
+
if (q === null)
|
|
50929
|
+
break;
|
|
50930
|
+
quoted2.push(q[1]);
|
|
50931
|
+
}
|
|
50932
|
+
out.push(`<blockquote>${render(quoted2.join("\n"), o, depth + 1)}</blockquote>`);
|
|
50933
|
+
continue;
|
|
50934
|
+
}
|
|
50935
|
+
if (line.trim() === "")
|
|
50936
|
+
flush();
|
|
50937
|
+
else
|
|
50938
|
+
para2.push(line);
|
|
50939
|
+
i++;
|
|
50940
|
+
}
|
|
50941
|
+
flush();
|
|
50942
|
+
return out.join("");
|
|
50943
|
+
}
|
|
50944
|
+
function renderMarkdown(src, opts = {}) {
|
|
50945
|
+
return render(src.replace(/\r\n?/g, "\n").replace(RESERVED2, ""), opts, 0);
|
|
50946
|
+
}
|
|
50947
|
+
|
|
50948
|
+
// src/rich.ts
|
|
50949
|
+
var MENTION_TYPE = "http://schema.skype.com/Mention";
|
|
50950
|
+
var EMOJI_TYPE = /schema\.skype\.com\/Emoji/i;
|
|
50951
|
+
var TEAMS = {
|
|
50952
|
+
element: (el, output2, inner) => {
|
|
50953
|
+
if (el.tag === "img") {
|
|
50954
|
+
const alt = attr(el.attrs, "alt");
|
|
50955
|
+
const text = EMOJI_TYPE.test(attr(el.attrs, "itemtype") ?? "") && alt ? decodeEntities(alt) : "[image]";
|
|
50956
|
+
return output2 === "html" ? escapeHtml(text) : text;
|
|
50957
|
+
}
|
|
50958
|
+
if (el.tag === "span" && attr(el.attrs, "itemtype") === MENTION_TYPE) {
|
|
50959
|
+
if (output2 === "markdown") return `@${inner.trim()}`;
|
|
50960
|
+
if (output2 === "html") {
|
|
50961
|
+
const id = attr(el.attrs, "itemid");
|
|
50962
|
+
const itemid = id !== void 0 && /^\d+$/.test(id) ? ` itemid="${id}"` : "";
|
|
50963
|
+
return `<span itemtype="${MENTION_TYPE}"${itemid}>${inner}</span>`;
|
|
50964
|
+
}
|
|
50965
|
+
}
|
|
50966
|
+
return void 0;
|
|
50967
|
+
}
|
|
50968
|
+
};
|
|
50969
|
+
function sanitiseHtml2(html) {
|
|
50970
|
+
return sanitiseHtml(html, TEAMS);
|
|
50971
|
+
}
|
|
50972
|
+
function bodyStructure2(html) {
|
|
50973
|
+
return bodyStructure(html, TEAMS);
|
|
50974
|
+
}
|
|
50975
|
+
function htmlToText2(html) {
|
|
50976
|
+
return htmlToText(html, TEAMS);
|
|
50977
|
+
}
|
|
50978
|
+
function htmlToMarkdown2(html) {
|
|
50979
|
+
return htmlToMarkdown(html, TEAMS);
|
|
50980
|
+
}
|
|
50981
|
+
function mentionsOf(raw) {
|
|
50982
|
+
let parsed = raw;
|
|
50983
|
+
if (typeof raw === "string") {
|
|
50984
|
+
try {
|
|
50985
|
+
parsed = JSON.parse(raw);
|
|
50986
|
+
} catch {
|
|
50987
|
+
return [];
|
|
50988
|
+
}
|
|
50989
|
+
}
|
|
50990
|
+
if (!Array.isArray(parsed)) return [];
|
|
50991
|
+
const out = [];
|
|
50992
|
+
for (const e of parsed) {
|
|
50993
|
+
if (e === null || typeof e !== "object") continue;
|
|
50994
|
+
const { mri, displayName } = e;
|
|
50995
|
+
if (typeof mri !== "string" || mri === "") continue;
|
|
50996
|
+
out.push({ mri, displayName: typeof displayName === "string" ? displayName : "" });
|
|
50997
|
+
}
|
|
50998
|
+
return out;
|
|
50999
|
+
}
|
|
51000
|
+
|
|
50212
51001
|
// src/model.ts
|
|
50213
51002
|
var SELF_CHAT = "48:notes";
|
|
50214
51003
|
var SELF_CHAT_TITLE = "Notes (self-chat)";
|
|
@@ -50357,7 +51146,7 @@ function conversationSummary(c, meMri, all = []) {
|
|
|
50357
51146
|
if (teamThread !== void 0) team = teamName(teamThread);
|
|
50358
51147
|
}
|
|
50359
51148
|
const lastActivity = last ? toIso(last.originalarrivaltime) ?? toIso(last.composetime) : void 0;
|
|
50360
|
-
const preview = systemEvent ? SYSTEM_EVENT_PREVIEW : last?.content !== void 0 ?
|
|
51149
|
+
const preview = systemEvent ? SYSTEM_EVENT_PREVIEW : last?.content !== void 0 ? htmlToText2(last.content) : void 0;
|
|
50361
51150
|
const unread = isUnreadCandidate(c, meMri);
|
|
50362
51151
|
const hidden = kind === "channel" && isHiddenChannel(c);
|
|
50363
51152
|
return {
|
|
@@ -50380,70 +51169,6 @@ function conversationSummary(c, meMri, all = []) {
|
|
|
50380
51169
|
function truncate(s, max) {
|
|
50381
51170
|
return s.length <= max ? s : `${s.slice(0, max - 1)}\u2026`;
|
|
50382
51171
|
}
|
|
50383
|
-
var QUOTE_OPEN = "";
|
|
50384
|
-
var QUOTE_CLOSE = "";
|
|
50385
|
-
var NAMED_ENTITIES = {
|
|
50386
|
-
amp: "&",
|
|
50387
|
-
lt: "<",
|
|
50388
|
-
gt: ">",
|
|
50389
|
-
quot: '"',
|
|
50390
|
-
apos: "'",
|
|
50391
|
-
nbsp: " "
|
|
50392
|
-
};
|
|
50393
|
-
function decodeEntities(s) {
|
|
50394
|
-
return s.replace(/&(?:#(\d+)|#x([0-9a-f]+)|([a-z]+));/gi, (whole, dec2, hex3, name) => {
|
|
50395
|
-
if (name !== void 0) return NAMED_ENTITIES[name.toLowerCase()] ?? whole;
|
|
50396
|
-
const code2 = dec2 !== void 0 ? Number(dec2) : parseInt(hex3, 16);
|
|
50397
|
-
if (!Number.isFinite(code2) || code2 > 1114111) return whole;
|
|
50398
|
-
if (code2 < 32 && code2 !== 9 && code2 !== 10) return "";
|
|
50399
|
-
return String.fromCodePoint(code2);
|
|
50400
|
-
});
|
|
50401
|
-
}
|
|
50402
|
-
function attr(tag, name) {
|
|
50403
|
-
const m = new RegExp(`\\s${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`, "i").exec(tag);
|
|
50404
|
-
return m ? m[1] ?? m[2] : void 0;
|
|
50405
|
-
}
|
|
50406
|
-
var stripTags = (s) => s.replace(/<\/?[a-z!][^>]*>/gi, "");
|
|
50407
|
-
function tableRow(row) {
|
|
50408
|
-
const cells = [...row.matchAll(/<t[dh]\b[^>]*>([\s\S]*?)(?:<\/t[dh]\s*>|(?=<t[dh]\b)|$)/gi)].map(
|
|
50409
|
-
([, cell]) => cell.replace(/[\u0001\u0002]/g, "").replace(/<br\s*\/?>|<\/?(p|div|li|h[1-6])\b[^>]*>|\r?\n/gi, " ").trim()
|
|
50410
|
-
);
|
|
50411
|
-
return cells.length > 0 ? cells.join(" | ") : row;
|
|
50412
|
-
}
|
|
50413
|
-
function htmlToText(html) {
|
|
50414
|
-
let s = html.replace(/[\u0001\u0002]/g, "");
|
|
50415
|
-
s = s.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/gi, "");
|
|
50416
|
-
s = s.replace(/<blockquote\b[^>]*>/gi, `
|
|
50417
|
-
${QUOTE_OPEN}
|
|
50418
|
-
`).replace(/<\/blockquote\s*>/gi, `
|
|
50419
|
-
${QUOTE_CLOSE}
|
|
50420
|
-
`);
|
|
50421
|
-
s = s.replace(/<img\b[^>]*>/gi, (tag) => {
|
|
50422
|
-
const alt = attr(tag, "alt");
|
|
50423
|
-
return /schema\.skype\.com\/Emoji/i.test(attr(tag, "itemtype") ?? "") && alt ? alt : "[image]";
|
|
50424
|
-
});
|
|
50425
|
-
s = s.replace(/<a\b([^>]*)>([\s\S]*?)<\/a\s*>/gi, (_whole, attrs, inner) => {
|
|
50426
|
-
const href = attr(` ${attrs}`, "href");
|
|
50427
|
-
const label = stripTags(inner).trim();
|
|
50428
|
-
if (!href) return inner;
|
|
50429
|
-
if (label === "" || label === href) return href;
|
|
50430
|
-
return `${inner} (${href})`;
|
|
50431
|
-
});
|
|
50432
|
-
s = s.replace(/<tr\b[^>]*>([\s\S]*?)<\/tr\s*>/gi, (_whole, row) => `
|
|
50433
|
-
${tableRow(row)}
|
|
50434
|
-
`);
|
|
50435
|
-
s = s.replace(/<br\s*\/?>/gi, "\n").replace(/<\/?(p|div|li|tr|h[1-6])\b[^>]*>/gi, "\n");
|
|
50436
|
-
s = decodeEntities(stripTags(s));
|
|
50437
|
-
const out = [];
|
|
50438
|
-
let depth = 0;
|
|
50439
|
-
for (const raw of s.split(/\r?\n/)) {
|
|
50440
|
-
const line = raw.replace(/[ \t ]+/g, " ").trim();
|
|
50441
|
-
if (line === QUOTE_OPEN) depth++;
|
|
50442
|
-
else if (line === QUOTE_CLOSE) depth = Math.max(0, depth - 1);
|
|
50443
|
-
else if (line !== "") out.push(`${"> ".repeat(depth)}${line}`);
|
|
50444
|
-
}
|
|
50445
|
-
return out.join("\n");
|
|
50446
|
-
}
|
|
50447
51172
|
function fileAttachments(raw) {
|
|
50448
51173
|
let parsed = raw;
|
|
50449
51174
|
if (typeof raw === "string") {
|
|
@@ -50459,11 +51184,11 @@ function fileAttachments(raw) {
|
|
|
50459
51184
|
if (f === null || typeof f !== "object") continue;
|
|
50460
51185
|
const o = f;
|
|
50461
51186
|
const info = o.fileInfo && typeof o.fileInfo === "object" ? o.fileInfo : {};
|
|
50462
|
-
const
|
|
50463
|
-
const name =
|
|
50464
|
-
const type =
|
|
50465
|
-
const openUrl =
|
|
50466
|
-
const url2 =
|
|
51187
|
+
const str4 = (v) => typeof v === "string" && v !== "" ? v : void 0;
|
|
51188
|
+
const name = str4(o.fileName) ?? str4(o.title) ?? "(file)";
|
|
51189
|
+
const type = str4(o.fileType) ?? str4(o.type);
|
|
51190
|
+
const openUrl = str4(o.openUrl) ?? str4(info.shareUrl);
|
|
51191
|
+
const url2 = str4(o.objectUrl) ?? str4(info.fileUrl);
|
|
50467
51192
|
out.push({
|
|
50468
51193
|
name,
|
|
50469
51194
|
...type !== void 0 ? { type } : {},
|
|
@@ -50568,17 +51293,23 @@ function normaliseMessage(m, meMri, opts = {}) {
|
|
|
50568
51293
|
const content = m.content ?? "";
|
|
50569
51294
|
const reactions = reactionsOf(props.emotions, meMri);
|
|
50570
51295
|
const timeLocal = opts.timeZone !== void 0 ? localIsoTime(time3, opts.timeZone) : void 0;
|
|
51296
|
+
const deleted = isDeleted(m);
|
|
51297
|
+
const { contentHtml, links: links2 } = deleted ? { links: [] } : bodyStructure2(content);
|
|
51298
|
+
const mentions = deleted ? [] : mentionsOf(props.mentions);
|
|
50571
51299
|
return {
|
|
50572
51300
|
id: m.id,
|
|
50573
51301
|
time: time3,
|
|
50574
51302
|
...timeLocal !== void 0 ? { time_local: timeLocal } : {},
|
|
50575
51303
|
sender: nonEmpty(m.imdisplayname) ?? mri ?? "unknown",
|
|
50576
51304
|
fromMe: mri !== void 0 && mri === meMri,
|
|
50577
|
-
text:
|
|
51305
|
+
text: htmlToText2(content),
|
|
51306
|
+
...contentHtml !== void 0 ? { content_html: contentHtml } : {},
|
|
51307
|
+
...mentions.length > 0 ? { mentions } : {},
|
|
51308
|
+
...links2.length > 0 ? { links: links2 } : {},
|
|
50578
51309
|
...subject !== void 0 ? { subject } : {},
|
|
50579
51310
|
...root !== void 0 && root !== m.id ? { replyTo: root } : {},
|
|
50580
51311
|
edited: props.edittime !== void 0 && props.edittime !== null && props.edittime !== "",
|
|
50581
|
-
...
|
|
51312
|
+
...deleted ? { deleted: true } : {},
|
|
50582
51313
|
attachments: { files: fileAttachments(props.files), images: imageAttachments(content) },
|
|
50583
51314
|
...reactions.length > 0 ? { reactions } : {}
|
|
50584
51315
|
};
|
|
@@ -50669,8 +51400,8 @@ var TIMING = /^(\d{1,2}:)?\d{2}:\d{2}\.\d{3}\s+-->\s+((?:\d{1,2}:)?\d{2}:\d{2}\.
|
|
|
50669
51400
|
function parseVtt(vtt) {
|
|
50670
51401
|
const blocks = vtt.replace(/^/, "").replace(/\r\n?/g, "\n").split(/\n{2,}/);
|
|
50671
51402
|
const cues = [];
|
|
50672
|
-
for (const
|
|
50673
|
-
const lines =
|
|
51403
|
+
for (const block2 of blocks) {
|
|
51404
|
+
const lines = block2.split("\n").filter((l) => l.trim() !== "");
|
|
50674
51405
|
const at = lines.findIndex((l) => TIMING.test(l.trim()));
|
|
50675
51406
|
if (at < 0) continue;
|
|
50676
51407
|
const timing = lines[at].trim();
|
|
@@ -50761,6 +51492,8 @@ function outcomeUnknown(method, e, hint) {
|
|
|
50761
51492
|
}
|
|
50762
51493
|
var SEND_OUTCOME_HINT = "The message may already have been posted \u2014 check the conversation (teams_list_messages) before retrying; do not resend blindly.";
|
|
50763
51494
|
var REACTION_OUTCOME_HINT = "The reaction change may already have been applied \u2014 check the message (teams_list_messages) before retrying.";
|
|
51495
|
+
var EDIT_OUTCOME_HINT = "The edit may already have been applied \u2014 read the message (teams_list_messages) before retrying.";
|
|
51496
|
+
var DELETE_OUTCOME_HINT = "The message may already have been deleted \u2014 read the conversation (teams_list_messages) before retrying.";
|
|
50764
51497
|
var THREAD_OUTCOME_HINT = "The change to the chat may already have been applied \u2014 check the chat (its name and members) before retrying.";
|
|
50765
51498
|
var CREATE_OUTCOME_HINT = "A chat may already have been created \u2014 check teams_list_conversations before retrying; a blind retry would create a second chat (and a chat cannot be deleted).";
|
|
50766
51499
|
var HORIZON_OUTCOME_HINT = "The read marker may already have moved \u2014 check the conversation (teams_list_messages) before retrying; moving it again to the same message is harmless.";
|
|
@@ -50948,6 +51681,32 @@ var ChatServiceClient = class {
|
|
|
50948
51681
|
const id = /\/messages\/([^/?#]+)\/?(?:[?#].*)?$/.exec(headers.get("location") ?? "")?.[1];
|
|
50949
51682
|
return id !== void 0 ? { id: decodeURIComponent(id) } : {};
|
|
50950
51683
|
}
|
|
51684
|
+
/**
|
|
51685
|
+
* Replace one of the user's own messages: `PUT …/messages/{id}` with the
|
|
51686
|
+
* new body (`teams_edit_message` builds it). An edit is idempotent, but a
|
|
51687
|
+
* request that was sent and got no usable answer is still a
|
|
51688
|
+
* `WriteOutcomeUnknownError`, so the tool reads the message back rather
|
|
51689
|
+
* than report a plain failure for a change that may have landed.
|
|
51690
|
+
*/
|
|
51691
|
+
async editMessage(conversationId, messageId2, body) {
|
|
51692
|
+
this.#requireConfigured();
|
|
51693
|
+
const url2 = `${this.#baseUrl}/users/ME/conversations/${encodeURIComponent(conversationId)}/messages/${encodeURIComponent(messageId2)}`;
|
|
51694
|
+
const { status } = await this.#send(url2, "text", void 0, { method: "PUT", body, hint: EDIT_OUTCOME_HINT });
|
|
51695
|
+
this.#checkWriteStatus("PUT", status, EDIT_OUTCOME_HINT);
|
|
51696
|
+
}
|
|
51697
|
+
/**
|
|
51698
|
+
* Delete one of the user's own messages: `DELETE …/messages/{id}`. Teams
|
|
51699
|
+
* keeps a deleted message in the conversation with `properties.deletetime`
|
|
51700
|
+
* set and no content. Deleting twice leaves it deleted, but a request that
|
|
51701
|
+
* was sent and got no usable answer is still a `WriteOutcomeUnknownError`,
|
|
51702
|
+
* so the tool reads the message back to settle it.
|
|
51703
|
+
*/
|
|
51704
|
+
async deleteMessage(conversationId, messageId2) {
|
|
51705
|
+
this.#requireConfigured();
|
|
51706
|
+
const url2 = `${this.#baseUrl}/users/ME/conversations/${encodeURIComponent(conversationId)}/messages/${encodeURIComponent(messageId2)}`;
|
|
51707
|
+
const { status } = await this.#send(url2, "text", void 0, { method: "DELETE", hint: DELETE_OUTCOME_HINT });
|
|
51708
|
+
this.#checkWriteStatus("DELETE", status, DELETE_OUTCOME_HINT);
|
|
51709
|
+
}
|
|
50951
51710
|
/**
|
|
50952
51711
|
* React to a message: `PUT …/messages/{id}/properties?name=emotions` with
|
|
50953
51712
|
* `{ emotions: { key, value: <epoch ms> } }` (captured live). Only the
|
|
@@ -51858,6 +52617,299 @@ function checkStatus(status, lookup) {
|
|
|
51858
52617
|
});
|
|
51859
52618
|
}
|
|
51860
52619
|
|
|
52620
|
+
// src/recap.ts
|
|
52621
|
+
init_dist2();
|
|
52622
|
+
init_session();
|
|
52623
|
+
|
|
52624
|
+
// src/recap-token-cache.ts
|
|
52625
|
+
init_session();
|
|
52626
|
+
init_dist2();
|
|
52627
|
+
init_token_cache();
|
|
52628
|
+
function recapTokenCachePath(env = process.env) {
|
|
52629
|
+
return resolveStateFile({
|
|
52630
|
+
env,
|
|
52631
|
+
envVar: "TEAMS_RECAP_TOKEN_FILE",
|
|
52632
|
+
subdir: ".microsoft-teams-mcp",
|
|
52633
|
+
fileName: "recap-token.json"
|
|
52634
|
+
});
|
|
52635
|
+
}
|
|
52636
|
+
function createRecapTokenCache(env = process.env) {
|
|
52637
|
+
if (!parseBoolEnv("TEAMS_TOKEN_CACHE", { env, default: true })) return null;
|
|
52638
|
+
if (parseBoolEnv("TEAMS_DISABLE_FETCHPROXY", { env })) return null;
|
|
52639
|
+
const file2 = createFileStatePersistence({
|
|
52640
|
+
filePath: recapTokenCachePath(env),
|
|
52641
|
+
boundTo: "fetchproxy",
|
|
52642
|
+
validate: (raw) => isBearerTokens(raw) ? raw : null
|
|
52643
|
+
});
|
|
52644
|
+
return {
|
|
52645
|
+
load: () => file2.load(),
|
|
52646
|
+
save(tokens) {
|
|
52647
|
+
try {
|
|
52648
|
+
file2.save(tokens);
|
|
52649
|
+
} catch (err) {
|
|
52650
|
+
reportCacheWriteFailure(err);
|
|
52651
|
+
}
|
|
52652
|
+
},
|
|
52653
|
+
clear() {
|
|
52654
|
+
try {
|
|
52655
|
+
file2.clear();
|
|
52656
|
+
} catch (err) {
|
|
52657
|
+
reportCacheWriteFailure(err);
|
|
52658
|
+
}
|
|
52659
|
+
}
|
|
52660
|
+
};
|
|
52661
|
+
}
|
|
52662
|
+
|
|
52663
|
+
// src/recap.ts
|
|
52664
|
+
var DEFAULT_MCPS_REGION = "us";
|
|
52665
|
+
var REQUEST_TIMEOUT_MS4 = 3e4;
|
|
52666
|
+
var MAX_RESPONSE_BYTES2 = 4 * 1024 * 1024;
|
|
52667
|
+
var GUID2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
52668
|
+
var GOID = /^[0-9a-f]{40,256}$/i;
|
|
52669
|
+
var THREAD_ID = /^19:[A-Za-z0-9_-]+@thread\.(?:v2|tacv2|skype)$/;
|
|
52670
|
+
var DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
52671
|
+
var EPOCH_TICKS = 621355968000000000n;
|
|
52672
|
+
async function captureRecapTokenLazily() {
|
|
52673
|
+
const mod = await Promise.resolve().then(() => (init_recap_auth(), recap_auth_exports));
|
|
52674
|
+
return mod.captureRecapTokenViaFetchproxy();
|
|
52675
|
+
}
|
|
52676
|
+
function obj2(v) {
|
|
52677
|
+
return v !== null && typeof v === "object" && !Array.isArray(v) ? v : void 0;
|
|
52678
|
+
}
|
|
52679
|
+
function str2(v) {
|
|
52680
|
+
return typeof v === "string" && v.trim() !== "" ? v.trim() : void 0;
|
|
52681
|
+
}
|
|
52682
|
+
function isoOf2(v) {
|
|
52683
|
+
const s = str2(v);
|
|
52684
|
+
if (s === void 0) return void 0;
|
|
52685
|
+
const ms = Date.parse(s);
|
|
52686
|
+
return Number.isFinite(ms) ? new Date(ms).toISOString() : void 0;
|
|
52687
|
+
}
|
|
52688
|
+
function httpsUrl(v) {
|
|
52689
|
+
const s = str2(v);
|
|
52690
|
+
return s !== void 0 && /^https:\/\//i.test(s) ? s : void 0;
|
|
52691
|
+
}
|
|
52692
|
+
function parseMeetingInfo(thread) {
|
|
52693
|
+
const raw = thread.properties?.meeting;
|
|
52694
|
+
let m;
|
|
52695
|
+
if (typeof raw === "string") {
|
|
52696
|
+
try {
|
|
52697
|
+
m = obj2(JSON.parse(raw));
|
|
52698
|
+
} catch {
|
|
52699
|
+
return void 0;
|
|
52700
|
+
}
|
|
52701
|
+
} else {
|
|
52702
|
+
m = obj2(raw);
|
|
52703
|
+
}
|
|
52704
|
+
const iCalUid = str2(m?.iCalUid);
|
|
52705
|
+
const organizerId = str2(m?.organizerId);
|
|
52706
|
+
const tenantId = str2(m?.tenantId);
|
|
52707
|
+
if (m === void 0 || iCalUid === void 0 || organizerId === void 0 || tenantId === void 0) return void 0;
|
|
52708
|
+
if (!GOID.test(iCalUid) || !GUID2.test(organizerId) || !GUID2.test(tenantId)) return void 0;
|
|
52709
|
+
const subject = str2(m.subject);
|
|
52710
|
+
const seriesStart = isoOf2(m.startTime);
|
|
52711
|
+
const joinUrl = httpsUrl(m.meetingJoinUrl);
|
|
52712
|
+
return {
|
|
52713
|
+
...subject !== void 0 ? { subject } : {},
|
|
52714
|
+
iCalUid,
|
|
52715
|
+
organizerId,
|
|
52716
|
+
tenantId,
|
|
52717
|
+
recurring: m.meetingType === "Recurring",
|
|
52718
|
+
...seriesStart !== void 0 ? { seriesStart } : {},
|
|
52719
|
+
...joinUrl !== void 0 ? { joinUrl } : {}
|
|
52720
|
+
};
|
|
52721
|
+
}
|
|
52722
|
+
function isOccurrenceDate(date5) {
|
|
52723
|
+
const m = DATE.exec(date5);
|
|
52724
|
+
if (!m) return false;
|
|
52725
|
+
const d = new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])));
|
|
52726
|
+
return d.toISOString().slice(0, 10) === date5;
|
|
52727
|
+
}
|
|
52728
|
+
function occurrenceUid(iCalUid, date5) {
|
|
52729
|
+
if (!GOID.test(iCalUid)) throw new Error(`not a meeting id: ${JSON.stringify(iCalUid)}`);
|
|
52730
|
+
if (!isOccurrenceDate(date5)) throw new Error(`not a YYYY-MM-DD date: ${JSON.stringify(date5)}`);
|
|
52731
|
+
const [y, mo, d] = date5.split("-").map(Number);
|
|
52732
|
+
const hex3 = [y >> 8, y & 255, mo, d].map((b) => b.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
52733
|
+
return iCalUid.slice(0, 32) + hex3 + iCalUid.slice(40);
|
|
52734
|
+
}
|
|
52735
|
+
function mcpsBase(env = process.env) {
|
|
52736
|
+
const region = readEnvVar("TEAMS_MCPS_REGION", { env }) ?? DEFAULT_MCPS_REGION;
|
|
52737
|
+
return `https://teams.cloud.microsoft/api/mcps/${encodeURIComponent(region)}`;
|
|
52738
|
+
}
|
|
52739
|
+
function collabObjectUrl(base, meeting, uid, threadId) {
|
|
52740
|
+
if (!GUID2.test(meeting.organizerId) || !GUID2.test(meeting.tenantId)) throw new Error("not a meeting organizer");
|
|
52741
|
+
if (!GOID.test(uid)) throw new Error(`not a meeting id: ${JSON.stringify(uid)}`);
|
|
52742
|
+
if (!THREAD_ID.test(threadId)) throw new Error(`not a meeting thread id: ${JSON.stringify(threadId)}`);
|
|
52743
|
+
return `${base}/collab/readcollabobject/V2/${meeting.organizerId}@${meeting.tenantId}/${uid}/${threadId}`;
|
|
52744
|
+
}
|
|
52745
|
+
function ticksToIso(ticks) {
|
|
52746
|
+
const s = str2(ticks);
|
|
52747
|
+
if (s === void 0 || !/^\d{15,20}$/.test(s)) return void 0;
|
|
52748
|
+
const ms = Number((BigInt(s) - EPOCH_TICKS) / 10000n);
|
|
52749
|
+
return Number.isFinite(ms) && ms > 0 ? new Date(ms).toISOString() : void 0;
|
|
52750
|
+
}
|
|
52751
|
+
function hms(totalSeconds) {
|
|
52752
|
+
const s = Math.floor(totalSeconds);
|
|
52753
|
+
return `${Math.floor(s / 3600)}:${String(Math.floor(s % 3600 / 60)).padStart(2, "0")}:${String(s % 60).padStart(2, "0")}`;
|
|
52754
|
+
}
|
|
52755
|
+
function timespan(v) {
|
|
52756
|
+
const m = /^(\d+):(\d{2}):(\d{2})/.exec(str2(v) ?? "");
|
|
52757
|
+
return m ? hms(Number(m[1]) * 3600 + Number(m[2]) * 60 + Number(m[3])) : void 0;
|
|
52758
|
+
}
|
|
52759
|
+
function parseCollabObject(body) {
|
|
52760
|
+
const list2 = obj2(body)?.resources;
|
|
52761
|
+
if (!Array.isArray(list2)) return [];
|
|
52762
|
+
const byId = /* @__PURE__ */ new Map();
|
|
52763
|
+
for (const raw of list2) {
|
|
52764
|
+
const r = obj2(raw);
|
|
52765
|
+
const id = str2(r?.id);
|
|
52766
|
+
const type = str2(r?.type);
|
|
52767
|
+
if (r === void 0 || id === void 0 || type === void 0 || byId.has(id)) continue;
|
|
52768
|
+
const location = str2(r.location);
|
|
52769
|
+
const added = isoOf2(r.additionDateTime);
|
|
52770
|
+
byId.set(id, {
|
|
52771
|
+
id,
|
|
52772
|
+
type,
|
|
52773
|
+
...location !== void 0 ? { location } : {},
|
|
52774
|
+
metadata: obj2(r.metadata) ?? {},
|
|
52775
|
+
...added !== void 0 ? { added } : {}
|
|
52776
|
+
});
|
|
52777
|
+
}
|
|
52778
|
+
return [...byId.values()];
|
|
52779
|
+
}
|
|
52780
|
+
function compact(o) {
|
|
52781
|
+
return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== void 0));
|
|
52782
|
+
}
|
|
52783
|
+
function summarizeRecap(resources) {
|
|
52784
|
+
const out = {
|
|
52785
|
+
recordings: [],
|
|
52786
|
+
transcripts: [],
|
|
52787
|
+
notes: [],
|
|
52788
|
+
attendance_reports: [],
|
|
52789
|
+
files: [],
|
|
52790
|
+
other: []
|
|
52791
|
+
};
|
|
52792
|
+
for (const r of resources) {
|
|
52793
|
+
const md2 = r.metadata;
|
|
52794
|
+
switch (r.type) {
|
|
52795
|
+
case "Recording": {
|
|
52796
|
+
const started = ticksToIso(md2.startTime);
|
|
52797
|
+
const ended = ticksToIso(md2.endTime);
|
|
52798
|
+
const duration3 = started && ended ? hms((Date.parse(ended) - Date.parse(started)) / 1e3) : void 0;
|
|
52799
|
+
out.recordings.push(compact({ started, ended, duration: duration3, url: httpsUrl(r.location) }));
|
|
52800
|
+
break;
|
|
52801
|
+
}
|
|
52802
|
+
case "TranscriptV2":
|
|
52803
|
+
out.transcripts.push(compact({ started: ticksToIso(md2.startTime), duration: timespan(md2.duration), url: httpsUrl(md2.webUrl) }));
|
|
52804
|
+
break;
|
|
52805
|
+
case "transcript":
|
|
52806
|
+
out.transcripts.push(compact({ started: isoOf2(md2.startTime), state: str2(md2.state) }));
|
|
52807
|
+
break;
|
|
52808
|
+
case "notes":
|
|
52809
|
+
out.notes.push(compact({ url: httpsUrl(r.location), added: r.added }));
|
|
52810
|
+
break;
|
|
52811
|
+
case "AttendanceReport":
|
|
52812
|
+
out.attendance_reports.push(compact({ started: ticksToIso(md2.startTime), url: httpsUrl(md2.webUrl) ?? httpsUrl(r.location) }));
|
|
52813
|
+
break;
|
|
52814
|
+
case "MeetingChat":
|
|
52815
|
+
case "MeetingStage":
|
|
52816
|
+
out.files.push(
|
|
52817
|
+
compact({
|
|
52818
|
+
name: str2(md2.fileTitle),
|
|
52819
|
+
file_type: str2(md2.fileType),
|
|
52820
|
+
app: str2(md2.appTitle),
|
|
52821
|
+
shared_in: r.type === "MeetingChat" ? "chat" : "meeting",
|
|
52822
|
+
url: httpsUrl(md2.shareUrl) ?? httpsUrl(r.location),
|
|
52823
|
+
added: r.added
|
|
52824
|
+
})
|
|
52825
|
+
);
|
|
52826
|
+
break;
|
|
52827
|
+
case "AISummary":
|
|
52828
|
+
out.ai_summary = compact({ exists: true, generated: r.added });
|
|
52829
|
+
break;
|
|
52830
|
+
default:
|
|
52831
|
+
out.other.push(compact({ type: r.type, url: httpsUrl(r.location), added: r.added }));
|
|
52832
|
+
}
|
|
52833
|
+
}
|
|
52834
|
+
return Object.fromEntries(
|
|
52835
|
+
Object.entries(out).filter(([, v]) => v !== void 0 && (!Array.isArray(v) || v.length > 0))
|
|
52836
|
+
);
|
|
52837
|
+
}
|
|
52838
|
+
var RecapClient = class {
|
|
52839
|
+
#fetchImpl;
|
|
52840
|
+
#base;
|
|
52841
|
+
#configError = null;
|
|
52842
|
+
#manager;
|
|
52843
|
+
constructor(opts = {}) {
|
|
52844
|
+
const env = opts.env ?? process.env;
|
|
52845
|
+
this.#fetchImpl = opts.fetchImpl ?? ((input2, init) => fetch(input2, init));
|
|
52846
|
+
this.#base = mcpsBase(env);
|
|
52847
|
+
this.#manager = createCapturedTokenManager({
|
|
52848
|
+
capture: opts.captureToken ?? captureRecapTokenLazily,
|
|
52849
|
+
persistence: createRecapTokenCache(env)
|
|
52850
|
+
});
|
|
52851
|
+
if (parseBoolEnv("TEAMS_DISABLE_FETCHPROXY", { env })) {
|
|
52852
|
+
this.#configError = new McpToolError("Meeting recaps are disabled (no token source).", {
|
|
52853
|
+
kind: "no_credential",
|
|
52854
|
+
hint: "Unset TEAMS_DISABLE_FETCHPROXY so a recap token can be captured from a signed-in Teams tab."
|
|
52855
|
+
});
|
|
52856
|
+
}
|
|
52857
|
+
}
|
|
52858
|
+
isConfigured() {
|
|
52859
|
+
return this.#configError === null;
|
|
52860
|
+
}
|
|
52861
|
+
async readCollabObject(meeting, uid, threadId) {
|
|
52862
|
+
if (this.#configError) throw this.#configError;
|
|
52863
|
+
const url2 = collabObjectUrl(this.#base, meeting, uid, threadId);
|
|
52864
|
+
let text = "";
|
|
52865
|
+
const res = await this.#manager.withAuth(async (token) => {
|
|
52866
|
+
let r;
|
|
52867
|
+
try {
|
|
52868
|
+
r = await fetchBounded(
|
|
52869
|
+
url2,
|
|
52870
|
+
{ method: "GET", headers: { authorization: `Bearer ${token}`, accept: "application/json" }, redirect: "error" },
|
|
52871
|
+
{ read: "text", maxBytes: MAX_RESPONSE_BYTES2, service: "Teams meeting recap", timeoutMs: REQUEST_TIMEOUT_MS4, fetchImpl: this.#fetchImpl }
|
|
52872
|
+
);
|
|
52873
|
+
} catch (e) {
|
|
52874
|
+
throw describeTransportFailure2(e, url2, "Teams meeting recap") ?? e;
|
|
52875
|
+
}
|
|
52876
|
+
text = r.body;
|
|
52877
|
+
return r.res;
|
|
52878
|
+
});
|
|
52879
|
+
checkStatus2(res.status);
|
|
52880
|
+
try {
|
|
52881
|
+
return parseCollabObject(JSON.parse(text));
|
|
52882
|
+
} catch {
|
|
52883
|
+
throw new McpToolError("The Teams meeting-recap service returned a response that is not JSON.", { status: res.status, kind: "http" });
|
|
52884
|
+
}
|
|
52885
|
+
}
|
|
52886
|
+
};
|
|
52887
|
+
function checkStatus2(status) {
|
|
52888
|
+
if (status >= 200 && status < 300) return;
|
|
52889
|
+
if (status === 401) {
|
|
52890
|
+
throw new McpToolError("The Teams meeting-recap service rejected the recap token (401) even after a fresh capture.", {
|
|
52891
|
+
status,
|
|
52892
|
+
kind: "credential_rejected",
|
|
52893
|
+
hint: "Open a meeting chat's Recap tab in a signed-in Teams tab to mint a fresh recap token, then retry."
|
|
52894
|
+
});
|
|
52895
|
+
}
|
|
52896
|
+
if (status === 403) {
|
|
52897
|
+
throw new McpToolError("You are not allowed to read this meeting's recap (403).", { status, kind: "http" });
|
|
52898
|
+
}
|
|
52899
|
+
if (status === 429) {
|
|
52900
|
+
throw new McpToolError("The Teams meeting-recap service is rate-limiting requests (429).", {
|
|
52901
|
+
status,
|
|
52902
|
+
kind: "http",
|
|
52903
|
+
hint: "Wait a minute before retrying."
|
|
52904
|
+
});
|
|
52905
|
+
}
|
|
52906
|
+
throw new McpToolError(`The Teams meeting-recap service returned HTTP ${status}.`, {
|
|
52907
|
+
status,
|
|
52908
|
+
kind: "http",
|
|
52909
|
+
...status >= 500 ? { hint: "A Teams-side failure; retry shortly." } : {}
|
|
52910
|
+
});
|
|
52911
|
+
}
|
|
52912
|
+
|
|
51861
52913
|
// src/tools/chat.ts
|
|
51862
52914
|
init_dist2();
|
|
51863
52915
|
init_zod();
|
|
@@ -52710,16 +53762,6 @@ init_dist2();
|
|
|
52710
53762
|
// src/compose.ts
|
|
52711
53763
|
init_dist2();
|
|
52712
53764
|
import { randomInt } from "node:crypto";
|
|
52713
|
-
var HTML_ESCAPES = {
|
|
52714
|
-
"&": "&",
|
|
52715
|
-
"<": "<",
|
|
52716
|
-
">": ">",
|
|
52717
|
-
'"': """,
|
|
52718
|
-
"'": "'"
|
|
52719
|
-
};
|
|
52720
|
-
function escapeHtml(s) {
|
|
52721
|
-
return s.replace(/[&<>"']/g, (c) => HTML_ESCAPES[c]);
|
|
52722
|
-
}
|
|
52723
53765
|
var NAMED_EMOJI = {
|
|
52724
53766
|
like: { title: "Like", char: "\u{1F44D}" },
|
|
52725
53767
|
heart: { title: "Heart", char: "\u2764\uFE0F" },
|
|
@@ -52734,30 +53776,83 @@ var NAMED_EMOJI = {
|
|
|
52734
53776
|
fire: { title: "Fire", char: "\u{1F525}" },
|
|
52735
53777
|
party: { title: "Party", char: "\u{1F389}" }
|
|
52736
53778
|
};
|
|
53779
|
+
var PLAIN_EMOJI = {
|
|
53780
|
+
rocket: "\u{1F680}",
|
|
53781
|
+
tada: "\u{1F389}",
|
|
53782
|
+
thumbsup: "\u{1F44D}",
|
|
53783
|
+
thumbsdown: "\u{1F44E}",
|
|
53784
|
+
clap: "\u{1F44F}",
|
|
53785
|
+
raised_hands: "\u{1F64C}",
|
|
53786
|
+
pray: "\u{1F64F}",
|
|
53787
|
+
muscle: "\u{1F4AA}",
|
|
53788
|
+
wave: "\u{1F44B}",
|
|
53789
|
+
eyes: "\u{1F440}",
|
|
53790
|
+
thinking: "\u{1F914}",
|
|
53791
|
+
joy: "\u{1F602}",
|
|
53792
|
+
sweat_smile: "\u{1F605}",
|
|
53793
|
+
grin: "\u{1F601}",
|
|
53794
|
+
slightly_smiling_face: "\u{1F642}",
|
|
53795
|
+
upside_down: "\u{1F643}",
|
|
53796
|
+
shrug: "\u{1F937}",
|
|
53797
|
+
facepalm: "\u{1F926}",
|
|
53798
|
+
white_check_mark: "\u2705",
|
|
53799
|
+
heavy_check_mark: "\u2714\uFE0F",
|
|
53800
|
+
x: "\u274C",
|
|
53801
|
+
warning: "\u26A0\uFE0F",
|
|
53802
|
+
bangbang: "\u203C\uFE0F",
|
|
53803
|
+
question: "\u2753",
|
|
53804
|
+
bulb: "\u{1F4A1}",
|
|
53805
|
+
star: "\u2B50",
|
|
53806
|
+
sparkles: "\u2728",
|
|
53807
|
+
zap: "\u26A1",
|
|
53808
|
+
boom: "\u{1F4A5}",
|
|
53809
|
+
"100": "\u{1F4AF}",
|
|
53810
|
+
robot: "\u{1F916}",
|
|
53811
|
+
brain: "\u{1F9E0}",
|
|
53812
|
+
coffee: "\u2615",
|
|
53813
|
+
chart_with_upwards_trend: "\u{1F4C8}",
|
|
53814
|
+
chart_with_downwards_trend: "\u{1F4C9}",
|
|
53815
|
+
memo: "\u{1F4DD}",
|
|
53816
|
+
calendar: "\u{1F4C5}",
|
|
53817
|
+
lock: "\u{1F512}",
|
|
53818
|
+
bug: "\u{1F41B}",
|
|
53819
|
+
wrench: "\u{1F527}",
|
|
53820
|
+
hammer: "\u{1F528}",
|
|
53821
|
+
package: "\u{1F4E6}",
|
|
53822
|
+
ship: "\u{1F6A2}",
|
|
53823
|
+
hourglass: "\u231B",
|
|
53824
|
+
stopwatch: "\u23F1\uFE0F",
|
|
53825
|
+
point_right: "\u{1F449}",
|
|
53826
|
+
point_up: "\u261D\uFE0F",
|
|
53827
|
+
ok_hand: "\u{1F44C}",
|
|
53828
|
+
crossed_fingers: "\u{1F91E}",
|
|
53829
|
+
see_no_evil: "\u{1F648}",
|
|
53830
|
+
skull: "\u{1F480}",
|
|
53831
|
+
partying_face: "\u{1F973}",
|
|
53832
|
+
exploding_head: "\u{1F92F}",
|
|
53833
|
+
mind_blown: "\u{1F92F}"
|
|
53834
|
+
};
|
|
52737
53835
|
var UNICODE_KEY = /^([0-9a-f]{4,6}(?:-[0-9a-f]{4,6})*)_([a-z0-9]+)$/;
|
|
52738
|
-
function
|
|
52739
|
-
let title;
|
|
52740
|
-
let char;
|
|
53836
|
+
function emojiHtml(key) {
|
|
52741
53837
|
const named = NAMED_EMOJI[key];
|
|
52742
53838
|
if (named !== void 0) {
|
|
52743
|
-
|
|
52744
|
-
|
|
52745
|
-
const m = UNICODE_KEY.exec(key);
|
|
52746
|
-
if (m === null) return void 0;
|
|
52747
|
-
const points = m[1].split("-").map((h) => parseInt(h, 16));
|
|
52748
|
-
if (points.some((p) => p > 1114111)) return void 0;
|
|
52749
|
-
char = String.fromCodePoint(...points);
|
|
52750
|
-
title = m[2];
|
|
53839
|
+
const t = escapeHtml(named.title);
|
|
53840
|
+
return `<span contenteditable="false" title="${t}" type="(${key})" class="animated-emoticon-20-${key}" itemscope><img itemscope itemtype="http://schema.skype.com/Emoji" itemid="${key}" src="https://statics.teams.cdn.office.net/evergreen-assets/personal-expressions/v2/assets/emoticons/${key}/default/20_f.png" title="${t}" alt="${escapeHtml(named.char)}" style="width:20px;height:20px;"></span>`;
|
|
52751
53841
|
}
|
|
52752
|
-
const
|
|
52753
|
-
|
|
53842
|
+
const plain = Object.hasOwn(PLAIN_EMOJI, key) ? PLAIN_EMOJI[key] : void 0;
|
|
53843
|
+
if (plain !== void 0) return plain;
|
|
53844
|
+
const m = UNICODE_KEY.exec(key);
|
|
53845
|
+
if (m === null) return void 0;
|
|
53846
|
+
const points = m[1].split("-").map((h) => parseInt(h, 16));
|
|
53847
|
+
if (points.some((p) => p > 1114111)) return void 0;
|
|
53848
|
+
return escapeHtml(String.fromCodePoint(...points));
|
|
52754
53849
|
}
|
|
52755
53850
|
function renderPlain(text) {
|
|
52756
53851
|
let out = "";
|
|
52757
53852
|
let at = 0;
|
|
52758
53853
|
const shortcode = /:([a-z0-9_-]+):/g;
|
|
52759
53854
|
for (let m = shortcode.exec(text); m !== null; m = shortcode.exec(text)) {
|
|
52760
|
-
const span =
|
|
53855
|
+
const span = emojiHtml(m[1]);
|
|
52761
53856
|
if (span === void 0) {
|
|
52762
53857
|
shortcode.lastIndex = m.index + m[0].length - 1;
|
|
52763
53858
|
continue;
|
|
@@ -52783,7 +53878,8 @@ function locate(text, name, taken) {
|
|
|
52783
53878
|
};
|
|
52784
53879
|
return find(`@${name}`, false, false) ?? find(`@${name}`, true, false) ?? find(name, true, true);
|
|
52785
53880
|
}
|
|
52786
|
-
|
|
53881
|
+
var MESSAGE_FORMATS = ["text", "markdown"];
|
|
53882
|
+
function placeMentions(text, mentions) {
|
|
52787
53883
|
const placed = [];
|
|
52788
53884
|
for (const m of mentions) {
|
|
52789
53885
|
const range = locate(
|
|
@@ -52798,15 +53894,39 @@ function renderMessageHtml(text, mentions) {
|
|
|
52798
53894
|
}
|
|
52799
53895
|
placed.push({ start: range[0], end: range[1], mri: m.mri });
|
|
52800
53896
|
}
|
|
52801
|
-
placed.sort((a, b) => a.start - b.start);
|
|
53897
|
+
return placed.sort((a, b) => a.start - b.start);
|
|
53898
|
+
}
|
|
53899
|
+
var mentionSpan = (n, shown3) => `<span itemscope itemtype="http://schema.skype.com/Mention" itemid="${n}">${escapeHtml(shown3)}</span>`;
|
|
53900
|
+
var MENTION_OPEN = "\uE010";
|
|
53901
|
+
var MENTION_CLOSE = "\uE011";
|
|
53902
|
+
var PLACEHOLDER_CHARS = /[\ue010-\ue01f]/g;
|
|
53903
|
+
function renderMessageHtml(text, mentions, format = "text") {
|
|
53904
|
+
const placed = placeMentions(text, mentions);
|
|
53905
|
+
const out = placed.map((p, n) => ({
|
|
53906
|
+
itemid: String(n),
|
|
53907
|
+
mri: p.mri,
|
|
53908
|
+
displayName: text.slice(p.start, p.end).replace(/^@/, "")
|
|
53909
|
+
}));
|
|
53910
|
+
if (format === "markdown") {
|
|
53911
|
+
let src = "";
|
|
53912
|
+
let at2 = 0;
|
|
53913
|
+
const clean = (s) => s.replace(PLACEHOLDER_CHARS, "");
|
|
53914
|
+
placed.forEach((p, n) => {
|
|
53915
|
+
src += clean(text.slice(at2, p.start)) + `${MENTION_OPEN}${n}${MENTION_CLOSE}`;
|
|
53916
|
+
at2 = p.end;
|
|
53917
|
+
});
|
|
53918
|
+
src += clean(text.slice(at2));
|
|
53919
|
+
const html2 = renderMarkdown(src, { shortcode: emojiHtml }).replace(
|
|
53920
|
+
new RegExp(`${MENTION_OPEN}(\\d+)${MENTION_CLOSE}`, "g"),
|
|
53921
|
+
(_w, n) => mentionSpan(Number(n), out[Number(n)].displayName)
|
|
53922
|
+
);
|
|
53923
|
+
return { html: html2, mentions: out };
|
|
53924
|
+
}
|
|
52802
53925
|
let html = "";
|
|
52803
53926
|
let at = 0;
|
|
52804
|
-
const out = [];
|
|
52805
53927
|
placed.forEach((p, n) => {
|
|
52806
|
-
const shown3 = text.slice(p.start, p.end).replace(/^@/, "");
|
|
52807
53928
|
html += renderPlain(text.slice(at, p.start));
|
|
52808
|
-
html +=
|
|
52809
|
-
out.push({ itemid: String(n), mri: p.mri, displayName: shown3 });
|
|
53929
|
+
html += mentionSpan(n, out[n].displayName);
|
|
52810
53930
|
at = p.end;
|
|
52811
53931
|
});
|
|
52812
53932
|
html += renderPlain(text.slice(at));
|
|
@@ -53032,7 +54152,7 @@ function registerMarkReadTools(server, { chatsvc }) {
|
|
|
53032
54152
|
up_to_message: untrustedField({
|
|
53033
54153
|
id: to,
|
|
53034
54154
|
sender: target.imdisplayname?.trim() || senderMri(target.from) || "unknown",
|
|
53035
|
-
preview: clipText(
|
|
54155
|
+
preview: clipText(htmlToText2(target.content ?? ""), PREVIEW_CHARS2)
|
|
53036
54156
|
}),
|
|
53037
54157
|
previous_horizon_message_id: previous
|
|
53038
54158
|
},
|
|
@@ -53279,7 +54399,7 @@ function registerConversationTools(server, { chatsvc }) {
|
|
|
53279
54399
|
"teams_list_messages",
|
|
53280
54400
|
{
|
|
53281
54401
|
title: "Read a Teams chat or channel",
|
|
53282
|
-
description: `Read the messages of any chat or channel the signed-in user is in, by id (from teams_list_conversations / teams_list_channels) or by name, without opening it in Teams. "48:notes" (or the name "notes" / "self") is the user's own notes self-chat. Messages come oldest first, each with id, time (UTC, ISO 8601), sender, fromMe, text (never truncated; table cells separated by " | "), subject, edited/deleted flags and attachments; a channel is returned as threads, each root post with its replies. A root older than the window is fetched and marked outside_window: true (it is context, not counted or cursored); up to ${MAX_ROOT_FETCHES} roots are fetched per call, and any beyond that or that cannot be fetched is { id, missing: true }. unread_only returns just the messages the user has not read; since stops at a time; limit keeps the newest (truncated says when more exist; unread_count_scope "window" says unread_count only covers what limit/since/after_message_id let through). after_message_id returns only messages newer than that id; next_cursor is the newest returned message id (or after_message_id when nothing is new) \u2014 pass it back as after_message_id to read only what arrived since. after_message_id takes message-id cursors only: to read what teams_list_changed_conversations counted, pass that row's after_message_id, never teams_list_changed_conversations' next_cursor (a time token for teams_list_changed_conversations). ` + CURSOR_NO_CACHE_DESCRIPTION + FORMAT_DESCRIPTION + `conversation may also be an array of up to ${MAX_CONVERSATIONS} ids/names: the result is then { conversations: [...], errors, fetched_at }, one single-read result per conversation (the other arguments apply to each); an ambiguous name takes its place among them as the same { ambiguous: true, ... } object a single read returns, and one that cannot be resolved or read is listed in errors (the argument as passed and, once it resolved, its id, title, kind, team and participants) while the rest still come back. ` + FROM_DESCRIPTION + "With from, limit keeps the OLDEST messages, unread_only pages only unread ones, and since, after_message_id and mark_read cannot be used; the result carries from_time, has_more, next_from and next_from_time in place of unread_count and next_cursor. " + MARK_READ_DESCRIPTION + "With mark_read the read marker of each conversation read moves up to the newest message returned (never backwards; outside_window roots do not count) and its result says marked_read; one whose limit or since cut off unread messages older than those returned is not marked (marked_read: { skipped, hint }), while a limit that cut only already-read messages does not stop it; the user confirms first \u2014 a prompt where the client supports one, otherwise the first call returns only a preview and a confirmToken, and the repeat call with it reads and marks. " + CONFIRM_INJECTION_RULE + " Attachments are listed per message (images by ref, files by name) and fetched with teams_get_attachment. A name that matches several conversations is not an error: the result is {ambiguous: true, query, match_count, candidates (up to 10, each with id, title, kind, team, lastActivity and match_reason), hint} and no messages \u2014 read again with one candidate's id. " + TIME_ZONE_DESCRIPTION + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
54402
|
+
description: `Read the messages of any chat or channel the signed-in user is in, by id (from teams_list_conversations / teams_list_channels) or by name, without opening it in Teams. "48:notes" (or the name "notes" / "self") is the user's own notes self-chat. Messages come oldest first, each with id, time (UTC, ISO 8601), sender, fromMe, text (never truncated; table cells separated by " | "; lists numbered or bulleted), subject, edited/deleted flags and attachments; a formatted message also carries content_html (its body as sanitised HTML: bold, lists, links, code, quotes, mentions), mentions ([{mri, displayName}], who was @mentioned) and links ([{href, text}]), each absent when there is none; a channel is returned as threads, each root post with its replies. A root older than the window is fetched and marked outside_window: true (it is context, not counted or cursored); up to ${MAX_ROOT_FETCHES} roots are fetched per call, and any beyond that or that cannot be fetched is { id, missing: true }. unread_only returns just the messages the user has not read; since stops at a time; limit keeps the newest (truncated says when more exist; unread_count_scope "window" says unread_count only covers what limit/since/after_message_id let through). after_message_id returns only messages newer than that id; next_cursor is the newest returned message id (or after_message_id when nothing is new) \u2014 pass it back as after_message_id to read only what arrived since. after_message_id takes message-id cursors only: to read what teams_list_changed_conversations counted, pass that row's after_message_id, never teams_list_changed_conversations' next_cursor (a time token for teams_list_changed_conversations). ` + CURSOR_NO_CACHE_DESCRIPTION + FORMAT_DESCRIPTION + `conversation may also be an array of up to ${MAX_CONVERSATIONS} ids/names: the result is then { conversations: [...], errors, fetched_at }, one single-read result per conversation (the other arguments apply to each); an ambiguous name takes its place among them as the same { ambiguous: true, ... } object a single read returns, and one that cannot be resolved or read is listed in errors (the argument as passed and, once it resolved, its id, title, kind, team and participants) while the rest still come back. ` + FROM_DESCRIPTION + "With from, limit keeps the OLDEST messages, unread_only pages only unread ones, and since, after_message_id and mark_read cannot be used; the result carries from_time, has_more, next_from and next_from_time in place of unread_count and next_cursor. " + MARK_READ_DESCRIPTION + "With mark_read the read marker of each conversation read moves up to the newest message returned (never backwards; outside_window roots do not count) and its result says marked_read; one whose limit or since cut off unread messages older than those returned is not marked (marked_read: { skipped, hint }), while a limit that cut only already-read messages does not stop it; the user confirms first \u2014 a prompt where the client supports one, otherwise the first call returns only a preview and a confirmToken, and the repeat call with it reads and marks. " + CONFIRM_INJECTION_RULE + " Attachments are listed per message (images by ref, files by name) and fetched with teams_get_attachment. A name that matches several conversations is not an error: the result is {ambiguous: true, query, match_count, candidates (up to 10, each with id, title, kind, team, lastActivity and match_reason), hint} and no messages \u2014 read again with one candidate's id. " + TIME_ZONE_DESCRIPTION + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
53283
54403
|
// A write only with mark_read, but a write: it moves the user's read marker (never backwards, so a repeat is a no-op).
|
|
53284
54404
|
annotations: toolAnnotations({ readOnly: false, destructive: false, idempotent: true, openWorld: true }),
|
|
53285
54405
|
_meta: workMeta("lookup", { aliases: ["messages", "chat history", "read the chat", "thread"] }),
|
|
@@ -54032,14 +55152,14 @@ import { basename as basename2, dirname as dirname6, join as join11 } from "node
|
|
|
54032
55152
|
// node_modules/@chrischall/mcp-utils/dist/export/zip.js
|
|
54033
55153
|
import { deflateRawSync } from "node:zlib";
|
|
54034
55154
|
var CRC_TABLE = (() => {
|
|
54035
|
-
const
|
|
55155
|
+
const table2 = new Uint32Array(256);
|
|
54036
55156
|
for (let n = 0; n < 256; n++) {
|
|
54037
55157
|
let c = n;
|
|
54038
55158
|
for (let k = 0; k < 8; k++)
|
|
54039
55159
|
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
54040
|
-
|
|
55160
|
+
table2[n] = c >>> 0;
|
|
54041
55161
|
}
|
|
54042
|
-
return
|
|
55162
|
+
return table2;
|
|
54043
55163
|
})();
|
|
54044
55164
|
function crc32(bytes) {
|
|
54045
55165
|
let crc = 4294967295;
|
|
@@ -54393,15 +55513,15 @@ function openDiskSink(dir, exportId, part) {
|
|
|
54393
55513
|
if (finished)
|
|
54394
55514
|
throw badInput2("This export part is already finished.");
|
|
54395
55515
|
finished = true;
|
|
54396
|
-
const
|
|
55516
|
+
const list2 = [...files.values()];
|
|
54397
55517
|
return {
|
|
54398
55518
|
mode: "disk",
|
|
54399
55519
|
exportId,
|
|
54400
55520
|
part,
|
|
54401
55521
|
location: dir,
|
|
54402
55522
|
dir,
|
|
54403
|
-
bytes:
|
|
54404
|
-
files:
|
|
55523
|
+
bytes: list2.reduce((n, f) => n + f.bytes, 0),
|
|
55524
|
+
files: list2
|
|
54405
55525
|
};
|
|
54406
55526
|
}
|
|
54407
55527
|
};
|
|
@@ -54494,10 +55614,10 @@ function decodeExportCursor(cursor) {
|
|
|
54494
55614
|
}
|
|
54495
55615
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
54496
55616
|
throw bad();
|
|
54497
|
-
const
|
|
54498
|
-
if (
|
|
55617
|
+
const obj3 = parsed;
|
|
55618
|
+
if (obj3.v !== CURSOR_VERSION)
|
|
54499
55619
|
throw bad();
|
|
54500
|
-
return
|
|
55620
|
+
return obj3;
|
|
54501
55621
|
}
|
|
54502
55622
|
function jsonlLine(value) {
|
|
54503
55623
|
const s = JSON.stringify(value);
|
|
@@ -54707,7 +55827,8 @@ function messageMd(m, level) {
|
|
|
54707
55827
|
const flags = [m.edited ? "edited" : void 0, m.deleted ? "deleted" : void 0].filter(Boolean);
|
|
54708
55828
|
const lines = [`${level} ${when(m)} \u2014 ${m.sender}${flags.length > 0 ? ` (${flags.join(", ")})` : ""}`, ""];
|
|
54709
55829
|
if (m.subject !== void 0) lines.push(`**Subject:** ${m.subject}`, "");
|
|
54710
|
-
|
|
55830
|
+
const body = m.content_html !== void 0 ? htmlToMarkdown2(m.content_html) : m.text;
|
|
55831
|
+
lines.push(body === "" ? "_(no text)_" : body, "");
|
|
54711
55832
|
const att = attachmentsLine(m);
|
|
54712
55833
|
if (att !== void 0) lines.push(att, "");
|
|
54713
55834
|
return lines.join("\n");
|
|
@@ -54717,7 +55838,7 @@ function threadName(root) {
|
|
|
54717
55838
|
const first = root.text.split("\n").find((l) => l.trim() !== "")?.trim() ?? "";
|
|
54718
55839
|
return first.length > 80 ? `${first.slice(0, 79)}\u2026` : first || "(no text)";
|
|
54719
55840
|
}
|
|
54720
|
-
function
|
|
55841
|
+
function renderMarkdown2(header, conversation, messages) {
|
|
54721
55842
|
const c = conversation;
|
|
54722
55843
|
const pre = [
|
|
54723
55844
|
`# ${c.title}`,
|
|
@@ -54749,7 +55870,7 @@ function renderMarkdown(header, conversation, messages) {
|
|
|
54749
55870
|
return [...pre, ...body].join("\n").replace(/\n*$/, "\n");
|
|
54750
55871
|
}
|
|
54751
55872
|
function renderConversation(format, header, conversation, messages) {
|
|
54752
|
-
return format === "markdown" ?
|
|
55873
|
+
return format === "markdown" ? renderMarkdown2(header, conversation, messages) : renderJsonl(header, conversation, messages);
|
|
54753
55874
|
}
|
|
54754
55875
|
|
|
54755
55876
|
// src/tools/export-attachments.ts
|
|
@@ -55357,7 +56478,7 @@ async function downloadSharedFile(sharepoint, file2, message, ids, naming, save)
|
|
|
55357
56478
|
});
|
|
55358
56479
|
const uri = file2.openUrl ?? file2.url;
|
|
55359
56480
|
const content = delivered.content.map(
|
|
55360
|
-
(
|
|
56481
|
+
(block2) => block2.type === "resource" ? { ...block2, resource: { ...block2.resource, uri } } : block2
|
|
55361
56482
|
);
|
|
55362
56483
|
return { content: [...content, ...caption.content] };
|
|
55363
56484
|
}
|
|
@@ -55454,13 +56575,13 @@ init_dist2();
|
|
|
55454
56575
|
// src/tools/people.ts
|
|
55455
56576
|
init_dist2();
|
|
55456
56577
|
var MRI = /^\d+:\S+$/;
|
|
55457
|
-
var
|
|
56578
|
+
var GUID3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
55458
56579
|
var RECENT_MESSAGES = 200;
|
|
55459
56580
|
var MAX_CANDIDATES2 = 10;
|
|
55460
56581
|
function personMri(input2) {
|
|
55461
56582
|
const s = input2.trim();
|
|
55462
56583
|
if (MRI.test(s)) return s;
|
|
55463
|
-
if (
|
|
56584
|
+
if (GUID3.test(s)) return `8:orgid:${s.toLowerCase()}`;
|
|
55464
56585
|
return void 0;
|
|
55465
56586
|
}
|
|
55466
56587
|
function normaliseName(name) {
|
|
@@ -55617,6 +56738,9 @@ var TOOL2 = "teams_send_message";
|
|
|
55617
56738
|
var READBACK_MESSAGES = 50;
|
|
55618
56739
|
var MAX_CANDIDATES3 = 10;
|
|
55619
56740
|
var PREVIEW_CHARS3 = 200;
|
|
56741
|
+
var formatParam = external_exports.enum(MESSAGE_FORMATS).optional().describe(
|
|
56742
|
+
'How text is written (default "text"). text: plain text, escaped. markdown: **bold**, *italic*, ~~strike~~, `code`, fenced code blocks, - and 1. lists (nested by indenting), [text](https://\u2026) links; nothing else is markup.'
|
|
56743
|
+
);
|
|
55620
56744
|
var mentionArg = external_exports.object({
|
|
55621
56745
|
name_in_text: external_exports.string().min(1).describe('How the person is named in text \u2014 its first "@name" (else "name") becomes the mention.'),
|
|
55622
56746
|
person: external_exports.string().min(1).describe("Who to mention: an MRI (8:orgid:\u2026), or a display name matched among recent senders in this conversation.")
|
|
@@ -55664,7 +56788,7 @@ async function quoted(chatsvc, conversationId, id) {
|
|
|
55664
56788
|
});
|
|
55665
56789
|
}
|
|
55666
56790
|
const mri = senderMri(m.from) ?? "";
|
|
55667
|
-
return { id: m.id, senderMri: mri, senderName: m.imdisplayname?.trim() || mri, text:
|
|
56791
|
+
return { id: m.id, senderMri: mri, senderName: m.imdisplayname?.trim() || mri, text: htmlToText2(m.content ?? "") };
|
|
55668
56792
|
}
|
|
55669
56793
|
async function threadRoot(chatsvc, channelId, id, me) {
|
|
55670
56794
|
const m = await chatsvc.getMessage(channelId, id);
|
|
@@ -55692,21 +56816,22 @@ function registerSendTools(server, { chatsvc }) {
|
|
|
55692
56816
|
TOOL2,
|
|
55693
56817
|
{
|
|
55694
56818
|
title: "Send a Teams message",
|
|
55695
|
-
description: `Post a message as the signed-in user to any chat or channel, by id (from teams_list_conversations / teams_list_channels) or by name. text is plain text: it is escaped, newlines are kept, and :key: shortcodes
|
|
56819
|
+
description: `Post a message as the signed-in user to any chat or channel, by id (from teams_list_conversations / teams_list_channels) or by name. text is plain text by default: it is escaped, newlines are kept, and :key: shortcodes become emoji: Teams' animated ones for like, heart, laugh, surprised, sad, angry, smile, wink, cool, hearteyes, fire and party; the plain character for common names (:rocket:, :tada:, :thumbsup:, :eyes:, :white_check_mark:, \u2026) and unicode-style keys (:1f680_rocket:). format "markdown" reads text as Markdown instead: **bold**, *italic*, ~~strike~~, \`inline code\`, \`\`\` code blocks \`\`\`, bulleted (- item) and numbered (1. item) lists, [link text](https://\u2026), blank-line paragraphs and line breaks; raw HTML, headings, quotes and images are escaped and shown as written. reply_to in a channel posts into that root post's thread; in a chat it quote-replies that message. quote quote-replies a message in any conversation. mentions @-mention people: name_in_text must appear in text, and person is an MRI or a display name matched among recent senders (ambiguous names are refused with the candidates). conversation "${SELF_CHAT}" (or "notes" / "self") is the user's own notes self-chat \u2014 use it to try this tool without anyone else seeing; other 48: system conversations are refused. Everyone in the conversation sees the post. The result says whether the post was found again by reading the conversation back (verified); status "unknown" means Teams did not confirm it \u2014 check the conversation before retrying. ` + CONFIRM_FLOW_SENTENCE + " The preview shows the conversation and exactly what would be posted. " + CONFIRM_INJECTION_RULE + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
55696
56820
|
annotations: toolAnnotations({ readOnly: false, destructive: true, idempotent: false, openWorld: true }),
|
|
55697
56821
|
_meta: workMeta("send", { aliases: ["message", "send a message", "reply", "tell", "post", "chat"] }),
|
|
55698
56822
|
inputSchema: {
|
|
55699
56823
|
conversation: external_exports.string().min(1).describe(
|
|
55700
56824
|
`The conversation id (or "${SELF_CHAT}" \u2014 also by the name "notes" or "self" \u2014 for the self-chat), or a case-insensitive substring of the chat title, channel name, team name or an untitled chat's participant names.`
|
|
55701
56825
|
),
|
|
55702
|
-
text: external_exports.string().min(1).describe(
|
|
56826
|
+
text: external_exports.string().min(1).describe('The message: plain text (newlines kept, :key: shortcodes become emoji), or Markdown with format "markdown".'),
|
|
56827
|
+
format: formatParam,
|
|
55703
56828
|
reply_to: external_exports.string().min(1).optional().describe("A message id. Channel: the root post to reply under (threaded). Chat: the message to quote-reply."),
|
|
55704
56829
|
quote: external_exports.string().min(1).optional().describe("A message id to quote-reply, in any conversation."),
|
|
55705
56830
|
mentions: external_exports.array(mentionArg).max(20).optional().describe("People to @-mention in text."),
|
|
55706
56831
|
confirmToken: confirmTokenParam
|
|
55707
56832
|
}
|
|
55708
56833
|
},
|
|
55709
|
-
async ({ conversation, text, reply_to, quote, mentions, confirmToken }, ctx) => {
|
|
56834
|
+
async ({ conversation, text, format = "text", reply_to, quote, mentions, confirmToken }, ctx) => {
|
|
55710
56835
|
try {
|
|
55711
56836
|
const [me, meName] = await Promise.all([chatsvc.meMri(), chatsvc.meDisplayName()]);
|
|
55712
56837
|
const target = await resolveTarget(chatsvc, conversation, me);
|
|
@@ -55726,7 +56851,8 @@ function registerSendTools(server, { chatsvc }) {
|
|
|
55726
56851
|
const people = await resolveMentions(chatsvc, target.id, mentions ?? []);
|
|
55727
56852
|
const rendered = renderMessageHtml(
|
|
55728
56853
|
text,
|
|
55729
|
-
people.map((p) => p.target)
|
|
56854
|
+
people.map((p) => p.target),
|
|
56855
|
+
format
|
|
55730
56856
|
);
|
|
55731
56857
|
const content = (q ? quoteHtml(q) : "") + rendered.html;
|
|
55732
56858
|
const properties = {
|
|
@@ -55752,6 +56878,7 @@ function registerSendTools(server, { chatsvc }) {
|
|
|
55752
56878
|
preview: {
|
|
55753
56879
|
conversation: untrustedField(target),
|
|
55754
56880
|
text,
|
|
56881
|
+
format,
|
|
55755
56882
|
...inChannel && reply_to !== void 0 ? { thread_root: reply_to } : {},
|
|
55756
56883
|
...people.length > 0 ? {
|
|
55757
56884
|
mentions: untrustedField(
|
|
@@ -55901,7 +57028,7 @@ function registerReactTools(server, { chatsvc }) {
|
|
|
55901
57028
|
message: untrustedField({
|
|
55902
57029
|
id: m.id,
|
|
55903
57030
|
sender: m.imdisplayname?.trim() || senderMri(m.from) || "unknown",
|
|
55904
|
-
preview: clipText(
|
|
57031
|
+
preview: clipText(htmlToText2(m.content ?? ""), PREVIEW_CHARS4)
|
|
55905
57032
|
}),
|
|
55906
57033
|
reaction: key,
|
|
55907
57034
|
already_reacted: already
|
|
@@ -55963,6 +57090,228 @@ function registerReactTools(server, { chatsvc }) {
|
|
|
55963
57090
|
);
|
|
55964
57091
|
}
|
|
55965
57092
|
|
|
57093
|
+
// src/tools/edit.ts
|
|
57094
|
+
init_zod();
|
|
57095
|
+
init_dist2();
|
|
57096
|
+
|
|
57097
|
+
// src/tools/own-message.ts
|
|
57098
|
+
init_dist2();
|
|
57099
|
+
var PARTICIPLE = { edit: "edited", delete: "deleted" };
|
|
57100
|
+
async function ownMessage(chatsvc, conversationId, id, me, verb) {
|
|
57101
|
+
const m = await chatsvc.getMessage(conversationId, id);
|
|
57102
|
+
if (m === void 0) {
|
|
57103
|
+
throw new McpToolError(`There is no message ${id} in this conversation to ${verb}.`, {
|
|
57104
|
+
hint: "Take message ids from teams_list_messages."
|
|
57105
|
+
});
|
|
57106
|
+
}
|
|
57107
|
+
if (senderMri(m.from)?.toLowerCase() !== me.toLowerCase()) {
|
|
57108
|
+
throw new McpToolError(`Message ${id} was not sent by you: you can ${verb} only your own messages.`, {
|
|
57109
|
+
hint: "Pick one of your own messages (fromMe: true in teams_list_messages)."
|
|
57110
|
+
});
|
|
57111
|
+
}
|
|
57112
|
+
if (!isUserMessage(m)) {
|
|
57113
|
+
throw new McpToolError(`Message ${id} is a system event (${m.messagetype}), not a message anyone wrote.`, {
|
|
57114
|
+
hint: `Only messages you wrote can be ${PARTICIPLE[verb]}.`
|
|
57115
|
+
});
|
|
57116
|
+
}
|
|
57117
|
+
return m;
|
|
57118
|
+
}
|
|
57119
|
+
async function writeAndReadBack(write, readBack, shows, verb, change) {
|
|
57120
|
+
let unconfirmed = false;
|
|
57121
|
+
try {
|
|
57122
|
+
await write();
|
|
57123
|
+
} catch (e) {
|
|
57124
|
+
if (!(e instanceof WriteOutcomeUnknownError)) throw e;
|
|
57125
|
+
unconfirmed = true;
|
|
57126
|
+
}
|
|
57127
|
+
let verified = false;
|
|
57128
|
+
let readBackFailed = false;
|
|
57129
|
+
try {
|
|
57130
|
+
verified = shows(await readBack());
|
|
57131
|
+
} catch {
|
|
57132
|
+
readBackFailed = true;
|
|
57133
|
+
}
|
|
57134
|
+
const check2 = "check the conversation (teams_list_messages)";
|
|
57135
|
+
if (unconfirmed && !verified) {
|
|
57136
|
+
return {
|
|
57137
|
+
status: "unknown",
|
|
57138
|
+
verified,
|
|
57139
|
+
warning: `Teams did not confirm this ${verb}, and reading the message back ${readBackFailed ? "failed" : `did not show ${change}`} \u2014 ${check2} before retrying.`
|
|
57140
|
+
};
|
|
57141
|
+
}
|
|
57142
|
+
const warning = unconfirmed ? `Teams did not confirm this ${verb}, but reading the message back shows ${change}.` : readBackFailed ? `Teams accepted the ${verb}, but reading the message back failed \u2014 ${check2}.` : !verified ? `Teams accepted the ${verb}, but reading the message back did not show ${change} \u2014 ${check2}.` : void 0;
|
|
57143
|
+
return { status: "done", verified, ...warning !== void 0 ? { warning } : {} };
|
|
57144
|
+
}
|
|
57145
|
+
|
|
57146
|
+
// src/tools/edit.ts
|
|
57147
|
+
var TOOL4 = "teams_edit_message";
|
|
57148
|
+
var QUOTE_BLOCK = /^\s*(<blockquote\b[^>]*schema\.skype\.com\/Reply[^>]*>[\s\S]*?<\/blockquote\s*>)/i;
|
|
57149
|
+
function quotePrefix(content) {
|
|
57150
|
+
return QUOTE_BLOCK.exec(content)?.[1] ?? "";
|
|
57151
|
+
}
|
|
57152
|
+
var readsAs = (m, content) => m !== void 0 && htmlToText2(m.content ?? "") === htmlToText2(content);
|
|
57153
|
+
var BLOCK_TAG = /\s*(<\/?(?:p|div|ol|ul|li|pre|blockquote|table|thead|tbody|tr|td|th|h[1-6])>)\s*/g;
|
|
57154
|
+
function sameBody(a, b) {
|
|
57155
|
+
const norm = (h) => sanitiseHtml2(h).replace(BLOCK_TAG, "$1").trim();
|
|
57156
|
+
return norm(a) === norm(b);
|
|
57157
|
+
}
|
|
57158
|
+
function registerEditTools(server, { chatsvc }) {
|
|
57159
|
+
server.registerTool(
|
|
57160
|
+
TOOL4,
|
|
57161
|
+
{
|
|
57162
|
+
title: "Edit a Teams message",
|
|
57163
|
+
description: `Replace the text of one of your own messages in any chat or channel. conversation is an id or name as for teams_list_messages; message_id comes from teams_list_messages and must be a message you sent (someone else's, a deleted one or a system event is refused). text replaces the whole message: plain text by default, or Markdown with format "markdown" (as teams_send_message reads it). mentions @-mention people as in teams_send_message. A quote-reply keeps its quote. Text that renders exactly as the message already does, mentioning the same people, changes nothing (status "unchanged"). Everyone in the conversation sees the message marked edited. The result says whether reading the message back shows the edit (verified); status "unknown" means Teams did not confirm it and the read-back did not show it \u2014 check the message before retrying. conversation "${SELF_CHAT}" (or "notes" / "self") is the user's own notes self-chat \u2014 use it to try this tool. ` + CONFIRM_FLOW_SENTENCE + " The preview shows the conversation, the current text, the new text and exactly what will replace it. " + CONFIRM_INJECTION_RULE + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
57164
|
+
annotations: toolAnnotations({ readOnly: false, destructive: true, idempotent: true, openWorld: true }),
|
|
57165
|
+
_meta: workMeta("change", { aliases: ["edit", "edit message", "fix my message", "correct", "reword", "update message"] }),
|
|
57166
|
+
inputSchema: {
|
|
57167
|
+
conversation: external_exports.string().min(1).describe(
|
|
57168
|
+
`The conversation id (or "${SELF_CHAT}" \u2014 also by the name "notes" or "self" \u2014 for the self-chat), or a case-insensitive substring of the chat title, channel name, team name or an untitled chat's participant names.`
|
|
57169
|
+
),
|
|
57170
|
+
message_id: external_exports.string().min(1).describe("The message to edit \u2014 one you sent \u2014 as teams_list_messages lists it."),
|
|
57171
|
+
text: external_exports.string().min(1).describe('The whole new message: plain text (newlines kept, :key: shortcodes become emoji), or Markdown with format "markdown".'),
|
|
57172
|
+
format: formatParam,
|
|
57173
|
+
mentions: external_exports.array(mentionArg).max(20).optional().describe("People to @-mention in text."),
|
|
57174
|
+
confirmToken: confirmTokenParam
|
|
57175
|
+
}
|
|
57176
|
+
},
|
|
57177
|
+
async ({ conversation, message_id, text, format = "text", mentions, confirmToken }, ctx) => {
|
|
57178
|
+
try {
|
|
57179
|
+
const me = await chatsvc.meMri();
|
|
57180
|
+
const target = await resolveTarget(chatsvc, conversation, me, "edit a message in");
|
|
57181
|
+
const original = await ownMessage(chatsvc, target.id, message_id, me, "edit");
|
|
57182
|
+
if (isDeleted(original)) {
|
|
57183
|
+
throw new McpToolError(`Message ${message_id} has been deleted, so it cannot be edited.`, {
|
|
57184
|
+
hint: "Send a new message instead (teams_send_message)."
|
|
57185
|
+
});
|
|
57186
|
+
}
|
|
57187
|
+
const before = original.content ?? "";
|
|
57188
|
+
const people = await resolveMentions(chatsvc, target.id, mentions ?? []);
|
|
57189
|
+
const rendered = renderMessageHtml(
|
|
57190
|
+
text,
|
|
57191
|
+
people.map((p) => p.target),
|
|
57192
|
+
format
|
|
57193
|
+
);
|
|
57194
|
+
const content = quotePrefix(before) + rendered.html;
|
|
57195
|
+
const mentionedNow = rendered.mentions.map((m) => m.mri.toLowerCase());
|
|
57196
|
+
const mentionedBefore = mentionsOf(original.properties?.mentions).map((m) => m.mri.toLowerCase());
|
|
57197
|
+
if (sameBody(content, before) && mentionedNow.join("\n") === mentionedBefore.join("\n")) {
|
|
57198
|
+
return untrustedResult2({ status: "unchanged", conversation: target, message_id });
|
|
57199
|
+
}
|
|
57200
|
+
const qtdMsgs = original.properties?.qtdMsgs;
|
|
57201
|
+
const body = {
|
|
57202
|
+
content,
|
|
57203
|
+
messagetype: "RichText/Html",
|
|
57204
|
+
contenttype: "text",
|
|
57205
|
+
amsreferences: [],
|
|
57206
|
+
properties: {
|
|
57207
|
+
mentions: rendered.mentions.length > 0 ? mentionsProperty(rendered.mentions) : "[]",
|
|
57208
|
+
...typeof qtdMsgs === "string" && quotePrefix(before) !== "" ? { qtdMsgs } : {}
|
|
57209
|
+
}
|
|
57210
|
+
};
|
|
57211
|
+
const path = `/users/ME/conversations/${encodeURIComponent(target.id)}/messages/${encodeURIComponent(message_id)}`;
|
|
57212
|
+
const gate = await confirmWrite(ctx, {
|
|
57213
|
+
tool: TOOL4,
|
|
57214
|
+
action: "chat.edit_message",
|
|
57215
|
+
message: "Review and confirm this edit before it replaces your Teams message:",
|
|
57216
|
+
// The title is someone else's text: JSON-quoted so it cannot break out of its quotes.
|
|
57217
|
+
summary: `Edit your message ${message_id} in ${target.kind} ${JSON.stringify(target.title)}`,
|
|
57218
|
+
account: me,
|
|
57219
|
+
target: `${target.id}/${message_id}`,
|
|
57220
|
+
request: { method: "PUT", path, body },
|
|
57221
|
+
preview: {
|
|
57222
|
+
conversation: untrustedField(target),
|
|
57223
|
+
message_id,
|
|
57224
|
+
// The user's own text, but a quote-reply's quote is someone else's.
|
|
57225
|
+
current_text: untrustedField(htmlToText2(before)),
|
|
57226
|
+
text,
|
|
57227
|
+
format,
|
|
57228
|
+
...people.length > 0 ? {
|
|
57229
|
+
mentions: untrustedField(
|
|
57230
|
+
people.map((p, i) => ({ name_in_text: mentions[i].name_in_text, person: p.person, mri: p.target.mri }))
|
|
57231
|
+
)
|
|
57232
|
+
} : {}
|
|
57233
|
+
},
|
|
57234
|
+
confirmToken
|
|
57235
|
+
});
|
|
57236
|
+
if (gate) return gate;
|
|
57237
|
+
const { status, ...settled } = await writeAndReadBack(
|
|
57238
|
+
() => chatsvc.editMessage(target.id, message_id, body),
|
|
57239
|
+
() => chatsvc.getMessage(target.id, message_id),
|
|
57240
|
+
(m) => readsAs(m, content),
|
|
57241
|
+
"edit",
|
|
57242
|
+
"the new text"
|
|
57243
|
+
);
|
|
57244
|
+
return untrustedResult2({ status: status === "done" ? "edited" : "unknown", conversation: target, message_id, ...settled });
|
|
57245
|
+
} catch (err) {
|
|
57246
|
+
throw wrapApiError(err, "edit the message");
|
|
57247
|
+
}
|
|
57248
|
+
}
|
|
57249
|
+
);
|
|
57250
|
+
}
|
|
57251
|
+
|
|
57252
|
+
// src/tools/delete.ts
|
|
57253
|
+
init_zod();
|
|
57254
|
+
init_dist2();
|
|
57255
|
+
var TOOL5 = "teams_delete_message";
|
|
57256
|
+
function registerDeleteTools(server, { chatsvc }) {
|
|
57257
|
+
server.registerTool(
|
|
57258
|
+
TOOL5,
|
|
57259
|
+
{
|
|
57260
|
+
title: "Delete a Teams message",
|
|
57261
|
+
description: `Delete one of your own messages in any chat or channel. conversation is an id or name as for teams_list_messages; message_id comes from teams_list_messages and must be a message you sent (someone else's or a system event is refused). One already deleted is reported as status "already_deleted" with nothing asked or sent. Everyone in the conversation sees that the message was deleted, and this MCP cannot bring it back. The result says whether reading the message back shows it deleted (verified); status "unknown" means Teams did not confirm it and the read-back did not show it deleted \u2014 check before retrying. conversation "${SELF_CHAT}" (or "notes" / "self") is the user's own notes self-chat \u2014 use it to try this tool. ` + CONFIRM_FLOW_SENTENCE + " The preview shows the conversation and the message that will be deleted. " + CONFIRM_INJECTION_RULE + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
57262
|
+
annotations: toolAnnotations({ readOnly: false, destructive: true, idempotent: true, openWorld: true }),
|
|
57263
|
+
_meta: workMeta("change", { aliases: ["delete", "delete message", "remove message", "unsend", "take back"] }),
|
|
57264
|
+
inputSchema: {
|
|
57265
|
+
conversation: external_exports.string().min(1).describe(
|
|
57266
|
+
`The conversation id (or "${SELF_CHAT}" \u2014 also by the name "notes" or "self" \u2014 for the self-chat), or a case-insensitive substring of the chat title, channel name, team name or an untitled chat's participant names.`
|
|
57267
|
+
),
|
|
57268
|
+
message_id: external_exports.string().min(1).describe("The message to delete \u2014 one you sent \u2014 as teams_list_messages lists it."),
|
|
57269
|
+
confirmToken: confirmTokenParam
|
|
57270
|
+
}
|
|
57271
|
+
},
|
|
57272
|
+
async ({ conversation, message_id, confirmToken }, ctx) => {
|
|
57273
|
+
try {
|
|
57274
|
+
const me = await chatsvc.meMri();
|
|
57275
|
+
const target = await resolveTarget(chatsvc, conversation, me, "delete a message in");
|
|
57276
|
+
const m = await ownMessage(chatsvc, target.id, message_id, me, "delete");
|
|
57277
|
+
if (isDeleted(m)) {
|
|
57278
|
+
return untrustedResult2({ status: "already_deleted", conversation: target, message_id });
|
|
57279
|
+
}
|
|
57280
|
+
const path = `/users/ME/conversations/${encodeURIComponent(target.id)}/messages/${encodeURIComponent(message_id)}`;
|
|
57281
|
+
const gate = await confirmWrite(ctx, {
|
|
57282
|
+
tool: TOOL5,
|
|
57283
|
+
action: "chat.delete_message",
|
|
57284
|
+
message: "Review and confirm before this Teams message of yours is deleted:",
|
|
57285
|
+
// The title is someone else's text: JSON-quoted so it cannot break out of its quotes.
|
|
57286
|
+
summary: `Delete your message ${message_id} in ${target.kind} ${JSON.stringify(target.title)}`,
|
|
57287
|
+
account: me,
|
|
57288
|
+
target: `${target.id}/${message_id}`,
|
|
57289
|
+
request: { method: "DELETE", path },
|
|
57290
|
+
preview: {
|
|
57291
|
+
conversation: untrustedField(target),
|
|
57292
|
+
message_id,
|
|
57293
|
+
time: normaliseMessage(m, me).time,
|
|
57294
|
+
// The user's own text, but a quote-reply's quote is someone else's.
|
|
57295
|
+
text: untrustedField(htmlToText2(m.content ?? ""))
|
|
57296
|
+
},
|
|
57297
|
+
confirmToken
|
|
57298
|
+
});
|
|
57299
|
+
if (gate) return gate;
|
|
57300
|
+
const { status, ...settled } = await writeAndReadBack(
|
|
57301
|
+
() => chatsvc.deleteMessage(target.id, message_id),
|
|
57302
|
+
() => chatsvc.getMessage(target.id, message_id),
|
|
57303
|
+
(back) => back === void 0 || isDeleted(back),
|
|
57304
|
+
"delete",
|
|
57305
|
+
"it deleted"
|
|
57306
|
+
);
|
|
57307
|
+
return untrustedResult2({ status: status === "done" ? "deleted" : "unknown", conversation: target, message_id, ...settled });
|
|
57308
|
+
} catch (err) {
|
|
57309
|
+
throw wrapApiError(err, "delete the message");
|
|
57310
|
+
}
|
|
57311
|
+
}
|
|
57312
|
+
);
|
|
57313
|
+
}
|
|
57314
|
+
|
|
55966
57315
|
// src/tools/group-chat.ts
|
|
55967
57316
|
init_zod();
|
|
55968
57317
|
init_dist2();
|
|
@@ -56422,13 +57771,13 @@ function activityOf(m) {
|
|
|
56422
57771
|
}
|
|
56423
57772
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
56424
57773
|
}
|
|
56425
|
-
function
|
|
57774
|
+
function str3(v) {
|
|
56426
57775
|
if (typeof v === "string") return v === "" ? void 0 : v;
|
|
56427
57776
|
if (typeof v === "number" && Number.isFinite(v)) return String(v);
|
|
56428
57777
|
return void 0;
|
|
56429
57778
|
}
|
|
56430
57779
|
function isoOrUndefined(v) {
|
|
56431
|
-
const s =
|
|
57780
|
+
const s = str3(v);
|
|
56432
57781
|
if (s === void 0) return void 0;
|
|
56433
57782
|
const ms = /^\d+$/.test(s) ? Number(s) : Date.parse(s);
|
|
56434
57783
|
return Number.isFinite(ms) ? new Date(ms).toISOString() : void 0;
|
|
@@ -56440,25 +57789,25 @@ function activityRow(m) {
|
|
|
56440
57789
|
if (m.properties?.deletetime) return void 0;
|
|
56441
57790
|
const a = activityOf(m);
|
|
56442
57791
|
if (a === void 0) return void 0;
|
|
56443
|
-
const type =
|
|
56444
|
-
const replyChain =
|
|
57792
|
+
const type = str3(a.activityType) ?? "";
|
|
57793
|
+
const replyChain = str3(a.sourceReplyChainId);
|
|
56445
57794
|
const isread = m.properties?.isread;
|
|
56446
57795
|
return {
|
|
56447
57796
|
id: m.id,
|
|
56448
57797
|
time: isoOrUndefined(a.activityTimestamp) ?? isoOrUndefined(m.originalarrivaltime),
|
|
56449
57798
|
kind: activityKind(type),
|
|
56450
57799
|
type,
|
|
56451
|
-
subtype:
|
|
57800
|
+
subtype: str3(a.activitySubtype) ?? "",
|
|
56452
57801
|
read: isread === true || isread === "true",
|
|
56453
|
-
from:
|
|
57802
|
+
from: str3(a.sourceUserImDisplayName),
|
|
56454
57803
|
where: {
|
|
56455
|
-
conversation_id:
|
|
56456
|
-
title:
|
|
56457
|
-
type:
|
|
57804
|
+
conversation_id: str3(a.sourceThreadId),
|
|
57805
|
+
title: str3(a.sourceThreadTopic),
|
|
57806
|
+
type: str3(a.sourceThreadType)
|
|
56458
57807
|
},
|
|
56459
|
-
message_id:
|
|
57808
|
+
message_id: str3(a.sourceMessageId),
|
|
56460
57809
|
...replyChain !== void 0 ? { reply_chain_id: replyChain } : {},
|
|
56461
|
-
preview: clip(
|
|
57810
|
+
preview: clip(htmlToText2(str3(a.messagePreview) ?? ""))
|
|
56462
57811
|
};
|
|
56463
57812
|
}
|
|
56464
57813
|
async function nameRows(name, rows) {
|
|
@@ -57034,12 +58383,115 @@ function recordingObjectOf(messages, id) {
|
|
|
57034
58383
|
return m === void 0 ? void 0 : parseRecording(m)?.object_id;
|
|
57035
58384
|
}
|
|
57036
58385
|
|
|
58386
|
+
// src/tools/recap.ts
|
|
58387
|
+
init_zod();
|
|
58388
|
+
init_dist2();
|
|
58389
|
+
var MAX_SCAN2 = 1e3;
|
|
58390
|
+
var MAX_PROBE = 5;
|
|
58391
|
+
var MAX_OTHERS2 = 20;
|
|
58392
|
+
var CALL_TYPES = /* @__PURE__ */ new Set(["Event/Call", "RichText/Media_CallRecording", "RichText/Media_CallTranscript"]);
|
|
58393
|
+
function callDays(messages) {
|
|
58394
|
+
const days = /* @__PURE__ */ new Map();
|
|
58395
|
+
for (const m of messages) {
|
|
58396
|
+
if (!CALL_TYPES.has(m.messagetype ?? "")) continue;
|
|
58397
|
+
const ms = Date.parse(m.composetime ?? m.originalarrivaltime ?? "") || Number(m.id);
|
|
58398
|
+
if (!Number.isFinite(ms) || ms <= 0) continue;
|
|
58399
|
+
const day = new Date(ms).toISOString().slice(0, 10);
|
|
58400
|
+
days.set(day, Math.max(days.get(day) ?? 0, ms));
|
|
58401
|
+
}
|
|
58402
|
+
return [...days.entries()].sort((a, b) => b[1] - a[1]).map(([d]) => d);
|
|
58403
|
+
}
|
|
58404
|
+
var isEmpty = (r) => Object.keys(r).length === 0;
|
|
58405
|
+
function hintFor(recap, occurrence, recurring, searched) {
|
|
58406
|
+
const parts = [];
|
|
58407
|
+
if (isEmpty(recap)) {
|
|
58408
|
+
parts.push(
|
|
58409
|
+
recurring && occurrence === void 0 && !searched ? "No call was found in this chat to pick an occurrence from: pass date (YYYY-MM-DD) for the occurrence you want." : `Nothing was recorded or shared for ${occurrence !== void 0 ? `the ${occurrence} occurrence` : "this meeting"}: no recording, transcript, notes or files.`
|
|
58410
|
+
);
|
|
58411
|
+
}
|
|
58412
|
+
if (recap.transcripts !== void 0) parts.push("teams_get_transcript reads a recording's transcript text from this same chat.");
|
|
58413
|
+
if (recap.ai_summary !== void 0) {
|
|
58414
|
+
parts.push("Teams made AI notes (Intelligent Recap) for this meeting; they are shown only in Teams, to licensed users, and are not read here.");
|
|
58415
|
+
}
|
|
58416
|
+
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
58417
|
+
}
|
|
58418
|
+
function registerRecapTools(server, { chatsvc, recap }) {
|
|
58419
|
+
server.registerTool(
|
|
58420
|
+
"teams_get_meeting_recap",
|
|
58421
|
+
{
|
|
58422
|
+
title: "Get a Teams meeting recap",
|
|
58423
|
+
description: `Get what a Teams meeting's Recap tab shows, from its meeting chat (by id or by name, as teams_list_conversations lists it): recordings (start, end, duration, play link), transcripts, the meeting notes (Loop) link, attendance reports, files shared in the meeting chat or on stage (e.g. a whiteboard), and whether Teams made AI notes (their text is not read). A recurring meeting has one recap per occurrence: pass date (YYYY-MM-DD) for one, else the newest day the chat shows a call on that has a recap is returned (up to ${MAX_PROBE} tried), with series (what belongs to the whole series) and other_occurrences (other call days, newest first). For the transcript text use teams_get_transcript. Uses its own token, captured when a Recap tab is opened in Teams. Does not mark anything read.` + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
58424
|
+
_meta: workMeta("lookup", {
|
|
58425
|
+
aliases: ["recap", "meeting recap", "meeting notes", "attendance report", "attendance", "recording link", "intelligent recap", "ai notes"]
|
|
58426
|
+
}),
|
|
58427
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
58428
|
+
inputSchema: {
|
|
58429
|
+
conversation: external_exports.string().min(1).describe("The meeting chat's id, or a case-insensitive substring of its title."),
|
|
58430
|
+
date: external_exports.string().refine(isOccurrenceDate, "date must be a real day, YYYY-MM-DD").optional().describe("For a recurring meeting: the occurrence, YYYY-MM-DD (the UTC day it met). Default: the newest with a recap.")
|
|
58431
|
+
}
|
|
58432
|
+
},
|
|
58433
|
+
async ({ conversation, date: date5 }) => {
|
|
58434
|
+
try {
|
|
58435
|
+
const [raw, me] = await Promise.all([chatsvc.listConversations(), chatsvc.meMri()]);
|
|
58436
|
+
const summary = await resolveListed(chatsvc, raw, me, conversation, "read the recap of");
|
|
58437
|
+
const meeting = parseMeetingInfo(await chatsvc.getThread(summary.id));
|
|
58438
|
+
if (meeting === void 0) {
|
|
58439
|
+
throw new McpToolError(`"${summary.title}" is not a meeting chat: it has no scheduled meeting to recap.`, {
|
|
58440
|
+
hint: `Pass a meeting's own chat (teams_list_conversations lists them with type "meeting").`
|
|
58441
|
+
});
|
|
58442
|
+
}
|
|
58443
|
+
const read = async (uid) => summarizeRecap(await recap.readCollabObject(meeting, uid, summary.id));
|
|
58444
|
+
const base = {
|
|
58445
|
+
conversation: summary.id,
|
|
58446
|
+
title: summary.title,
|
|
58447
|
+
meeting: {
|
|
58448
|
+
...meeting.subject !== void 0 ? { subject: meeting.subject } : {},
|
|
58449
|
+
recurring: meeting.recurring,
|
|
58450
|
+
...meeting.joinUrl !== void 0 ? { join_url: meeting.joinUrl } : {}
|
|
58451
|
+
}
|
|
58452
|
+
};
|
|
58453
|
+
if (!meeting.recurring) {
|
|
58454
|
+
const r2 = await read(meeting.iCalUid);
|
|
58455
|
+
const hint2 = hintFor(r2, void 0, false, true);
|
|
58456
|
+
return untrustedResult2({ ...base, recap: r2, ...hint2 !== void 0 ? { hint: hint2 } : {} });
|
|
58457
|
+
}
|
|
58458
|
+
const days = date5 !== void 0 ? [date5] : callDays(await chatsvc.getMessages(summary.id, { max: MAX_SCAN2 }));
|
|
58459
|
+
const series = await read(meeting.iCalUid);
|
|
58460
|
+
let chosen;
|
|
58461
|
+
for (const day of days.slice(0, MAX_PROBE)) {
|
|
58462
|
+
const r2 = await read(occurrenceUid(meeting.iCalUid, day));
|
|
58463
|
+
chosen ??= { day, recap: r2 };
|
|
58464
|
+
if (!isEmpty(r2)) {
|
|
58465
|
+
chosen = { day, recap: r2 };
|
|
58466
|
+
break;
|
|
58467
|
+
}
|
|
58468
|
+
}
|
|
58469
|
+
const r = chosen?.recap ?? {};
|
|
58470
|
+
const others = days.filter((d) => d !== chosen?.day).slice(0, MAX_OTHERS2);
|
|
58471
|
+
const hint = hintFor(r, chosen?.day, true, days.length > 0);
|
|
58472
|
+
return untrustedResult2({
|
|
58473
|
+
...base,
|
|
58474
|
+
...chosen !== void 0 ? { occurrence: chosen.day } : {},
|
|
58475
|
+
recap: r,
|
|
58476
|
+
...!isEmpty(series) ? { series } : {},
|
|
58477
|
+
...others.length > 0 ? { other_occurrences: others } : {},
|
|
58478
|
+
...hint !== void 0 ? { hint } : {}
|
|
58479
|
+
});
|
|
58480
|
+
} catch (err) {
|
|
58481
|
+
if (err instanceof AmbiguousConversationError) return untrustedResult2(ambiguousResult(err));
|
|
58482
|
+
throw wrapApiError(err, "get the meeting recap");
|
|
58483
|
+
}
|
|
58484
|
+
}
|
|
58485
|
+
);
|
|
58486
|
+
}
|
|
58487
|
+
|
|
57037
58488
|
// src/index.ts
|
|
57038
58489
|
loadDotenvSafely();
|
|
57039
58490
|
var deps = {
|
|
57040
58491
|
chatsvc: new ChatServiceClient(),
|
|
57041
58492
|
sharepoint: new SharePointClient(),
|
|
57042
|
-
substrate: new SubstrateClient()
|
|
58493
|
+
substrate: new SubstrateClient(),
|
|
58494
|
+
recap: new RecapClient()
|
|
57043
58495
|
};
|
|
57044
58496
|
await runMcp({
|
|
57045
58497
|
name: "microsoft-teams-mcp",
|
|
@@ -57054,6 +58506,8 @@ await runMcp({
|
|
|
57054
58506
|
registerChangesTools,
|
|
57055
58507
|
registerAttachmentTools,
|
|
57056
58508
|
registerSendTools,
|
|
58509
|
+
registerEditTools,
|
|
58510
|
+
registerDeleteTools,
|
|
57057
58511
|
registerReactTools,
|
|
57058
58512
|
registerMarkReadTools,
|
|
57059
58513
|
registerGroupChatTools,
|
|
@@ -57061,6 +58515,7 @@ await runMcp({
|
|
|
57061
58515
|
registerSearchTools,
|
|
57062
58516
|
registerExportTools,
|
|
57063
58517
|
registerTranscriptTools,
|
|
58518
|
+
registerRecapTools,
|
|
57064
58519
|
registerHealthcheckTool
|
|
57065
58520
|
]
|
|
57066
58521
|
});
|