@chrischall/microsoft-teams-mcp 0.2.6 → 0.3.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 +2 -2
- package/README.md +9 -1
- package/dist/bundle.js +430 -91
- package/dist/client.js +21 -12
- package/dist/tools/activity.js +11 -4
- package/dist/tools/channels.js +17 -9
- package/dist/tools/chat.js +17 -9
- package/dist/tools/conversation.js +7 -1
- package/dist/tools/healthcheck.js +15 -0
- package/dist/tools/limit.js +52 -0
- package/dist/version.js +1 -1
- package/package.json +5 -5
- package/server.json +18 -3
package/dist/bundle.js
CHANGED
|
@@ -121,9 +121,9 @@ var require_buffer_util = __commonJS({
|
|
|
121
121
|
toBuffer,
|
|
122
122
|
unmask: _unmask
|
|
123
123
|
};
|
|
124
|
-
if (
|
|
124
|
+
if (false) {
|
|
125
125
|
try {
|
|
126
|
-
const bufferUtil =
|
|
126
|
+
const bufferUtil = null;
|
|
127
127
|
module.exports.mask = function(source, mask, output2, offset, length) {
|
|
128
128
|
if (length < 48) _mask(source, mask, output2, offset, length);
|
|
129
129
|
else bufferUtil.mask(source, mask, output2, offset, length);
|
|
@@ -760,9 +760,9 @@ var require_validation2 = __commonJS({
|
|
|
760
760
|
module.exports.isValidUTF8 = function(buf) {
|
|
761
761
|
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
762
762
|
};
|
|
763
|
-
} else if (
|
|
763
|
+
} else if (false) {
|
|
764
764
|
try {
|
|
765
|
-
const isValidUTF8 =
|
|
765
|
+
const isValidUTF8 = null;
|
|
766
766
|
module.exports.isValidUTF8 = function(buf) {
|
|
767
767
|
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
768
768
|
};
|
|
@@ -2335,11 +2335,23 @@ var require_websocket = __commonJS({
|
|
|
2335
2335
|
this._isServer = false;
|
|
2336
2336
|
this._redirects = 0;
|
|
2337
2337
|
if (protocols === void 0) {
|
|
2338
|
-
protocols
|
|
2338
|
+
if (!options || options.protocols === void 0) {
|
|
2339
|
+
protocols = [];
|
|
2340
|
+
} else if (Array.isArray(options.protocols)) {
|
|
2341
|
+
protocols = options.protocols;
|
|
2342
|
+
} else {
|
|
2343
|
+
protocols = [options.protocols];
|
|
2344
|
+
}
|
|
2339
2345
|
} else if (!Array.isArray(protocols)) {
|
|
2340
2346
|
if (typeof protocols === "object" && protocols !== null) {
|
|
2341
2347
|
options = protocols;
|
|
2342
|
-
protocols
|
|
2348
|
+
if (options.protocols === void 0) {
|
|
2349
|
+
protocols = [];
|
|
2350
|
+
} else if (Array.isArray(options.protocols)) {
|
|
2351
|
+
protocols = options.protocols;
|
|
2352
|
+
} else {
|
|
2353
|
+
protocols = [options.protocols];
|
|
2354
|
+
}
|
|
2343
2355
|
} else {
|
|
2344
2356
|
protocols = [protocols];
|
|
2345
2357
|
}
|
|
@@ -2536,7 +2548,6 @@ var require_websocket = __commonJS({
|
|
|
2536
2548
|
}
|
|
2537
2549
|
return;
|
|
2538
2550
|
}
|
|
2539
|
-
this._readyState = _WebSocket.CLOSING;
|
|
2540
2551
|
this._sender.close(code, data, !this._isServer, (err) => {
|
|
2541
2552
|
if (err) return;
|
|
2542
2553
|
this._closeFrameSent = true;
|
|
@@ -2544,6 +2555,7 @@ var require_websocket = __commonJS({
|
|
|
2544
2555
|
this._socket.end();
|
|
2545
2556
|
}
|
|
2546
2557
|
});
|
|
2558
|
+
this._readyState = _WebSocket.CLOSING;
|
|
2547
2559
|
setCloseTimer(this);
|
|
2548
2560
|
}
|
|
2549
2561
|
/**
|
|
@@ -2768,6 +2780,7 @@ var require_websocket = __commonJS({
|
|
|
2768
2780
|
socketPath: void 0,
|
|
2769
2781
|
hostname: void 0,
|
|
2770
2782
|
protocol: void 0,
|
|
2783
|
+
protocols: void 0,
|
|
2771
2784
|
timeout: void 0,
|
|
2772
2785
|
method: "GET",
|
|
2773
2786
|
host: void 0,
|
|
@@ -21514,8 +21527,8 @@ function currencyCode2(_params) {
|
|
|
21514
21527
|
return _stringFormat(ZodCustomStringFormat, "currency_code", currencyCode, _params);
|
|
21515
21528
|
}
|
|
21516
21529
|
function hash(alg, params) {
|
|
21517
|
-
const
|
|
21518
|
-
const format = `${alg}_${
|
|
21530
|
+
const enc7 = params?.enc ?? "hex";
|
|
21531
|
+
const format = `${alg}_${enc7}`;
|
|
21519
21532
|
const regex = regexes_exports[format];
|
|
21520
21533
|
if (!regex)
|
|
21521
21534
|
throw new Error(`Unrecognized hash format: ${format}`);
|
|
@@ -38166,11 +38179,19 @@ var DEFAULT_ERROR_MESSAGE_MAX = 500;
|
|
|
38166
38179
|
var McpToolError = class extends Error {
|
|
38167
38180
|
/** Actionable remediation text, when one applies. */
|
|
38168
38181
|
hint;
|
|
38182
|
+
/** The upstream HTTP status this failure came from, when known. */
|
|
38183
|
+
status;
|
|
38184
|
+
/** What kind of failure this is, when the thrower knows. */
|
|
38185
|
+
kind;
|
|
38169
38186
|
constructor(message, opts) {
|
|
38170
38187
|
super(message, opts?.cause !== void 0 ? { cause: opts.cause } : void 0);
|
|
38171
38188
|
this.name = "McpToolError";
|
|
38172
38189
|
if (opts?.hint !== void 0)
|
|
38173
38190
|
this.hint = opts.hint;
|
|
38191
|
+
if (opts?.status !== void 0)
|
|
38192
|
+
this.status = opts.status;
|
|
38193
|
+
if (opts?.kind !== void 0)
|
|
38194
|
+
this.kind = opts.kind;
|
|
38174
38195
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
38175
38196
|
}
|
|
38176
38197
|
};
|
|
@@ -38195,7 +38216,7 @@ var API_KEY_RE = new RegExp([
|
|
|
38195
38216
|
// webhook signing secret (Stripe-style)
|
|
38196
38217
|
].map((p) => `\\b${p}`).join("|"), "g");
|
|
38197
38218
|
var GOOGLE_OAUTH_TOKEN_RE = /(?<![A-Za-z0-9+/])(?:ya29\.|1\/\/)[A-Za-z0-9._-]{8,}/g;
|
|
38198
|
-
var QUERY_SECRET_RE = new RegExp(`([?&](?:(?:access|refresh|id|auth|session|csrf|xsrf)[_-]?token|client[_-]?secret|api[_-]?secret|api[_-]?key|password|passwd|signature|token|key|sig|(?:php|j)?sess(?:ion)?[_-]?id|sid|x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN})=)[^&#\\s"'<>\`]+`, "gi");
|
|
38219
|
+
var QUERY_SECRET_RE = new RegExp(`([?&](?:(?:access|refresh|id|auth|session|csrf|xsrf)[_-]?token|client[_-]?secret|api[_-]?secret|api[_-]?key|password|passwd|signature|token|key|sig|(?:code[_-]?)?verifier|(?:php|j)?sess(?:ion)?[_-]?id|sid|x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN})=)[^&#\\s"'<>\`]+`, "gi");
|
|
38199
38220
|
var OAUTH_CODE_RE = /([?&]code=)(?=[^&#\s"'<>`]{16,})[^&#\s"'<>`]+/gi;
|
|
38200
38221
|
var FORM_PASSWORD_RE = /((?:^|[\s,;:"'(\[{])(?:password|passwd)=)[^&#\s"'<>`]+/gim;
|
|
38201
38222
|
var HEADER_SECRET_RE = new RegExp(`(\\b(?:x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN}|api[-_]?key)\\s*:\\s*)[^\\s,;"'<>\`]+`, "gi");
|
|
@@ -38206,6 +38227,8 @@ var JSON_SECRET_KEYS = [
|
|
|
38206
38227
|
"api[_-]?secret",
|
|
38207
38228
|
"(?:x[_-])?api[_-]?key",
|
|
38208
38229
|
"private[_-]?key",
|
|
38230
|
+
"code[_-]?verifier",
|
|
38231
|
+
// PKCE; a bare `verifier` key is too generic for JSON
|
|
38209
38232
|
`x[_-]${HEADER_NAME_RUN}?(?:api[_-]?key|token|secret|auth)${HEADER_NAME_RUN}`,
|
|
38210
38233
|
// bounded like HEADER_SECRET_RE
|
|
38211
38234
|
"(?:proxy-)?authorization",
|
|
@@ -38322,7 +38345,7 @@ function readEnvVar(key, opts = {}) {
|
|
|
38322
38345
|
if (typeof raw === "string") {
|
|
38323
38346
|
const trimmed = raw.trim();
|
|
38324
38347
|
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
38325
|
-
return trimmed;
|
|
38348
|
+
return opts.trim === false ? raw : trimmed;
|
|
38326
38349
|
}
|
|
38327
38350
|
}
|
|
38328
38351
|
return opts.default;
|
|
@@ -38364,12 +38387,14 @@ var SERVER_PROTOCOL_VERSIONS = Object.freeze([
|
|
|
38364
38387
|
...SUPPORTED_PROTOCOL_VERSIONS
|
|
38365
38388
|
]);
|
|
38366
38389
|
function hintResultOrRethrow(err) {
|
|
38390
|
+
if (err instanceof ProtocolError && err.code === ProtocolErrorCode.UrlElicitationRequired)
|
|
38391
|
+
throw err;
|
|
38367
38392
|
if (err instanceof McpToolError && err.hint) {
|
|
38368
38393
|
return errorResult(`${err.message}
|
|
38369
38394
|
|
|
38370
38395
|
Hint: ${err.hint}`);
|
|
38371
38396
|
}
|
|
38372
|
-
|
|
38397
|
+
return errorResult(messageOf(err));
|
|
38373
38398
|
}
|
|
38374
38399
|
function mcpRequestFrom(args) {
|
|
38375
38400
|
const ctx = args.at(-1);
|
|
@@ -38572,6 +38597,8 @@ var ApiError = class extends Error {
|
|
|
38572
38597
|
var EdgeBlockedError = class extends ApiError {
|
|
38573
38598
|
/** Which edge refused the request, e.g. `'CloudFront'` or `'Cloudflare'`. */
|
|
38574
38599
|
vendor;
|
|
38600
|
+
/** Always `'edge_blocked'`: the credential was never judged. */
|
|
38601
|
+
kind = "edge_blocked";
|
|
38575
38602
|
/**
|
|
38576
38603
|
* @param where The service the request was for, and — when the thrower knows
|
|
38577
38604
|
* it — the method and path, which the message names.
|
|
@@ -38639,7 +38666,7 @@ var PositiveInt = external_exports.number().int().positive();
|
|
|
38639
38666
|
var NonNegInt = external_exports.number().int().nonnegative();
|
|
38640
38667
|
var NonEmptyString = external_exports.string().min(1);
|
|
38641
38668
|
var IsoDate = external_exports.iso.date();
|
|
38642
|
-
var IsoTime = external_exports.string().regex(/^([01]?\d|2[0-3]):[0-5]\d$/, "must be HH:MM (24h), e.g. 19:30");
|
|
38669
|
+
var IsoTime = external_exports.string().regex(/^([01]?\d|2[0-3]):[0-5]\d$/, "must be HH:MM (24h), e.g. 19:30").overwrite((v) => v.padStart(5, "0"));
|
|
38643
38670
|
var NumericIdString = external_exports.string().regex(/^\d+$/, "must be a numeric id (digits only)").describe("A numeric id string (digits only), safe to interpolate into a URL path.");
|
|
38644
38671
|
var SafePathSegment = external_exports.string().min(1).regex(/^[^/?#\s]+$/, 'must not contain "/", "?", "#", or whitespace').refine((v) => !v.includes(".."), 'must not contain ".."').describe('A single URL path segment, safe to interpolate: no "/", "..", "?", "#", or whitespace.');
|
|
38645
38672
|
var schemaOrigin = external_exports.string().optional().describe("Portal origin (e.g. https://<vendor>.example.co) selecting which active session to use. Optional when only one session is active.");
|
|
@@ -38667,7 +38694,7 @@ function toolAnnotations(opts = {}) {
|
|
|
38667
38694
|
|
|
38668
38695
|
// src/version.ts
|
|
38669
38696
|
var PACKAGE_NAME = "microsoft-teams-mcp";
|
|
38670
|
-
var VERSION = "0.
|
|
38697
|
+
var VERSION = "0.3.0";
|
|
38671
38698
|
|
|
38672
38699
|
// node_modules/@fetchproxy/protocol/dist/crypto.js
|
|
38673
38700
|
var subtle = globalThis.crypto.subtle;
|
|
@@ -38871,6 +38898,60 @@ var KNOWN_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
|
38871
38898
|
"graphql",
|
|
38872
38899
|
"write_cookies"
|
|
38873
38900
|
]);
|
|
38901
|
+
var ACCOUNT_KEY_FRAME = "account-key";
|
|
38902
|
+
var ACCOUNT_ATTEST_FRAME = "account-attest";
|
|
38903
|
+
var BRIDGE_ROLE_FRAME = "bridge-role";
|
|
38904
|
+
var BRIDGE_SERVE_FRAME = "bridge-serve";
|
|
38905
|
+
var ROOM_PING_FRAME = "room-ping";
|
|
38906
|
+
var ROOM_PONG_FRAME = "room-pong";
|
|
38907
|
+
var BRIDGE_ROLE_LABEL_MAX = 64;
|
|
38908
|
+
var ROOM_FRAME_ACCEPTS = Object.freeze({
|
|
38909
|
+
[BRIDGE_ROLE_FRAME]: BRIDGE_ROLE_FRAME,
|
|
38910
|
+
[BRIDGE_SERVE_FRAME]: BRIDGE_SERVE_FRAME,
|
|
38911
|
+
[ROOM_PING_FRAME]: ROOM_PING_FRAME,
|
|
38912
|
+
[ROOM_PONG_FRAME]: ROOM_PING_FRAME
|
|
38913
|
+
});
|
|
38914
|
+
|
|
38915
|
+
// node_modules/@fetchproxy/protocol/dist/mcp-id.js
|
|
38916
|
+
var ID_RE = /^([^:]+):([^:]+):([0-9a-f]{16})$/;
|
|
38917
|
+
function generateMcpId(serverName, version2) {
|
|
38918
|
+
if (serverName.includes(":")) {
|
|
38919
|
+
throw new Error(`serverName cannot contain ':': ${serverName}`);
|
|
38920
|
+
}
|
|
38921
|
+
if (version2.includes(":")) {
|
|
38922
|
+
throw new Error(`version cannot contain ':': ${version2}`);
|
|
38923
|
+
}
|
|
38924
|
+
const rand = randomHex(8);
|
|
38925
|
+
return `${serverName}:${version2}:${rand}`;
|
|
38926
|
+
}
|
|
38927
|
+
function isValidMcpId(id) {
|
|
38928
|
+
return typeof id === "string" && ID_RE.test(id);
|
|
38929
|
+
}
|
|
38930
|
+
function randomHex(bytes) {
|
|
38931
|
+
const arr = new Uint8Array(bytes);
|
|
38932
|
+
globalThis.crypto.getRandomValues(arr);
|
|
38933
|
+
return Array.from(arr, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
38934
|
+
}
|
|
38935
|
+
|
|
38936
|
+
// node_modules/@fetchproxy/protocol/dist/account-attest.js
|
|
38937
|
+
var ACCOUNT_ATTEST_CONSENTS = Object.freeze([
|
|
38938
|
+
"silent",
|
|
38939
|
+
"confirm",
|
|
38940
|
+
"confirm-each"
|
|
38941
|
+
]);
|
|
38942
|
+
var NO_SCOPE_DIGEST = "0".repeat(64);
|
|
38943
|
+
var ACCOUNT_ID_RE = /^[A-Za-z0-9_.\-]{1,128}$/;
|
|
38944
|
+
var HEX64_RE = /^[0-9a-f]{64}$/;
|
|
38945
|
+
var ACCOUNT_KID_RE = /^[0-9a-f]{16}$/;
|
|
38946
|
+
var enc2 = new TextEncoder();
|
|
38947
|
+
|
|
38948
|
+
// node_modules/@fetchproxy/protocol/dist/awaiting-approval.js
|
|
38949
|
+
var AWAITING_APPROVAL_REASON_PREFIX = "awaiting-approval:";
|
|
38950
|
+
function parseAwaitingApprovalReason(reason) {
|
|
38951
|
+
if (!reason.startsWith(AWAITING_APPROVAL_REASON_PREFIX))
|
|
38952
|
+
return null;
|
|
38953
|
+
return reason.slice(AWAITING_APPROVAL_REASON_PREFIX.length).trim();
|
|
38954
|
+
}
|
|
38874
38955
|
|
|
38875
38956
|
// node_modules/@fetchproxy/protocol/dist/capability-availability.js
|
|
38876
38957
|
var CAPABILITY_UNAVAILABLE_CODE = "capability_unavailable";
|
|
@@ -38896,27 +38977,6 @@ function parseUnsupportedCapabilityReason(reason) {
|
|
|
38896
38977
|
return rest.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
38897
38978
|
}
|
|
38898
38979
|
|
|
38899
|
-
// node_modules/@fetchproxy/protocol/dist/mcp-id.js
|
|
38900
|
-
var ID_RE = /^([^:]+):([^:]+):([0-9a-f]{16})$/;
|
|
38901
|
-
function generateMcpId(serverName, version2) {
|
|
38902
|
-
if (serverName.includes(":")) {
|
|
38903
|
-
throw new Error(`serverName cannot contain ':': ${serverName}`);
|
|
38904
|
-
}
|
|
38905
|
-
if (version2.includes(":")) {
|
|
38906
|
-
throw new Error(`version cannot contain ':': ${version2}`);
|
|
38907
|
-
}
|
|
38908
|
-
const rand = randomHex(8);
|
|
38909
|
-
return `${serverName}:${version2}:${rand}`;
|
|
38910
|
-
}
|
|
38911
|
-
function isValidMcpId(id) {
|
|
38912
|
-
return typeof id === "string" && ID_RE.test(id);
|
|
38913
|
-
}
|
|
38914
|
-
function randomHex(bytes) {
|
|
38915
|
-
const arr = new Uint8Array(bytes);
|
|
38916
|
-
globalThis.crypto.getRandomValues(arr);
|
|
38917
|
-
return Array.from(arr, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
38918
|
-
}
|
|
38919
|
-
|
|
38920
38980
|
// node_modules/@fetchproxy/protocol/dist/json-pointer.js
|
|
38921
38981
|
function matchesDeclaredKey(requested, declared) {
|
|
38922
38982
|
for (const decl of declared) {
|
|
@@ -39512,6 +39572,16 @@ function validateFrame(raw) {
|
|
|
39512
39572
|
return { type: "extension-disconnected" };
|
|
39513
39573
|
if (t === "peer-gone")
|
|
39514
39574
|
return validatePeerGone(raw);
|
|
39575
|
+
if (t === ACCOUNT_KEY_FRAME)
|
|
39576
|
+
return validateAccountKey(raw);
|
|
39577
|
+
if (t === ACCOUNT_ATTEST_FRAME)
|
|
39578
|
+
return validateAccountAttest(raw);
|
|
39579
|
+
if (t === BRIDGE_ROLE_FRAME)
|
|
39580
|
+
return validateBridgeRole(raw);
|
|
39581
|
+
if (t === BRIDGE_SERVE_FRAME || t === ROOM_PING_FRAME || t === ROOM_PONG_FRAME) {
|
|
39582
|
+
assertExactFields(raw, TYPE_ONLY_FIELDS, t);
|
|
39583
|
+
return { type: t };
|
|
39584
|
+
}
|
|
39515
39585
|
throw new ProtocolError3(`unknown frame type: ${String(t)}`);
|
|
39516
39586
|
}
|
|
39517
39587
|
function validateHello(raw) {
|
|
@@ -39715,6 +39785,165 @@ function validateHelloRejected(raw) {
|
|
|
39715
39785
|
}
|
|
39716
39786
|
return { type: "hello-rejected", mcpId: raw.mcpId, reason: raw.reason };
|
|
39717
39787
|
}
|
|
39788
|
+
var DISPLAY_FORBIDDEN_RE = /[\u0000-\u001f\u007f-\u009f\u200e\u200f\u202a-\u202e\u2066-\u2069]/;
|
|
39789
|
+
function assertExactFields(raw, allowed, label) {
|
|
39790
|
+
for (const k of Object.keys(raw)) {
|
|
39791
|
+
if (!allowed.includes(k)) {
|
|
39792
|
+
throw new ProtocolError3(`${label}: unexpected field ${JSON.stringify(k)}`);
|
|
39793
|
+
}
|
|
39794
|
+
}
|
|
39795
|
+
}
|
|
39796
|
+
function assertMatch(x, re, label, what) {
|
|
39797
|
+
assertString(x, label);
|
|
39798
|
+
if (!re.test(x))
|
|
39799
|
+
throw new ProtocolError3(`${label}: must be ${what}`);
|
|
39800
|
+
}
|
|
39801
|
+
function assertPositiveSafeInt(x, label) {
|
|
39802
|
+
if (typeof x !== "number" || !Number.isSafeInteger(x) || x <= 0) {
|
|
39803
|
+
throw new ProtocolError3(`${label}: expected positive safe integer`);
|
|
39804
|
+
}
|
|
39805
|
+
}
|
|
39806
|
+
function assertDisplayString(x, label, min, max) {
|
|
39807
|
+
assertString(x, label);
|
|
39808
|
+
if (x.length < min || x.length > max) {
|
|
39809
|
+
throw new ProtocolError3(`${label}: must be ${min}-${max} characters`);
|
|
39810
|
+
}
|
|
39811
|
+
if (DISPLAY_FORBIDDEN_RE.test(x)) {
|
|
39812
|
+
throw new ProtocolError3(`${label}: control or bidi-override character`);
|
|
39813
|
+
}
|
|
39814
|
+
}
|
|
39815
|
+
var ACCOUNT_KEY_FIELDS = [
|
|
39816
|
+
"type",
|
|
39817
|
+
"accountId",
|
|
39818
|
+
"slug",
|
|
39819
|
+
"displayName",
|
|
39820
|
+
"confirmedBy",
|
|
39821
|
+
"tokenId",
|
|
39822
|
+
"kid",
|
|
39823
|
+
"publicKey",
|
|
39824
|
+
"generation",
|
|
39825
|
+
"bridgedRegistrations"
|
|
39826
|
+
];
|
|
39827
|
+
function validateAccountKey(raw) {
|
|
39828
|
+
const L = "account-key";
|
|
39829
|
+
assertMatch(raw.accountId, ACCOUNT_ID_RE, `${L}.accountId`, "an account id");
|
|
39830
|
+
assertMatch(raw.slug, ACCOUNT_ID_RE, `${L}.slug`, "a slug");
|
|
39831
|
+
assertDisplayString(raw.displayName, `${L}.displayName`, 0, 128);
|
|
39832
|
+
assertDisplayString(raw.confirmedBy, `${L}.confirmedBy`, 1, 256);
|
|
39833
|
+
assertMatch(raw.tokenId, ACCOUNT_ID_RE, `${L}.tokenId`, "a token id");
|
|
39834
|
+
assertMatch(raw.kid, ACCOUNT_KID_RE, `${L}.kid`, "16 lowercase hex");
|
|
39835
|
+
assertBase64Bytes(raw.publicKey, `${L}.publicKey`, 32);
|
|
39836
|
+
assertPositiveSafeInt(raw.generation, `${L}.generation`);
|
|
39837
|
+
const n = raw.bridgedRegistrations;
|
|
39838
|
+
if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 0) {
|
|
39839
|
+
throw new ProtocolError3(`${L}.bridgedRegistrations: expected non-negative safe integer`);
|
|
39840
|
+
}
|
|
39841
|
+
assertExactFields(raw, ACCOUNT_KEY_FIELDS, L);
|
|
39842
|
+
return {
|
|
39843
|
+
type: ACCOUNT_KEY_FRAME,
|
|
39844
|
+
accountId: raw.accountId,
|
|
39845
|
+
slug: raw.slug,
|
|
39846
|
+
displayName: raw.displayName,
|
|
39847
|
+
confirmedBy: raw.confirmedBy,
|
|
39848
|
+
tokenId: raw.tokenId,
|
|
39849
|
+
kid: raw.kid,
|
|
39850
|
+
publicKey: raw.publicKey,
|
|
39851
|
+
generation: raw.generation,
|
|
39852
|
+
bridgedRegistrations: n
|
|
39853
|
+
};
|
|
39854
|
+
}
|
|
39855
|
+
var ACCOUNT_ATTEST_FIELDS = [
|
|
39856
|
+
"type",
|
|
39857
|
+
"mcpId",
|
|
39858
|
+
"accountId",
|
|
39859
|
+
"generation",
|
|
39860
|
+
"tokenId",
|
|
39861
|
+
"kid",
|
|
39862
|
+
"registrationId",
|
|
39863
|
+
"slug",
|
|
39864
|
+
"identityHash",
|
|
39865
|
+
"identityEd25519Pub",
|
|
39866
|
+
"scopeDigest",
|
|
39867
|
+
"consent",
|
|
39868
|
+
"notAfter",
|
|
39869
|
+
"sig"
|
|
39870
|
+
];
|
|
39871
|
+
function validateAccountAttest(raw) {
|
|
39872
|
+
const L = "account-attest";
|
|
39873
|
+
if (!isValidMcpId(raw.mcpId))
|
|
39874
|
+
throw new ProtocolError3(`${L}.mcpId: invalid format`);
|
|
39875
|
+
assertMatch(raw.accountId, ACCOUNT_ID_RE, `${L}.accountId`, "an account id");
|
|
39876
|
+
assertPositiveSafeInt(raw.generation, `${L}.generation`);
|
|
39877
|
+
assertMatch(raw.tokenId, ACCOUNT_ID_RE, `${L}.tokenId`, "a token id");
|
|
39878
|
+
assertMatch(raw.kid, ACCOUNT_KID_RE, `${L}.kid`, "16 lowercase hex");
|
|
39879
|
+
assertMatch(raw.registrationId, ACCOUNT_ID_RE, `${L}.registrationId`, "a registration id");
|
|
39880
|
+
assertMatch(raw.slug, ACCOUNT_ID_RE, `${L}.slug`, "a slug");
|
|
39881
|
+
assertMatch(raw.identityHash, HEX64_RE, `${L}.identityHash`, "64 lowercase hex");
|
|
39882
|
+
assertBase64Bytes(raw.identityEd25519Pub, `${L}.identityEd25519Pub`, 32);
|
|
39883
|
+
assertMatch(raw.scopeDigest, HEX64_RE, `${L}.scopeDigest`, "64 lowercase hex");
|
|
39884
|
+
assertString(raw.consent, `${L}.consent`);
|
|
39885
|
+
const consent = raw.consent;
|
|
39886
|
+
const known = ACCOUNT_ATTEST_CONSENTS.find((c) => c === consent);
|
|
39887
|
+
if (known === void 0) {
|
|
39888
|
+
throw new ProtocolError3(`${L}.consent: must be one of ${ACCOUNT_ATTEST_CONSENTS.join(", ")}`);
|
|
39889
|
+
}
|
|
39890
|
+
assertPositiveSafeInt(raw.notAfter, `${L}.notAfter`);
|
|
39891
|
+
assertBase64Bytes(raw.sig, `${L}.sig`, 64);
|
|
39892
|
+
assertExactFields(raw, ACCOUNT_ATTEST_FIELDS, L);
|
|
39893
|
+
return {
|
|
39894
|
+
type: ACCOUNT_ATTEST_FRAME,
|
|
39895
|
+
mcpId: raw.mcpId,
|
|
39896
|
+
accountId: raw.accountId,
|
|
39897
|
+
generation: raw.generation,
|
|
39898
|
+
tokenId: raw.tokenId,
|
|
39899
|
+
kid: raw.kid,
|
|
39900
|
+
registrationId: raw.registrationId,
|
|
39901
|
+
slug: raw.slug,
|
|
39902
|
+
identityHash: raw.identityHash,
|
|
39903
|
+
identityEd25519Pub: raw.identityEd25519Pub,
|
|
39904
|
+
scopeDigest: raw.scopeDigest,
|
|
39905
|
+
consent: known,
|
|
39906
|
+
notAfter: raw.notAfter,
|
|
39907
|
+
sig: raw.sig
|
|
39908
|
+
};
|
|
39909
|
+
}
|
|
39910
|
+
var TYPE_ONLY_FIELDS = ["type"];
|
|
39911
|
+
var BRIDGE_ROLE_FIELDS = ["type", "role", "canServe", "serving"];
|
|
39912
|
+
var BRIDGE_ROLE_SERVING_FIELDS = ["label", "since"];
|
|
39913
|
+
function validateBridgeRole(raw) {
|
|
39914
|
+
const L = BRIDGE_ROLE_FRAME;
|
|
39915
|
+
const role = raw.role;
|
|
39916
|
+
if (role !== "serving" && role !== "standby") {
|
|
39917
|
+
throw new ProtocolError3(`${L}.role: must be one of serving, standby`);
|
|
39918
|
+
}
|
|
39919
|
+
const canServe = raw.canServe;
|
|
39920
|
+
assertBoolean(canServe, `${L}.canServe`);
|
|
39921
|
+
assertExactFields(raw, BRIDGE_ROLE_FIELDS, L);
|
|
39922
|
+
const serving = raw.serving;
|
|
39923
|
+
if (role === "serving") {
|
|
39924
|
+
if (serving !== void 0) {
|
|
39925
|
+
throw new ProtocolError3(`${L}.serving: must be absent when role is serving`);
|
|
39926
|
+
}
|
|
39927
|
+
return { type: BRIDGE_ROLE_FRAME, role, canServe };
|
|
39928
|
+
}
|
|
39929
|
+
if (serving === void 0) {
|
|
39930
|
+
throw new ProtocolError3(`${L}.serving: required when role is standby`);
|
|
39931
|
+
}
|
|
39932
|
+
assertObject(serving, `${L}.serving`);
|
|
39933
|
+
const label = serving.label;
|
|
39934
|
+
assertDisplayString(label, `${L}.serving.label`, 1, BRIDGE_ROLE_LABEL_MAX);
|
|
39935
|
+
const since = serving.since;
|
|
39936
|
+
if (typeof since !== "number" || !Number.isSafeInteger(since) || since < 0) {
|
|
39937
|
+
throw new ProtocolError3(`${L}.serving.since: expected non-negative safe integer (Unix ms)`);
|
|
39938
|
+
}
|
|
39939
|
+
assertExactFields(serving, BRIDGE_ROLE_SERVING_FIELDS, `${L}.serving`);
|
|
39940
|
+
return {
|
|
39941
|
+
type: BRIDGE_ROLE_FRAME,
|
|
39942
|
+
role,
|
|
39943
|
+
canServe,
|
|
39944
|
+
serving: { label, since }
|
|
39945
|
+
};
|
|
39946
|
+
}
|
|
39718
39947
|
function validateInnerFrame(raw) {
|
|
39719
39948
|
assertObject(raw, "inner");
|
|
39720
39949
|
const t = raw.type;
|
|
@@ -40182,10 +40411,10 @@ function validateInnerResponse(raw) {
|
|
|
40182
40411
|
}
|
|
40183
40412
|
|
|
40184
40413
|
// node_modules/@fetchproxy/protocol/dist/pair-code.js
|
|
40185
|
-
var
|
|
40414
|
+
var enc3 = new TextEncoder();
|
|
40186
40415
|
var PAIR_LABEL = "fetchproxy/4/pair";
|
|
40187
40416
|
async function pairTranscript(mcpIdentityPub, extIdentityPub, mcpNonce, extNonce, mcpSessionPub) {
|
|
40188
|
-
const label =
|
|
40417
|
+
const label = enc3.encode(PAIR_LABEL);
|
|
40189
40418
|
const parts = [mcpIdentityPub, extIdentityPub, mcpNonce, extNonce, mcpSessionPub];
|
|
40190
40419
|
const out = new Uint8Array(label.length + 1 + parts.reduce((n, p) => n + p.length, 0));
|
|
40191
40420
|
out.set(label, 0);
|
|
@@ -40206,7 +40435,7 @@ function digits(hash2) {
|
|
|
40206
40435
|
}
|
|
40207
40436
|
|
|
40208
40437
|
// node_modules/@fetchproxy/protocol/dist/seal.js
|
|
40209
|
-
var
|
|
40438
|
+
var enc4 = new TextEncoder();
|
|
40210
40439
|
var dec = new TextDecoder();
|
|
40211
40440
|
function randomIv() {
|
|
40212
40441
|
const iv = new Uint8Array(12);
|
|
@@ -40219,14 +40448,14 @@ function base64Length(byteLength) {
|
|
|
40219
40448
|
return Math.ceil(byteLength / 3) * 4;
|
|
40220
40449
|
}
|
|
40221
40450
|
function encodeInnerFrame(inner) {
|
|
40222
|
-
return
|
|
40451
|
+
return enc4.encode(JSON.stringify(inner));
|
|
40223
40452
|
}
|
|
40224
40453
|
function plaintextOf(inner) {
|
|
40225
40454
|
return inner instanceof Uint8Array ? inner : encodeInnerFrame(inner);
|
|
40226
40455
|
}
|
|
40227
40456
|
function sealedFrameWireBytes(mcpId, seq, inner) {
|
|
40228
40457
|
const plaintext = plaintextOf(inner).length;
|
|
40229
|
-
const envelope =
|
|
40458
|
+
const envelope = enc4.encode(JSON.stringify({ type: "frame", mcpId, seq, iv: "", ciphertext: "" })).length;
|
|
40230
40459
|
return envelope + IV_B64_BYTES + base64Length(plaintext + AES_GCM_TAG_BYTES);
|
|
40231
40460
|
}
|
|
40232
40461
|
var MAX_FRAME_BYTES = 42 * 1024 * 1024;
|
|
@@ -40566,14 +40795,23 @@ var FetchproxyHelloRejectedError = class extends Error {
|
|
|
40566
40795
|
platform;
|
|
40567
40796
|
/**
|
|
40568
40797
|
* #418: the remedy, when the reason is one this package knows how to
|
|
40569
|
-
* explain —
|
|
40570
|
-
*
|
|
40798
|
+
* explain — `unsupported-capability`, which blames the browser rather than
|
|
40799
|
+
* the MCP, and (D12) `awaiting-approval`, which says to approve in the
|
|
40800
|
+
* browser. `null` otherwise.
|
|
40571
40801
|
*/
|
|
40572
40802
|
hint;
|
|
40803
|
+
/**
|
|
40804
|
+
* D12: `true` only for an `awaiting-approval:` refusal — the extension has
|
|
40805
|
+
* queued an approval card and nobody is at the browser yet, so the same call
|
|
40806
|
+
* succeeds once the person approves. Every other refusal is the extension's
|
|
40807
|
+
* final answer, and retrying unchanged is refused the same way.
|
|
40808
|
+
*/
|
|
40809
|
+
retryable;
|
|
40573
40810
|
constructor(info) {
|
|
40574
40811
|
const unavailable = parseUnsupportedCapabilityReason(info.reason);
|
|
40812
|
+
const awaiting = parseAwaitingApprovalReason(info.reason);
|
|
40575
40813
|
const platform = info.platform ?? null;
|
|
40576
|
-
const hint = unavailable !== null ? `${platform ? `this browser (${platform})` : "this browser"} cannot serve any of the capabilities this MCP needs (${unavailable.join(", ")}) \u2014 ContextMint Bridge checked for the browser APIs and they are missing. Nothing is wrong with the MCP or your pairing, and updating will not change it: use this MCP from a browser that provides them (for example Chrome).` : null;
|
|
40814
|
+
const hint = awaiting !== null ? `The extension is waiting for you to approve this MCP` + (awaiting !== "" ? ` (${awaiting})` : "") + ` \u2014 open ContextMint Bridge in your browser, approve it there, then retry. Nothing is wrong with the MCP or your sign-in.` : unavailable !== null ? `${platform ? `this browser (${platform})` : "this browser"} cannot serve any of the capabilities this MCP needs (${unavailable.join(", ")}) \u2014 ContextMint Bridge checked for the browser APIs and they are missing. Nothing is wrong with the MCP or your pairing, and updating will not change it: use this MCP from a browser that provides them (for example Chrome).` : null;
|
|
40577
40815
|
super(`fetchproxy: the extension refused the connection for "${info.mcpId}": ${info.reason}. ` + (hint !== null ? hint : `This is the extension's own reason \u2014 it is not a timeout, and retrying unchanged will be refused the same way.`));
|
|
40578
40816
|
this.name = "FetchproxyHelloRejectedError";
|
|
40579
40817
|
this.mcpId = info.mcpId;
|
|
@@ -40581,6 +40819,7 @@ var FetchproxyHelloRejectedError = class extends Error {
|
|
|
40581
40819
|
this.unavailableCapabilities = unavailable ?? [];
|
|
40582
40820
|
this.platform = platform;
|
|
40583
40821
|
this.hint = hint;
|
|
40822
|
+
this.retryable = awaiting !== null;
|
|
40584
40823
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
40585
40824
|
}
|
|
40586
40825
|
};
|
|
@@ -41133,7 +41372,7 @@ function originVerdict(origin, allowLocal) {
|
|
|
41133
41372
|
}
|
|
41134
41373
|
var HANDSHAKE_TIMEOUT_MS = 15e3;
|
|
41135
41374
|
var MAX_PAYLOAD_BYTES = MAX_FRAME_BYTES;
|
|
41136
|
-
var
|
|
41375
|
+
var enc5 = new TextEncoder();
|
|
41137
41376
|
var OWN_DECRYPT_FAILURES_BEFORE_REHANDSHAKE = 3;
|
|
41138
41377
|
async function startHost(opts) {
|
|
41139
41378
|
const allowLocalOrigins = envAllowsLocalOrigins();
|
|
@@ -41204,10 +41443,20 @@ async function startHost(opts) {
|
|
|
41204
41443
|
let resolveOwnSession;
|
|
41205
41444
|
let rejectOwnSession;
|
|
41206
41445
|
let ownSessionReady;
|
|
41446
|
+
let ownRetryableRefusal = false;
|
|
41447
|
+
let ownSessionSettled = false;
|
|
41207
41448
|
function resetSessionPromise() {
|
|
41449
|
+
ownRetryableRefusal = false;
|
|
41450
|
+
ownSessionSettled = false;
|
|
41208
41451
|
ownSessionReady = new Promise((resolve, reject) => {
|
|
41209
|
-
resolveOwnSession =
|
|
41210
|
-
|
|
41452
|
+
resolveOwnSession = (st) => {
|
|
41453
|
+
ownSessionSettled = true;
|
|
41454
|
+
resolve(st);
|
|
41455
|
+
};
|
|
41456
|
+
rejectOwnSession = (e) => {
|
|
41457
|
+
ownSessionSettled = true;
|
|
41458
|
+
reject(e);
|
|
41459
|
+
};
|
|
41211
41460
|
});
|
|
41212
41461
|
ownSessionReady.catch(() => {
|
|
41213
41462
|
});
|
|
@@ -41474,13 +41723,15 @@ async function startHost(opts) {
|
|
|
41474
41723
|
const extPub = fromB64(frame.extensionSessionPub);
|
|
41475
41724
|
const shared = await ecdhX25519(held.priv, extPub);
|
|
41476
41725
|
const salt = await transcriptHash(held.nonce, extNonce, held.pub, extPub);
|
|
41477
|
-
const key = await hkdfSha256(shared, salt,
|
|
41726
|
+
const key = await hkdfSha256(shared, salt, enc5.encode(HKDF_SESSION_INFO), 32);
|
|
41478
41727
|
if (extensionWs !== ws)
|
|
41479
41728
|
return;
|
|
41480
41729
|
ownSession = new SessionState(key);
|
|
41481
41730
|
ownSessionInfo = sessionInfoFromHello(verifiedHello);
|
|
41482
41731
|
ownDecryptFailures = 0;
|
|
41483
41732
|
ownPendingPairCode = null;
|
|
41733
|
+
if (ownRetryableRefusal)
|
|
41734
|
+
resetSessionPromise();
|
|
41484
41735
|
resolveOwnSession(ownSession);
|
|
41485
41736
|
} else {
|
|
41486
41737
|
const slot = peers.get(frame.mcpId);
|
|
@@ -41549,11 +41800,17 @@ async function startHost(opts) {
|
|
|
41549
41800
|
}
|
|
41550
41801
|
if (frame.type === "hello-rejected" && identified === "extension") {
|
|
41551
41802
|
if (frame.mcpId === opts.ownMcpId) {
|
|
41552
|
-
|
|
41803
|
+
const refusal = new FetchproxyHelloRejectedError({
|
|
41553
41804
|
mcpId: frame.mcpId,
|
|
41554
41805
|
reason: frame.reason,
|
|
41555
41806
|
platform: extensionHello?.platform ?? null
|
|
41556
|
-
})
|
|
41807
|
+
});
|
|
41808
|
+
if (ownRetryableRefusal)
|
|
41809
|
+
resetSessionPromise();
|
|
41810
|
+
const settlesPending = !ownSessionSettled;
|
|
41811
|
+
rejectOwnSession(refusal);
|
|
41812
|
+
if (refusal.retryable && settlesPending)
|
|
41813
|
+
ownRetryableRefusal = true;
|
|
41557
41814
|
} else {
|
|
41558
41815
|
const slot = peers.get(frame.mcpId);
|
|
41559
41816
|
if (slot?.helloFrame.accepts?.includes("hello-rejected")) {
|
|
@@ -41669,7 +41926,7 @@ async function startHost(opts) {
|
|
|
41669
41926
|
|
|
41670
41927
|
// node_modules/@fetchproxy/server/dist/peer.js
|
|
41671
41928
|
var PEER_DIAL_TIMEOUT_MS = 5e3;
|
|
41672
|
-
var
|
|
41929
|
+
var enc6 = new TextEncoder();
|
|
41673
41930
|
function notSentError() {
|
|
41674
41931
|
return new Error("fetchproxy: request not sent \u2014 the connection to the bridge host closed before it went out, so nothing reached the browser. It is safe to retry.");
|
|
41675
41932
|
}
|
|
@@ -41769,7 +42026,9 @@ async function startPeer(opts) {
|
|
|
41769
42026
|
let rejectFirstReady;
|
|
41770
42027
|
let sessionPromise;
|
|
41771
42028
|
let sessionPromiseSettled = false;
|
|
42029
|
+
let retryableRefusal = false;
|
|
41772
42030
|
function resetSessionPromise() {
|
|
42031
|
+
retryableRefusal = false;
|
|
41773
42032
|
sessionPromiseSettled = false;
|
|
41774
42033
|
sessionPromise = new Promise((resolve, reject) => {
|
|
41775
42034
|
resolveFirstReady = (st) => {
|
|
@@ -41866,6 +42125,8 @@ async function startPeer(opts) {
|
|
|
41866
42125
|
raw = JSON.parse(data.toString());
|
|
41867
42126
|
const frame = validateFrame(raw);
|
|
41868
42127
|
if (frame.type === "hello" && frame.role === "extension") {
|
|
42128
|
+
if (retryableRefusal)
|
|
42129
|
+
resetSessionPromise();
|
|
41869
42130
|
extensionHello = frame;
|
|
41870
42131
|
const mintedKeypair = await generateSessionKeypair();
|
|
41871
42132
|
const mintedHello = await buildServerHello({
|
|
@@ -41895,6 +42156,8 @@ async function startPeer(opts) {
|
|
|
41895
42156
|
session = null;
|
|
41896
42157
|
if (sessionPromiseSettled)
|
|
41897
42158
|
resetSessionPromise();
|
|
42159
|
+
} else if (retryableRefusal) {
|
|
42160
|
+
resetSessionPromise();
|
|
41898
42161
|
}
|
|
41899
42162
|
extensionDisconnectListeners.forEach((cb) => cb());
|
|
41900
42163
|
return;
|
|
@@ -41916,7 +42179,7 @@ async function startPeer(opts) {
|
|
|
41916
42179
|
const extNonce = fromB64(authenticated.sessionNonce);
|
|
41917
42180
|
const shared = await ecdhX25519(held.priv, extPub);
|
|
41918
42181
|
const salt = await transcriptHash(held.nonce, extNonce, held.pub, extPub);
|
|
41919
|
-
const sessionKey = await hkdfSha256(shared, salt,
|
|
42182
|
+
const sessionKey = await hkdfSha256(shared, salt, enc6.encode(HKDF_SESSION_INFO), 32);
|
|
41920
42183
|
if (sessionEphemeral !== held) {
|
|
41921
42184
|
console.warn(`[fetchproxy] ${opts.serverName}: dropping a session derived against an ephemeral that was superseded while it was being derived`);
|
|
41922
42185
|
return;
|
|
@@ -41929,16 +42192,24 @@ async function startPeer(opts) {
|
|
|
41929
42192
|
if (isRenegotiation) {
|
|
41930
42193
|
renegotiateListeners.forEach((cb) => cb());
|
|
41931
42194
|
} else {
|
|
42195
|
+
if (retryableRefusal)
|
|
42196
|
+
resetSessionPromise();
|
|
41932
42197
|
resolveFirstReady(session);
|
|
41933
42198
|
}
|
|
41934
42199
|
return;
|
|
41935
42200
|
}
|
|
41936
42201
|
if (frame.type === "hello-rejected" && frame.mcpId === opts.mcpId) {
|
|
41937
|
-
|
|
42202
|
+
const refusal = new FetchproxyHelloRejectedError({
|
|
41938
42203
|
mcpId: frame.mcpId,
|
|
41939
42204
|
reason: frame.reason,
|
|
41940
42205
|
platform: extensionHello?.platform ?? null
|
|
41941
|
-
})
|
|
42206
|
+
});
|
|
42207
|
+
if (retryableRefusal)
|
|
42208
|
+
resetSessionPromise();
|
|
42209
|
+
const settlesPending = !sessionPromiseSettled;
|
|
42210
|
+
rejectFirstReady(refusal);
|
|
42211
|
+
if (refusal.retryable && settlesPending)
|
|
42212
|
+
retryableRefusal = true;
|
|
41942
42213
|
}
|
|
41943
42214
|
if (frame.type === "pair-pending" && frame.mcpId === opts.mcpId) {
|
|
41944
42215
|
const hello2 = extensionHello;
|
|
@@ -42102,8 +42373,9 @@ function classifyFetchError(error62, code) {
|
|
|
42102
42373
|
|
|
42103
42374
|
// node_modules/@fetchproxy/server/dist/classify-bridge-error.js
|
|
42104
42375
|
function classifyBridgeError(err) {
|
|
42105
|
-
if (err instanceof FetchproxyHelloRejectedError)
|
|
42106
|
-
return "hello_rejected";
|
|
42376
|
+
if (err instanceof FetchproxyHelloRejectedError) {
|
|
42377
|
+
return err.retryable ? "awaiting_approval" : "hello_rejected";
|
|
42378
|
+
}
|
|
42107
42379
|
if (err instanceof FetchproxySessionNotReadyError)
|
|
42108
42380
|
return "session_not_ready";
|
|
42109
42381
|
if (err instanceof FetchproxyTimeoutError)
|
|
@@ -42122,7 +42394,7 @@ function classifyBridgeError(err) {
|
|
|
42122
42394
|
// node_modules/@fetchproxy/server/dist/ws-server.js
|
|
42123
42395
|
import { isIP } from "node:net";
|
|
42124
42396
|
function envWsPort() {
|
|
42125
|
-
const raw =
|
|
42397
|
+
const raw = void 0;
|
|
42126
42398
|
if (raw === void 0 || raw.trim() === "")
|
|
42127
42399
|
return void 0;
|
|
42128
42400
|
if (!/^\d+$/.test(raw.trim()))
|
|
@@ -44918,7 +45190,13 @@ var DOM_LIST_SELECTORS = [
|
|
|
44918
45190
|
];
|
|
44919
45191
|
var TeamsClient = class {
|
|
44920
45192
|
#transport;
|
|
44921
|
-
|
|
45193
|
+
/**
|
|
45194
|
+
* The in-flight (or settled) start, memoized so parallel first calls share
|
|
45195
|
+
* ONE `transport.start()` — two concurrent starts would each create and
|
|
45196
|
+
* persist a fresh fetchproxy identity keypair, leaving the paired key and
|
|
45197
|
+
* the on-disk key out of step. Cleared on failure so the next call retries.
|
|
45198
|
+
*/
|
|
45199
|
+
#starting;
|
|
44922
45200
|
constructor(opts = {}) {
|
|
44923
45201
|
this.#transport = opts.transport ?? createFetchproxyTransport({
|
|
44924
45202
|
serverName: PACKAGE_NAME,
|
|
@@ -44944,10 +45222,12 @@ var TeamsClient = class {
|
|
|
44944
45222
|
* lazily, so a server that never gets a tool call never touches the
|
|
44945
45223
|
* bridge at all.
|
|
44946
45224
|
*/
|
|
44947
|
-
|
|
44948
|
-
|
|
44949
|
-
|
|
44950
|
-
|
|
45225
|
+
#ensureStarted() {
|
|
45226
|
+
this.#starting ??= this.#transport.start().catch((e) => {
|
|
45227
|
+
this.#starting = void 0;
|
|
45228
|
+
throw e;
|
|
45229
|
+
});
|
|
45230
|
+
return this.#starting;
|
|
44951
45231
|
}
|
|
44952
45232
|
/** Reads a declared selector off the single supported domain's live tab. */
|
|
44953
45233
|
async #readDomList(name) {
|
|
@@ -44990,12 +45270,14 @@ var TeamsClient = class {
|
|
|
44990
45270
|
return await this.#readDomList("channelPosts");
|
|
44991
45271
|
}
|
|
44992
45272
|
/**
|
|
44993
|
-
*
|
|
44994
|
-
*
|
|
45273
|
+
* Every sidebar row Teams marks as selected (up to 5). Usually one, but the
|
|
45274
|
+
* selector spans BOTH the Chat and the Teams-and-Channels sidebars, so a
|
|
45275
|
+
* channel row can stay selected while a chat is open (and vice versa) —
|
|
45276
|
+
* callers must pick by `itemType` (see `tools/conversation.ts`), never
|
|
45277
|
+
* just take the first row.
|
|
44995
45278
|
*/
|
|
44996
|
-
async
|
|
44997
|
-
|
|
44998
|
-
return rows[0] ?? null;
|
|
45279
|
+
async getSelectedConversations() {
|
|
45280
|
+
return await this.#readDomList("openConversation");
|
|
44999
45281
|
}
|
|
45000
45282
|
/** The Activity feed (the bell icon in the left nav), regardless of which item is selected. */
|
|
45001
45283
|
async getActivity() {
|
|
@@ -45003,7 +45285,7 @@ var TeamsClient = class {
|
|
|
45003
45285
|
}
|
|
45004
45286
|
async close() {
|
|
45005
45287
|
await this.#transport.close();
|
|
45006
|
-
this.#
|
|
45288
|
+
this.#starting = void 0;
|
|
45007
45289
|
}
|
|
45008
45290
|
/** Non-secret bridge status for the healthcheck tool. */
|
|
45009
45291
|
status() {
|
|
@@ -45053,7 +45335,8 @@ var OPEN_CONVERSATION_DESCRIPTION = " The result names the open conversation (`c
|
|
|
45053
45335
|
async function readOpenConversation(client2, kind) {
|
|
45054
45336
|
let conversation = null;
|
|
45055
45337
|
try {
|
|
45056
|
-
|
|
45338
|
+
const matches = (await client2.getSelectedConversations()).filter((row) => row.itemType === kind);
|
|
45339
|
+
conversation = matches.length === 1 ? matches[0] : null;
|
|
45057
45340
|
} catch {
|
|
45058
45341
|
conversation = null;
|
|
45059
45342
|
}
|
|
@@ -45069,6 +45352,36 @@ async function readOpenConversation(client2, kind) {
|
|
|
45069
45352
|
};
|
|
45070
45353
|
}
|
|
45071
45354
|
|
|
45355
|
+
// src/tools/limit.ts
|
|
45356
|
+
var DEFAULT_LIMIT = 50;
|
|
45357
|
+
function limitArg(max, what) {
|
|
45358
|
+
return external_exports.number().int().min(1).max(max).optional().describe(`Maximum ${what} to return, newest first kept (default ${DEFAULT_LIMIT}, max ${max}).`);
|
|
45359
|
+
}
|
|
45360
|
+
function trimRows(rows, limit, newestAt, max) {
|
|
45361
|
+
const n = limit ?? DEFAULT_LIMIT;
|
|
45362
|
+
if (rows.length <= n) return { rows };
|
|
45363
|
+
const kept = newestAt === "end" ? rows.slice(rows.length - n) : rows.slice(0, n);
|
|
45364
|
+
return {
|
|
45365
|
+
rows: kept,
|
|
45366
|
+
truncated: {
|
|
45367
|
+
total: rows.length,
|
|
45368
|
+
returned: kept.length,
|
|
45369
|
+
hint: `Only the newest ${kept.length} of ${rows.length} were returned; pass a larger limit (max ${max}) to read more.`
|
|
45370
|
+
}
|
|
45371
|
+
};
|
|
45372
|
+
}
|
|
45373
|
+
var sinceArg = external_exports.string().refine((s) => !Number.isNaN(Date.parse(s)), { message: "since must be an ISO 8601 date-time" }).optional().describe(
|
|
45374
|
+
"Only return messages at or after this ISO 8601 date-time (e.g. 2026-09-21T09:00:00Z). Messages whose time cannot be read are kept."
|
|
45375
|
+
);
|
|
45376
|
+
function filterSince(rows, since) {
|
|
45377
|
+
if (since === void 0) return rows;
|
|
45378
|
+
const cutoff = Date.parse(since);
|
|
45379
|
+
return rows.filter((row) => {
|
|
45380
|
+
const t = row.time === void 0 ? Number.NaN : Date.parse(row.time);
|
|
45381
|
+
return Number.isNaN(t) || t >= cutoff;
|
|
45382
|
+
});
|
|
45383
|
+
}
|
|
45384
|
+
|
|
45072
45385
|
// src/tools/chat.ts
|
|
45073
45386
|
function registerChatTools(server, client2) {
|
|
45074
45387
|
server.registerTool(
|
|
@@ -45076,13 +45389,18 @@ function registerChatTools(server, client2) {
|
|
|
45076
45389
|
{
|
|
45077
45390
|
title: "List Teams chats",
|
|
45078
45391
|
description: "List the chats in the signed-in user's Teams chat sidebar (1:1s, group chats, meeting chats), each with its title, last-message preview, last-activity time, and a conversationKey (Teams' internal thread id \u2014 not usable to open the chat, there is no navigate capability). Reads the currently-rendered list from the user's live browser tab." + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
45079
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
45080
|
-
inputSchema: {}
|
|
45392
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
45393
|
+
inputSchema: { limit: limitArg(200, "chats") }
|
|
45081
45394
|
},
|
|
45082
|
-
async () => {
|
|
45395
|
+
async ({ limit }) => {
|
|
45083
45396
|
try {
|
|
45084
45397
|
const rows = await client2.listChats();
|
|
45085
|
-
return untrustedResult2(
|
|
45398
|
+
return untrustedResult2(
|
|
45399
|
+
rows.length > 0 ? trimRows(rows, limit, "start", 200) : {
|
|
45400
|
+
rows,
|
|
45401
|
+
empty_hint: "No chat list is rendered. The Teams tab is probably not on the Chat view \u2014 ask the user to click Chat in the left nav, then retry."
|
|
45402
|
+
}
|
|
45403
|
+
);
|
|
45086
45404
|
} catch (err) {
|
|
45087
45405
|
throw wrapBridgeError(err, "list chats");
|
|
45088
45406
|
}
|
|
@@ -45093,14 +45411,15 @@ function registerChatTools(server, client2) {
|
|
|
45093
45411
|
{
|
|
45094
45412
|
title: "Read the currently open Teams chat",
|
|
45095
45413
|
description: "Read the message thread of whichever Teams chat is CURRENTLY OPEN in the user's signed-in browser tab \u2014 sender, ISO-8601 time, message id, and text for each message. There is no way to choose a different chat from here (the bridge can only read the DOM, not navigate it): ask the user to open the chat they mean first, or use teams_list_chats to show them what is available. A quoted-reply message's text may include the quoted preview concatenated in." + OPEN_CONVERSATION_DESCRIPTION + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
45096
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
45097
|
-
inputSchema: {}
|
|
45414
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
45415
|
+
inputSchema: { limit: limitArg(200, "messages"), since: sinceArg }
|
|
45098
45416
|
},
|
|
45099
|
-
async () => {
|
|
45417
|
+
async ({ limit, since }) => {
|
|
45100
45418
|
try {
|
|
45101
|
-
const
|
|
45419
|
+
const all = await client2.getOpenChatMessages();
|
|
45102
45420
|
const identity = await readOpenConversation(client2, "chat");
|
|
45103
|
-
|
|
45421
|
+
const { rows: messages, truncated } = trimRows(filterSince(all, since), limit, "end", 200);
|
|
45422
|
+
return untrustedResult2({ ...identity, messages, ...truncated ? { truncated } : {} });
|
|
45104
45423
|
} catch (err) {
|
|
45105
45424
|
throw wrapBridgeError(err, "read the open chat");
|
|
45106
45425
|
}
|
|
@@ -45115,13 +45434,18 @@ function registerChannelTools(server, client2) {
|
|
|
45115
45434
|
{
|
|
45116
45435
|
title: "List Teams and their channels",
|
|
45117
45436
|
description: `List the Teams the signed-in user belongs to and their channels, from the "Teams" nav section's sidebar (a DIFFERENT view from Chat). Each row is a team or a channel \u2014 itemType distinguishes them; a channel row's teamName names its parent team. Requires the user's browser to have the Teams-and-Channels view open (not Chat) \u2014 if it returns nothing, ask them to click "Teams" in the left nav.` + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
45118
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
45119
|
-
inputSchema: {}
|
|
45437
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
45438
|
+
inputSchema: { limit: limitArg(300, "team and channel rows") }
|
|
45120
45439
|
},
|
|
45121
|
-
async () => {
|
|
45440
|
+
async ({ limit }) => {
|
|
45122
45441
|
try {
|
|
45123
45442
|
const rows = await client2.listTeamsAndChannels();
|
|
45124
|
-
return untrustedResult2(
|
|
45443
|
+
return untrustedResult2(
|
|
45444
|
+
rows.length > 0 ? trimRows(rows, limit, "start", 300) : {
|
|
45445
|
+
rows,
|
|
45446
|
+
empty_hint: "No teams or channels are rendered. The Teams tab is probably not on the Teams view \u2014 ask the user to click Teams in the left nav, then retry."
|
|
45447
|
+
}
|
|
45448
|
+
);
|
|
45125
45449
|
} catch (err) {
|
|
45126
45450
|
throw wrapBridgeError(err, "list teams and channels");
|
|
45127
45451
|
}
|
|
@@ -45132,14 +45456,15 @@ function registerChannelTools(server, client2) {
|
|
|
45132
45456
|
{
|
|
45133
45457
|
title: "Read the currently open channel",
|
|
45134
45458
|
description: `Read the top-level posts in whichever Teams CHANNEL is CURRENTLY OPEN in the user's signed-in browser tab \u2014 sender, time (prose, e.g. "Tuesday, August 4, 2026 7:50 AM" \u2014 not ISO 8601), subject (when the post has a title), and text. Threaded replies under a post are not included, only the top-level posts. There is no way to choose a different channel from here: ask the user to open the channel they mean first (the Teams-and-Channels view, not Chat), or use teams_list_teams_and_channels to show them what is available.` + OPEN_CONVERSATION_DESCRIPTION + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
45135
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
45136
|
-
inputSchema: {}
|
|
45459
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
45460
|
+
inputSchema: { limit: limitArg(200, "posts") }
|
|
45137
45461
|
},
|
|
45138
|
-
async () => {
|
|
45462
|
+
async ({ limit }) => {
|
|
45139
45463
|
try {
|
|
45140
|
-
const
|
|
45464
|
+
const all = await client2.getOpenChannelPosts();
|
|
45141
45465
|
const identity = await readOpenConversation(client2, "channel");
|
|
45142
|
-
|
|
45466
|
+
const { rows: posts, truncated } = trimRows(all, limit, "end", 200);
|
|
45467
|
+
return untrustedResult2({ ...identity, posts, ...truncated ? { truncated } : {} });
|
|
45143
45468
|
} catch (err) {
|
|
45144
45469
|
throw wrapBridgeError(err, "read the open channel");
|
|
45145
45470
|
}
|
|
@@ -45154,13 +45479,18 @@ function registerActivityTools(server, client2) {
|
|
|
45154
45479
|
{
|
|
45155
45480
|
title: "Read the Activity feed",
|
|
45156
45481
|
description: "List the rows in the Activity feed (the bell icon in the left nav) \u2014 mentions, replies, reactions, and the like across every chat and channel \u2014 each with its title, message preview, prose time (not ISO 8601), and location (the team/channel or chat it happened in). Requires the user's browser to have the Activity view open \u2014 if it returns nothing, ask them to click the bell icon in the left nav." + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
45157
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
45158
|
-
inputSchema: {}
|
|
45482
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
45483
|
+
inputSchema: { limit: limitArg(200, "activity rows") }
|
|
45159
45484
|
},
|
|
45160
|
-
async () => {
|
|
45485
|
+
async ({ limit }) => {
|
|
45161
45486
|
try {
|
|
45162
45487
|
const rows = await client2.getActivity();
|
|
45163
|
-
return untrustedResult2(
|
|
45488
|
+
return untrustedResult2(
|
|
45489
|
+
rows.length > 0 ? trimRows(rows, limit, "start", 200) : {
|
|
45490
|
+
rows,
|
|
45491
|
+
empty_hint: "No Activity feed is rendered. The Teams tab is probably not on the Activity view \u2014 ask the user to click the bell icon (Activity) in the left nav, then retry."
|
|
45492
|
+
}
|
|
45493
|
+
);
|
|
45164
45494
|
} catch (err) {
|
|
45165
45495
|
throw wrapBridgeError(err, "read the Activity feed");
|
|
45166
45496
|
}
|
|
@@ -45178,10 +45508,19 @@ function registerHealthcheckTool(server, client2) {
|
|
|
45178
45508
|
probePath: "chat list (read_dom_list against the currently open Teams tab)",
|
|
45179
45509
|
probeFn: async () => {
|
|
45180
45510
|
const rows = await client2.listChats();
|
|
45511
|
+
if (rows.length === 0) throw new ChatViewNotOpenError();
|
|
45181
45512
|
return `${rows.length} chat(s) visible in the sidebar`;
|
|
45182
|
-
}
|
|
45513
|
+
},
|
|
45514
|
+
classifyThrown: (err) => err instanceof ChatViewNotOpenError ? { kind: "chat_view_not_open", hint: CHAT_VIEW_NOT_OPEN_HINT } : void 0
|
|
45183
45515
|
});
|
|
45184
45516
|
}
|
|
45517
|
+
var CHAT_VIEW_NOT_OPEN_HINT = "The bridge reached the teams.cloud.microsoft tab, but no chat list is rendered: the Chat view is not open (the tab is probably on Teams, Activity or Calendar). Ask the user to click Chat in the left nav, then retry.";
|
|
45518
|
+
var ChatViewNotOpenError = class extends Error {
|
|
45519
|
+
constructor() {
|
|
45520
|
+
super("bridge OK but no chat list rendered \u2014 is the Chat view open?");
|
|
45521
|
+
this.name = "ChatViewNotOpenError";
|
|
45522
|
+
}
|
|
45523
|
+
};
|
|
45185
45524
|
|
|
45186
45525
|
// src/index.ts
|
|
45187
45526
|
loadDotenvSafely();
|