@beeper/desktop-mcp 4.2.3 → 4.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/LICENSE +1 -1
- package/README.md +18 -199
- package/auth.d.mts +6 -0
- package/auth.d.mts.map +1 -0
- package/auth.d.ts +6 -0
- package/auth.d.ts.map +1 -0
- package/auth.js +37 -0
- package/auth.js.map +1 -0
- package/auth.mjs +32 -0
- package/auth.mjs.map +1 -0
- package/code-tool-types.d.mts +7 -7
- package/code-tool-types.d.mts.map +1 -1
- package/code-tool-types.d.ts +7 -7
- package/code-tool-types.d.ts.map +1 -1
- package/code-tool-worker.d.mts.map +1 -1
- package/code-tool-worker.d.ts.map +1 -1
- package/code-tool-worker.js +103 -19
- package/code-tool-worker.js.map +1 -1
- package/code-tool-worker.mjs +103 -19
- package/code-tool-worker.mjs.map +1 -1
- package/code-tool.d.mts +12 -3
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +12 -3
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +276 -95
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +273 -95
- package/code-tool.mjs.map +1 -1
- package/http.d.mts +6 -9
- package/http.d.mts.map +1 -1
- package/http.d.ts +6 -9
- package/http.d.ts.map +1 -1
- package/http.js +81 -47
- package/http.js.map +1 -1
- package/http.mjs +80 -43
- package/http.mjs.map +1 -1
- package/index.js +19 -50
- package/index.js.map +1 -1
- package/index.mjs +19 -50
- package/index.mjs.map +1 -1
- package/instructions.d.mts +2 -0
- package/instructions.d.mts.map +1 -0
- package/instructions.d.ts +2 -0
- package/instructions.d.ts.map +1 -0
- package/instructions.js +48 -0
- package/instructions.js.map +1 -0
- package/instructions.mjs +45 -0
- package/instructions.mjs.map +1 -0
- package/logger.d.mts +7 -0
- package/logger.d.mts.map +1 -0
- package/logger.d.ts +7 -0
- package/logger.d.ts.map +1 -0
- package/logger.js +29 -0
- package/logger.js.map +1 -0
- package/logger.mjs +22 -0
- package/logger.mjs.map +1 -0
- package/methods.d.mts +10 -0
- package/methods.d.mts.map +1 -0
- package/methods.d.ts +10 -0
- package/methods.d.ts.map +1 -0
- package/methods.js +203 -0
- package/methods.js.map +1 -0
- package/methods.mjs +199 -0
- package/methods.mjs.map +1 -0
- package/options.d.mts +9 -10
- package/options.d.mts.map +1 -1
- package/options.d.ts +9 -10
- package/options.d.ts.map +1 -1
- package/options.js +52 -363
- package/options.js.map +1 -1
- package/options.mjs +52 -363
- package/options.mjs.map +1 -1
- package/package.json +68 -82
- package/server.d.mts +10 -16
- package/server.d.mts.map +1 -1
- package/server.d.ts +10 -16
- package/server.d.ts.map +1 -1
- package/server.js +82 -105
- package/server.js.map +1 -1
- package/server.mjs +81 -100
- package/server.mjs.map +1 -1
- package/src/auth.ts +42 -0
- package/src/code-tool-types.ts +8 -5
- package/src/code-tool-worker.ts +118 -34
- package/src/code-tool.ts +359 -118
- package/src/http.ts +99 -50
- package/src/index.ts +22 -63
- package/src/instructions.ts +67 -0
- package/src/logger.ts +28 -0
- package/src/methods.ts +224 -0
- package/src/options.ts +69 -390
- package/src/server.ts +95 -121
- package/src/stdio.ts +6 -5
- package/src/{tools/types.ts → types.ts} +25 -5
- package/src/util.ts +25 -0
- package/stdio.d.mts +1 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts +1 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +5 -4
- package/stdio.js.map +1 -1
- package/stdio.mjs +5 -4
- package/stdio.mjs.map +1 -1
- package/{tools/types.d.mts → types.d.mts} +10 -2
- package/types.d.mts.map +1 -0
- package/{tools/types.d.ts → types.d.ts} +10 -2
- package/types.d.ts.map +1 -0
- package/{tools/types.js → types.js} +12 -0
- package/types.js.map +1 -0
- package/{tools/types.mjs → types.mjs} +11 -0
- package/types.mjs.map +1 -0
- package/util.d.mts +4 -0
- package/util.d.mts.map +1 -0
- package/util.d.ts +4 -0
- package/util.d.ts.map +1 -0
- package/util.js +30 -0
- package/util.js.map +1 -0
- package/util.mjs +24 -0
- package/util.mjs.map +1 -0
- package/compat.d.mts +0 -58
- package/compat.d.mts.map +0 -1
- package/compat.d.ts +0 -58
- package/compat.d.ts.map +0 -1
- package/compat.js +0 -387
- package/compat.js.map +0 -1
- package/compat.mjs +0 -378
- package/compat.mjs.map +0 -1
- package/docs-search-tool.d.mts +0 -44
- package/docs-search-tool.d.mts.map +0 -1
- package/docs-search-tool.d.ts +0 -44
- package/docs-search-tool.d.ts.map +0 -1
- package/docs-search-tool.js +0 -43
- package/docs-search-tool.js.map +0 -1
- package/docs-search-tool.mjs +0 -39
- package/docs-search-tool.mjs.map +0 -1
- package/dynamic-tools.d.mts +0 -12
- package/dynamic-tools.d.mts.map +0 -1
- package/dynamic-tools.d.ts +0 -12
- package/dynamic-tools.d.ts.map +0 -1
- package/dynamic-tools.js +0 -135
- package/dynamic-tools.js.map +0 -1
- package/dynamic-tools.mjs +0 -132
- package/dynamic-tools.mjs.map +0 -1
- package/filtering.d.mts +0 -2
- package/filtering.d.mts.map +0 -1
- package/filtering.d.ts +0 -2
- package/filtering.d.ts.map +0 -1
- package/filtering.js +0 -20
- package/filtering.js.map +0 -1
- package/filtering.mjs +0 -13
- package/filtering.mjs.map +0 -1
- package/handlers/get-accounts.d.mts +0 -3
- package/handlers/get-accounts.d.mts.map +0 -1
- package/handlers/get-accounts.d.ts +0 -3
- package/handlers/get-accounts.d.ts.map +0 -1
- package/handlers/get-accounts.js +0 -32
- package/handlers/get-accounts.js.map +0 -1
- package/handlers/get-accounts.mjs +0 -28
- package/handlers/get-accounts.mjs.map +0 -1
- package/handlers/get-chat.d.mts +0 -3
- package/handlers/get-chat.d.mts.map +0 -1
- package/handlers/get-chat.d.ts +0 -3
- package/handlers/get-chat.d.ts.map +0 -1
- package/handlers/get-chat.js +0 -20
- package/handlers/get-chat.js.map +0 -1
- package/handlers/get-chat.mjs +0 -16
- package/handlers/get-chat.mjs.map +0 -1
- package/handlers/index.d.mts +0 -3
- package/handlers/index.d.mts.map +0 -1
- package/handlers/index.d.ts +0 -3
- package/handlers/index.d.ts.map +0 -1
- package/handlers/index.js +0 -30
- package/handlers/index.js.map +0 -1
- package/handlers/index.mjs +0 -27
- package/handlers/index.mjs.map +0 -1
- package/handlers/list-chats.d.mts +0 -3
- package/handlers/list-chats.d.mts.map +0 -1
- package/handlers/list-chats.d.ts +0 -3
- package/handlers/list-chats.d.ts.map +0 -1
- package/handlers/list-chats.js +0 -46
- package/handlers/list-chats.js.map +0 -1
- package/handlers/list-chats.mjs +0 -42
- package/handlers/list-chats.mjs.map +0 -1
- package/handlers/list-messages.d.mts +0 -3
- package/handlers/list-messages.d.mts.map +0 -1
- package/handlers/list-messages.d.ts +0 -3
- package/handlers/list-messages.d.ts.map +0 -1
- package/handlers/list-messages.js +0 -34
- package/handlers/list-messages.js.map +0 -1
- package/handlers/list-messages.mjs +0 -30
- package/handlers/list-messages.mjs.map +0 -1
- package/handlers/open-app.d.mts +0 -3
- package/handlers/open-app.d.mts.map +0 -1
- package/handlers/open-app.d.ts +0 -3
- package/handlers/open-app.d.ts.map +0 -1
- package/handlers/open-app.js +0 -26
- package/handlers/open-app.js.map +0 -1
- package/handlers/open-app.mjs +0 -22
- package/handlers/open-app.mjs.map +0 -1
- package/handlers/search-chats.d.mts +0 -3
- package/handlers/search-chats.d.mts.map +0 -1
- package/handlers/search-chats.d.ts +0 -3
- package/handlers/search-chats.d.ts.map +0 -1
- package/handlers/search-chats.js +0 -38
- package/handlers/search-chats.js.map +0 -1
- package/handlers/search-chats.mjs +0 -34
- package/handlers/search-chats.mjs.map +0 -1
- package/handlers/search-messages.d.mts +0 -3
- package/handlers/search-messages.d.mts.map +0 -1
- package/handlers/search-messages.d.ts +0 -3
- package/handlers/search-messages.d.ts.map +0 -1
- package/handlers/search-messages.js +0 -11
- package/handlers/search-messages.js.map +0 -1
- package/handlers/search-messages.mjs +0 -7
- package/handlers/search-messages.mjs.map +0 -1
- package/handlers/search.d.mts +0 -3
- package/handlers/search.d.mts.map +0 -1
- package/handlers/search.d.ts +0 -3
- package/handlers/search.d.ts.map +0 -1
- package/handlers/search.js +0 -29
- package/handlers/search.js.map +0 -1
- package/handlers/search.mjs +0 -25
- package/handlers/search.mjs.map +0 -1
- package/handlers/send-message.d.mts +0 -3
- package/handlers/send-message.d.mts.map +0 -1
- package/handlers/send-message.d.ts +0 -3
- package/handlers/send-message.d.ts.map +0 -1
- package/handlers/send-message.js +0 -20
- package/handlers/send-message.js.map +0 -1
- package/handlers/send-message.mjs +0 -16
- package/handlers/send-message.mjs.map +0 -1
- package/handlers/utils.d.mts +0 -29
- package/handlers/utils.d.mts.map +0 -1
- package/handlers/utils.d.ts +0 -29
- package/handlers/utils.d.ts.map +0 -1
- package/handlers/utils.js +0 -296
- package/handlers/utils.js.map +0 -1
- package/handlers/utils.mjs +0 -282
- package/handlers/utils.mjs.map +0 -1
- package/headers.d.mts +0 -4
- package/headers.d.mts.map +0 -1
- package/headers.d.ts +0 -4
- package/headers.d.ts.map +0 -1
- package/headers.js +0 -22
- package/headers.js.map +0 -1
- package/headers.mjs +0 -18
- package/headers.mjs.map +0 -1
- package/src/compat.ts +0 -483
- package/src/docs-search-tool.ts +0 -48
- package/src/dynamic-tools.ts +0 -159
- package/src/filtering.ts +0 -14
- package/src/handlers/get-accounts.ts +0 -28
- package/src/handlers/get-chat.ts +0 -18
- package/src/handlers/index.ts +0 -29
- package/src/handlers/list-chats.ts +0 -47
- package/src/handlers/list-messages.ts +0 -33
- package/src/handlers/open-app.ts +0 -20
- package/src/handlers/search-chats.ts +0 -39
- package/src/handlers/search-messages.ts +0 -8
- package/src/handlers/search.ts +0 -24
- package/src/handlers/send-message.ts +0 -17
- package/src/handlers/utils.ts +0 -381
- package/src/headers.ts +0 -23
- package/src/tools/accounts/get-accounts.ts +0 -34
- package/src/tools/chats/archive-chat.ts +0 -43
- package/src/tools/chats/get-chat.ts +0 -45
- package/src/tools/chats/reminders/clear-chat-reminder.ts +0 -41
- package/src/tools/chats/reminders/set-chat-reminder.ts +0 -54
- package/src/tools/chats/search-chats.ts +0 -104
- package/src/tools/index.ts +0 -92
- package/src/tools/messages/list-messages.ts +0 -51
- package/src/tools/messages/search-messages.ts +0 -123
- package/src/tools/messages/send-message.ts +0 -47
- package/src/tools/top-level/focus-app.ts +0 -52
- package/src/tools/top-level/search.ts +0 -41
- package/src/tools.ts +0 -1
- package/tools/accounts/get-accounts.d.mts +0 -45
- package/tools/accounts/get-accounts.d.mts.map +0 -1
- package/tools/accounts/get-accounts.d.ts +0 -45
- package/tools/accounts/get-accounts.d.ts.map +0 -1
- package/tools/accounts/get-accounts.js +0 -31
- package/tools/accounts/get-accounts.js.map +0 -1
- package/tools/accounts/get-accounts.mjs +0 -27
- package/tools/accounts/get-accounts.mjs.map +0 -1
- package/tools/chats/archive-chat.d.mts +0 -45
- package/tools/chats/archive-chat.d.mts.map +0 -1
- package/tools/chats/archive-chat.d.ts +0 -45
- package/tools/chats/archive-chat.d.ts.map +0 -1
- package/tools/chats/archive-chat.js +0 -40
- package/tools/chats/archive-chat.js.map +0 -1
- package/tools/chats/archive-chat.mjs +0 -36
- package/tools/chats/archive-chat.mjs.map +0 -1
- package/tools/chats/get-chat.d.mts +0 -45
- package/tools/chats/get-chat.d.mts.map +0 -1
- package/tools/chats/get-chat.d.ts +0 -45
- package/tools/chats/get-chat.d.ts.map +0 -1
- package/tools/chats/get-chat.js +0 -41
- package/tools/chats/get-chat.js.map +0 -1
- package/tools/chats/get-chat.mjs +0 -37
- package/tools/chats/get-chat.mjs.map +0 -1
- package/tools/chats/reminders/clear-chat-reminder.d.mts +0 -45
- package/tools/chats/reminders/clear-chat-reminder.d.mts.map +0 -1
- package/tools/chats/reminders/clear-chat-reminder.d.ts +0 -45
- package/tools/chats/reminders/clear-chat-reminder.d.ts.map +0 -1
- package/tools/chats/reminders/clear-chat-reminder.js +0 -38
- package/tools/chats/reminders/clear-chat-reminder.js.map +0 -1
- package/tools/chats/reminders/clear-chat-reminder.mjs +0 -34
- package/tools/chats/reminders/clear-chat-reminder.mjs.map +0 -1
- package/tools/chats/reminders/set-chat-reminder.d.mts +0 -45
- package/tools/chats/reminders/set-chat-reminder.d.mts.map +0 -1
- package/tools/chats/reminders/set-chat-reminder.d.ts +0 -45
- package/tools/chats/reminders/set-chat-reminder.d.ts.map +0 -1
- package/tools/chats/reminders/set-chat-reminder.js +0 -51
- package/tools/chats/reminders/set-chat-reminder.js.map +0 -1
- package/tools/chats/reminders/set-chat-reminder.mjs +0 -47
- package/tools/chats/reminders/set-chat-reminder.mjs.map +0 -1
- package/tools/chats/search-chats.d.mts +0 -45
- package/tools/chats/search-chats.d.mts.map +0 -1
- package/tools/chats/search-chats.d.ts +0 -45
- package/tools/chats/search-chats.d.ts.map +0 -1
- package/tools/chats/search-chats.js +0 -92
- package/tools/chats/search-chats.js.map +0 -1
- package/tools/chats/search-chats.mjs +0 -88
- package/tools/chats/search-chats.mjs.map +0 -1
- package/tools/index.d.mts +0 -10
- package/tools/index.d.mts.map +0 -1
- package/tools/index.d.ts +0 -10
- package/tools/index.d.ts.map +0 -1
- package/tools/index.js +0 -76
- package/tools/index.js.map +0 -1
- package/tools/index.mjs +0 -69
- package/tools/index.mjs.map +0 -1
- package/tools/messages/list-messages.d.mts +0 -45
- package/tools/messages/list-messages.d.mts.map +0 -1
- package/tools/messages/list-messages.d.ts +0 -45
- package/tools/messages/list-messages.d.ts.map +0 -1
- package/tools/messages/list-messages.js +0 -47
- package/tools/messages/list-messages.js.map +0 -1
- package/tools/messages/list-messages.mjs +0 -43
- package/tools/messages/list-messages.mjs.map +0 -1
- package/tools/messages/search-messages.d.mts +0 -45
- package/tools/messages/search-messages.d.mts.map +0 -1
- package/tools/messages/search-messages.d.ts +0 -45
- package/tools/messages/search-messages.d.ts.map +0 -1
- package/tools/messages/search-messages.js +0 -110
- package/tools/messages/search-messages.js.map +0 -1
- package/tools/messages/search-messages.mjs +0 -106
- package/tools/messages/search-messages.mjs.map +0 -1
- package/tools/messages/send-message.d.mts +0 -45
- package/tools/messages/send-message.d.mts.map +0 -1
- package/tools/messages/send-message.d.ts +0 -45
- package/tools/messages/send-message.d.ts.map +0 -1
- package/tools/messages/send-message.js +0 -43
- package/tools/messages/send-message.js.map +0 -1
- package/tools/messages/send-message.mjs +0 -39
- package/tools/messages/send-message.mjs.map +0 -1
- package/tools/top-level/focus-app.d.mts +0 -45
- package/tools/top-level/focus-app.d.mts.map +0 -1
- package/tools/top-level/focus-app.d.ts +0 -45
- package/tools/top-level/focus-app.d.ts.map +0 -1
- package/tools/top-level/focus-app.js +0 -47
- package/tools/top-level/focus-app.js.map +0 -1
- package/tools/top-level/focus-app.mjs +0 -43
- package/tools/top-level/focus-app.mjs.map +0 -1
- package/tools/top-level/search.d.mts +0 -45
- package/tools/top-level/search.d.mts.map +0 -1
- package/tools/top-level/search.d.ts +0 -45
- package/tools/top-level/search.d.ts.map +0 -1
- package/tools/top-level/search.js +0 -37
- package/tools/top-level/search.js.map +0 -1
- package/tools/top-level/search.mjs +0 -33
- package/tools/top-level/search.mjs.map +0 -1
- package/tools/types.d.mts.map +0 -1
- package/tools/types.d.ts.map +0 -1
- package/tools/types.js.map +0 -1
- package/tools/types.mjs.map +0 -1
- package/tools.d.mts +0 -2
- package/tools.d.mts.map +0 -1
- package/tools.d.ts +0 -2
- package/tools.d.ts.map +0 -1
- package/tools.js +0 -18
- package/tools.js.map +0 -1
- package/tools.mjs +0 -2
- package/tools.mjs.map +0 -1
package/src/dynamic-tools.ts
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import BeeperDesktop from '@beeper/desktop-api';
|
|
2
|
-
import { Endpoint, asTextContentResult, ToolCallResult } from './tools/types';
|
|
3
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import { Cabidela } from '@cloudflare/cabidela';
|
|
6
|
-
|
|
7
|
-
function zodToInputSchema(schema: z.ZodSchema) {
|
|
8
|
-
return {
|
|
9
|
-
type: 'object' as const,
|
|
10
|
-
...(zodToJsonSchema(schema) as any),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A list of tools that expose all the endpoints in the API dynamically.
|
|
16
|
-
*
|
|
17
|
-
* Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
|
|
18
|
-
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
19
|
-
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
20
|
-
*
|
|
21
|
-
* @param endpoints - The endpoints to include in the list.
|
|
22
|
-
*/
|
|
23
|
-
export function dynamicTools(endpoints: Endpoint[]): Endpoint[] {
|
|
24
|
-
const listEndpointsSchema = z.object({
|
|
25
|
-
search_query: z
|
|
26
|
-
.string()
|
|
27
|
-
.optional()
|
|
28
|
-
.describe(
|
|
29
|
-
'An optional search query to filter the endpoints by. Provide a partial name, resource, operation, or tag to filter the endpoints returned.',
|
|
30
|
-
),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const listEndpointsTool = {
|
|
34
|
-
metadata: {
|
|
35
|
-
resource: 'dynamic_tools',
|
|
36
|
-
operation: 'read' as const,
|
|
37
|
-
tags: [],
|
|
38
|
-
},
|
|
39
|
-
tool: {
|
|
40
|
-
name: 'list_api_endpoints',
|
|
41
|
-
description: 'List or search for all endpoints in the TypeScript SDK for Beeper Desktop API',
|
|
42
|
-
inputSchema: zodToInputSchema(listEndpointsSchema),
|
|
43
|
-
},
|
|
44
|
-
handler: async (
|
|
45
|
-
client: BeeperDesktop,
|
|
46
|
-
args: Record<string, unknown> | undefined,
|
|
47
|
-
): Promise<ToolCallResult> => {
|
|
48
|
-
const query = args && listEndpointsSchema.parse(args).search_query?.trim();
|
|
49
|
-
|
|
50
|
-
const filteredEndpoints =
|
|
51
|
-
query && query.length > 0 ?
|
|
52
|
-
endpoints.filter((endpoint) => {
|
|
53
|
-
const fieldsToMatch = [
|
|
54
|
-
endpoint.tool.name,
|
|
55
|
-
endpoint.tool.description,
|
|
56
|
-
endpoint.metadata.resource,
|
|
57
|
-
endpoint.metadata.operation,
|
|
58
|
-
...endpoint.metadata.tags,
|
|
59
|
-
];
|
|
60
|
-
return fieldsToMatch.some((field) => field && field.toLowerCase().includes(query.toLowerCase()));
|
|
61
|
-
})
|
|
62
|
-
: endpoints;
|
|
63
|
-
|
|
64
|
-
return asTextContentResult({
|
|
65
|
-
tools: filteredEndpoints.map(({ tool, metadata }) => ({
|
|
66
|
-
name: tool.name,
|
|
67
|
-
description: tool.description,
|
|
68
|
-
resource: metadata.resource,
|
|
69
|
-
operation: metadata.operation,
|
|
70
|
-
tags: metadata.tags,
|
|
71
|
-
})),
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const getEndpointSchema = z.object({
|
|
77
|
-
endpoint: z.string().describe('The name of the endpoint to get the schema for.'),
|
|
78
|
-
});
|
|
79
|
-
const getEndpointTool = {
|
|
80
|
-
metadata: {
|
|
81
|
-
resource: 'dynamic_tools',
|
|
82
|
-
operation: 'read' as const,
|
|
83
|
-
tags: [],
|
|
84
|
-
},
|
|
85
|
-
tool: {
|
|
86
|
-
name: 'get_api_endpoint_schema',
|
|
87
|
-
description:
|
|
88
|
-
'Get the schema for an endpoint in the TypeScript SDK for Beeper Desktop API. You can use the schema returned by this tool to invoke an endpoint with the `invoke_api_endpoint` tool.',
|
|
89
|
-
inputSchema: zodToInputSchema(getEndpointSchema),
|
|
90
|
-
},
|
|
91
|
-
handler: async (client: BeeperDesktop, args: Record<string, unknown> | undefined) => {
|
|
92
|
-
if (!args) {
|
|
93
|
-
throw new Error('No endpoint provided');
|
|
94
|
-
}
|
|
95
|
-
const endpointName = getEndpointSchema.parse(args).endpoint;
|
|
96
|
-
|
|
97
|
-
const endpoint = endpoints.find((e) => e.tool.name === endpointName);
|
|
98
|
-
if (!endpoint) {
|
|
99
|
-
throw new Error(`Endpoint ${endpointName} not found`);
|
|
100
|
-
}
|
|
101
|
-
return asTextContentResult(endpoint.tool);
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const invokeEndpointSchema = z.object({
|
|
106
|
-
endpoint_name: z.string().describe('The name of the endpoint to invoke.'),
|
|
107
|
-
args: z
|
|
108
|
-
.record(z.string(), z.any())
|
|
109
|
-
.describe(
|
|
110
|
-
'The arguments to pass to the endpoint. This must match the schema returned by the `get_api_endpoint_schema` tool.',
|
|
111
|
-
),
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const invokeEndpointTool = {
|
|
115
|
-
metadata: {
|
|
116
|
-
resource: 'dynamic_tools',
|
|
117
|
-
operation: 'write' as const,
|
|
118
|
-
tags: [],
|
|
119
|
-
},
|
|
120
|
-
tool: {
|
|
121
|
-
name: 'invoke_api_endpoint',
|
|
122
|
-
description:
|
|
123
|
-
'Invoke an endpoint in the TypeScript SDK for Beeper Desktop API. Note: use the `list_api_endpoints` tool to get the list of endpoints and `get_api_endpoint_schema` tool to get the schema for an endpoint.',
|
|
124
|
-
inputSchema: zodToInputSchema(invokeEndpointSchema),
|
|
125
|
-
},
|
|
126
|
-
handler: async (
|
|
127
|
-
client: BeeperDesktop,
|
|
128
|
-
args: Record<string, unknown> | undefined,
|
|
129
|
-
): Promise<ToolCallResult> => {
|
|
130
|
-
if (!args) {
|
|
131
|
-
throw new Error('No endpoint provided');
|
|
132
|
-
}
|
|
133
|
-
const { success, data, error } = invokeEndpointSchema.safeParse(args);
|
|
134
|
-
if (!success) {
|
|
135
|
-
throw new Error(`Invalid arguments for endpoint. ${error?.format()}`);
|
|
136
|
-
}
|
|
137
|
-
const { endpoint_name, args: endpointArgs } = data;
|
|
138
|
-
|
|
139
|
-
const endpoint = endpoints.find((e) => e.tool.name === endpoint_name);
|
|
140
|
-
if (!endpoint) {
|
|
141
|
-
throw new Error(
|
|
142
|
-
`Endpoint ${endpoint_name} not found. Use the \`list_api_endpoints\` tool to get the list of available endpoints.`,
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
try {
|
|
147
|
-
// Try to validate the arguments for a better error message
|
|
148
|
-
const cabidela = new Cabidela(endpoint.tool.inputSchema, { fullErrors: true });
|
|
149
|
-
cabidela.validate(endpointArgs);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
throw new Error(`Invalid arguments for endpoint ${endpoint_name}:\n${error}`);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return await endpoint.handler(client, endpointArgs);
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
return [getEndpointTool, listEndpointsTool, invokeEndpointTool];
|
|
159
|
-
}
|
package/src/filtering.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import initJq from 'jq-web';
|
|
3
|
-
|
|
4
|
-
export async function maybeFilter(jqFilter: unknown | undefined, response: any): Promise<any> {
|
|
5
|
-
if (jqFilter && typeof jqFilter === 'string') {
|
|
6
|
-
return await jq(response, jqFilter);
|
|
7
|
-
} else {
|
|
8
|
-
return response;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async function jq(json: any, jqFilter: string) {
|
|
13
|
-
return (await initJq).json(json, jqFilter);
|
|
14
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { HandlerFunction } from '../tools/types';
|
|
2
|
-
import { asMarkdownContentResult } from './utils';
|
|
3
|
-
|
|
4
|
-
export const handler: HandlerFunction = async (client) => {
|
|
5
|
-
const accounts = await client.accounts.list();
|
|
6
|
-
if (!accounts || accounts.length === 0)
|
|
7
|
-
throw new Error('No accounts found. This should never happen, please contact help@beeper.com.');
|
|
8
|
-
const lines: string[] = [];
|
|
9
|
-
lines.push('# Accounts');
|
|
10
|
-
for (const acc of accounts) {
|
|
11
|
-
if (!acc.user) {
|
|
12
|
-
lines.push(`\n## ${acc.network}`);
|
|
13
|
-
lines.push(`**Account ID**: \`${acc.accountID}\``);
|
|
14
|
-
lines.push('**User**: Unknown');
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const name = acc.user.fullName || acc.user.username || acc.user.id;
|
|
19
|
-
lines.push(`\n## ${acc.network}`);
|
|
20
|
-
lines.push(`**Account ID**: \`${acc.accountID}\``);
|
|
21
|
-
lines.push(`**User**: ${name}`);
|
|
22
|
-
if (acc.user.email) lines.push(`**Email**: ${acc.user.email}`);
|
|
23
|
-
if (acc.user.phoneNumber) lines.push(`**Phone**: ${acc.user.phoneNumber}`);
|
|
24
|
-
}
|
|
25
|
-
lines.push('\n# Using this information\n');
|
|
26
|
-
lines.push('- Pass accountIDs to narrow chat/message queries when known.');
|
|
27
|
-
return asMarkdownContentResult(lines);
|
|
28
|
-
};
|
package/src/handlers/get-chat.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { HandlerFunction } from '../tools/types';
|
|
2
|
-
import { asMarkdownContentResult, formatChatToMarkdown } from './utils';
|
|
3
|
-
|
|
4
|
-
export const handler: HandlerFunction = async (client, args) => {
|
|
5
|
-
const { chatID, ...queryParams } = args as any;
|
|
6
|
-
const chat = await client.chats.retrieve(chatID, queryParams);
|
|
7
|
-
|
|
8
|
-
const lines: string[] = [];
|
|
9
|
-
if (!chat) {
|
|
10
|
-
lines.push('Chat not found.');
|
|
11
|
-
return asMarkdownContentResult(lines);
|
|
12
|
-
}
|
|
13
|
-
lines.push(formatChatToMarkdown(chat, undefined));
|
|
14
|
-
lines.push('\n# Using this information\n');
|
|
15
|
-
lines.push('- Use search_messages to find specific content in this chat.');
|
|
16
|
-
lines.push('- Link the "open" link to the user to allow them to view the chat in Beeper Desktop.');
|
|
17
|
-
return asMarkdownContentResult(lines);
|
|
18
|
-
};
|
package/src/handlers/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Endpoint, HandlerFunction } from '../tools';
|
|
2
|
-
|
|
3
|
-
import { handler as get_accounts } from './get-accounts';
|
|
4
|
-
import { handler as open_in_app } from './open-app';
|
|
5
|
-
import { handler as search } from './search';
|
|
6
|
-
import { handler as get_chat } from './get-chat';
|
|
7
|
-
import { handler as search_chats } from './search-chats';
|
|
8
|
-
import { handler as search_messages } from './search-messages';
|
|
9
|
-
import { handler as send_message } from './send-message';
|
|
10
|
-
|
|
11
|
-
const HANDLER_OVERRIDES: Record<string, HandlerFunction> = {
|
|
12
|
-
get_accounts,
|
|
13
|
-
open_in_app,
|
|
14
|
-
focus_app: open_in_app,
|
|
15
|
-
search,
|
|
16
|
-
get_chat,
|
|
17
|
-
search_chats,
|
|
18
|
-
search_messages,
|
|
19
|
-
send_message,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function mapEndpoint(endpoint: Endpoint): Endpoint {
|
|
23
|
-
const handler = HANDLER_OVERRIDES[endpoint.tool.name];
|
|
24
|
-
if (!handler) return endpoint;
|
|
25
|
-
return {
|
|
26
|
-
...endpoint,
|
|
27
|
-
handler,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { HandlerFunction } from '../tools/types';
|
|
2
|
-
import { asMarkdownContentResult, formatChatToMarkdown } from './utils';
|
|
3
|
-
|
|
4
|
-
export const handler: HandlerFunction = async (client, args) => {
|
|
5
|
-
const body = args as any;
|
|
6
|
-
const output = await client.chats.search(body);
|
|
7
|
-
|
|
8
|
-
const lines: string[] = [];
|
|
9
|
-
lines.push('# Chats');
|
|
10
|
-
|
|
11
|
-
const items = output.items || [];
|
|
12
|
-
const hasMore = !!output.hasMore;
|
|
13
|
-
|
|
14
|
-
if (hasMore) {
|
|
15
|
-
lines.push(`\nShowing ${items.length} chats (more available)`);
|
|
16
|
-
if (output.oldestCursor) {
|
|
17
|
-
lines.push(`Next page (older): cursor='${output.oldestCursor}', direction='before'`);
|
|
18
|
-
}
|
|
19
|
-
if (output.newestCursor) {
|
|
20
|
-
lines.push(`Previous page (newer): cursor='${output.newestCursor}', direction='after'`);
|
|
21
|
-
}
|
|
22
|
-
} else if (items.length > 0) {
|
|
23
|
-
lines.push(`\nShowing ${items.length} chat${items.length === 1 ? '' : 's'}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (items.length === 0) {
|
|
27
|
-
lines.push('\nNo chats found.');
|
|
28
|
-
} else {
|
|
29
|
-
for (const chatWithPreview of items) {
|
|
30
|
-
lines.push(formatChatToMarkdown(chatWithPreview, undefined));
|
|
31
|
-
const preview = (chatWithPreview as any).preview;
|
|
32
|
-
if (preview) {
|
|
33
|
-
lines.push(`**Last message**: ${preview.text || '(no text)'}`);
|
|
34
|
-
if (preview.senderName) {
|
|
35
|
-
lines.push(`**From**: ${preview.senderName}`);
|
|
36
|
-
}
|
|
37
|
-
lines.push(`**Timestamp**: ${preview.timestamp}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
lines.push('\n# Using this information\n');
|
|
42
|
-
lines.push(
|
|
43
|
-
'- Pass the "chatID" to get_chat or search_messages for details about a chat, or send_message to send a message to a chat.',
|
|
44
|
-
);
|
|
45
|
-
lines.push('- Link the "open" link to the user to allow them to view the chat in Beeper Desktop.');
|
|
46
|
-
return asMarkdownContentResult(lines);
|
|
47
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { asTextContentResult, type HandlerFunction } from '../tools/types';
|
|
2
|
-
import { mapMessagesToText } from './utils';
|
|
3
|
-
|
|
4
|
-
export const handler: HandlerFunction = async (client, args) => {
|
|
5
|
-
const body = args as any;
|
|
6
|
-
const output = await client.messages.search(body);
|
|
7
|
-
|
|
8
|
-
const lines: string[] = [];
|
|
9
|
-
lines.push('# Messages');
|
|
10
|
-
|
|
11
|
-
const items = (output as any).items || [];
|
|
12
|
-
const hasMore = !!(output as any).hasMore;
|
|
13
|
-
|
|
14
|
-
if (hasMore) {
|
|
15
|
-
lines.push(`\nShowing ${items.length} messages (more available)`);
|
|
16
|
-
if ((output as any).oldestCursor) {
|
|
17
|
-
lines.push(`Next page (older): cursor='${(output as any).oldestCursor}', direction='before'`);
|
|
18
|
-
}
|
|
19
|
-
if ((output as any).newestCursor) {
|
|
20
|
-
lines.push(`Previous page (newer): cursor='${(output as any).newestCursor}', direction='after'`);
|
|
21
|
-
}
|
|
22
|
-
} else if (items.length > 0) {
|
|
23
|
-
lines.push(`\nShowing ${items.length} message${items.length === 1 ? '' : 's'}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (items.length === 0) {
|
|
27
|
-
lines.push('\nNo messages found.');
|
|
28
|
-
} else {
|
|
29
|
-
lines.push(mapMessagesToText(output as any, body, undefined));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return asTextContentResult(lines.join('\n'));
|
|
33
|
-
};
|
package/src/handlers/open-app.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { asTextContentResult, type HandlerFunction } from '../tools/types';
|
|
2
|
-
|
|
3
|
-
export const handler: HandlerFunction = async (client, args) => {
|
|
4
|
-
const body = args as any;
|
|
5
|
-
const output = await client.focus(body);
|
|
6
|
-
|
|
7
|
-
const lines: string[] = [];
|
|
8
|
-
if (output.success) {
|
|
9
|
-
lines.push('Beeper was opened.');
|
|
10
|
-
if (body?.chatID) {
|
|
11
|
-
const chatRef = String(body.chatID);
|
|
12
|
-
lines.push(`Focused chat: ${chatRef}`);
|
|
13
|
-
}
|
|
14
|
-
if (body?.draftText) lines.push(`Draft text populated: ${body.draftText}`);
|
|
15
|
-
if (body?.draftAttachmentPath) lines.push(`Draft attachment populated: ${body.draftAttachmentPath}`);
|
|
16
|
-
} else {
|
|
17
|
-
lines.push('Failed to open Beeper.');
|
|
18
|
-
}
|
|
19
|
-
return asTextContentResult(lines.join('\n'));
|
|
20
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { HandlerFunction } from '../tools/types';
|
|
2
|
-
import { asMarkdownContentResult, formatChatToMarkdown } from './utils';
|
|
3
|
-
|
|
4
|
-
export const handler: HandlerFunction = async (client, args) => {
|
|
5
|
-
const body = args as any;
|
|
6
|
-
const output = await client.chats.search(body);
|
|
7
|
-
|
|
8
|
-
const lines: string[] = [];
|
|
9
|
-
lines.push('# Chats');
|
|
10
|
-
|
|
11
|
-
const items = output.items || [];
|
|
12
|
-
const hasMore = !!output.hasMore;
|
|
13
|
-
|
|
14
|
-
if (hasMore) {
|
|
15
|
-
lines.push(`\nFound ${items.length}+ chats (showing ${items.length})`);
|
|
16
|
-
if (output.oldestCursor) {
|
|
17
|
-
lines.push(`Next page (older): cursor='${output.oldestCursor}', direction='before'`);
|
|
18
|
-
}
|
|
19
|
-
if (output.newestCursor) {
|
|
20
|
-
lines.push(`Previous page (newer): cursor='${output.newestCursor}', direction='after'`);
|
|
21
|
-
}
|
|
22
|
-
} else if (items.length > 0) {
|
|
23
|
-
lines.push(`\nFound ${items.length} chat${items.length === 1 ? '' : 's'}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (items.length === 0) {
|
|
27
|
-
lines.push('\nNo chats found.');
|
|
28
|
-
} else {
|
|
29
|
-
for (const chat of items) {
|
|
30
|
-
lines.push(formatChatToMarkdown(chat, undefined));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
lines.push('\n# Using this information\n');
|
|
34
|
-
lines.push(
|
|
35
|
-
'- Pass the "chatID" to get_chat or search_messages for details about a chat, or send_message to send a message to a chat.',
|
|
36
|
-
);
|
|
37
|
-
lines.push('- Link the "open" link to the user to allow them to view the chat in Beeper Desktop.');
|
|
38
|
-
return asMarkdownContentResult(lines);
|
|
39
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { HandlerFunction } from '../tools/types';
|
|
2
|
-
import { mapMessagesToText, asMarkdownContentResult } from './utils';
|
|
3
|
-
|
|
4
|
-
export const handler: HandlerFunction = async (client, args) => {
|
|
5
|
-
const body = args as any;
|
|
6
|
-
const output = await client.messages.search(body);
|
|
7
|
-
return asMarkdownContentResult(mapMessagesToText(output, body, undefined));
|
|
8
|
-
};
|
package/src/handlers/search.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { HandlerFunction } from '../tools/types';
|
|
2
|
-
import { asMarkdownContentResult, formatChatToMarkdown, mapMessagesToText } from './utils';
|
|
3
|
-
|
|
4
|
-
export const handler: HandlerFunction = async (client, args) => {
|
|
5
|
-
const body = args as any;
|
|
6
|
-
const output = await client.search(body);
|
|
7
|
-
|
|
8
|
-
const lines: string[] = [];
|
|
9
|
-
if (body?.query) lines.push(`Query: "${body.query}"`);
|
|
10
|
-
const results = output?.results;
|
|
11
|
-
if (results?.chats?.length) {
|
|
12
|
-
lines.push('\n# Chats');
|
|
13
|
-
for (const chat of results.chats) lines.push(formatChatToMarkdown(chat, undefined));
|
|
14
|
-
}
|
|
15
|
-
if (results?.in_groups?.length) {
|
|
16
|
-
lines.push('\n# In Groups');
|
|
17
|
-
for (const chat of results.in_groups) lines.push(formatChatToMarkdown(chat, undefined));
|
|
18
|
-
}
|
|
19
|
-
if (results?.messages?.items?.length) {
|
|
20
|
-
lines.push('\n# Messages');
|
|
21
|
-
lines.push(mapMessagesToText(results.messages as any, body, undefined));
|
|
22
|
-
}
|
|
23
|
-
return asMarkdownContentResult(lines);
|
|
24
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { HandlerFunction } from '../tools/types';
|
|
2
|
-
import { asMarkdownContentResult, createOpenLink } from './utils';
|
|
3
|
-
|
|
4
|
-
export const handler: HandlerFunction = async (client, args) => {
|
|
5
|
-
const { chatID, ...body } = args as any;
|
|
6
|
-
const output = await client.messages.send(chatID, body);
|
|
7
|
-
|
|
8
|
-
const lines: string[] = [];
|
|
9
|
-
if (output.pendingMessageID) {
|
|
10
|
-
const deeplink = createOpenLink('', chatID ?? '');
|
|
11
|
-
if (deeplink) lines.push(`**Open the chat in Beeper**: ${deeplink}`);
|
|
12
|
-
} else {
|
|
13
|
-
lines.push('Failed to send message.');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return asMarkdownContentResult(lines);
|
|
17
|
-
};
|