teams-api 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -20
- package/dist/actions/conversation-actions.d.ts.map +1 -1
- package/dist/actions/conversation-actions.js.map +1 -1
- package/dist/actions/definitions.d.ts.map +1 -1
- package/dist/actions/definitions.js +2 -0
- package/dist/actions/definitions.js.map +1 -1
- package/dist/actions/file-actions.d.ts.map +1 -1
- package/dist/actions/file-actions.js +3 -1
- package/dist/actions/file-actions.js.map +1 -1
- package/dist/actions/image-description-actions.d.ts +28 -0
- package/dist/actions/image-description-actions.d.ts.map +1 -0
- package/dist/actions/image-description-actions.js +148 -0
- package/dist/actions/image-description-actions.js.map +1 -0
- package/dist/actions/message-actions.d.ts.map +1 -1
- package/dist/actions/message-actions.js +175 -9
- package/dist/actions/message-actions.js.map +1 -1
- package/dist/actions/utility-actions.d.ts.map +1 -1
- package/dist/actions/utility-actions.js.map +1 -1
- package/dist/api/chat-service.d.ts +2 -12
- package/dist/api/chat-service.d.ts.map +1 -1
- package/dist/api/chat-service.js +33 -41
- package/dist/api/chat-service.js.map +1 -1
- package/dist/api/common.d.ts +4 -0
- package/dist/api/common.d.ts.map +1 -1
- package/dist/api/common.js +10 -1
- package/dist/api/common.js.map +1 -1
- package/dist/api/image-description.d.ts +20 -0
- package/dist/api/image-description.d.ts.map +1 -0
- package/dist/api/image-description.js +77 -0
- package/dist/api/image-description.js.map +1 -0
- package/dist/audit.d.ts +17 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +53 -0
- package/dist/audit.js.map +1 -0
- package/dist/auth/auto-login.d.ts.map +1 -1
- package/dist/auth/auto-login.js +1 -3
- package/dist/auth/auto-login.js.map +1 -1
- package/dist/auth/interactive.d.ts.map +1 -1
- package/dist/auth/interactive.js +7 -8
- package/dist/auth/interactive.js.map +1 -1
- package/dist/auth/token-capture.d.ts.map +1 -1
- package/dist/auth/token-capture.js +62 -8
- package/dist/auth/token-capture.js.map +1 -1
- package/dist/browser-runtime.d.ts +11 -0
- package/dist/browser-runtime.d.ts.map +1 -1
- package/dist/browser-runtime.js +106 -0
- package/dist/browser-runtime.js.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/conversation-protection.d.ts +21 -0
- package/dist/conversation-protection.d.ts.map +1 -0
- package/dist/conversation-protection.js +47 -0
- package/dist/conversation-protection.js.map +1 -0
- package/dist/credential-store.d.ts.map +1 -1
- package/dist/credential-store.js +10 -2
- package/dist/credential-store.js.map +1 -1
- package/dist/emoji-map.d.ts.map +1 -1
- package/dist/emoji-map.js.map +1 -1
- package/dist/html-utils.d.ts +23 -3
- package/dist/html-utils.d.ts.map +1 -1
- package/dist/html-utils.js +34 -3
- package/dist/html-utils.js.map +1 -1
- package/dist/mcp-auth.d.ts +56 -0
- package/dist/mcp-auth.d.ts.map +1 -0
- package/dist/mcp-auth.js +207 -0
- package/dist/mcp-auth.js.map +1 -0
- package/dist/mcp-server.d.ts +1 -0
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +37 -213
- package/dist/mcp-server.js.map +1 -1
- package/dist/model-context-protocol-download-content.d.ts +7 -0
- package/dist/model-context-protocol-download-content.d.ts.map +1 -0
- package/dist/model-context-protocol-download-content.js +90 -0
- package/dist/model-context-protocol-download-content.js.map +1 -0
- package/dist/server-instructions.d.ts.map +1 -1
- package/dist/server-instructions.js +4 -0
- package/dist/server-instructions.js.map +1 -1
- package/dist/smart-login.d.ts.map +1 -1
- package/dist/smart-login.js +3 -3
- package/dist/smart-login.js.map +1 -1
- package/dist/teams-client.d.ts +20 -3
- package/dist/teams-client.d.ts.map +1 -1
- package/dist/teams-client.js +117 -29
- package/dist/teams-client.js.map +1 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +5 -1
- package/dist/telemetry.js.map +1 -1
- package/dist/token-store.d.ts.map +1 -1
- package/dist/token-store.js.map +1 -1
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +8 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildDownloadContentBlocks = buildDownloadContentBlocks;
|
|
4
|
+
exports.createDownloadOutputResults = createDownloadOutputResults;
|
|
5
|
+
const node_url_1 = require("node:url");
|
|
6
|
+
const TEXT_MIME_PREFIXES = [
|
|
7
|
+
"text/",
|
|
8
|
+
"application/json",
|
|
9
|
+
"application/xml",
|
|
10
|
+
"application/javascript",
|
|
11
|
+
"application/typescript",
|
|
12
|
+
"application/x-yaml",
|
|
13
|
+
"application/yaml",
|
|
14
|
+
"application/toml",
|
|
15
|
+
];
|
|
16
|
+
const TEXT_FILE_EXTENSIONS = new Set([
|
|
17
|
+
"md",
|
|
18
|
+
"txt",
|
|
19
|
+
"csv",
|
|
20
|
+
"tsv",
|
|
21
|
+
"json",
|
|
22
|
+
"xml",
|
|
23
|
+
"yaml",
|
|
24
|
+
"yml",
|
|
25
|
+
"toml",
|
|
26
|
+
"html",
|
|
27
|
+
"htm",
|
|
28
|
+
"css",
|
|
29
|
+
"js",
|
|
30
|
+
"ts",
|
|
31
|
+
"jsx",
|
|
32
|
+
"tsx",
|
|
33
|
+
"py",
|
|
34
|
+
"rb",
|
|
35
|
+
"sh",
|
|
36
|
+
"bash",
|
|
37
|
+
"zsh",
|
|
38
|
+
"ps1",
|
|
39
|
+
"bat",
|
|
40
|
+
"cmd",
|
|
41
|
+
"sql",
|
|
42
|
+
"graphql",
|
|
43
|
+
"svg",
|
|
44
|
+
"log",
|
|
45
|
+
"ini",
|
|
46
|
+
"cfg",
|
|
47
|
+
"conf",
|
|
48
|
+
"env",
|
|
49
|
+
"properties",
|
|
50
|
+
]);
|
|
51
|
+
function isTextContent(mimeType, fileName) {
|
|
52
|
+
const lowerMimeType = mimeType.toLowerCase();
|
|
53
|
+
if (TEXT_MIME_PREFIXES.some((prefix) => lowerMimeType.startsWith(prefix))) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
const extension = fileName.includes(".")
|
|
57
|
+
? fileName.split(".").pop()?.toLowerCase()
|
|
58
|
+
: undefined;
|
|
59
|
+
return extension !== undefined && TEXT_FILE_EXTENSIONS.has(extension);
|
|
60
|
+
}
|
|
61
|
+
function buildDownloadContentBlocks(downloads) {
|
|
62
|
+
const contentBlocks = [];
|
|
63
|
+
for (const download of downloads) {
|
|
64
|
+
if (download.contentType.toLowerCase().startsWith("image/")) {
|
|
65
|
+
contentBlocks.push({
|
|
66
|
+
type: "image",
|
|
67
|
+
data: download.data.toString("base64"),
|
|
68
|
+
mimeType: download.contentType,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else if (isTextContent(download.contentType, download.fileName)) {
|
|
72
|
+
contentBlocks.push({
|
|
73
|
+
type: "resource",
|
|
74
|
+
resource: {
|
|
75
|
+
uri: (0, node_url_1.pathToFileURL)(download.savedTo).toString(),
|
|
76
|
+
mimeType: download.contentType,
|
|
77
|
+
text: download.data.toString("utf-8"),
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return contentBlocks;
|
|
83
|
+
}
|
|
84
|
+
function createDownloadOutputResults(downloads) {
|
|
85
|
+
return downloads.map(({ data, ...download }) => ({
|
|
86
|
+
...download,
|
|
87
|
+
byteLength: data.byteLength,
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=model-context-protocol-download-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-context-protocol-download-content.js","sourceRoot":"","sources":["../src/model-context-protocol-download-content.ts"],"names":[],"mappings":";;AA+DA,gEAuBC;AAED,kEAOC;AA/FD,uCAAyC;AAIzC,MAAM,kBAAkB,GAAG;IACzB,OAAO;IACP,kBAAkB;IAClB,iBAAiB;IACjB,wBAAwB;IACxB,wBAA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AC;YAC5D,aAAa,CAAC,IAAI,CAAC;gBACjB,IAAI,EAAE,OAAgB;gBACtB,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACtC,QAAQ,EAAE,QAAQ,CAAC,WAAW;aAC/B,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,aAAa,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClE,aAAa,CAAC,IAAI,CAAC;gBACjB,IAAI,EAAE,UAAmB;gBACzB,QAAQ,EAAE;oBACR,GAAG,EAAE,IAAA,wBAAa,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE;oBAC/C,QAAQ,EAAE,QAAQ,CAAC,WAAW;oBAC9B,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;iBACtC;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAgB,2BAA2B,CACzC,SAA2B;IAE3B,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QAC/C,GAAG,QAAQ;QACX,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-instructions.d.ts","sourceRoot":"","sources":["../src/server-instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"server-instructions.d.ts","sourceRoot":"","sources":["../src/server-instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,kBAAkB,QAuDvB,CAAC"}
|
|
@@ -54,6 +54,10 @@ Call teams_find_people to search the organization directory by name. Call teams_
|
|
|
54
54
|
|
|
55
55
|
Call teams_get_transcript with chat: "Meeting Name" to retrieve the parsed transcript, or pass rawVtt: true for the original VTT file.
|
|
56
56
|
|
|
57
|
+
### Describe an inline image
|
|
58
|
+
|
|
59
|
+
Call teams_describe_image with chat/to/conversationId plus messageId to describe an inline Teams image, or pass amsObjectId directly if you already have it. The tool requires TEAMS_IMAGE_DESCRIPTION_API_KEY or OPENAI_API_KEY for an OpenAI-compatible vision endpoint.
|
|
60
|
+
|
|
57
61
|
## Important notes
|
|
58
62
|
|
|
59
63
|
- Most tools accept chat, to, or conversationId to identify a conversation. You only need one — the server resolves the rest automatically.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-instructions.js","sourceRoot":"","sources":["../src/server-instructions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEU,QAAA,kBAAkB,GAAG
|
|
1
|
+
{"version":3,"file":"server-instructions.js","sourceRoot":"","sources":["../src/server-instructions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEU,QAAA,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuDjC,CAAC,IAAI,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-login.d.ts","sourceRoot":"","sources":["../src/smart-login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"smart-login.d.ts","sourceRoot":"","sources":["../src/smart-login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAEV,UAAU,EACV,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAKpB,wBAAsB,yBAAyB,CAC7C,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,UAAU,CAAC,CA8BrB"}
|
package/dist/smart-login.js
CHANGED
|
@@ -15,9 +15,7 @@ const platform_js_1 = require("./platform.js");
|
|
|
15
15
|
const auto_login_js_1 = require("./auth/auto-login.js");
|
|
16
16
|
const interactive_js_1 = require("./auth/interactive.js");
|
|
17
17
|
async function acquireTokenViaSmartLogin(options) {
|
|
18
|
-
const log = options?.verbose
|
|
19
|
-
? console.error.bind(console)
|
|
20
|
-
: () => { };
|
|
18
|
+
const log = options?.log ?? (options?.verbose ? console.error.bind(console) : () => { });
|
|
21
19
|
// Try auto-login if prerequisites are met
|
|
22
20
|
if (options?.email && (0, platform_js_1.canAttemptAutoLogin)()) {
|
|
23
21
|
log("Auto-login prerequisites met (macOS + Chrome), attempting...");
|
|
@@ -27,6 +25,7 @@ async function acquireTokenViaSmartLogin(options) {
|
|
|
27
25
|
region: options.region,
|
|
28
26
|
headless: true,
|
|
29
27
|
verbose: options.verbose,
|
|
28
|
+
log,
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
catch (error) {
|
|
@@ -39,6 +38,7 @@ async function acquireTokenViaSmartLogin(options) {
|
|
|
39
38
|
region: options?.region,
|
|
40
39
|
email: options?.email,
|
|
41
40
|
verbose: options?.verbose,
|
|
41
|
+
log,
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=smart-login.js.map
|
package/dist/smart-login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-login.js","sourceRoot":"","sources":["../src/smart-login.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;
|
|
1
|
+
{"version":3,"file":"smart-login.js","sourceRoot":"","sources":["../src/smart-login.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAWH,8DAgCC;AApCD,+CAAoD;AACpD,wDAAgE;AAChE,0DAAwE;AAEjE,KAAK,UAAU,yBAAyB,CAC7C,OAA2B;IAE3B,MAAM,GAAG,GACP,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAE9E,0CAA0C;IAC1C,IAAI,OAAO,EAAE,KAAK,IAAI,IAAA,iCAAmB,GAAE,EAAE,CAAC;QAC5C,GAAG,CAAC,8DAA8D,CAAC,CAAC;QACpE,IAAI,CAAC;YACH,OAAO,MAAM,IAAA,wCAAwB,EAAC;gBACpC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,GAAG;aACJ,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CACD,sBAAuB,KAAe,CAAC,OAAO,wCAAwC,CACvF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,oDAAoD;IACpD,GAAG,CAAC,oCAAoC,CAAC,CAAC;IAC1C,OAAO,IAAA,gDAA+B,EAAC;QACrC,MAAM,EAAE,OAAO,EAAE,MAAM;QACvB,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,OAAO,EAAE,OAAO,EAAE,OAAO;QACzB,GAAG;KACJ,CAAC,CAAC;AACL,CAAC"}
|
package/dist/teams-client.d.ts
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* "optional-substrate-token",
|
|
30
30
|
* );
|
|
31
31
|
*/
|
|
32
|
-
import type { TeamsToken, AutoLoginOptions, InteractiveLoginOptions, ManualTokenOptions, SmartLoginOptions, Conversation, Message, MessageFormat, Member, SentMessage, EditedMessage, DeletedMessage, ReactionResult, ScheduledMessage, GetMessagesOptions, ListConversationsOptions, OneOnOneSearchResult, PersonSearchResult, ChatSearchResult, MessagesPage, TranscriptResult, MessageContentPart, FileSharingScope } from "./types.js";
|
|
32
|
+
import type { TeamsToken, AutoLoginOptions, InteractiveLoginOptions, ManualTokenOptions, SmartLoginOptions, Conversation, Message, MessageFormat, Member, SentMessage, EditedMessage, DeletedMessage, ReactionResult, ScheduledMessage, GetMessagesOptions, ListConversationsOptions, OneOnOneSearchResult, PersonSearchResult, ChatSearchResult, MessagesPage, TranscriptResult, MessageContentPart, FileSharingScope, ReplyCheckResult } from "./types.js";
|
|
33
33
|
export { acquireTokenViaAutoLogin } from "./auth/auto-login.js";
|
|
34
34
|
export { acquireTokenViaInteractiveLogin } from "./auth/interactive.js";
|
|
35
35
|
export { acquireTokenViaDebugSession } from "./auth/debug-session.js";
|
|
@@ -44,6 +44,8 @@ export { searchPeople, searchChats } from "./api/substrate.js";
|
|
|
44
44
|
export { fetchTranscript, fetchTranscriptVtt, parseVtt, extractTranscriptUrl, extractMeetingTitle, isSuccessfulRecording, } from "./api/transcripts.js";
|
|
45
45
|
export { fetchAmsImage, uploadAmsImage, buildAmsImageTag, parseInlineImages, parseFileAttachments, uploadSharePointFile, buildFilesPropertyJson, createSharePointSharingLink, } from "./api/attachments.js";
|
|
46
46
|
export type { SharePointUploadResult } from "./api/attachments.js";
|
|
47
|
+
export { describeImageWithOpenAiCompatibleVision } from "./api/image-description.js";
|
|
48
|
+
export type { DescribeImageOptions, ImageDescriptionResult, } from "./api/image-description.js";
|
|
47
49
|
export { saveToken, loadToken, clearToken } from "./token-store.js";
|
|
48
50
|
export { actions } from "./actions/definitions.js";
|
|
49
51
|
export { formatOutput } from "./actions/formatters.js";
|
|
@@ -211,7 +213,14 @@ export declare class TeamsClient {
|
|
|
211
213
|
* The `subject` parameter sets the post title, which is displayed prominently
|
|
212
214
|
* above the message body in channel posts.
|
|
213
215
|
*/
|
|
214
|
-
sendMessage(conversationId: string, content: string, format?: MessageFormat, amsReferences?: string[], subject?: string): Promise<SentMessage>;
|
|
216
|
+
sendMessage(conversationId: string, content: string, format?: MessageFormat, amsReferences?: string[], subject?: string, quoteMessageId?: string): Promise<SentMessage>;
|
|
217
|
+
/**
|
|
218
|
+
* Check whether a message has thread replies.
|
|
219
|
+
*
|
|
220
|
+
* Fetches a small batch of messages from the thread context and filters out
|
|
221
|
+
* the root message and system events to determine if real replies exist.
|
|
222
|
+
*/
|
|
223
|
+
checkForReplies(conversationId: string, messageId: string): Promise<ReplyCheckResult>;
|
|
215
224
|
/**
|
|
216
225
|
* Edit an existing message in a conversation.
|
|
217
226
|
*
|
|
@@ -220,7 +229,15 @@ export declare class TeamsClient {
|
|
|
220
229
|
* - `"markdown"` (default) — converted from Markdown to HTML
|
|
221
230
|
* - `"html"` — raw HTML, sent as-is
|
|
222
231
|
*/
|
|
223
|
-
editMessage(conversationId: string, messageId: string, content: string, format?: MessageFormat): Promise<EditedMessage>;
|
|
232
|
+
editMessage(conversationId: string, messageId: string, content: string, format?: MessageFormat, quoteMessageId?: string): Promise<EditedMessage>;
|
|
233
|
+
/**
|
|
234
|
+
* Look up a message in a conversation and build quote HTML for it.
|
|
235
|
+
*
|
|
236
|
+
* Fetches up to 200 recent messages (newest-first) to find the target.
|
|
237
|
+
* Since quotes typically reference recent messages, this handles the
|
|
238
|
+
* common case efficiently with a single page fetch.
|
|
239
|
+
*/
|
|
240
|
+
private buildQuoteHtmlForMessage;
|
|
224
241
|
/** Delete a message from a conversation. */
|
|
225
242
|
deleteMessage(conversationId: string, messageId: string): Promise<DeletedMessage>;
|
|
226
243
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"teams-client.d.ts","sourceRoot":"","sources":["../src/teams-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,aAAa,EACb,MAAM,EACN,WAAW,EACX,aAAa,EACb,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAGhB,kBAAkB,EAClB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"teams-client.d.ts","sourceRoot":"","sources":["../src/teams-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,aAAa,EACb,MAAM,EACN,WAAW,EACX,aAAa,EACb,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAGhB,kBAAkB,EAClB,gBAAgB,EAEhB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AA2EpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,aAAa,EACb,MAAM,EACN,WAAW,EACX,aAAa,EACb,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;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;;;;;OAKG;IACG,aAAa,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAMtE;;OAEG;YACW,mBAAmB;IASjC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA4BjC;;OAEG;IACG,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC;YAMpC,0BAA0B;IA6DxC;;;;;OAKG;YACW,YAAY;IAkC1B;;;;;;OAMG;YACW,gBAAgB;CAc/B"}
|
package/dist/teams-client.js
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* );
|
|
32
32
|
*/
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.TeamsClient = exports.formatOutput = exports.actions = exports.clearToken = exports.loadToken = exports.saveToken = exports.createSharePointSharingLink = exports.buildFilesPropertyJson = exports.uploadSharePointFile = exports.parseFileAttachments = exports.parseInlineImages = exports.buildAmsImageTag = exports.uploadAmsImage = exports.fetchAmsImage = exports.isSuccessfulRecording = exports.extractMeetingTitle = exports.extractTranscriptUrl = exports.parseVtt = exports.fetchTranscriptVtt = exports.fetchTranscript = exports.searchChats = exports.searchPeople = exports.fetchProfiles = exports.ApiRateLimitError = exports.ApiAuthError = exports.parseRawMessage = exports.isTextMessageType = exports.SYSTEM_STREAM_TYPES = exports.acquireTokenViaSmartLogin = exports.acquireTokenViaDebugSession = exports.acquireTokenViaInteractiveLogin = exports.acquireTokenViaAutoLogin = void 0;
|
|
34
|
+
exports.TeamsClient = exports.formatOutput = exports.actions = exports.clearToken = exports.loadToken = exports.saveToken = exports.describeImageWithOpenAiCompatibleVision = exports.createSharePointSharingLink = exports.buildFilesPropertyJson = exports.uploadSharePointFile = exports.parseFileAttachments = exports.parseInlineImages = exports.buildAmsImageTag = exports.uploadAmsImage = exports.fetchAmsImage = exports.isSuccessfulRecording = exports.extractMeetingTitle = exports.extractTranscriptUrl = exports.parseVtt = exports.fetchTranscriptVtt = exports.fetchTranscript = exports.searchChats = exports.searchPeople = exports.fetchProfiles = exports.ApiRateLimitError = exports.ApiAuthError = exports.parseRawMessage = exports.isTextMessageType = exports.SYSTEM_STREAM_TYPES = exports.acquireTokenViaSmartLogin = exports.acquireTokenViaDebugSession = exports.acquireTokenViaInteractiveLogin = exports.acquireTokenViaAutoLogin = void 0;
|
|
35
35
|
const types_js_1 = require("./types.js");
|
|
36
36
|
const constants_js_1 = require("./constants.js");
|
|
37
37
|
const chat_service_js_1 = require("./api/chat-service.js");
|
|
@@ -40,6 +40,8 @@ const emoji_map_js_1 = require("./emoji-map.js");
|
|
|
40
40
|
const middle_tier_js_1 = require("./api/middle-tier.js");
|
|
41
41
|
const substrate_js_1 = require("./api/substrate.js");
|
|
42
42
|
const transcripts_js_1 = require("./api/transcripts.js");
|
|
43
|
+
const html_utils_js_1 = require("./html-utils.js");
|
|
44
|
+
const formatters_js_1 = require("./actions/formatters.js");
|
|
43
45
|
const attachments_js_1 = require("./api/attachments.js");
|
|
44
46
|
const auto_login_js_1 = require("./auth/auto-login.js");
|
|
45
47
|
const interactive_js_1 = require("./auth/interactive.js");
|
|
@@ -64,6 +66,18 @@ function extractEmailFromToken(token) {
|
|
|
64
66
|
return undefined;
|
|
65
67
|
}
|
|
66
68
|
}
|
|
69
|
+
function extractObjectIdFromToken(token) {
|
|
70
|
+
const bearerToken = token.bearerToken;
|
|
71
|
+
if (!bearerToken)
|
|
72
|
+
return undefined;
|
|
73
|
+
try {
|
|
74
|
+
const payload = JSON.parse(Buffer.from(bearerToken.split(".")[1], "base64").toString("utf-8"));
|
|
75
|
+
return payload.oid ?? undefined;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
67
81
|
var auto_login_js_2 = require("./auth/auto-login.js");
|
|
68
82
|
Object.defineProperty(exports, "acquireTokenViaAutoLogin", { enumerable: true, get: function () { return auto_login_js_2.acquireTokenViaAutoLogin; } });
|
|
69
83
|
var interactive_js_2 = require("./auth/interactive.js");
|
|
@@ -102,14 +116,16 @@ Object.defineProperty(exports, "parseFileAttachments", { enumerable: true, get:
|
|
|
102
116
|
Object.defineProperty(exports, "uploadSharePointFile", { enumerable: true, get: function () { return attachments_js_2.uploadSharePointFile; } });
|
|
103
117
|
Object.defineProperty(exports, "buildFilesPropertyJson", { enumerable: true, get: function () { return attachments_js_2.buildFilesPropertyJson; } });
|
|
104
118
|
Object.defineProperty(exports, "createSharePointSharingLink", { enumerable: true, get: function () { return attachments_js_2.createSharePointSharingLink; } });
|
|
119
|
+
var image_description_js_1 = require("./api/image-description.js");
|
|
120
|
+
Object.defineProperty(exports, "describeImageWithOpenAiCompatibleVision", { enumerable: true, get: function () { return image_description_js_1.describeImageWithOpenAiCompatibleVision; } });
|
|
105
121
|
var token_store_js_2 = require("./token-store.js");
|
|
106
122
|
Object.defineProperty(exports, "saveToken", { enumerable: true, get: function () { return token_store_js_2.saveToken; } });
|
|
107
123
|
Object.defineProperty(exports, "loadToken", { enumerable: true, get: function () { return token_store_js_2.loadToken; } });
|
|
108
124
|
Object.defineProperty(exports, "clearToken", { enumerable: true, get: function () { return token_store_js_2.clearToken; } });
|
|
109
125
|
var definitions_js_1 = require("./actions/definitions.js");
|
|
110
126
|
Object.defineProperty(exports, "actions", { enumerable: true, get: function () { return definitions_js_1.actions; } });
|
|
111
|
-
var
|
|
112
|
-
Object.defineProperty(exports, "formatOutput", { enumerable: true, get: function () { return
|
|
127
|
+
var formatters_js_2 = require("./actions/formatters.js");
|
|
128
|
+
Object.defineProperty(exports, "formatOutput", { enumerable: true, get: function () { return formatters_js_2.formatOutput; } });
|
|
113
129
|
/**
|
|
114
130
|
* Extract the MRI suffix from a sender URL or return the input unchanged.
|
|
115
131
|
* API messages use full URLs (e.g. ".../contacts/8:orgid:uuid"),
|
|
@@ -183,7 +199,7 @@ class TeamsClient {
|
|
|
183
199
|
* Token lifetime is ~24 hours. Cached tokens are reused within 23 hours.
|
|
184
200
|
*/
|
|
185
201
|
static async create(options) {
|
|
186
|
-
const log = options.verbose ? console.error.bind(console) : () => { };
|
|
202
|
+
const log = options.log ?? (options.verbose ? console.error.bind(console) : () => { });
|
|
187
203
|
const cachedToken = await (0, token_store_js_1.loadToken)(options.email);
|
|
188
204
|
if (cachedToken) {
|
|
189
205
|
// Re-authenticate if the cached token is missing substrate or bearer
|
|
@@ -237,7 +253,8 @@ class TeamsClient {
|
|
|
237
253
|
* until they expire (~23 hours).
|
|
238
254
|
*/
|
|
239
255
|
static async connect(options) {
|
|
240
|
-
const log = options?.
|
|
256
|
+
const log = options?.log ??
|
|
257
|
+
(options?.verbose ? console.error.bind(console) : () => { });
|
|
241
258
|
// Check for cached token — use email if provided, otherwise try the default account
|
|
242
259
|
const cacheKey = options?.email ?? DEFAULT_ACCOUNT;
|
|
243
260
|
const cachedToken = await (0, token_store_js_1.loadToken)(cacheKey);
|
|
@@ -662,19 +679,15 @@ class TeamsClient {
|
|
|
662
679
|
}
|
|
663
680
|
}
|
|
664
681
|
// Strategy 1: Substrate search API for people + chat lookup
|
|
665
|
-
let
|
|
682
|
+
let matchedPersonForConversation;
|
|
666
683
|
try {
|
|
667
684
|
const people = await (0, substrate_js_1.searchPeople)(this.token, personName, 5);
|
|
668
685
|
const matchedPerson = people.find((person) => person.displayName.toLowerCase().includes(targetLower));
|
|
669
686
|
if (matchedPerson) {
|
|
670
|
-
// Validate MRI early
|
|
671
|
-
//
|
|
687
|
+
// Validate MRI early because both conversation lookup and virtual ID
|
|
688
|
+
// construction require an organization user UUID.
|
|
672
689
|
if (/^8:orgid:[0-9a-f-]+$/i.test(matchedPerson.mri)) {
|
|
673
|
-
|
|
674
|
-
// set before the chat search so that a searchChats failure (5xx /
|
|
675
|
-
// network error) doesn't silently prevent us from falling back to
|
|
676
|
-
// the idempotent create call further below.
|
|
677
|
-
matchedPersonForCreation = matchedPerson;
|
|
690
|
+
matchedPersonForConversation = matchedPerson;
|
|
678
691
|
}
|
|
679
692
|
// Try to find an existing chat via Substrate search.
|
|
680
693
|
let chatSearchResults = [];
|
|
@@ -698,8 +711,7 @@ class TeamsClient {
|
|
|
698
711
|
}
|
|
699
712
|
}
|
|
700
713
|
// Check if any conversation ID contains the person's UUID.
|
|
701
|
-
// This only covers the 100 most-recent conversations
|
|
702
|
-
// that no longer appear here are handled by createOneOnOneConversation.
|
|
714
|
+
// This only covers the 100 most-recent conversations.
|
|
703
715
|
const personUuid = matchedPerson.mri.replace("8:orgid:", "");
|
|
704
716
|
const matchingConversation = conversations.find((conversation) => conversation.id.includes(personUuid) &&
|
|
705
717
|
conversation.threadType === "chat");
|
|
@@ -719,7 +731,7 @@ class TeamsClient {
|
|
|
719
731
|
}
|
|
720
732
|
// Fallback person discovery: scan group chat members and resolve
|
|
721
733
|
// via profiles when Substrate search is unavailable.
|
|
722
|
-
if (!
|
|
734
|
+
if (!matchedPersonForConversation) {
|
|
723
735
|
try {
|
|
724
736
|
const memberMris = new Set();
|
|
725
737
|
// Extract UUIDs from 1:1 conversation IDs
|
|
@@ -761,7 +773,7 @@ class TeamsClient {
|
|
|
761
773
|
const matchedProfile = profiles.find((profile) => profile.displayName.toLowerCase().includes(targetLower));
|
|
762
774
|
if (matchedProfile &&
|
|
763
775
|
/^8:orgid:[0-9a-f-]+$/i.test(matchedProfile.mri)) {
|
|
764
|
-
|
|
776
|
+
matchedPersonForConversation = {
|
|
765
777
|
displayName: matchedProfile.displayName,
|
|
766
778
|
mri: matchedProfile.mri,
|
|
767
779
|
};
|
|
@@ -785,14 +797,46 @@ class TeamsClient {
|
|
|
785
797
|
// Profile-based fallback failed — continue to other strategies
|
|
786
798
|
}
|
|
787
799
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
800
|
+
if (matchedPersonForConversation) {
|
|
801
|
+
const currentUserObjectId = extractObjectIdFromToken(this.token);
|
|
802
|
+
if (currentUserObjectId) {
|
|
803
|
+
const matchedPersonMri = matchedPersonForConversation.mri;
|
|
804
|
+
const matchedPersonObjectId = matchedPersonMri.replace("8:orgid:", "");
|
|
805
|
+
const candidateConversationIds = [
|
|
806
|
+
`19:${currentUserObjectId}_${matchedPersonObjectId}@unq.gbl.spaces`,
|
|
807
|
+
`19:${matchedPersonObjectId}_${currentUserObjectId}@unq.gbl.spaces`,
|
|
808
|
+
];
|
|
809
|
+
for (const candidateConversationId of candidateConversationIds) {
|
|
810
|
+
try {
|
|
811
|
+
const members = await (0, chat_service_js_1.fetchMembers)(this.token, candidateConversationId);
|
|
812
|
+
if (members.some((member) => member.id.toLowerCase() === matchedPersonMri.toLowerCase())) {
|
|
813
|
+
return {
|
|
814
|
+
conversationId: candidateConversationId,
|
|
815
|
+
memberDisplayName: matchedPersonForConversation.displayName,
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
catch (error) {
|
|
820
|
+
if (error instanceof common_js_1.ApiResponseError &&
|
|
821
|
+
error.statusCode === 404) {
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
throw error;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
// New 1:1 chats use a deterministic virtual ID. Teams persists the
|
|
830
|
+
// conversation when its first message is sent.
|
|
831
|
+
if (matchedPersonForConversation) {
|
|
832
|
+
const currentUserObjectId = extractObjectIdFromToken(this.token);
|
|
833
|
+
if (currentUserObjectId) {
|
|
834
|
+
const targetUserObjectId = matchedPersonForConversation.mri.replace("8:orgid:", "");
|
|
835
|
+
return {
|
|
836
|
+
conversationId: `19:${currentUserObjectId}_${targetUserObjectId}@unq.gbl.spaces`,
|
|
837
|
+
memberDisplayName: matchedPersonForConversation.displayName,
|
|
838
|
+
};
|
|
839
|
+
}
|
|
796
840
|
}
|
|
797
841
|
// Strategy 2: Profile-based matching for 1:1 chats (uses Bearer token)
|
|
798
842
|
{
|
|
@@ -1006,10 +1050,30 @@ class TeamsClient {
|
|
|
1006
1050
|
* The `subject` parameter sets the post title, which is displayed prominently
|
|
1007
1051
|
* above the message body in channel posts.
|
|
1008
1052
|
*/
|
|
1009
|
-
async sendMessage(conversationId, content, format = "markdown", amsReferences = [], subject) {
|
|
1053
|
+
async sendMessage(conversationId, content, format = "markdown", amsReferences = [], subject, quoteMessageId) {
|
|
1010
1054
|
return this.withTokenRefresh(async () => {
|
|
1011
1055
|
const displayName = await this.getCurrentUserDisplayName();
|
|
1012
|
-
|
|
1056
|
+
const quoteHtml = quoteMessageId
|
|
1057
|
+
? await this.buildQuoteHtmlForMessage(conversationId, quoteMessageId)
|
|
1058
|
+
: undefined;
|
|
1059
|
+
return (0, chat_service_js_1.postMessage)(this.token, conversationId, content, displayName, format, amsReferences, undefined, subject, quoteHtml);
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Check whether a message has thread replies.
|
|
1064
|
+
*
|
|
1065
|
+
* Fetches a small batch of messages from the thread context and filters out
|
|
1066
|
+
* the root message and system events to determine if real replies exist.
|
|
1067
|
+
*/
|
|
1068
|
+
async checkForReplies(conversationId, messageId) {
|
|
1069
|
+
return this.withTokenRefresh(async () => {
|
|
1070
|
+
const threadConversationId = `${conversationId};messageid=${messageId}`;
|
|
1071
|
+
const messages = await this.getMessages(threadConversationId, {
|
|
1072
|
+
limit: 50,
|
|
1073
|
+
pageSize: 50,
|
|
1074
|
+
});
|
|
1075
|
+
const replies = messages.filter((message) => message.id !== messageId && !message.isDeleted);
|
|
1076
|
+
return { hasReplies: replies.length > 0, replyCount: replies.length };
|
|
1013
1077
|
});
|
|
1014
1078
|
}
|
|
1015
1079
|
/**
|
|
@@ -1020,10 +1084,34 @@ class TeamsClient {
|
|
|
1020
1084
|
* - `"markdown"` (default) — converted from Markdown to HTML
|
|
1021
1085
|
* - `"html"` — raw HTML, sent as-is
|
|
1022
1086
|
*/
|
|
1023
|
-
async editMessage(conversationId, messageId, content, format = "markdown") {
|
|
1087
|
+
async editMessage(conversationId, messageId, content, format = "markdown", quoteMessageId) {
|
|
1024
1088
|
return this.withTokenRefresh(async () => {
|
|
1025
1089
|
const displayName = await this.getCurrentUserDisplayName();
|
|
1026
|
-
|
|
1090
|
+
const quoteHtml = quoteMessageId
|
|
1091
|
+
? await this.buildQuoteHtmlForMessage(conversationId, quoteMessageId)
|
|
1092
|
+
: undefined;
|
|
1093
|
+
return (0, chat_service_js_1.editMessage)(this.token, conversationId, messageId, content, displayName, format, quoteHtml);
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Look up a message in a conversation and build quote HTML for it.
|
|
1098
|
+
*
|
|
1099
|
+
* Fetches up to 200 recent messages (newest-first) to find the target.
|
|
1100
|
+
* Since quotes typically reference recent messages, this handles the
|
|
1101
|
+
* common case efficiently with a single page fetch.
|
|
1102
|
+
*/
|
|
1103
|
+
async buildQuoteHtmlForMessage(conversationId, quoteMessageId) {
|
|
1104
|
+
const messages = await this.getMessages(conversationId, { limit: 200 });
|
|
1105
|
+
const target = messages.find((message) => message.id === quoteMessageId);
|
|
1106
|
+
if (!target) {
|
|
1107
|
+
throw new Error(`Could not find message ${quoteMessageId} in conversation ${conversationId} (searched 200 most recent messages)`);
|
|
1108
|
+
}
|
|
1109
|
+
const previewText = (0, formatters_js_1.cleanContent)(target.content);
|
|
1110
|
+
return (0, html_utils_js_1.buildQuoteHtml)({
|
|
1111
|
+
messageId: quoteMessageId,
|
|
1112
|
+
senderMri: target.senderMri,
|
|
1113
|
+
senderDisplayName: target.senderDisplayName || "(unknown)",
|
|
1114
|
+
previewText,
|
|
1027
1115
|
});
|
|
1028
1116
|
}
|
|
1029
1117
|
/** Delete a message from a conversation. */
|