@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/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2026 beeperdesktop
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
# Beeper Desktop
|
|
1
|
+
# TypeScript SDK for Beeper Desktop MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
>
|
|
5
|
-
> [Learn more about the built-in Beeper Desktop MCP server here.](https://developers.beeper.com/desktop-api/mcp/)
|
|
3
|
+
It is generated with [Stainless](https://www.stainless.com/).
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
@@ -27,7 +25,7 @@ For clients with a configuration JSON, it might look something like this:
|
|
|
27
25
|
"mcpServers": {
|
|
28
26
|
"beeper_desktop_api_api": {
|
|
29
27
|
"command": "npx",
|
|
30
|
-
"args": ["-y", "@beeper/desktop-mcp"
|
|
28
|
+
"args": ["-y", "@beeper/desktop-mcp"],
|
|
31
29
|
"env": {
|
|
32
30
|
"BEEPER_ACCESS_TOKEN": "My Access Token"
|
|
33
31
|
}
|
|
@@ -41,14 +39,14 @@ For clients with a configuration JSON, it might look something like this:
|
|
|
41
39
|
If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
|
|
42
40
|
in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.
|
|
43
41
|
|
|
44
|
-
[](https://cursor.com/en-US/install-mcp?name
|
|
42
|
+
[](https://cursor.com/en-US/install-mcp?name=%40beeper%2Fdesktop-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBiZWVwZXIvZGVza3RvcC1tY3AiXSwiZW52Ijp7IkJFRVBFUl9BQ0NFU1NfVE9LRU4iOiJNeSBBY2Nlc3MgVG9rZW4ifX0)
|
|
45
43
|
|
|
46
44
|
### VS Code
|
|
47
45
|
|
|
48
46
|
If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables
|
|
49
47
|
in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration.
|
|
50
48
|
|
|
51
|
-
[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40beeper%2Fdesktop-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40beeper%2Fdesktop-mcp%22%5D%2C%22env%22%3A%7B%22BEEPER_ACCESS_TOKEN%22%3A%
|
|
49
|
+
[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40beeper%2Fdesktop-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40beeper%2Fdesktop-mcp%22%5D%2C%22env%22%3A%7B%22BEEPER_ACCESS_TOKEN%22%3A%22My%20Access%20Token%22%7D%7D)
|
|
52
50
|
|
|
53
51
|
### Claude Code
|
|
54
52
|
|
|
@@ -56,114 +54,25 @@ If you use Claude Code, you can install the MCP server by running the command be
|
|
|
56
54
|
environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
|
|
57
55
|
|
|
58
56
|
```
|
|
59
|
-
claude mcp add
|
|
57
|
+
claude mcp add beeper_desktop_mcp_api --env BEEPER_ACCESS_TOKEN="My Access Token" -- npx -y @beeper/desktop-mcp
|
|
60
58
|
```
|
|
61
59
|
|
|
62
|
-
##
|
|
60
|
+
## Code Mode
|
|
63
61
|
|
|
64
|
-
|
|
62
|
+
This MCP server is built on the "Code Mode" tool scheme. In this MCP Server,
|
|
63
|
+
your agent will write code against the TypeScript SDK, which will then be executed in an
|
|
64
|
+
isolated sandbox. To accomplish this, the server will expose two tools to your agent:
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
3. Exposing a docs search tool and a code execution tool, allowing the client to write code to be executed against the TypeScript client
|
|
66
|
+
- The first tool is a docs search tool, which can be used to generically query for
|
|
67
|
+
documentation about your API/SDK.
|
|
69
68
|
|
|
70
|
-
|
|
69
|
+
- The second tool is a code tool, where the agent can write code against the TypeScript SDK.
|
|
70
|
+
The code will be executed in a sandbox environment without web or filesystem access. Then,
|
|
71
|
+
anything the code returns or prints will be returned to the agent as the result of the
|
|
72
|
+
tool call.
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
context window.
|
|
75
|
-
|
|
76
|
-
You can filter by multiple aspects:
|
|
77
|
-
|
|
78
|
-
- `--tool` includes a specific tool by name
|
|
79
|
-
- `--resource` includes all tools under a specific resource, and can have wildcards, e.g. `my.resource*`
|
|
80
|
-
- `--operation` includes just read (get/list) or just write operations
|
|
81
|
-
- `--tag` includes a set of endpoints with custom tags provided
|
|
82
|
-
|
|
83
|
-
### Dynamic tools
|
|
84
|
-
|
|
85
|
-
If you specify `--tools=dynamic` to the MCP server, instead of exposing one tool per endpoint in the API, it will
|
|
86
|
-
expose the following tools:
|
|
87
|
-
|
|
88
|
-
1. `list_api_endpoints` - Discovers available endpoints, with optional filtering by search query
|
|
89
|
-
2. `get_api_endpoint_schema` - Gets detailed schema information for a specific endpoint
|
|
90
|
-
3. `invoke_api_endpoint` - Executes any endpoint with the appropriate parameters
|
|
91
|
-
|
|
92
|
-
This allows you to have the full set of API endpoints available to your MCP Client, while not requiring that all
|
|
93
|
-
of their schemas be loaded into context at once. Instead, the LLM will automatically use these tools together to
|
|
94
|
-
search for, look up, and invoke endpoints dynamically. However, due to the indirect nature of the schemas, it
|
|
95
|
-
can struggle to provide the correct properties a bit more than when tools are imported explicitly. Therefore,
|
|
96
|
-
you can opt-in to explicit tools, the dynamic tools, or both.
|
|
97
|
-
|
|
98
|
-
See more information with `--help`.
|
|
99
|
-
|
|
100
|
-
All of these command-line options can be repeated, combined together, and have corresponding exclusion versions (e.g. `--no-tool`).
|
|
101
|
-
|
|
102
|
-
Use `--list` to see the list of available tools, or see below.
|
|
103
|
-
|
|
104
|
-
### Code execution
|
|
105
|
-
|
|
106
|
-
If you specify `--tools=code` to the MCP server, it will expose just two tools:
|
|
107
|
-
|
|
108
|
-
- `search_docs` - Searches the API documentation and returns a list of markdown results
|
|
109
|
-
- `execute` - Runs code against the TypeScript client
|
|
110
|
-
|
|
111
|
-
This allows the LLM to implement more complex logic by chaining together many API calls without loading
|
|
112
|
-
intermediary results into its context window.
|
|
113
|
-
|
|
114
|
-
The code execution itself happens in a Deno sandbox that has network access only to the base URL for the API.
|
|
115
|
-
|
|
116
|
-
### Specifying the MCP Client
|
|
117
|
-
|
|
118
|
-
Different clients have varying abilities to handle arbitrary tools and schemas.
|
|
119
|
-
|
|
120
|
-
You can specify the client you are using with the `--client` argument, and the MCP server will automatically
|
|
121
|
-
serve tools and schemas that are more compatible with that client.
|
|
122
|
-
|
|
123
|
-
- `--client=<type>`: Set all capabilities based on a known MCP client
|
|
124
|
-
|
|
125
|
-
- Valid values: `openai-agents`, `claude`, `claude-code`, `cursor`
|
|
126
|
-
- Example: `--client=cursor`
|
|
127
|
-
|
|
128
|
-
Additionally, if you have a client not on the above list, or the client has gotten better
|
|
129
|
-
over time, you can manually enable or disable certain capabilities:
|
|
130
|
-
|
|
131
|
-
- `--capability=<name>`: Specify individual client capabilities
|
|
132
|
-
- Available capabilities:
|
|
133
|
-
- `top-level-unions`: Enable support for top-level unions in tool schemas
|
|
134
|
-
- `valid-json`: Enable JSON string parsing for arguments
|
|
135
|
-
- `refs`: Enable support for $ref pointers in schemas
|
|
136
|
-
- `unions`: Enable support for union types (anyOf) in schemas
|
|
137
|
-
- `formats`: Enable support for format validations in schemas (e.g. date-time, email)
|
|
138
|
-
- `tool-name-length=N`: Set maximum tool name length to N characters
|
|
139
|
-
- Example: `--capability=top-level-unions --capability=tool-name-length=40`
|
|
140
|
-
- Example: `--capability=top-level-unions,tool-name-length=40`
|
|
141
|
-
|
|
142
|
-
### Examples
|
|
143
|
-
|
|
144
|
-
1. Filter for read operations on cards:
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
--resource=cards --operation=read
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
2. Exclude specific tools while including others:
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
--resource=cards --no-tool=create_cards
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
3. Configure for Cursor client with custom max tool name length:
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
--client=cursor --capability=tool-name-length=40
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
4. Complex filtering with multiple criteria:
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
--resource=cards,accounts --operation=read --tag=kyc --no-tool=create_cards
|
|
166
|
-
```
|
|
74
|
+
Using this scheme, agents are capable of performing very complex tasks deterministically
|
|
75
|
+
and repeatably.
|
|
167
76
|
|
|
168
77
|
## Running remotely
|
|
169
78
|
|
|
@@ -190,93 +99,3 @@ A configuration JSON for this server might look like this, assuming the server i
|
|
|
190
99
|
}
|
|
191
100
|
}
|
|
192
101
|
```
|
|
193
|
-
|
|
194
|
-
The command-line arguments for filtering tools and specifying clients can also be used as query parameters in the URL.
|
|
195
|
-
For example, to exclude specific tools while including others, use the URL:
|
|
196
|
-
|
|
197
|
-
```
|
|
198
|
-
http://localhost:3000?resource=cards&resource=accounts&no_tool=create_cards
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
Or, to configure for the Cursor client, with a custom max tool name length, use the URL:
|
|
202
|
-
|
|
203
|
-
```
|
|
204
|
-
http://localhost:3000?client=cursor&capability=tool-name-length%3D40
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## Importing the tools and server individually
|
|
208
|
-
|
|
209
|
-
```js
|
|
210
|
-
// Import the server, generated endpoints, or the init function
|
|
211
|
-
import { server, endpoints, init } from "@beeper/desktop-mcp/server";
|
|
212
|
-
|
|
213
|
-
// import a specific tool
|
|
214
|
-
import focusApp from "@beeper/desktop-mcp/tools/top-level/focus-app";
|
|
215
|
-
|
|
216
|
-
// initialize the server and all endpoints
|
|
217
|
-
init({ server, endpoints });
|
|
218
|
-
|
|
219
|
-
// manually start server
|
|
220
|
-
const transport = new StdioServerTransport();
|
|
221
|
-
await server.connect(transport);
|
|
222
|
-
|
|
223
|
-
// or initialize your own server with specific tools
|
|
224
|
-
const myServer = new McpServer(...);
|
|
225
|
-
|
|
226
|
-
// define your own endpoint
|
|
227
|
-
const myCustomEndpoint = {
|
|
228
|
-
tool: {
|
|
229
|
-
name: 'my_custom_tool',
|
|
230
|
-
description: 'My custom tool',
|
|
231
|
-
inputSchema: zodToJsonSchema(z.object({ a_property: z.string() })),
|
|
232
|
-
},
|
|
233
|
-
handler: async (client: client, args: any) => {
|
|
234
|
-
return { myResponse: 'Hello world!' };
|
|
235
|
-
})
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
// initialize the server with your custom endpoints
|
|
239
|
-
init({ server: myServer, endpoints: [focusApp, myCustomEndpoint] });
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## Available Tools
|
|
243
|
-
|
|
244
|
-
The following tools are available in this MCP server.
|
|
245
|
-
|
|
246
|
-
### Resource `$client`:
|
|
247
|
-
|
|
248
|
-
- `focus_app` (`write`) tags: [app]: Focus Beeper Desktop and optionally navigate to a specific chat, message, or pre-fill draft text and attachment.
|
|
249
|
-
- `search` (`read`) tags: [app]: Search for chats, participant name matches in groups, and the first page of messages in one call. Use this when the user asks for a specific chat, group, or person.
|
|
250
|
-
|
|
251
|
-
### Resource `accounts`:
|
|
252
|
-
|
|
253
|
-
- `get_accounts` (`read`) tags: [accounts]: List connected accounts on this device.
|
|
254
|
-
|
|
255
|
-
### Resource `chats`:
|
|
256
|
-
|
|
257
|
-
- `get_chat` (`read`) tags: [chats]: Get chat details: metadata, participants (limited), last activity.
|
|
258
|
-
- `archive_chat` (`write`) tags: [chats]: Archive or unarchive a chat.
|
|
259
|
-
- `search_chats` (`read`) tags: [chats]: Search chats by title/network or participants using Beeper Desktop's renderer algorithm. Optional 'scope'.
|
|
260
|
-
|
|
261
|
-
### Resource `chats.reminders`:
|
|
262
|
-
|
|
263
|
-
- `set_chat_reminder` (`write`) tags: [chats]: Set a reminder for a chat at a specific time.
|
|
264
|
-
- `clear_chat_reminder` (`write`) tags: [chats]: Clear a chat reminder.
|
|
265
|
-
|
|
266
|
-
### Resource `messages`:
|
|
267
|
-
|
|
268
|
-
- `list_messages` (`read`) tags: [messages]: List messages from a specific chat with pagination support.
|
|
269
|
-
- `search_messages` (`read`) tags: [messages]: Search messages across chats using Beeper's message index.
|
|
270
|
-
- When to use: find messages by text and/or filters (chatIDs, accountIDs, chatType, media type filters, sender, date ranges).
|
|
271
|
-
- CRITICAL: Query is LITERAL WORD MATCHING, NOT semantic search! Only finds messages containing these EXACT words.
|
|
272
|
-
• ✅ RIGHT: query="dinner" or query="sick" or query="error" (single words users type)
|
|
273
|
-
• ❌ WRONG: query="dinner plans tonight" or query="health issues" (phrases/concepts)
|
|
274
|
-
• The query matches ALL words provided (in any order). Example: query="flight booking" finds messages with both "flight" AND "booking".
|
|
275
|
-
- Performance: provide chatIDs/accountIDs when known. Omitted 'query' returns results based on filters only. Partial matches enabled; 'excludeLowPriority' defaults to true.
|
|
276
|
-
- Workflow tip: To search messages in specific conversations: 1) Use find-chats to get chatIDs, 2) Use search-messages with those chatIDs.
|
|
277
|
-
- IMPORTANT: Chat names vary widely. ASK the user for clarification:
|
|
278
|
-
• "Which chat do you mean by family?" (could be "The Smiths", "Mom Dad Kids", etc.)
|
|
279
|
-
• "What's the name of your work chat?" (could be "Team", company name, project name)
|
|
280
|
-
• "Who are the participants?" (use scope="participants" in search-chats)
|
|
281
|
-
Returns: matching messages and referenced chats.
|
|
282
|
-
- `send_message` (`write`) tags: [messages]: Send a text message to a specific chat. Supports replying to existing messages. Returns the sent message ID and a deeplink to the chat
|
package/auth.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IncomingMessage } from 'node:http';
|
|
2
|
+
import { ClientOptions } from '@beeper/desktop-api';
|
|
3
|
+
import { McpOptions } from "./options.mjs";
|
|
4
|
+
export declare const parseClientAuthHeaders: (req: IncomingMessage, required?: boolean) => Partial<ClientOptions>;
|
|
5
|
+
export declare const getStainlessApiKey: (req: IncomingMessage, mcpOptions: McpOptions) => string | undefined;
|
|
6
|
+
//# sourceMappingURL=auth.d.mts.map
|
package/auth.d.mts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.mts","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":"OAEO,EAAE,eAAe,EAAE,MAAM,WAAW;OACpC,EAAE,aAAa,EAAE,MAAM,qBAAqB;OAC5C,EAAE,UAAU,EAAE;AAErB,eAAO,MAAM,sBAAsB,GAAI,KAAK,eAAe,EAAE,WAAW,OAAO,KAAG,OAAO,CAAC,aAAa,CAqBtG,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,KAAK,eAAe,EAAE,YAAY,UAAU,KAAG,MAAM,GAAG,SAY1F,CAAC"}
|
package/auth.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IncomingMessage } from 'node:http';
|
|
2
|
+
import { ClientOptions } from '@beeper/desktop-api';
|
|
3
|
+
import { McpOptions } from "./options.js";
|
|
4
|
+
export declare const parseClientAuthHeaders: (req: IncomingMessage, required?: boolean) => Partial<ClientOptions>;
|
|
5
|
+
export declare const getStainlessApiKey: (req: IncomingMessage, mcpOptions: McpOptions) => string | undefined;
|
|
6
|
+
//# sourceMappingURL=auth.d.ts.map
|
package/auth.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":"OAEO,EAAE,eAAe,EAAE,MAAM,WAAW;OACpC,EAAE,aAAa,EAAE,MAAM,qBAAqB;OAC5C,EAAE,UAAU,EAAE;AAErB,eAAO,MAAM,sBAAsB,GAAI,KAAK,eAAe,EAAE,WAAW,OAAO,KAAG,OAAO,CAAC,aAAa,CAqBtG,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,KAAK,eAAe,EAAE,YAAY,UAAU,KAAG,MAAM,GAAG,SAY1F,CAAC"}
|
package/auth.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getStainlessApiKey = exports.parseClientAuthHeaders = void 0;
|
|
5
|
+
const parseClientAuthHeaders = (req, required) => {
|
|
6
|
+
if (req.headers.authorization) {
|
|
7
|
+
const scheme = req.headers.authorization.split(' ')[0];
|
|
8
|
+
const value = req.headers.authorization.slice(scheme.length + 1);
|
|
9
|
+
switch (scheme) {
|
|
10
|
+
case 'Bearer':
|
|
11
|
+
return { accessToken: req.headers.authorization.slice('Bearer '.length) };
|
|
12
|
+
default:
|
|
13
|
+
throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else if (required) {
|
|
17
|
+
throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
|
|
18
|
+
}
|
|
19
|
+
const accessToken = Array.isArray(req.headers['x-beeper-access-token']) ?
|
|
20
|
+
req.headers['x-beeper-access-token'][0]
|
|
21
|
+
: req.headers['x-beeper-access-token'];
|
|
22
|
+
return { accessToken };
|
|
23
|
+
};
|
|
24
|
+
exports.parseClientAuthHeaders = parseClientAuthHeaders;
|
|
25
|
+
const getStainlessApiKey = (req, mcpOptions) => {
|
|
26
|
+
// Try to get the key from the x-stainless-api-key header
|
|
27
|
+
const headerKey = Array.isArray(req.headers['x-stainless-api-key']) ?
|
|
28
|
+
req.headers['x-stainless-api-key'][0]
|
|
29
|
+
: req.headers['x-stainless-api-key'];
|
|
30
|
+
if (headerKey && typeof headerKey === 'string') {
|
|
31
|
+
return headerKey;
|
|
32
|
+
}
|
|
33
|
+
// Fall back to value set in the mcpOptions (e.g. from environment variable), if provided
|
|
34
|
+
return mcpOptions.stainlessApiKey;
|
|
35
|
+
};
|
|
36
|
+
exports.getStainlessApiKey = getStainlessApiKey;
|
|
37
|
+
//# sourceMappingURL=auth.js.map
|
package/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAM/E,MAAM,sBAAsB,GAAG,CAAC,GAAoB,EAAE,QAAkB,EAA0B,EAAE;IACzG,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjE,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5E;gBACE,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;QACN,CAAC;IACH,CAAC;SAAM,IAAI,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACrG,CAAC;IAED,MAAM,WAAW,GACf,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzC,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC,CAAC;AArBW,QAAA,sBAAsB,0BAqBjC;AAEK,MAAM,kBAAkB,GAAG,CAAC,GAAoB,EAAE,UAAsB,EAAsB,EAAE;IACrG,yDAAyD;IACzD,MAAM,SAAS,GACb,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACjD,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACvC,IAAI,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,yFAAyF;IACzF,OAAO,UAAU,CAAC,eAAe,CAAC;AACpC,CAAC,CAAC;AAZW,QAAA,kBAAkB,sBAY7B"}
|
package/auth.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
export const parseClientAuthHeaders = (req, required) => {
|
|
3
|
+
if (req.headers.authorization) {
|
|
4
|
+
const scheme = req.headers.authorization.split(' ')[0];
|
|
5
|
+
const value = req.headers.authorization.slice(scheme.length + 1);
|
|
6
|
+
switch (scheme) {
|
|
7
|
+
case 'Bearer':
|
|
8
|
+
return { accessToken: req.headers.authorization.slice('Bearer '.length) };
|
|
9
|
+
default:
|
|
10
|
+
throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
else if (required) {
|
|
14
|
+
throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
|
|
15
|
+
}
|
|
16
|
+
const accessToken = Array.isArray(req.headers['x-beeper-access-token']) ?
|
|
17
|
+
req.headers['x-beeper-access-token'][0]
|
|
18
|
+
: req.headers['x-beeper-access-token'];
|
|
19
|
+
return { accessToken };
|
|
20
|
+
};
|
|
21
|
+
export const getStainlessApiKey = (req, mcpOptions) => {
|
|
22
|
+
// Try to get the key from the x-stainless-api-key header
|
|
23
|
+
const headerKey = Array.isArray(req.headers['x-stainless-api-key']) ?
|
|
24
|
+
req.headers['x-stainless-api-key'][0]
|
|
25
|
+
: req.headers['x-stainless-api-key'];
|
|
26
|
+
if (headerKey && typeof headerKey === 'string') {
|
|
27
|
+
return headerKey;
|
|
28
|
+
}
|
|
29
|
+
// Fall back to value set in the mcpOptions (e.g. from environment variable), if provided
|
|
30
|
+
return mcpOptions.stainlessApiKey;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=auth.mjs.map
|
package/auth.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.mjs","sourceRoot":"","sources":["src/auth.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAMtF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAoB,EAAE,QAAkB,EAA0B,EAAE;IACzG,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjE,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5E;gBACE,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;QACN,CAAC;IACH,CAAC;SAAM,IAAI,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACrG,CAAC;IAED,MAAM,WAAW,GACf,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzC,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAoB,EAAE,UAAsB,EAAsB,EAAE;IACrG,yDAAyD;IACzD,MAAM,SAAS,GACb,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACjD,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACvC,IAAI,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,yFAAyF;IACzF,OAAO,UAAU,CAAC,eAAe,CAAC;AACpC,CAAC,CAAC"}
|
package/code-tool-types.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ClientOptions } from '@beeper/desktop-api';
|
|
2
2
|
export type WorkerInput = {
|
|
3
|
-
|
|
3
|
+
project_name: string;
|
|
4
4
|
code: string;
|
|
5
|
+
client_opts: ClientOptions;
|
|
6
|
+
intent?: string | undefined;
|
|
5
7
|
};
|
|
6
|
-
export type
|
|
8
|
+
export type WorkerOutput = {
|
|
9
|
+
is_error: boolean;
|
|
7
10
|
result: unknown | null;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export type WorkerError = {
|
|
12
|
-
message: string | undefined;
|
|
11
|
+
log_lines: string[];
|
|
12
|
+
err_lines: string[];
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=code-tool-types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,
|
|
1
|
+
{"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
package/code-tool-types.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ClientOptions } from '@beeper/desktop-api';
|
|
2
2
|
export type WorkerInput = {
|
|
3
|
-
|
|
3
|
+
project_name: string;
|
|
4
4
|
code: string;
|
|
5
|
+
client_opts: ClientOptions;
|
|
6
|
+
intent?: string | undefined;
|
|
5
7
|
};
|
|
6
|
-
export type
|
|
8
|
+
export type WorkerOutput = {
|
|
9
|
+
is_error: boolean;
|
|
7
10
|
result: unknown | null;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export type WorkerError = {
|
|
12
|
-
message: string | undefined;
|
|
11
|
+
log_lines: string[];
|
|
12
|
+
err_lines: string[];
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=code-tool-types.d.ts.map
|
package/code-tool-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,
|
|
1
|
+
{"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-worker.d.mts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"code-tool-worker.d.mts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBA8N0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAsErD,wBAAyB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-tool-worker.d.ts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"code-tool-worker.d.ts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBA8N0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAsErD,wBAAyB"}
|
package/code-tool-worker.js
CHANGED
|
@@ -4,38 +4,101 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
7
8
|
const node_util_1 = __importDefault(require("node:util"));
|
|
8
9
|
const fuse_js_1 = __importDefault(require("fuse.js"));
|
|
9
10
|
const typescript_1 = __importDefault(require("typescript"));
|
|
10
11
|
const desktop_api_1 = require("@beeper/desktop-api");
|
|
11
|
-
function
|
|
12
|
+
function getRunFunctionSource(code) {
|
|
12
13
|
const sourceFile = typescript_1.default.createSourceFile('code.ts', code, typescript_1.default.ScriptTarget.Latest, true);
|
|
14
|
+
const printer = typescript_1.default.createPrinter();
|
|
13
15
|
for (const statement of sourceFile.statements) {
|
|
14
16
|
// Check for top-level function declarations
|
|
15
17
|
if (typescript_1.default.isFunctionDeclaration(statement)) {
|
|
16
18
|
if (statement.name?.text === 'run') {
|
|
17
|
-
return
|
|
19
|
+
return {
|
|
20
|
+
type: 'declaration',
|
|
21
|
+
client: statement.parameters[0]?.name.getText(),
|
|
22
|
+
code: printer.printNode(typescript_1.default.EmitHint.Unspecified, statement.body, sourceFile),
|
|
23
|
+
};
|
|
18
24
|
}
|
|
19
25
|
}
|
|
20
26
|
// Check for variable declarations: const run = () => {} or const run = function() {}
|
|
21
27
|
if (typescript_1.default.isVariableStatement(statement)) {
|
|
22
28
|
for (const declaration of statement.declarationList.declarations) {
|
|
23
|
-
if (typescript_1.default.isIdentifier(declaration.name) &&
|
|
29
|
+
if (typescript_1.default.isIdentifier(declaration.name) &&
|
|
30
|
+
declaration.name.text === 'run' &&
|
|
24
31
|
// Check if it's initialized with a function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
declaration.initializer &&
|
|
33
|
+
(typescript_1.default.isFunctionExpression(declaration.initializer) || typescript_1.default.isArrowFunction(declaration.initializer))) {
|
|
34
|
+
return {
|
|
35
|
+
type: 'expression',
|
|
36
|
+
client: declaration.initializer.parameters[0]?.name.getText(),
|
|
37
|
+
code: printer.printNode(typescript_1.default.EmitHint.Unspecified, declaration.initializer, sourceFile),
|
|
38
|
+
};
|
|
29
39
|
}
|
|
30
40
|
}
|
|
31
41
|
}
|
|
32
42
|
}
|
|
33
43
|
return null;
|
|
34
44
|
}
|
|
45
|
+
function getTSDiagnostics(code) {
|
|
46
|
+
const functionSource = getRunFunctionSource(code);
|
|
47
|
+
const codeWithImport = [
|
|
48
|
+
'import { BeeperDesktop } from "@beeper/desktop-api";',
|
|
49
|
+
functionSource.type === 'declaration' ?
|
|
50
|
+
`async function run(${functionSource.client}: BeeperDesktop)`
|
|
51
|
+
: `const run: (${functionSource.client}: BeeperDesktop) => Promise<unknown> =`,
|
|
52
|
+
functionSource.code,
|
|
53
|
+
].join('\n');
|
|
54
|
+
const sourcePath = node_path_1.default.resolve('code.ts');
|
|
55
|
+
const ast = typescript_1.default.createSourceFile(sourcePath, codeWithImport, typescript_1.default.ScriptTarget.Latest, true);
|
|
56
|
+
const options = typescript_1.default.getDefaultCompilerOptions();
|
|
57
|
+
options.target = typescript_1.default.ScriptTarget.Latest;
|
|
58
|
+
options.module = typescript_1.default.ModuleKind.NodeNext;
|
|
59
|
+
options.moduleResolution = typescript_1.default.ModuleResolutionKind.NodeNext;
|
|
60
|
+
const host = typescript_1.default.createCompilerHost(options, true);
|
|
61
|
+
const newHost = {
|
|
62
|
+
...host,
|
|
63
|
+
getSourceFile: (...args) => {
|
|
64
|
+
if (node_path_1.default.resolve(args[0]) === sourcePath) {
|
|
65
|
+
return ast;
|
|
66
|
+
}
|
|
67
|
+
return host.getSourceFile(...args);
|
|
68
|
+
},
|
|
69
|
+
readFile: (...args) => {
|
|
70
|
+
if (node_path_1.default.resolve(args[0]) === sourcePath) {
|
|
71
|
+
return codeWithImport;
|
|
72
|
+
}
|
|
73
|
+
return host.readFile(...args);
|
|
74
|
+
},
|
|
75
|
+
fileExists: (...args) => {
|
|
76
|
+
if (node_path_1.default.resolve(args[0]) === sourcePath) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return host.fileExists(...args);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
const program = typescript_1.default.createProgram({
|
|
83
|
+
options,
|
|
84
|
+
rootNames: [sourcePath],
|
|
85
|
+
host: newHost,
|
|
86
|
+
});
|
|
87
|
+
const diagnostics = typescript_1.default.getPreEmitDiagnostics(program, ast);
|
|
88
|
+
return diagnostics.map((d) => {
|
|
89
|
+
const message = typescript_1.default.flattenDiagnosticMessageText(d.messageText, '\n');
|
|
90
|
+
if (!d.file || !d.start)
|
|
91
|
+
return `- ${message}`;
|
|
92
|
+
const { line: lineNumber } = typescript_1.default.getLineAndCharacterOfPosition(d.file, d.start);
|
|
93
|
+
const line = codeWithImport.split('\n').at(lineNumber)?.trim();
|
|
94
|
+
return line ? `- ${message}\n ${line}` : `- ${message}`;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
35
97
|
const fuse = new fuse_js_1.default([
|
|
36
98
|
'client.focus',
|
|
37
99
|
'client.search',
|
|
38
100
|
'client.accounts.list',
|
|
101
|
+
'client.accounts.contacts.list',
|
|
39
102
|
'client.accounts.contacts.search',
|
|
40
103
|
'client.chats.archive',
|
|
41
104
|
'client.chats.create',
|
|
@@ -44,10 +107,17 @@ const fuse = new fuse_js_1.default([
|
|
|
44
107
|
'client.chats.search',
|
|
45
108
|
'client.chats.reminders.create',
|
|
46
109
|
'client.chats.reminders.delete',
|
|
110
|
+
'client.chats.messages.reactions.add',
|
|
111
|
+
'client.chats.messages.reactions.delete',
|
|
47
112
|
'client.messages.list',
|
|
48
113
|
'client.messages.search',
|
|
49
114
|
'client.messages.send',
|
|
115
|
+
'client.messages.update',
|
|
50
116
|
'client.assets.download',
|
|
117
|
+
'client.assets.serve',
|
|
118
|
+
'client.assets.upload',
|
|
119
|
+
'client.assets.uploadBase64',
|
|
120
|
+
'client.info.retrieve',
|
|
51
121
|
], { threshold: 1, shouldSort: true });
|
|
52
122
|
function getMethodSuggestions(fullyQualifiedMethodName) {
|
|
53
123
|
return fuse
|
|
@@ -119,28 +189,38 @@ function parseError(code, error) {
|
|
|
119
189
|
}
|
|
120
190
|
const fetch = async (req) => {
|
|
121
191
|
const { opts, code } = (await req.json());
|
|
122
|
-
|
|
192
|
+
const runFunctionSource = code ? getRunFunctionSource(code) : null;
|
|
193
|
+
if (!runFunctionSource) {
|
|
194
|
+
const message = code ?
|
|
195
|
+
'The code is missing a top-level `run` function.'
|
|
196
|
+
: 'The code argument is missing. Provide one containing a top-level `run` function.';
|
|
123
197
|
return Response.json({
|
|
124
|
-
|
|
198
|
+
is_error: true,
|
|
199
|
+
result: `${message} Write code within this template:\n\n\`\`\`\nasync function run(client) {\n // Fill this out\n}\n\`\`\``,
|
|
200
|
+
log_lines: [],
|
|
201
|
+
err_lines: [],
|
|
125
202
|
}, { status: 400, statusText: 'Code execution error' });
|
|
126
203
|
}
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
204
|
+
const diagnostics = getTSDiagnostics(code);
|
|
205
|
+
if (diagnostics.length > 0) {
|
|
129
206
|
return Response.json({
|
|
130
|
-
|
|
207
|
+
is_error: true,
|
|
208
|
+
result: `The code contains TypeScript diagnostics:\n${diagnostics.join('\n')}`,
|
|
209
|
+
log_lines: [],
|
|
210
|
+
err_lines: [],
|
|
131
211
|
}, { status: 400, statusText: 'Code execution error' });
|
|
132
212
|
}
|
|
133
213
|
const client = new desktop_api_1.BeeperDesktop({
|
|
134
214
|
...opts,
|
|
135
215
|
});
|
|
136
|
-
const
|
|
137
|
-
const
|
|
216
|
+
const log_lines = [];
|
|
217
|
+
const err_lines = [];
|
|
138
218
|
const console = {
|
|
139
219
|
log: (...args) => {
|
|
140
|
-
|
|
220
|
+
log_lines.push(node_util_1.default.format(...args));
|
|
141
221
|
},
|
|
142
222
|
error: (...args) => {
|
|
143
|
-
|
|
223
|
+
err_lines.push(node_util_1.default.format(...args));
|
|
144
224
|
},
|
|
145
225
|
};
|
|
146
226
|
try {
|
|
@@ -148,14 +228,18 @@ const fetch = async (req) => {
|
|
|
148
228
|
eval(`${code}\nrun_ = run;`);
|
|
149
229
|
const result = await run_(makeSdkProxy(client, { path: ['client'] }));
|
|
150
230
|
return Response.json({
|
|
231
|
+
is_error: false,
|
|
151
232
|
result,
|
|
152
|
-
|
|
153
|
-
|
|
233
|
+
log_lines,
|
|
234
|
+
err_lines,
|
|
154
235
|
});
|
|
155
236
|
}
|
|
156
237
|
catch (e) {
|
|
157
238
|
return Response.json({
|
|
158
|
-
|
|
239
|
+
is_error: true,
|
|
240
|
+
result: parseError(code, e),
|
|
241
|
+
log_lines,
|
|
242
|
+
err_lines,
|
|
159
243
|
}, { status: 400, statusText: 'Code execution error' });
|
|
160
244
|
}
|
|
161
245
|
};
|