msteams-mcp 0.2.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 +229 -0
- package/dist/__fixtures__/api-responses.d.ts +228 -0
- package/dist/__fixtures__/api-responses.js +217 -0
- package/dist/api/chatsvc-api.d.ts +171 -0
- package/dist/api/chatsvc-api.js +459 -0
- package/dist/api/csa-api.d.ts +44 -0
- package/dist/api/csa-api.js +148 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/api/index.js +6 -0
- package/dist/api/substrate-api.d.ts +50 -0
- package/dist/api/substrate-api.js +305 -0
- package/dist/auth/crypto.d.ts +32 -0
- package/dist/auth/crypto.js +66 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.js +6 -0
- package/dist/auth/session-store.d.ts +82 -0
- package/dist/auth/session-store.js +136 -0
- package/dist/auth/token-extractor.d.ts +69 -0
- package/dist/auth/token-extractor.js +330 -0
- package/dist/browser/auth.d.ts +43 -0
- package/dist/browser/auth.js +232 -0
- package/dist/browser/context.d.ts +40 -0
- package/dist/browser/context.js +121 -0
- package/dist/browser/session.d.ts +34 -0
- package/dist/browser/session.js +92 -0
- package/dist/constants.d.ts +54 -0
- package/dist/constants.js +72 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -0
- package/dist/research/explore.d.ts +11 -0
- package/dist/research/explore.js +267 -0
- package/dist/research/search-research.d.ts +17 -0
- package/dist/research/search-research.js +317 -0
- package/dist/server.d.ts +64 -0
- package/dist/server.js +291 -0
- package/dist/teams/api-interceptor.d.ts +54 -0
- package/dist/teams/api-interceptor.js +391 -0
- package/dist/teams/direct-api.d.ts +321 -0
- package/dist/teams/direct-api.js +1305 -0
- package/dist/teams/messages.d.ts +14 -0
- package/dist/teams/messages.js +142 -0
- package/dist/teams/search.d.ts +40 -0
- package/dist/teams/search.js +458 -0
- package/dist/test/cli.d.ts +12 -0
- package/dist/test/cli.js +328 -0
- package/dist/test/debug-search.d.ts +10 -0
- package/dist/test/debug-search.js +147 -0
- package/dist/test/manual-test.d.ts +11 -0
- package/dist/test/manual-test.js +160 -0
- package/dist/test/mcp-harness.d.ts +17 -0
- package/dist/test/mcp-harness.js +427 -0
- package/dist/tools/auth-tools.d.ts +26 -0
- package/dist/tools/auth-tools.js +127 -0
- package/dist/tools/index.d.ts +45 -0
- package/dist/tools/index.js +12 -0
- package/dist/tools/message-tools.d.ts +139 -0
- package/dist/tools/message-tools.js +433 -0
- package/dist/tools/people-tools.d.ts +46 -0
- package/dist/tools/people-tools.js +123 -0
- package/dist/tools/registry.d.ts +23 -0
- package/dist/tools/registry.js +61 -0
- package/dist/tools/search-tools.d.ts +79 -0
- package/dist/tools/search-tools.js +168 -0
- package/dist/types/errors.d.ts +58 -0
- package/dist/types/errors.js +132 -0
- package/dist/types/result.d.ts +43 -0
- package/dist/types/result.js +51 -0
- package/dist/types/teams.d.ts +79 -0
- package/dist/types/teams.js +5 -0
- package/dist/utils/api-config.d.ts +66 -0
- package/dist/utils/api-config.js +113 -0
- package/dist/utils/auth-guards.d.ts +29 -0
- package/dist/utils/auth-guards.js +54 -0
- package/dist/utils/http.d.ts +29 -0
- package/dist/utils/http.js +111 -0
- package/dist/utils/parsers.d.ts +187 -0
- package/dist/utils/parsers.js +574 -0
- package/dist/utils/parsers.test.d.ts +7 -0
- package/dist/utils/parsers.test.js +360 -0
- package/package.json +58 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messaging-related tool handlers.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import type { RegisteredTool } from './index.js';
|
|
6
|
+
export declare const SendMessageInputSchema: z.ZodObject<{
|
|
7
|
+
content: z.ZodString;
|
|
8
|
+
conversationId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
9
|
+
replyToMessageId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
content: string;
|
|
12
|
+
conversationId: string;
|
|
13
|
+
replyToMessageId?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
content: string;
|
|
16
|
+
conversationId?: string | undefined;
|
|
17
|
+
replyToMessageId?: string | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const ReplyToThreadInputSchema: z.ZodObject<{
|
|
20
|
+
content: z.ZodString;
|
|
21
|
+
conversationId: z.ZodString;
|
|
22
|
+
messageId: z.ZodString;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
content: string;
|
|
25
|
+
conversationId: string;
|
|
26
|
+
messageId: string;
|
|
27
|
+
}, {
|
|
28
|
+
content: string;
|
|
29
|
+
conversationId: string;
|
|
30
|
+
messageId: string;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const FavoriteInputSchema: z.ZodObject<{
|
|
33
|
+
conversationId: z.ZodString;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
conversationId: string;
|
|
36
|
+
}, {
|
|
37
|
+
conversationId: string;
|
|
38
|
+
}>;
|
|
39
|
+
export declare const SaveMessageInputSchema: z.ZodObject<{
|
|
40
|
+
conversationId: z.ZodString;
|
|
41
|
+
messageId: z.ZodString;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
conversationId: string;
|
|
44
|
+
messageId: string;
|
|
45
|
+
}, {
|
|
46
|
+
conversationId: string;
|
|
47
|
+
messageId: string;
|
|
48
|
+
}>;
|
|
49
|
+
export declare const GetChatInputSchema: z.ZodObject<{
|
|
50
|
+
userId: z.ZodString;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
userId: string;
|
|
53
|
+
}, {
|
|
54
|
+
userId: string;
|
|
55
|
+
}>;
|
|
56
|
+
export declare const EditMessageInputSchema: z.ZodObject<{
|
|
57
|
+
conversationId: z.ZodString;
|
|
58
|
+
messageId: z.ZodString;
|
|
59
|
+
content: z.ZodString;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
content: string;
|
|
62
|
+
conversationId: string;
|
|
63
|
+
messageId: string;
|
|
64
|
+
}, {
|
|
65
|
+
content: string;
|
|
66
|
+
conversationId: string;
|
|
67
|
+
messageId: string;
|
|
68
|
+
}>;
|
|
69
|
+
export declare const DeleteMessageInputSchema: z.ZodObject<{
|
|
70
|
+
conversationId: z.ZodString;
|
|
71
|
+
messageId: z.ZodString;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
conversationId: string;
|
|
74
|
+
messageId: string;
|
|
75
|
+
}, {
|
|
76
|
+
conversationId: string;
|
|
77
|
+
messageId: string;
|
|
78
|
+
}>;
|
|
79
|
+
export declare const sendMessageTool: RegisteredTool<typeof SendMessageInputSchema>;
|
|
80
|
+
export declare const replyToThreadTool: RegisteredTool<typeof ReplyToThreadInputSchema>;
|
|
81
|
+
export declare const getFavoritesTool: RegisteredTool<z.ZodObject<Record<string, never>>>;
|
|
82
|
+
export declare const addFavoriteTool: RegisteredTool<typeof FavoriteInputSchema>;
|
|
83
|
+
export declare const removeFavoriteTool: RegisteredTool<typeof FavoriteInputSchema>;
|
|
84
|
+
export declare const saveMessageTool: RegisteredTool<typeof SaveMessageInputSchema>;
|
|
85
|
+
export declare const unsaveMessageTool: RegisteredTool<typeof SaveMessageInputSchema>;
|
|
86
|
+
export declare const getChatTool: RegisteredTool<typeof GetChatInputSchema>;
|
|
87
|
+
export declare const editMessageTool: RegisteredTool<typeof EditMessageInputSchema>;
|
|
88
|
+
export declare const deleteMessageTool: RegisteredTool<typeof DeleteMessageInputSchema>;
|
|
89
|
+
/** All message-related tools. */
|
|
90
|
+
export declare const messageTools: (RegisteredTool<z.ZodObject<{
|
|
91
|
+
content: z.ZodString;
|
|
92
|
+
conversationId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
93
|
+
replyToMessageId: z.ZodOptional<z.ZodString>;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
content: string;
|
|
96
|
+
conversationId: string;
|
|
97
|
+
replyToMessageId?: string | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
content: string;
|
|
100
|
+
conversationId?: string | undefined;
|
|
101
|
+
replyToMessageId?: string | undefined;
|
|
102
|
+
}>> | RegisteredTool<z.ZodObject<{
|
|
103
|
+
content: z.ZodString;
|
|
104
|
+
conversationId: z.ZodString;
|
|
105
|
+
messageId: z.ZodString;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
content: string;
|
|
108
|
+
conversationId: string;
|
|
109
|
+
messageId: string;
|
|
110
|
+
}, {
|
|
111
|
+
content: string;
|
|
112
|
+
conversationId: string;
|
|
113
|
+
messageId: string;
|
|
114
|
+
}>> | RegisteredTool<z.ZodObject<Record<string, never>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
115
|
+
[x: string]: never;
|
|
116
|
+
}, {
|
|
117
|
+
[x: string]: never;
|
|
118
|
+
}>> | RegisteredTool<z.ZodObject<{
|
|
119
|
+
conversationId: z.ZodString;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
conversationId: string;
|
|
122
|
+
}, {
|
|
123
|
+
conversationId: string;
|
|
124
|
+
}>> | RegisteredTool<z.ZodObject<{
|
|
125
|
+
conversationId: z.ZodString;
|
|
126
|
+
messageId: z.ZodString;
|
|
127
|
+
}, "strip", z.ZodTypeAny, {
|
|
128
|
+
conversationId: string;
|
|
129
|
+
messageId: string;
|
|
130
|
+
}, {
|
|
131
|
+
conversationId: string;
|
|
132
|
+
messageId: string;
|
|
133
|
+
}>> | RegisteredTool<z.ZodObject<{
|
|
134
|
+
userId: z.ZodString;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
userId: string;
|
|
137
|
+
}, {
|
|
138
|
+
userId: string;
|
|
139
|
+
}>>)[];
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messaging-related tool handlers.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { sendMessage, sendNoteToSelf, replyToThread, saveMessage, unsaveMessage, getOneOnOneChatId, editMessage, deleteMessage, } from '../api/chatsvc-api.js';
|
|
6
|
+
import { getFavorites, addFavorite, removeFavorite } from '../api/csa-api.js';
|
|
7
|
+
import { SELF_CHAT_ID } from '../constants.js';
|
|
8
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
9
|
+
// Schemas
|
|
10
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
11
|
+
export const SendMessageInputSchema = z.object({
|
|
12
|
+
content: z.string().min(1, 'Message content cannot be empty'),
|
|
13
|
+
conversationId: z.string().optional().default(SELF_CHAT_ID),
|
|
14
|
+
replyToMessageId: z.string().optional(),
|
|
15
|
+
});
|
|
16
|
+
export const ReplyToThreadInputSchema = z.object({
|
|
17
|
+
content: z.string().min(1, 'Reply content cannot be empty'),
|
|
18
|
+
conversationId: z.string().min(1, 'Conversation ID is required'),
|
|
19
|
+
messageId: z.string().min(1, 'Message ID is required'),
|
|
20
|
+
});
|
|
21
|
+
export const FavoriteInputSchema = z.object({
|
|
22
|
+
conversationId: z.string().min(1, 'Conversation ID cannot be empty'),
|
|
23
|
+
});
|
|
24
|
+
export const SaveMessageInputSchema = z.object({
|
|
25
|
+
conversationId: z.string().min(1, 'Conversation ID cannot be empty'),
|
|
26
|
+
messageId: z.string().min(1, 'Message ID cannot be empty'),
|
|
27
|
+
});
|
|
28
|
+
export const GetChatInputSchema = z.object({
|
|
29
|
+
userId: z.string().min(1, 'User ID cannot be empty'),
|
|
30
|
+
});
|
|
31
|
+
export const EditMessageInputSchema = z.object({
|
|
32
|
+
conversationId: z.string().min(1, 'Conversation ID cannot be empty'),
|
|
33
|
+
messageId: z.string().min(1, 'Message ID cannot be empty'),
|
|
34
|
+
content: z.string().min(1, 'Content cannot be empty'),
|
|
35
|
+
});
|
|
36
|
+
export const DeleteMessageInputSchema = z.object({
|
|
37
|
+
conversationId: z.string().min(1, 'Conversation ID cannot be empty'),
|
|
38
|
+
messageId: z.string().min(1, 'Message ID cannot be empty'),
|
|
39
|
+
});
|
|
40
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
41
|
+
// Tool Definitions
|
|
42
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
43
|
+
const sendMessageToolDefinition = {
|
|
44
|
+
name: 'teams_send_message',
|
|
45
|
+
description: 'Send a message to a Teams conversation. By default, sends to your own notes (self-chat). For channel thread replies, use teams_reply_to_thread instead (simpler). For chats (1:1, group, meeting), just provide the conversationId.',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
content: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
description: 'The message content to send. Can include basic HTML formatting.',
|
|
52
|
+
},
|
|
53
|
+
conversationId: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'The conversation ID to send to. Use "48:notes" for self-chat (default), or a channel/chat conversation ID.',
|
|
56
|
+
},
|
|
57
|
+
replyToMessageId: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'For channel thread replies (advanced). Prefer using teams_reply_to_thread instead.',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
required: ['content'],
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
const replyToThreadToolDefinition = {
|
|
66
|
+
name: 'teams_reply_to_thread',
|
|
67
|
+
description: 'Reply to a channel message as a threaded reply. Use the conversationId and messageId from search results, or conversationId and threadReplyId from a previous teams_send_message response.',
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
content: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: 'The reply content to send.',
|
|
74
|
+
},
|
|
75
|
+
conversationId: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
description: 'The channel conversation ID.',
|
|
78
|
+
},
|
|
79
|
+
messageId: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
description: 'The message ID to reply to. Use messageId from search results, or threadReplyId from a teams_send_message response.',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
required: ['content', 'conversationId', 'messageId'],
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
const getFavoritesToolDefinition = {
|
|
88
|
+
name: 'teams_get_favorites',
|
|
89
|
+
description: 'Get the user\'s favourite/pinned conversations in Teams. Returns conversation IDs with display names (channel name, chat topic, or participant names) and type (Channel, Chat, Meeting).',
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
const addFavoriteToolDefinition = {
|
|
96
|
+
name: 'teams_add_favorite',
|
|
97
|
+
description: 'Add a conversation to the user\'s favourites/pinned list.',
|
|
98
|
+
inputSchema: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
properties: {
|
|
101
|
+
conversationId: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
description: 'The conversation ID to pin (e.g., "19:abc@thread.tacv2")',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
required: ['conversationId'],
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
const removeFavoriteToolDefinition = {
|
|
110
|
+
name: 'teams_remove_favorite',
|
|
111
|
+
description: 'Remove a conversation from the user\'s favourites/pinned list.',
|
|
112
|
+
inputSchema: {
|
|
113
|
+
type: 'object',
|
|
114
|
+
properties: {
|
|
115
|
+
conversationId: {
|
|
116
|
+
type: 'string',
|
|
117
|
+
description: 'The conversation ID to unpin',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
required: ['conversationId'],
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
const saveMessageToolDefinition = {
|
|
124
|
+
name: 'teams_save_message',
|
|
125
|
+
description: 'Save (bookmark) a message in Teams. Saved messages can be accessed later from the Saved view in Teams.',
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: {
|
|
129
|
+
conversationId: {
|
|
130
|
+
type: 'string',
|
|
131
|
+
description: 'The conversation ID containing the message',
|
|
132
|
+
},
|
|
133
|
+
messageId: {
|
|
134
|
+
type: 'string',
|
|
135
|
+
description: 'The message ID to save (numeric string from search results)',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
required: ['conversationId', 'messageId'],
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
const unsaveMessageToolDefinition = {
|
|
142
|
+
name: 'teams_unsave_message',
|
|
143
|
+
description: 'Remove a saved (bookmarked) message in Teams.',
|
|
144
|
+
inputSchema: {
|
|
145
|
+
type: 'object',
|
|
146
|
+
properties: {
|
|
147
|
+
conversationId: {
|
|
148
|
+
type: 'string',
|
|
149
|
+
description: 'The conversation ID containing the message',
|
|
150
|
+
},
|
|
151
|
+
messageId: {
|
|
152
|
+
type: 'string',
|
|
153
|
+
description: 'The message ID to unsave',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
required: ['conversationId', 'messageId'],
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
const getChatToolDefinition = {
|
|
160
|
+
name: 'teams_get_chat',
|
|
161
|
+
description: 'Get the conversation ID for a 1:1 chat with a person. Use this to start a new chat or find an existing one. The conversation ID can then be used with teams_send_message to send messages.',
|
|
162
|
+
inputSchema: {
|
|
163
|
+
type: 'object',
|
|
164
|
+
properties: {
|
|
165
|
+
userId: {
|
|
166
|
+
type: 'string',
|
|
167
|
+
description: 'The user\'s identifier. Can be: MRI (8:orgid:guid), object ID with tenant (guid@tenantId), or raw object ID (guid). Get this from teams_search_people results.',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
required: ['userId'],
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
const editMessageToolDefinition = {
|
|
174
|
+
name: 'teams_edit_message',
|
|
175
|
+
description: 'Edit one of your own messages. You can only edit messages you sent. The API will reject attempts to edit other users\' messages.',
|
|
176
|
+
inputSchema: {
|
|
177
|
+
type: 'object',
|
|
178
|
+
properties: {
|
|
179
|
+
conversationId: {
|
|
180
|
+
type: 'string',
|
|
181
|
+
description: 'The conversation ID containing the message',
|
|
182
|
+
},
|
|
183
|
+
messageId: {
|
|
184
|
+
type: 'string',
|
|
185
|
+
description: 'The message ID to edit (numeric string from search results or teams_get_thread)',
|
|
186
|
+
},
|
|
187
|
+
content: {
|
|
188
|
+
type: 'string',
|
|
189
|
+
description: 'The new content for the message. Can include basic HTML formatting.',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
required: ['conversationId', 'messageId', 'content'],
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
const deleteMessageToolDefinition = {
|
|
196
|
+
name: 'teams_delete_message',
|
|
197
|
+
description: 'Delete one of your own messages (soft delete). You can only delete messages you sent, unless you are a channel owner/moderator. The API will reject unauthorised attempts.',
|
|
198
|
+
inputSchema: {
|
|
199
|
+
type: 'object',
|
|
200
|
+
properties: {
|
|
201
|
+
conversationId: {
|
|
202
|
+
type: 'string',
|
|
203
|
+
description: 'The conversation ID containing the message',
|
|
204
|
+
},
|
|
205
|
+
messageId: {
|
|
206
|
+
type: 'string',
|
|
207
|
+
description: 'The message ID to delete (numeric string from search results or teams_get_thread)',
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
required: ['conversationId', 'messageId'],
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
214
|
+
// Handlers
|
|
215
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
216
|
+
async function handleSendMessage(input, _ctx) {
|
|
217
|
+
const result = input.conversationId === SELF_CHAT_ID
|
|
218
|
+
? await sendNoteToSelf(input.content)
|
|
219
|
+
: await sendMessage(input.conversationId, input.content, {
|
|
220
|
+
replyToMessageId: input.replyToMessageId,
|
|
221
|
+
});
|
|
222
|
+
if (!result.ok) {
|
|
223
|
+
return { success: false, error: result.error };
|
|
224
|
+
}
|
|
225
|
+
// The timestamp is what Teams uses for threading - convert to string for use as threadReplyId
|
|
226
|
+
const threadReplyId = result.value.timestamp ? String(result.value.timestamp) : undefined;
|
|
227
|
+
const response = {
|
|
228
|
+
messageId: result.value.messageId,
|
|
229
|
+
timestamp: result.value.timestamp,
|
|
230
|
+
conversationId: input.conversationId,
|
|
231
|
+
};
|
|
232
|
+
// Add threadReplyId for channel messages (needed to reply to this message later)
|
|
233
|
+
if (threadReplyId && input.conversationId.includes('@thread.tacv2')) {
|
|
234
|
+
response.threadReplyId = threadReplyId;
|
|
235
|
+
response.note = 'Use threadReplyId (not messageId) if you want to reply to this message later.';
|
|
236
|
+
}
|
|
237
|
+
// Include replyToMessageId in response if this was a thread reply
|
|
238
|
+
if (input.replyToMessageId) {
|
|
239
|
+
response.replyToMessageId = input.replyToMessageId;
|
|
240
|
+
response.note = 'Message posted as a reply to the thread.';
|
|
241
|
+
}
|
|
242
|
+
return { success: true, data: response };
|
|
243
|
+
}
|
|
244
|
+
async function handleReplyToThread(input, _ctx) {
|
|
245
|
+
const result = await replyToThread(input.conversationId, input.messageId, input.content);
|
|
246
|
+
if (!result.ok) {
|
|
247
|
+
return { success: false, error: result.error };
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
success: true,
|
|
251
|
+
data: {
|
|
252
|
+
messageId: result.value.messageId,
|
|
253
|
+
timestamp: result.value.timestamp,
|
|
254
|
+
conversationId: result.value.conversationId,
|
|
255
|
+
threadRootMessageId: result.value.threadRootMessageId,
|
|
256
|
+
note: 'Reply posted to thread successfully.',
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
async function handleGetFavorites(_input, _ctx) {
|
|
261
|
+
const result = await getFavorites();
|
|
262
|
+
if (!result.ok) {
|
|
263
|
+
return { success: false, error: result.error };
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
success: true,
|
|
267
|
+
data: {
|
|
268
|
+
count: result.value.favorites.length,
|
|
269
|
+
favorites: result.value.favorites,
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
async function handleAddFavorite(input, _ctx) {
|
|
274
|
+
const result = await addFavorite(input.conversationId);
|
|
275
|
+
if (!result.ok) {
|
|
276
|
+
return { success: false, error: result.error };
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
success: true,
|
|
280
|
+
data: {
|
|
281
|
+
message: `Added ${input.conversationId} to favourites`,
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
async function handleRemoveFavorite(input, _ctx) {
|
|
286
|
+
const result = await removeFavorite(input.conversationId);
|
|
287
|
+
if (!result.ok) {
|
|
288
|
+
return { success: false, error: result.error };
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
success: true,
|
|
292
|
+
data: {
|
|
293
|
+
message: `Removed ${input.conversationId} from favourites`,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
async function handleSaveMessage(input, _ctx) {
|
|
298
|
+
const result = await saveMessage(input.conversationId, input.messageId);
|
|
299
|
+
if (!result.ok) {
|
|
300
|
+
return { success: false, error: result.error };
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
success: true,
|
|
304
|
+
data: {
|
|
305
|
+
message: 'Message saved',
|
|
306
|
+
conversationId: input.conversationId,
|
|
307
|
+
messageId: input.messageId,
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
async function handleUnsaveMessage(input, _ctx) {
|
|
312
|
+
const result = await unsaveMessage(input.conversationId, input.messageId);
|
|
313
|
+
if (!result.ok) {
|
|
314
|
+
return { success: false, error: result.error };
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
success: true,
|
|
318
|
+
data: {
|
|
319
|
+
message: 'Message unsaved',
|
|
320
|
+
conversationId: input.conversationId,
|
|
321
|
+
messageId: input.messageId,
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
async function handleGetChat(input, _ctx) {
|
|
326
|
+
const result = getOneOnOneChatId(input.userId);
|
|
327
|
+
if (!result.ok) {
|
|
328
|
+
return { success: false, error: result.error };
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
success: true,
|
|
332
|
+
data: {
|
|
333
|
+
conversationId: result.value.conversationId,
|
|
334
|
+
otherUserId: result.value.otherUserId,
|
|
335
|
+
currentUserId: result.value.currentUserId,
|
|
336
|
+
note: 'Use this conversationId with teams_send_message to send a message. The conversation is created automatically when the first message is sent.',
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
async function handleEditMessage(input, _ctx) {
|
|
341
|
+
const result = await editMessage(input.conversationId, input.messageId, input.content);
|
|
342
|
+
if (!result.ok) {
|
|
343
|
+
return { success: false, error: result.error };
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
success: true,
|
|
347
|
+
data: {
|
|
348
|
+
message: 'Message edited successfully',
|
|
349
|
+
conversationId: result.value.conversationId,
|
|
350
|
+
messageId: result.value.messageId,
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
async function handleDeleteMessage(input, _ctx) {
|
|
355
|
+
const result = await deleteMessage(input.conversationId, input.messageId);
|
|
356
|
+
if (!result.ok) {
|
|
357
|
+
return { success: false, error: result.error };
|
|
358
|
+
}
|
|
359
|
+
return {
|
|
360
|
+
success: true,
|
|
361
|
+
data: {
|
|
362
|
+
message: 'Message deleted successfully',
|
|
363
|
+
conversationId: result.value.conversationId,
|
|
364
|
+
messageId: result.value.messageId,
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
369
|
+
// Exports
|
|
370
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
371
|
+
export const sendMessageTool = {
|
|
372
|
+
definition: sendMessageToolDefinition,
|
|
373
|
+
schema: SendMessageInputSchema,
|
|
374
|
+
handler: handleSendMessage,
|
|
375
|
+
};
|
|
376
|
+
export const replyToThreadTool = {
|
|
377
|
+
definition: replyToThreadToolDefinition,
|
|
378
|
+
schema: ReplyToThreadInputSchema,
|
|
379
|
+
handler: handleReplyToThread,
|
|
380
|
+
};
|
|
381
|
+
export const getFavoritesTool = {
|
|
382
|
+
definition: getFavoritesToolDefinition,
|
|
383
|
+
schema: z.object({}),
|
|
384
|
+
handler: handleGetFavorites,
|
|
385
|
+
};
|
|
386
|
+
export const addFavoriteTool = {
|
|
387
|
+
definition: addFavoriteToolDefinition,
|
|
388
|
+
schema: FavoriteInputSchema,
|
|
389
|
+
handler: handleAddFavorite,
|
|
390
|
+
};
|
|
391
|
+
export const removeFavoriteTool = {
|
|
392
|
+
definition: removeFavoriteToolDefinition,
|
|
393
|
+
schema: FavoriteInputSchema,
|
|
394
|
+
handler: handleRemoveFavorite,
|
|
395
|
+
};
|
|
396
|
+
export const saveMessageTool = {
|
|
397
|
+
definition: saveMessageToolDefinition,
|
|
398
|
+
schema: SaveMessageInputSchema,
|
|
399
|
+
handler: handleSaveMessage,
|
|
400
|
+
};
|
|
401
|
+
export const unsaveMessageTool = {
|
|
402
|
+
definition: unsaveMessageToolDefinition,
|
|
403
|
+
schema: SaveMessageInputSchema,
|
|
404
|
+
handler: handleUnsaveMessage,
|
|
405
|
+
};
|
|
406
|
+
export const getChatTool = {
|
|
407
|
+
definition: getChatToolDefinition,
|
|
408
|
+
schema: GetChatInputSchema,
|
|
409
|
+
handler: handleGetChat,
|
|
410
|
+
};
|
|
411
|
+
export const editMessageTool = {
|
|
412
|
+
definition: editMessageToolDefinition,
|
|
413
|
+
schema: EditMessageInputSchema,
|
|
414
|
+
handler: handleEditMessage,
|
|
415
|
+
};
|
|
416
|
+
export const deleteMessageTool = {
|
|
417
|
+
definition: deleteMessageToolDefinition,
|
|
418
|
+
schema: DeleteMessageInputSchema,
|
|
419
|
+
handler: handleDeleteMessage,
|
|
420
|
+
};
|
|
421
|
+
/** All message-related tools. */
|
|
422
|
+
export const messageTools = [
|
|
423
|
+
sendMessageTool,
|
|
424
|
+
replyToThreadTool,
|
|
425
|
+
getFavoritesTool,
|
|
426
|
+
addFavoriteTool,
|
|
427
|
+
removeFavoriteTool,
|
|
428
|
+
saveMessageTool,
|
|
429
|
+
unsaveMessageTool,
|
|
430
|
+
getChatTool,
|
|
431
|
+
editMessageTool,
|
|
432
|
+
deleteMessageTool,
|
|
433
|
+
];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* People-related tool handlers.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import type { RegisteredTool } from './index.js';
|
|
6
|
+
export declare const SearchPeopleInputSchema: z.ZodObject<{
|
|
7
|
+
query: z.ZodString;
|
|
8
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
query: string;
|
|
11
|
+
limit: number;
|
|
12
|
+
}, {
|
|
13
|
+
query: string;
|
|
14
|
+
limit?: number | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const FrequentContactsInputSchema: z.ZodObject<{
|
|
17
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
limit: number;
|
|
20
|
+
}, {
|
|
21
|
+
limit?: number | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const getMeTool: RegisteredTool<z.ZodObject<Record<string, never>>>;
|
|
24
|
+
export declare const searchPeopleTool: RegisteredTool<typeof SearchPeopleInputSchema>;
|
|
25
|
+
export declare const frequentContactsTool: RegisteredTool<typeof FrequentContactsInputSchema>;
|
|
26
|
+
/** All people-related tools. */
|
|
27
|
+
export declare const peopleTools: (RegisteredTool<z.ZodObject<Record<string, never>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
28
|
+
[x: string]: never;
|
|
29
|
+
}, {
|
|
30
|
+
[x: string]: never;
|
|
31
|
+
}>> | RegisteredTool<z.ZodObject<{
|
|
32
|
+
query: z.ZodString;
|
|
33
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
query: string;
|
|
36
|
+
limit: number;
|
|
37
|
+
}, {
|
|
38
|
+
query: string;
|
|
39
|
+
limit?: number | undefined;
|
|
40
|
+
}>> | RegisteredTool<z.ZodObject<{
|
|
41
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
limit: number;
|
|
44
|
+
}, {
|
|
45
|
+
limit?: number | undefined;
|
|
46
|
+
}>>)[];
|