teams-api-mcp 0.1.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/LICENSE +21 -0
- package/README.md +406 -0
- package/SKILL.md +130 -0
- package/dist/actions.d.ts +49 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +842 -0
- package/dist/actions.js.map +1 -0
- package/dist/api.d.ts +111 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +630 -0
- package/dist/api.js.map +1 -0
- package/dist/auth.d.ts +53 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +479 -0
- package/dist/auth.js.map +1 -0
- package/dist/cli.d.ts +13 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +178 -0
- package/dist/cli.js.map +1 -0
- package/dist/mcp-server.d.ts +35 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +144 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/teams-client.d.ts +197 -0
- package/dist/teams-client.d.ts.map +1 -0
- package/dist/teams-client.js +545 -0
- package/dist/teams-client.js.map +1 -0
- package/dist/token-store.d.ts +14 -0
- package/dist/token-store.d.ts.map +1 -0
- package/dist/token-store.js +79 -0
- package/dist/token-store.js.map +1 -0
- package/dist/types.d.ts +245 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/package.json +69 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* teams-api CLI
|
|
5
|
+
*
|
|
6
|
+
* Thin adapter that maps unified action definitions to CLI commands.
|
|
7
|
+
* All commands, parameters, descriptions, and execution logic come
|
|
8
|
+
* from `src/actions.ts` — the single source of truth.
|
|
9
|
+
*
|
|
10
|
+
* Special commands (auth, logout) are defined here directly since
|
|
11
|
+
* they handle authentication rather than Teams data operations.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const node_fs_1 = require("node:fs");
|
|
15
|
+
const node_path_1 = require("node:path");
|
|
16
|
+
const commander_1 = require("commander");
|
|
17
|
+
const teams_client_js_1 = require("./teams-client.js");
|
|
18
|
+
const actions_js_1 = require("./actions.js");
|
|
19
|
+
const VALID_FORMATS = ["json", "text", "md", "toon"];
|
|
20
|
+
const program = new commander_1.Command();
|
|
21
|
+
program
|
|
22
|
+
.name("teams-api")
|
|
23
|
+
.description("AI-native Microsoft Teams integration CLI")
|
|
24
|
+
.version("0.1.0");
|
|
25
|
+
function addAuthOptions(command) {
|
|
26
|
+
return command
|
|
27
|
+
.option("--auto", "Auto-acquire token via FIDO2 passkey (macOS)")
|
|
28
|
+
.option("--login", "Interactive browser login (all platforms, no FIDO2 needed)")
|
|
29
|
+
.option("--email <email>", "Corporate email (required with --auto, optional with --login)")
|
|
30
|
+
.option("--token <token>", "Use an existing skype token directly")
|
|
31
|
+
.option("--bearer-token <token>", "Optional middle-tier bearer token for profile/member resolution")
|
|
32
|
+
.option("--substrate-token <token>", "Optional Substrate bearer token for people/chat search")
|
|
33
|
+
.option("--debug-port <port>", "Chrome debug port for manual token capture", "9222")
|
|
34
|
+
.option("--region <region>", "API region", "apac");
|
|
35
|
+
}
|
|
36
|
+
async function createClient(flags) {
|
|
37
|
+
if (flags.token) {
|
|
38
|
+
return teams_client_js_1.TeamsClient.fromToken(flags.token, flags.region, flags.bearerToken, flags.substrateToken);
|
|
39
|
+
}
|
|
40
|
+
if (flags.auto) {
|
|
41
|
+
if (!flags.email) {
|
|
42
|
+
console.error("Error: --email is required when using --auto");
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
const autoLoginOptions = {
|
|
46
|
+
email: flags.email,
|
|
47
|
+
headless: true,
|
|
48
|
+
verbose: true,
|
|
49
|
+
};
|
|
50
|
+
return teams_client_js_1.TeamsClient.create(autoLoginOptions);
|
|
51
|
+
}
|
|
52
|
+
if (flags.login) {
|
|
53
|
+
const interactiveLoginOptions = {
|
|
54
|
+
region: flags.region,
|
|
55
|
+
email: flags.email,
|
|
56
|
+
verbose: true,
|
|
57
|
+
};
|
|
58
|
+
return teams_client_js_1.TeamsClient.fromInteractiveLogin(interactiveLoginOptions);
|
|
59
|
+
}
|
|
60
|
+
const manualOptions = {
|
|
61
|
+
debugPort: Number(flags.debugPort),
|
|
62
|
+
};
|
|
63
|
+
return teams_client_js_1.TeamsClient.fromDebugSession(manualOptions);
|
|
64
|
+
}
|
|
65
|
+
// ── Helpers ────────────────────────────────────────────────────────────
|
|
66
|
+
function camelToKebab(name) {
|
|
67
|
+
return name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
68
|
+
}
|
|
69
|
+
function coerceParameter(value, type) {
|
|
70
|
+
if (value === undefined)
|
|
71
|
+
return undefined;
|
|
72
|
+
switch (type) {
|
|
73
|
+
case "number":
|
|
74
|
+
return Number(value);
|
|
75
|
+
case "boolean":
|
|
76
|
+
return value === true || value === "true";
|
|
77
|
+
default:
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// ── Register actions as CLI commands ──────────────────────────────────
|
|
82
|
+
for (const action of actions_js_1.actions) {
|
|
83
|
+
const command = new commander_1.Command(action.name).description(action.description);
|
|
84
|
+
addAuthOptions(command);
|
|
85
|
+
for (const parameter of action.parameters) {
|
|
86
|
+
const flag = camelToKebab(parameter.name);
|
|
87
|
+
if (parameter.type === "boolean") {
|
|
88
|
+
if (parameter.default === true) {
|
|
89
|
+
// Default-true boolean: define --no-* to allow opting out.
|
|
90
|
+
// Commander auto-sets the value to true when --no-* is absent.
|
|
91
|
+
command.option(`--no-${flag}`, `Disable: ${parameter.description}`);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
command.option(`--${flag}`, parameter.description);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (parameter.required) {
|
|
98
|
+
command.requiredOption(`--${flag} <value>`, parameter.description);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
command.option(`--${flag} <value>`, parameter.description, parameter.default !== undefined ? String(parameter.default) : undefined);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
command.option("--format <format>", "Output format (json, text, md, toon)");
|
|
105
|
+
command.option("--output <file>", "Export output to file (default format: md)");
|
|
106
|
+
command.action(async (flags) => {
|
|
107
|
+
const client = await createClient(flags);
|
|
108
|
+
const actionParameters = {};
|
|
109
|
+
for (const parameter of action.parameters) {
|
|
110
|
+
actionParameters[parameter.name] = coerceParameter(flags[parameter.name], parameter.type);
|
|
111
|
+
}
|
|
112
|
+
// Inject progress callback for message fetching
|
|
113
|
+
if (action.name === "get-messages") {
|
|
114
|
+
actionParameters.onProgress = (count) => process.stderr.write(`\r ${count} messages fetched...`);
|
|
115
|
+
}
|
|
116
|
+
// Determine output format
|
|
117
|
+
const rawFormat = flags.format;
|
|
118
|
+
if (rawFormat && !VALID_FORMATS.includes(rawFormat)) {
|
|
119
|
+
console.error(`Error: Invalid format "${rawFormat}". Valid formats: ${VALID_FORMATS.join(", ")}`);
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
let outputFormat;
|
|
123
|
+
if (rawFormat) {
|
|
124
|
+
outputFormat = rawFormat;
|
|
125
|
+
}
|
|
126
|
+
else if (flags.output) {
|
|
127
|
+
outputFormat = "md";
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
outputFormat = "text";
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const result = await action.execute(client, actionParameters);
|
|
134
|
+
if (action.name === "get-messages") {
|
|
135
|
+
process.stderr.write("\n");
|
|
136
|
+
}
|
|
137
|
+
const output = (0, actions_js_1.formatOutput)(action, result, outputFormat);
|
|
138
|
+
if (flags.output) {
|
|
139
|
+
const outputPath = (0, node_path_1.resolve)(flags.output);
|
|
140
|
+
(0, node_fs_1.writeFileSync)(outputPath, output, "utf-8");
|
|
141
|
+
console.log(`Output written to ${outputPath}`);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
console.log(output);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
if (action.name === "get-messages") {
|
|
149
|
+
process.stderr.write("\n");
|
|
150
|
+
}
|
|
151
|
+
console.error(`Error: ${error.message}`);
|
|
152
|
+
process.exit(1);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
program.addCommand(command);
|
|
156
|
+
}
|
|
157
|
+
// ── auth command (special — creates a client, not a data operation) ───
|
|
158
|
+
addAuthOptions(program
|
|
159
|
+
.command("auth")
|
|
160
|
+
.description("Acquire a Teams token and print it to stdout")).action(async (flags) => {
|
|
161
|
+
const client = await createClient(flags);
|
|
162
|
+
const token = client.getToken();
|
|
163
|
+
console.log(JSON.stringify(token, null, 2));
|
|
164
|
+
});
|
|
165
|
+
// ── logout command (special — clears cached token) ────────────────────
|
|
166
|
+
program
|
|
167
|
+
.command("logout")
|
|
168
|
+
.description("Clear cached token from the macOS Keychain")
|
|
169
|
+
.requiredOption("--email <email>", "Email whose cached token to clear")
|
|
170
|
+
.action((flags) => {
|
|
171
|
+
teams_client_js_1.TeamsClient.clearCachedToken(flags.email);
|
|
172
|
+
console.log(`Cached token for ${flags.email} cleared.`);
|
|
173
|
+
});
|
|
174
|
+
program.parseAsync().catch((error) => {
|
|
175
|
+
console.error("Fatal error:", error.message);
|
|
176
|
+
process.exit(1);
|
|
177
|
+
});
|
|
178
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;;;;;;GASG;;AAEH,qCAAwC;AACxC,yCAAoC;AACpC,yCAAoC;AACpC,uDAAgD;AAChD,6CAAqD;AAQrD,MAAM,aAAa,GAAmB,CAA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AC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,CAAC,KAAK,WAAW,CAAC,CAAC;AAC1D,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;IAC1C,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env npx tsx
|
|
2
|
+
/**
|
|
3
|
+
* MCP Server for Teams API
|
|
4
|
+
*
|
|
5
|
+
* Thin adapter that maps unified action definitions to MCP tools.
|
|
6
|
+
* All tools, parameters, descriptions, and execution logic come
|
|
7
|
+
* from `src/actions.ts` — the single source of truth.
|
|
8
|
+
*
|
|
9
|
+
* Configuration:
|
|
10
|
+
* Set environment variables for authentication:
|
|
11
|
+
* TEAMS_TOKEN — Use an existing skype token
|
|
12
|
+
* TEAMS_BEARER_TOKEN — Optional middle-tier bearer token for profile resolution
|
|
13
|
+
* TEAMS_SUBSTRATE_TOKEN — Optional Substrate bearer token for people/chat search
|
|
14
|
+
* TEAMS_REGION — API region (default: "apac")
|
|
15
|
+
* TEAMS_EMAIL — Corporate email (for auto-login or interactive login)
|
|
16
|
+
* TEAMS_AUTO — Set to "true" to use auto-login (macOS + FIDO2)
|
|
17
|
+
* TEAMS_LOGIN — Set to "true" to use interactive browser login (all platforms)
|
|
18
|
+
* TEAMS_DEBUG_PORT — Chrome debug port (default: 9222)
|
|
19
|
+
*
|
|
20
|
+
* Usage in VS Code settings (mcp config):
|
|
21
|
+
* {
|
|
22
|
+
* "mcpServers": {
|
|
23
|
+
* "teams": {
|
|
24
|
+
* "command": "npx",
|
|
25
|
+
* "args": ["-y", "teams-api-mcp"],
|
|
26
|
+
* "env": {
|
|
27
|
+
* "TEAMS_AUTO": "true",
|
|
28
|
+
* "TEAMS_EMAIL": "user@company.com"
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
*/
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* MCP Server for Teams API
|
|
5
|
+
*
|
|
6
|
+
* Thin adapter that maps unified action definitions to MCP tools.
|
|
7
|
+
* All tools, parameters, descriptions, and execution logic come
|
|
8
|
+
* from `src/actions.ts` — the single source of truth.
|
|
9
|
+
*
|
|
10
|
+
* Configuration:
|
|
11
|
+
* Set environment variables for authentication:
|
|
12
|
+
* TEAMS_TOKEN — Use an existing skype token
|
|
13
|
+
* TEAMS_BEARER_TOKEN — Optional middle-tier bearer token for profile resolution
|
|
14
|
+
* TEAMS_SUBSTRATE_TOKEN — Optional Substrate bearer token for people/chat search
|
|
15
|
+
* TEAMS_REGION — API region (default: "apac")
|
|
16
|
+
* TEAMS_EMAIL — Corporate email (for auto-login or interactive login)
|
|
17
|
+
* TEAMS_AUTO — Set to "true" to use auto-login (macOS + FIDO2)
|
|
18
|
+
* TEAMS_LOGIN — Set to "true" to use interactive browser login (all platforms)
|
|
19
|
+
* TEAMS_DEBUG_PORT — Chrome debug port (default: 9222)
|
|
20
|
+
*
|
|
21
|
+
* Usage in VS Code settings (mcp config):
|
|
22
|
+
* {
|
|
23
|
+
* "mcpServers": {
|
|
24
|
+
* "teams": {
|
|
25
|
+
* "command": "npx",
|
|
26
|
+
* "args": ["-y", "teams-api-mcp"],
|
|
27
|
+
* "env": {
|
|
28
|
+
* "TEAMS_AUTO": "true",
|
|
29
|
+
* "TEAMS_EMAIL": "user@company.com"
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
*/
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
37
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
38
|
+
const zod_1 = require("zod");
|
|
39
|
+
const teams_client_js_1 = require("./teams-client.js");
|
|
40
|
+
const actions_js_1 = require("./actions.js");
|
|
41
|
+
let clientInstance = null;
|
|
42
|
+
async function getClient() {
|
|
43
|
+
if (clientInstance) {
|
|
44
|
+
return clientInstance;
|
|
45
|
+
}
|
|
46
|
+
const envToken = process.env.TEAMS_TOKEN;
|
|
47
|
+
const envBearerToken = process.env.TEAMS_BEARER_TOKEN;
|
|
48
|
+
const envSubstrateToken = process.env.TEAMS_SUBSTRATE_TOKEN;
|
|
49
|
+
const envRegion = process.env.TEAMS_REGION ?? "apac";
|
|
50
|
+
const envEmail = process.env.TEAMS_EMAIL;
|
|
51
|
+
const envAuto = process.env.TEAMS_AUTO === "true";
|
|
52
|
+
const envLogin = process.env.TEAMS_LOGIN === "true";
|
|
53
|
+
const envDebugPort = process.env.TEAMS_DEBUG_PORT
|
|
54
|
+
? Number(process.env.TEAMS_DEBUG_PORT)
|
|
55
|
+
: 9222;
|
|
56
|
+
if (envToken) {
|
|
57
|
+
clientInstance = teams_client_js_1.TeamsClient.fromToken(envToken, envRegion, envBearerToken, envSubstrateToken);
|
|
58
|
+
}
|
|
59
|
+
else if (envAuto && envEmail) {
|
|
60
|
+
clientInstance = await teams_client_js_1.TeamsClient.create({
|
|
61
|
+
email: envEmail,
|
|
62
|
+
headless: true,
|
|
63
|
+
verbose: false,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
else if (envLogin) {
|
|
67
|
+
clientInstance = await teams_client_js_1.TeamsClient.fromInteractiveLogin({
|
|
68
|
+
region: envRegion,
|
|
69
|
+
email: envEmail,
|
|
70
|
+
verbose: false,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
clientInstance = await teams_client_js_1.TeamsClient.fromDebugSession({
|
|
75
|
+
debugPort: envDebugPort,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return clientInstance;
|
|
79
|
+
}
|
|
80
|
+
function parameterToZod(parameter) {
|
|
81
|
+
let schema;
|
|
82
|
+
switch (parameter.type) {
|
|
83
|
+
case "string":
|
|
84
|
+
schema = zod_1.z.string();
|
|
85
|
+
break;
|
|
86
|
+
case "number":
|
|
87
|
+
schema = zod_1.z.number();
|
|
88
|
+
break;
|
|
89
|
+
case "boolean":
|
|
90
|
+
schema = zod_1.z.boolean();
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
schema = schema.describe(parameter.description);
|
|
94
|
+
if (!parameter.required) {
|
|
95
|
+
schema = schema.optional();
|
|
96
|
+
}
|
|
97
|
+
return schema;
|
|
98
|
+
}
|
|
99
|
+
const server = new mcp_js_1.McpServer({
|
|
100
|
+
name: "teams-api",
|
|
101
|
+
version: "0.1.0",
|
|
102
|
+
});
|
|
103
|
+
// ── Register all actions as MCP tools ─────────────────────────────────
|
|
104
|
+
for (const action of actions_js_1.actions) {
|
|
105
|
+
const toolName = `teams_${action.name.replace(/-/g, "_")}`;
|
|
106
|
+
const inputSchema = {};
|
|
107
|
+
for (const parameter of action.parameters) {
|
|
108
|
+
inputSchema[parameter.name] = parameterToZod(parameter);
|
|
109
|
+
}
|
|
110
|
+
inputSchema["format"] = zod_1.z
|
|
111
|
+
.enum(["json", "text", "md", "toon"])
|
|
112
|
+
.describe("Output format (default: toon)")
|
|
113
|
+
.optional();
|
|
114
|
+
server.registerTool(toolName, {
|
|
115
|
+
title: action.title,
|
|
116
|
+
description: action.description,
|
|
117
|
+
inputSchema,
|
|
118
|
+
}, async (parameters) => {
|
|
119
|
+
const client = await getClient();
|
|
120
|
+
const outputFormat = parameters.format ?? "toon";
|
|
121
|
+
const result = await action.execute(client, parameters);
|
|
122
|
+
const structuredContent = result !== null && typeof result === "object" && !Array.isArray(result)
|
|
123
|
+
? result
|
|
124
|
+
: { data: result };
|
|
125
|
+
return {
|
|
126
|
+
content: [
|
|
127
|
+
{
|
|
128
|
+
type: "text",
|
|
129
|
+
text: (0, actions_js_1.formatOutput)(action, result, outputFormat),
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
structuredContent,
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async function main() {
|
|
137
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
138
|
+
await server.connect(transport);
|
|
139
|
+
}
|
|
140
|
+
main().catch((error) => {
|
|
141
|
+
console.error("MCP server error:", error.message);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
});
|
|
144
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;AAEH,oEAAoE;AACpE,wEAAiF;AACjF,6BAAwB;AACxB,uDAAgD;AAChD,6CAAqD;AAGrD,IAAI,cAAc,GAAuB,IAAI,CAAC;AAE9C,KAAK,UAAU,SAAS;IACtB,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IACzC,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IACtD,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAC5D,MAAM,SAAS,GAAG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AM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,MAAM,YAAY,GAAI,UAAU,CAAC,MAAuB,IAAI,MAAM,CAAC;QACnE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CACjC,MAAM,EACN,UAAqC,CACtC,CAAC;QAEF,MAAM,iBAAiB,GACrB,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YACrE,CAAC,CAAE,MAAkC;YACrC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAEvB,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAA,yBAAY,EAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC;iBACjD;aACF;YACD,iBAAiB;SAClB,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TeamsClient — the public API for interacting with Microsoft Teams.
|
|
3
|
+
*
|
|
4
|
+
* This is the primary entry point for the teams-api package.
|
|
5
|
+
* It wraps authentication, conversation listing, message reading/sending,
|
|
6
|
+
* and member management behind a clean, strongly-typed interface.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Auto-login (macOS with FIDO2 passkey)
|
|
10
|
+
* const client = await TeamsClient.fromAutoLogin({
|
|
11
|
+
* email: "user@company.com",
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* // List conversations
|
|
15
|
+
* const conversations = await client.listConversations();
|
|
16
|
+
*
|
|
17
|
+
* // Read messages
|
|
18
|
+
* const messages = await client.getMessages(conversations[0].id);
|
|
19
|
+
*
|
|
20
|
+
* // Send a message
|
|
21
|
+
* await client.sendMessage(conversations[0].id, "Hello from the API!");
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // From an existing token
|
|
25
|
+
* const client = TeamsClient.fromToken(
|
|
26
|
+
* "skype-token-here",
|
|
27
|
+
* "apac",
|
|
28
|
+
* "optional-bearer-token",
|
|
29
|
+
* "optional-substrate-token",
|
|
30
|
+
* );
|
|
31
|
+
*/
|
|
32
|
+
import type { TeamsToken, AutoLoginOptions, InteractiveLoginOptions, ManualTokenOptions, Conversation, Message, MessageFormat, Member, SentMessage, GetMessagesOptions, ListConversationsOptions, OneOnOneSearchResult, PersonSearchResult, ChatSearchResult, MessagesPage, TranscriptResult } from "./types.js";
|
|
33
|
+
export { acquireTokenViaAutoLogin, acquireTokenViaInteractiveLogin, acquireTokenViaDebugSession, } from "./auth.js";
|
|
34
|
+
export type { TeamsToken, AutoLoginOptions, InteractiveLoginOptions, ManualTokenOptions, Conversation, Message, MessageFormat, Member, SentMessage, GetMessagesOptions, ListConversationsOptions, OneOnOneSearchResult, MessagesPage, Mention, Reaction, UserProfile, PersonSearchResult, ChatSearchResult, TranscriptEntry, TranscriptResult, } from "./types.js";
|
|
35
|
+
export { SYSTEM_STREAM_TYPES } from "./types.js";
|
|
36
|
+
export { parseRawMessage, ApiAuthError, ApiRateLimitError, fetchProfiles, searchPeople, searchChats, fetchTranscript, fetchTranscriptVtt, parseVtt, extractTranscriptUrl, extractMeetingTitle, isSuccessfulRecording, } from "./api.js";
|
|
37
|
+
export { saveToken, loadToken, clearToken } from "./token-store.js";
|
|
38
|
+
export { actions, formatOutput } from "./actions.js";
|
|
39
|
+
export type { ActionDefinition, ActionParameter, OutputFormat, } from "./actions.js";
|
|
40
|
+
export declare class TeamsClient {
|
|
41
|
+
private token;
|
|
42
|
+
private autoLoginOptions;
|
|
43
|
+
private cachedDisplayName;
|
|
44
|
+
private constructor();
|
|
45
|
+
/**
|
|
46
|
+
* Create a client with secure token caching and automatic refresh.
|
|
47
|
+
*
|
|
48
|
+
* This is the recommended entry point. It:
|
|
49
|
+
* 1. Checks the macOS Keychain for a cached, non-expired token
|
|
50
|
+
* 2. If none found, launches auto-login to acquire a fresh token
|
|
51
|
+
* 3. Saves the token to the Keychain for future use
|
|
52
|
+
* 4. Automatically re-acquires the token if a 401 occurs mid-session
|
|
53
|
+
*
|
|
54
|
+
* Token lifetime is ~24 hours. Cached tokens are reused within 23 hours.
|
|
55
|
+
*/
|
|
56
|
+
static create(options: AutoLoginOptions): Promise<TeamsClient>;
|
|
57
|
+
/**
|
|
58
|
+
* Create a client by automatically logging in via FIDO2 passkey.
|
|
59
|
+
*
|
|
60
|
+
* Launches system Chrome with a fresh profile, completes the Microsoft
|
|
61
|
+
* Entra ID FIDO2 login flow using a platform authenticator, and
|
|
62
|
+
* captures the skype token. Zero user interaction required.
|
|
63
|
+
*/
|
|
64
|
+
static fromAutoLogin(options: AutoLoginOptions): Promise<TeamsClient>;
|
|
65
|
+
/**
|
|
66
|
+
* Create a client by connecting to a running Chrome debug session.
|
|
67
|
+
*
|
|
68
|
+
* Requires Chrome started with --remote-debugging-port and Teams
|
|
69
|
+
* already open and authenticated.
|
|
70
|
+
*/
|
|
71
|
+
static fromDebugSession(options?: ManualTokenOptions): Promise<TeamsClient>;
|
|
72
|
+
/**
|
|
73
|
+
* Create a client via interactive browser login.
|
|
74
|
+
*
|
|
75
|
+
* Opens a visible Chromium window where the user manually logs into
|
|
76
|
+
* Teams. Works on all platforms (macOS, Windows, Linux) without
|
|
77
|
+
* requiring FIDO2 passkeys or system Chrome.
|
|
78
|
+
*/
|
|
79
|
+
static fromInteractiveLogin(options?: InteractiveLoginOptions): Promise<TeamsClient>;
|
|
80
|
+
/**
|
|
81
|
+
* Create a client from an existing token bundle.
|
|
82
|
+
*
|
|
83
|
+
* `bearerToken` enables profile/member resolution and `substrateToken`
|
|
84
|
+
* enables reliable people/chat search. Both are optional; basic chat
|
|
85
|
+
* operations only require `skypeToken`.
|
|
86
|
+
*/
|
|
87
|
+
static fromToken(skypeToken: string, region?: string, bearerToken?: string, substrateToken?: string): TeamsClient;
|
|
88
|
+
/**
|
|
89
|
+
* Clear a cached token from the macOS Keychain.
|
|
90
|
+
*
|
|
91
|
+
* Use this to force a fresh login on the next `create()` call.
|
|
92
|
+
*/
|
|
93
|
+
static clearCachedToken(email: string): void;
|
|
94
|
+
/** Get the underlying token (for persistence or debugging). */
|
|
95
|
+
getToken(): TeamsToken;
|
|
96
|
+
/**
|
|
97
|
+
* List conversations (chats, group chats, meetings, channels).
|
|
98
|
+
*
|
|
99
|
+
* By default, excludes system streams (annotations, notifications,
|
|
100
|
+
* mentions). Set `excludeSystemStreams: false` to include everything.
|
|
101
|
+
*/
|
|
102
|
+
listConversations(options?: ListConversationsOptions): Promise<Conversation[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Find a conversation by topic name (case-insensitive partial match).
|
|
105
|
+
*
|
|
106
|
+
* When a Substrate token is available, also searches via the Substrate
|
|
107
|
+
* chat search API for matches by name or member. Falls back to local
|
|
108
|
+
* topic matching when Substrate is unavailable.
|
|
109
|
+
*/
|
|
110
|
+
findConversation(query: string): Promise<Conversation | null>;
|
|
111
|
+
/**
|
|
112
|
+
* Search for people in the organization directory by name.
|
|
113
|
+
*
|
|
114
|
+
* Uses the Substrate search API (requires a Substrate token captured
|
|
115
|
+
* during authentication). Returns matching people with MRIs, emails,
|
|
116
|
+
* job titles, and departments.
|
|
117
|
+
*/
|
|
118
|
+
findPeople(query: string, maxResults?: number): Promise<PersonSearchResult[]>;
|
|
119
|
+
/**
|
|
120
|
+
* Search for chats by name or member name.
|
|
121
|
+
*
|
|
122
|
+
* Uses the Substrate search API (requires a Substrate token captured
|
|
123
|
+
* during authentication). Returns matching chats with thread IDs,
|
|
124
|
+
* member lists, and matching member details.
|
|
125
|
+
*/
|
|
126
|
+
findChats(query: string, maxResults?: number): Promise<ChatSearchResult[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Find a 1:1 conversation with a specific person.
|
|
129
|
+
*
|
|
130
|
+
* Uses the Substrate people/chat search API to find the person by name
|
|
131
|
+
* and locate the corresponding 1:1 chat thread. Falls back to scanning
|
|
132
|
+
* message history when the Substrate token is unavailable.
|
|
133
|
+
*
|
|
134
|
+
* Also checks the self-chat (48:notes) if the query matches the
|
|
135
|
+
* current user's name.
|
|
136
|
+
*/
|
|
137
|
+
findOneOnOneConversation(personName: string): Promise<OneOnOneSearchResult | null>;
|
|
138
|
+
/**
|
|
139
|
+
* Get all messages from a conversation.
|
|
140
|
+
*
|
|
141
|
+
* Follows pagination links to fetch the complete message history.
|
|
142
|
+
* Use `maxPages` and `pageSize` to control how much is fetched.
|
|
143
|
+
*/
|
|
144
|
+
getMessages(conversationId: string, options?: GetMessagesOptions): Promise<Message[]>;
|
|
145
|
+
/**
|
|
146
|
+
* Get one page of messages from a conversation.
|
|
147
|
+
*
|
|
148
|
+
* Returns the page along with a backwardLink for manual pagination.
|
|
149
|
+
*/
|
|
150
|
+
getMessagesPage(conversationId: string, pageSize?: number, backwardLink?: string): Promise<MessagesPage>;
|
|
151
|
+
/**
|
|
152
|
+
* Send a message to a conversation.
|
|
153
|
+
*
|
|
154
|
+
* The `format` parameter controls how `content` is interpreted:
|
|
155
|
+
* - `"text"` — plain text, sent as-is
|
|
156
|
+
* - `"markdown"` (default) — converted from Markdown to HTML
|
|
157
|
+
* - `"html"` — raw HTML, sent as-is
|
|
158
|
+
*/
|
|
159
|
+
sendMessage(conversationId: string, content: string, format?: MessageFormat): Promise<SentMessage>;
|
|
160
|
+
/**
|
|
161
|
+
* Get members of a conversation.
|
|
162
|
+
*
|
|
163
|
+
* Display names are resolved via the Teams middle-tier profile API when a
|
|
164
|
+
* Bearer token is available. Falls back to scanning message history when it
|
|
165
|
+
* is not.
|
|
166
|
+
*/
|
|
167
|
+
getMembers(conversationId: string): Promise<Member[]>;
|
|
168
|
+
/**
|
|
169
|
+
* Get the meeting transcript for a conversation.
|
|
170
|
+
*
|
|
171
|
+
* Searches messages for a successful recording, extracts the AMS
|
|
172
|
+
* transcript URL, fetches the VTT, and parses it into structured entries.
|
|
173
|
+
*/
|
|
174
|
+
getTranscript(conversationId: string): Promise<TranscriptResult>;
|
|
175
|
+
/**
|
|
176
|
+
* Get the display name of the currently authenticated user.
|
|
177
|
+
*
|
|
178
|
+
* Resolved by reading messages from the self-chat (48:notes) or
|
|
179
|
+
* falling back to the user properties endpoint.
|
|
180
|
+
*/
|
|
181
|
+
getCurrentUserDisplayName(): Promise<string>;
|
|
182
|
+
/**
|
|
183
|
+
* Re-acquire the token via auto-login and update the cached version.
|
|
184
|
+
*
|
|
185
|
+
* Called automatically by `withTokenRefresh` on 401 errors.
|
|
186
|
+
*/
|
|
187
|
+
private refreshToken;
|
|
188
|
+
/**
|
|
189
|
+
* Wrap an operation with automatic token refresh on 401.
|
|
190
|
+
*
|
|
191
|
+
* If the operation throws an `ApiAuthError` and auto-login options
|
|
192
|
+
* are configured, the token is re-acquired and the operation retried
|
|
193
|
+
* exactly once.
|
|
194
|
+
*/
|
|
195
|
+
private withTokenRefresh;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=teams-client.d.ts.map
|
|
@@ -0,0 +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,YAAY,EACZ,OAAO,EACP,aAAa,EACb,MAAM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