@beeper/desktop-mcp 0.1.2
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 +7 -0
- package/README.md +252 -0
- package/code-tool-paths.cjs +6 -0
- package/code-tool-paths.cjs.map +1 -0
- package/code-tool-paths.d.cts +2 -0
- package/code-tool-paths.d.cts.map +1 -0
- package/code-tool-types.d.mts +14 -0
- package/code-tool-types.d.mts.map +1 -0
- package/code-tool-types.d.ts +14 -0
- package/code-tool-types.d.ts.map +1 -0
- package/code-tool-types.js +4 -0
- package/code-tool-types.js.map +1 -0
- package/code-tool-types.mjs +3 -0
- package/code-tool-types.mjs.map +1 -0
- package/code-tool-worker.d.mts +5 -0
- package/code-tool-worker.d.mts.map +1 -0
- package/code-tool-worker.d.ts +5 -0
- package/code-tool-worker.d.ts.map +1 -0
- package/code-tool-worker.js +45 -0
- package/code-tool-worker.js.map +1 -0
- package/code-tool-worker.mjs +40 -0
- package/code-tool-worker.mjs.map +1 -0
- package/code-tool.d.mts +12 -0
- package/code-tool.d.mts.map +1 -0
- package/code-tool.d.ts +12 -0
- package/code-tool.d.ts.map +1 -0
- package/code-tool.js +123 -0
- package/code-tool.js.map +1 -0
- package/code-tool.mjs +120 -0
- package/code-tool.mjs.map +1 -0
- package/compat.d.mts +58 -0
- package/compat.d.mts.map +1 -0
- package/compat.d.ts +58 -0
- package/compat.d.ts.map +1 -0
- package/compat.js +387 -0
- package/compat.js.map +1 -0
- package/compat.mjs +378 -0
- package/compat.mjs.map +1 -0
- package/dynamic-tools.d.mts +12 -0
- package/dynamic-tools.d.mts.map +1 -0
- package/dynamic-tools.d.ts +12 -0
- package/dynamic-tools.d.ts.map +1 -0
- package/dynamic-tools.js +135 -0
- package/dynamic-tools.js.map +1 -0
- package/dynamic-tools.mjs +132 -0
- package/dynamic-tools.mjs.map +1 -0
- package/filtering.d.mts +2 -0
- package/filtering.d.mts.map +1 -0
- package/filtering.d.ts +2 -0
- package/filtering.d.ts.map +1 -0
- package/filtering.js +20 -0
- package/filtering.js.map +1 -0
- package/filtering.mjs +13 -0
- package/filtering.mjs.map +1 -0
- package/headers.d.mts +4 -0
- package/headers.d.mts.map +1 -0
- package/headers.d.ts +4 -0
- package/headers.d.ts.map +1 -0
- package/headers.js +22 -0
- package/headers.js.map +1 -0
- package/headers.mjs +18 -0
- package/headers.mjs.map +1 -0
- package/http.d.mts +5 -0
- package/http.d.mts.map +1 -0
- package/http.d.ts +5 -0
- package/http.d.ts.map +1 -0
- package/http.js +127 -0
- package/http.js.map +1 -0
- package/http.mjs +119 -0
- package/http.mjs.map +1 -0
- package/index.d.mts +3 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +91 -0
- package/index.js.map +1 -0
- package/index.mjs +89 -0
- package/index.mjs.map +1 -0
- package/options.d.mts +19 -0
- package/options.d.mts.map +1 -0
- package/options.d.ts +19 -0
- package/options.d.ts.map +1 -0
- package/options.js +417 -0
- package/options.js.map +1 -0
- package/options.mjs +410 -0
- package/options.mjs.map +1 -0
- package/package.json +206 -0
- package/server.d.mts +35 -0
- package/server.d.mts.map +1 -0
- package/server.d.ts +35 -0
- package/server.d.ts.map +1 -0
- package/server.js +151 -0
- package/server.js.map +1 -0
- package/server.mjs +137 -0
- package/server.mjs.map +1 -0
- package/src/code-tool-paths.cts +3 -0
- package/src/code-tool-types.ts +14 -0
- package/src/code-tool-worker.ts +46 -0
- package/src/code-tool.ts +144 -0
- package/src/compat.ts +483 -0
- package/src/dynamic-tools.ts +159 -0
- package/src/filtering.ts +14 -0
- package/src/headers.ts +23 -0
- package/src/http.ts +137 -0
- package/src/index.ts +108 -0
- package/src/options.ts +456 -0
- package/src/server.ts +184 -0
- package/src/stdio.ts +13 -0
- package/src/tools/accounts/get-accounts.ts +34 -0
- package/src/tools/app/open-app.ts +47 -0
- package/src/tools/chats/archive-chat.ts +42 -0
- package/src/tools/chats/get-chat.ts +46 -0
- package/src/tools/chats/search-chats.ts +101 -0
- package/src/tools/index.ts +89 -0
- package/src/tools/messages/get-attachment.ts +42 -0
- package/src/tools/messages/search-messages.ts +133 -0
- package/src/tools/messages/send-message.ts +46 -0
- package/src/tools/reminders/clear-chat-reminder.ts +38 -0
- package/src/tools/reminders/set-chat-reminder.ts +53 -0
- package/src/tools/types.ts +103 -0
- package/src/tools.ts +1 -0
- package/src/tsconfig.json +11 -0
- package/stdio.d.mts +3 -0
- package/stdio.d.mts.map +1 -0
- package/stdio.d.ts +3 -0
- package/stdio.d.ts.map +1 -0
- package/stdio.js +14 -0
- package/stdio.js.map +1 -0
- package/stdio.mjs +10 -0
- package/stdio.mjs.map +1 -0
- package/tools/accounts/get-accounts.d.mts +45 -0
- package/tools/accounts/get-accounts.d.mts.map +1 -0
- package/tools/accounts/get-accounts.d.ts +45 -0
- package/tools/accounts/get-accounts.d.ts.map +1 -0
- package/tools/accounts/get-accounts.js +31 -0
- package/tools/accounts/get-accounts.js.map +1 -0
- package/tools/accounts/get-accounts.mjs +27 -0
- package/tools/accounts/get-accounts.mjs.map +1 -0
- package/tools/app/open-app.d.mts +45 -0
- package/tools/app/open-app.d.mts.map +1 -0
- package/tools/app/open-app.d.ts +45 -0
- package/tools/app/open-app.d.ts.map +1 -0
- package/tools/app/open-app.js +43 -0
- package/tools/app/open-app.js.map +1 -0
- package/tools/app/open-app.mjs +39 -0
- package/tools/app/open-app.mjs.map +1 -0
- package/tools/chats/archive-chat.d.mts +45 -0
- package/tools/chats/archive-chat.d.mts.map +1 -0
- package/tools/chats/archive-chat.d.ts +45 -0
- package/tools/chats/archive-chat.d.ts.map +1 -0
- package/tools/chats/archive-chat.js +39 -0
- package/tools/chats/archive-chat.js.map +1 -0
- package/tools/chats/archive-chat.mjs +35 -0
- package/tools/chats/archive-chat.mjs.map +1 -0
- package/tools/chats/get-chat.d.mts +45 -0
- package/tools/chats/get-chat.d.mts.map +1 -0
- package/tools/chats/get-chat.d.ts +45 -0
- package/tools/chats/get-chat.d.ts.map +1 -0
- package/tools/chats/get-chat.js +41 -0
- package/tools/chats/get-chat.js.map +1 -0
- package/tools/chats/get-chat.mjs +37 -0
- package/tools/chats/get-chat.mjs.map +1 -0
- package/tools/chats/search-chats.d.mts +45 -0
- package/tools/chats/search-chats.d.mts.map +1 -0
- package/tools/chats/search-chats.d.ts +45 -0
- package/tools/chats/search-chats.d.ts.map +1 -0
- package/tools/chats/search-chats.js +90 -0
- package/tools/chats/search-chats.js.map +1 -0
- package/tools/chats/search-chats.mjs +86 -0
- package/tools/chats/search-chats.mjs.map +1 -0
- package/tools/index.d.mts +10 -0
- package/tools/index.d.mts.map +1 -0
- package/tools/index.d.ts +10 -0
- package/tools/index.d.ts.map +1 -0
- package/tools/index.js +73 -0
- package/tools/index.js.map +1 -0
- package/tools/index.mjs +66 -0
- package/tools/index.mjs.map +1 -0
- package/tools/messages/get-attachment.d.mts +45 -0
- package/tools/messages/get-attachment.d.mts.map +1 -0
- package/tools/messages/get-attachment.d.ts +45 -0
- package/tools/messages/get-attachment.d.ts.map +1 -0
- package/tools/messages/get-attachment.js +39 -0
- package/tools/messages/get-attachment.js.map +1 -0
- package/tools/messages/get-attachment.mjs +35 -0
- package/tools/messages/get-attachment.mjs.map +1 -0
- package/tools/messages/search-messages.d.mts +45 -0
- package/tools/messages/search-messages.d.mts.map +1 -0
- package/tools/messages/search-messages.d.ts +45 -0
- package/tools/messages/search-messages.d.ts.map +1 -0
- package/tools/messages/search-messages.js +121 -0
- package/tools/messages/search-messages.js.map +1 -0
- package/tools/messages/search-messages.mjs +117 -0
- package/tools/messages/search-messages.mjs.map +1 -0
- package/tools/messages/send-message.d.mts +45 -0
- package/tools/messages/send-message.d.mts.map +1 -0
- package/tools/messages/send-message.d.ts +45 -0
- package/tools/messages/send-message.d.ts.map +1 -0
- package/tools/messages/send-message.js +43 -0
- package/tools/messages/send-message.js.map +1 -0
- package/tools/messages/send-message.mjs +39 -0
- package/tools/messages/send-message.mjs.map +1 -0
- package/tools/reminders/clear-chat-reminder.d.mts +45 -0
- package/tools/reminders/clear-chat-reminder.d.mts.map +1 -0
- package/tools/reminders/clear-chat-reminder.d.ts +45 -0
- package/tools/reminders/clear-chat-reminder.d.ts.map +1 -0
- package/tools/reminders/clear-chat-reminder.js +35 -0
- package/tools/reminders/clear-chat-reminder.js.map +1 -0
- package/tools/reminders/clear-chat-reminder.mjs +31 -0
- package/tools/reminders/clear-chat-reminder.mjs.map +1 -0
- package/tools/reminders/set-chat-reminder.d.mts +45 -0
- package/tools/reminders/set-chat-reminder.d.mts.map +1 -0
- package/tools/reminders/set-chat-reminder.d.ts +45 -0
- package/tools/reminders/set-chat-reminder.d.ts.map +1 -0
- package/tools/reminders/set-chat-reminder.js +50 -0
- package/tools/reminders/set-chat-reminder.js.map +1 -0
- package/tools/reminders/set-chat-reminder.mjs +46 -0
- package/tools/reminders/set-chat-reminder.mjs.map +1 -0
- package/tools/types.d.mts +51 -0
- package/tools/types.d.mts.map +1 -0
- package/tools/types.d.ts +51 -0
- package/tools/types.d.ts.map +1 -0
- package/tools/types.js +46 -0
- package/tools/types.js.map +1 -0
- package/tools/types.mjs +42 -0
- package/tools/types.mjs.map +1 -0
- package/tools.d.mts +2 -0
- package/tools.d.mts.map +1 -0
- package/tools.d.ts +2 -0
- package/tools.d.ts.map +1 -0
- package/tools.js +18 -0
- package/tools.js.map +1 -0
- package/tools.mjs +2 -0
- package/tools.mjs.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 beeperdesktop
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Beeper Desktop API MCP Server
|
|
2
|
+
|
|
3
|
+
> **⚠️ Warning: Work in Progress**
|
|
4
|
+
>
|
|
5
|
+
> This project is work in progress and should not be used.
|
|
6
|
+
> Please use the built-in MCP server Beeper Desktop comes with for now.
|
|
7
|
+
>
|
|
8
|
+
> We plan to migrate the built-in server to this package soon.
|
|
9
|
+
>
|
|
10
|
+
> [Learn more about the built-in Beeper Desktop MCP server here.](https://developers.beeper.com/desktop-api/mcp/)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
### Direct invocation
|
|
15
|
+
|
|
16
|
+
You can run the MCP Server directly via `npx`:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
export BEEPER_ACCESS_TOKEN="My Access Token"
|
|
20
|
+
npx -y @beeper/desktop-mcp@latest
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Via MCP Client
|
|
24
|
+
|
|
25
|
+
There is a partial list of existing clients at [modelcontextprotocol.io](https://modelcontextprotocol.io/clients). If you already
|
|
26
|
+
have a client, consult their documentation to install the MCP server.
|
|
27
|
+
|
|
28
|
+
For clients with a configuration JSON, it might look something like this:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"mcpServers": {
|
|
33
|
+
"beeper_desktop_api_api": {
|
|
34
|
+
"command": "npx",
|
|
35
|
+
"args": ["-y", "@beeper/desktop-mcp", "--client=claude", "--tools=all"],
|
|
36
|
+
"env": {
|
|
37
|
+
"BEEPER_ACCESS_TOKEN": "My Access Token"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Exposing endpoints to your MCP Client
|
|
45
|
+
|
|
46
|
+
There are two ways to expose endpoints as tools in the MCP server:
|
|
47
|
+
|
|
48
|
+
1. Exposing one tool per endpoint, and filtering as necessary
|
|
49
|
+
2. Exposing a set of tools to dynamically discover and invoke endpoints from the API
|
|
50
|
+
|
|
51
|
+
### Filtering endpoints and tools
|
|
52
|
+
|
|
53
|
+
You can run the package on the command line to discover and filter the set of tools that are exposed by the
|
|
54
|
+
MCP Server. This can be helpful for large APIs where including all endpoints at once is too much for your AI's
|
|
55
|
+
context window.
|
|
56
|
+
|
|
57
|
+
You can filter by multiple aspects:
|
|
58
|
+
|
|
59
|
+
- `--tool` includes a specific tool by name
|
|
60
|
+
- `--resource` includes all tools under a specific resource, and can have wildcards, e.g. `my.resource*`
|
|
61
|
+
- `--operation` includes just read (get/list) or just write operations
|
|
62
|
+
- `--tag` includes a set of endpoints with custom tags provided
|
|
63
|
+
|
|
64
|
+
### Dynamic tools
|
|
65
|
+
|
|
66
|
+
If you specify `--tools=dynamic` to the MCP server, instead of exposing one tool per endpoint in the API, it will
|
|
67
|
+
expose the following tools:
|
|
68
|
+
|
|
69
|
+
1. `list_api_endpoints` - Discovers available endpoints, with optional filtering by search query
|
|
70
|
+
2. `get_api_endpoint_schema` - Gets detailed schema information for a specific endpoint
|
|
71
|
+
3. `invoke_api_endpoint` - Executes any endpoint with the appropriate parameters
|
|
72
|
+
|
|
73
|
+
This allows you to have the full set of API endpoints available to your MCP Client, while not requiring that all
|
|
74
|
+
of their schemas be loaded into context at once. Instead, the LLM will automatically use these tools together to
|
|
75
|
+
search for, look up, and invoke endpoints dynamically. However, due to the indirect nature of the schemas, it
|
|
76
|
+
can struggle to provide the correct properties a bit more than when tools are imported explicitly. Therefore,
|
|
77
|
+
you can opt-in to explicit tools, the dynamic tools, or both.
|
|
78
|
+
|
|
79
|
+
See more information with `--help`.
|
|
80
|
+
|
|
81
|
+
All of these command-line options can be repeated, combined together, and have corresponding exclusion versions (e.g. `--no-tool`).
|
|
82
|
+
|
|
83
|
+
Use `--list` to see the list of available tools, or see below.
|
|
84
|
+
|
|
85
|
+
### Specifying the MCP Client
|
|
86
|
+
|
|
87
|
+
Different clients have varying abilities to handle arbitrary tools and schemas.
|
|
88
|
+
|
|
89
|
+
You can specify the client you are using with the `--client` argument, and the MCP server will automatically
|
|
90
|
+
serve tools and schemas that are more compatible with that client.
|
|
91
|
+
|
|
92
|
+
- `--client=<type>`: Set all capabilities based on a known MCP client
|
|
93
|
+
|
|
94
|
+
- Valid values: `openai-agents`, `claude`, `claude-code`, `cursor`
|
|
95
|
+
- Example: `--client=cursor`
|
|
96
|
+
|
|
97
|
+
Additionally, if you have a client not on the above list, or the client has gotten better
|
|
98
|
+
over time, you can manually enable or disable certain capabilities:
|
|
99
|
+
|
|
100
|
+
- `--capability=<name>`: Specify individual client capabilities
|
|
101
|
+
- Available capabilities:
|
|
102
|
+
- `top-level-unions`: Enable support for top-level unions in tool schemas
|
|
103
|
+
- `valid-json`: Enable JSON string parsing for arguments
|
|
104
|
+
- `refs`: Enable support for $ref pointers in schemas
|
|
105
|
+
- `unions`: Enable support for union types (anyOf) in schemas
|
|
106
|
+
- `formats`: Enable support for format validations in schemas (e.g. date-time, email)
|
|
107
|
+
- `tool-name-length=N`: Set maximum tool name length to N characters
|
|
108
|
+
- Example: `--capability=top-level-unions --capability=tool-name-length=40`
|
|
109
|
+
- Example: `--capability=top-level-unions,tool-name-length=40`
|
|
110
|
+
|
|
111
|
+
### Examples
|
|
112
|
+
|
|
113
|
+
1. Filter for read operations on cards:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
--resource=cards --operation=read
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
2. Exclude specific tools while including others:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
--resource=cards --no-tool=create_cards
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
3. Configure for Cursor client with custom max tool name length:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
--client=cursor --capability=tool-name-length=40
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
4. Complex filtering with multiple criteria:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
--resource=cards,accounts --operation=read --tag=kyc --no-tool=create_cards
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Running remotely
|
|
138
|
+
|
|
139
|
+
Launching the client with `--transport=http` launches the server as a remote server using Streamable HTTP transport. The `--port` setting can choose the port it will run on, and the `--socket` setting allows it to run on a Unix socket.
|
|
140
|
+
|
|
141
|
+
Authorization can be provided via the `Authorization` header using the Bearer scheme.
|
|
142
|
+
|
|
143
|
+
Additionally, authorization can be provided via the following headers:
|
|
144
|
+
| Header | Equivalent client option | Security scheme |
|
|
145
|
+
| ----------------------- | ------------------------ | --------------- |
|
|
146
|
+
| `x-beeper-access-token` | `accessToken` | bearerAuth |
|
|
147
|
+
|
|
148
|
+
A configuration JSON for this server might look like this, assuming the server is hosted at `http://localhost:3000`:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"mcpServers": {
|
|
153
|
+
"beeper_desktop_api_api": {
|
|
154
|
+
"url": "http://localhost:3000",
|
|
155
|
+
"headers": {
|
|
156
|
+
"Authorization": "Bearer <auth value>"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The command-line arguments for filtering tools and specifying clients can also be used as query parameters in the URL.
|
|
164
|
+
For example, to exclude specific tools while including others, use the URL:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
http://localhost:3000?resource=cards&resource=accounts&no_tool=create_cards
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Or, to configure for the Cursor client, with a custom max tool name length, use the URL:
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
http://localhost:3000?client=cursor&capability=tool-name-length%3D40
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Importing the tools and server individually
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
// Import the server, generated endpoints, or the init function
|
|
180
|
+
import { server, endpoints, init } from "@beeper/desktop-mcp/server";
|
|
181
|
+
|
|
182
|
+
// import a specific tool
|
|
183
|
+
import getAccounts from "@beeper/desktop-mcp/tools/accounts/get-accounts";
|
|
184
|
+
|
|
185
|
+
// initialize the server and all endpoints
|
|
186
|
+
init({ server, endpoints });
|
|
187
|
+
|
|
188
|
+
// manually start server
|
|
189
|
+
const transport = new StdioServerTransport();
|
|
190
|
+
await server.connect(transport);
|
|
191
|
+
|
|
192
|
+
// or initialize your own server with specific tools
|
|
193
|
+
const myServer = new McpServer(...);
|
|
194
|
+
|
|
195
|
+
// define your own endpoint
|
|
196
|
+
const myCustomEndpoint = {
|
|
197
|
+
tool: {
|
|
198
|
+
name: 'my_custom_tool',
|
|
199
|
+
description: 'My custom tool',
|
|
200
|
+
inputSchema: zodToJsonSchema(z.object({ a_property: z.string() })),
|
|
201
|
+
},
|
|
202
|
+
handler: async (client: client, args: any) => {
|
|
203
|
+
return { myResponse: 'Hello world!' };
|
|
204
|
+
})
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// initialize the server with your custom endpoints
|
|
208
|
+
init({ server: myServer, endpoints: [getAccounts, myCustomEndpoint] });
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Available Tools
|
|
212
|
+
|
|
213
|
+
The following tools are available in this MCP server.
|
|
214
|
+
|
|
215
|
+
### Resource `accounts`:
|
|
216
|
+
|
|
217
|
+
- `get_accounts` (`read`) tags: [accounts]: List connected accounts on this device. Use to pick account context.
|
|
218
|
+
|
|
219
|
+
### Resource `app`:
|
|
220
|
+
|
|
221
|
+
- `open_app` (`write`) tags: [app]: Open Beeper, optionally focusing a chat or message, or pre-filling a draft.
|
|
222
|
+
|
|
223
|
+
### Resource `chats`:
|
|
224
|
+
|
|
225
|
+
- `archive_chat` (`write`) tags: [chats]: Archive or unarchive a chat.
|
|
226
|
+
- `get_chat` (`read`) tags: [chats]: Get chat details: metadata, participants (limited), last activity.
|
|
227
|
+
- `search_chats` (`read`) tags: [chats]: Search chats by inbox, type, unread status, or text. Paginates.
|
|
228
|
+
|
|
229
|
+
### Resource `messages`:
|
|
230
|
+
|
|
231
|
+
- `get_attachment` (`write`) tags: [messages]: Download a message attachment and return the local file path.
|
|
232
|
+
- `search_messages` (`read`) tags: [messages]: Search messages across chats using Beeper's message index.
|
|
233
|
+
- When to use: find messages by text and/or filters (chatIDs, accountIDs, chatType, media type filters, sender, date ranges).
|
|
234
|
+
- CRITICAL: Query is LITERAL WORD MATCHING, NOT semantic search! Only finds messages containing these EXACT words.
|
|
235
|
+
• ✅ RIGHT: query="dinner" or query="sick" or query="error" (single words users type)
|
|
236
|
+
• ❌ WRONG: query="dinner plans tonight" or query="health issues" (phrases/concepts)
|
|
237
|
+
• The query matches ALL words provided (in any order). Example: query="flight booking" finds messages with both "flight" AND "booking".
|
|
238
|
+
- Media filters: Use onlyWithMedia for any media, or specific filters like onlyWithVideo, onlyWithImage, onlyWithLink, onlyWithFile for specific types.
|
|
239
|
+
- Pagination: use 'oldestCursor' + direction='before' for older; 'newestCursor' + direction='after' for newer.
|
|
240
|
+
- Performance: provide chatIDs/accountIDs when known. Omitted 'query' returns results based on filters only. Partial matches enabled; 'excludeLowPriority' defaults to true.
|
|
241
|
+
- Workflow tip: To search messages in specific conversations: 1) Use find-chats to get chatIDs, 2) Use search-messages with those chatIDs.
|
|
242
|
+
- IMPORTANT: Chat names vary widely. ASK the user for clarification:
|
|
243
|
+
• "Which chat do you mean by family?" (could be "The Smiths", "Mom Dad Kids", etc.)
|
|
244
|
+
• "What's the name of your work chat?" (could be "Team", company name, project name)
|
|
245
|
+
• "Who are the participants?" (use participantQuery in find-chats)
|
|
246
|
+
Returns: matching messages and referenced chats.
|
|
247
|
+
- `send_message` (`write`) tags: [messages]: Send a text message to a chat. Can reply to an existing message.
|
|
248
|
+
|
|
249
|
+
### Resource `reminders`:
|
|
250
|
+
|
|
251
|
+
- `clear_chat_reminder` (`write`) tags: [reminders]: Clear a chat reminder.
|
|
252
|
+
- `set_chat_reminder` (`write`) tags: [reminders]: Set a reminder for a chat at a specific time.
|
|
@@ -0,0 +1,6 @@
|
|
|
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.workerPath = void 0;
|
|
5
|
+
exports.workerPath = require.resolve('./code-tool-worker.mjs');
|
|
6
|
+
//# sourceMappingURL=code-tool-paths.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool-paths.cjs","sourceRoot":"","sources":["src/code-tool-paths.cts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEzE,QAAA,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool-paths.d.cts","sourceRoot":"","sources":["src/code-tool-paths.cts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,QAA4C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ClientOptions } from '@beeper/desktop-api';
|
|
2
|
+
export type WorkerInput = {
|
|
3
|
+
opts: ClientOptions;
|
|
4
|
+
code: string;
|
|
5
|
+
};
|
|
6
|
+
export type WorkerSuccess = {
|
|
7
|
+
result: unknown | null;
|
|
8
|
+
logLines: string[];
|
|
9
|
+
errLines: string[];
|
|
10
|
+
};
|
|
11
|
+
export type WorkerError = {
|
|
12
|
+
message: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=code-tool-types.d.mts.map
|
|
@@ -0,0 +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,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ClientOptions } from '@beeper/desktop-api';
|
|
2
|
+
export type WorkerInput = {
|
|
3
|
+
opts: ClientOptions;
|
|
4
|
+
code: string;
|
|
5
|
+
};
|
|
6
|
+
export type WorkerSuccess = {
|
|
7
|
+
result: unknown | null;
|
|
8
|
+
logLines: string[];
|
|
9
|
+
errLines: string[];
|
|
10
|
+
};
|
|
11
|
+
export type WorkerError = {
|
|
12
|
+
message: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=code-tool-types.d.ts.map
|
|
@@ -0,0 +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,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool-types.js","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":";AAAA,sFAAsF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool-types.mjs","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool-worker.d.mts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBAM0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAuCrD,wBAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool-worker.d.ts","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";iBAM0B,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAuCrD,wBAAyB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const node_util_1 = __importDefault(require("node:util"));
|
|
8
|
+
const desktop_api_1 = require("@beeper/desktop-api");
|
|
9
|
+
const fetch = async (req) => {
|
|
10
|
+
const { opts, code } = (await req.json());
|
|
11
|
+
const client = new desktop_api_1.BeeperDesktop({
|
|
12
|
+
...opts,
|
|
13
|
+
});
|
|
14
|
+
const logLines = [];
|
|
15
|
+
const errLines = [];
|
|
16
|
+
const console = {
|
|
17
|
+
log: (...args) => {
|
|
18
|
+
logLines.push(node_util_1.default.format(...args));
|
|
19
|
+
},
|
|
20
|
+
error: (...args) => {
|
|
21
|
+
errLines.push(node_util_1.default.format(...args));
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
try {
|
|
25
|
+
let run_ = async (client) => { };
|
|
26
|
+
eval(`
|
|
27
|
+
${code}
|
|
28
|
+
run_ = run;
|
|
29
|
+
`);
|
|
30
|
+
const result = await run_(client);
|
|
31
|
+
return Response.json({
|
|
32
|
+
result,
|
|
33
|
+
logLines,
|
|
34
|
+
errLines,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
const message = e instanceof Error ? e.message : undefined;
|
|
39
|
+
return Response.json({
|
|
40
|
+
message,
|
|
41
|
+
}, { status: 400, statusText: 'Code execution error' });
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.default = { fetch };
|
|
45
|
+
//# sourceMappingURL=code-tool-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool-worker.js","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;AAEtF,0DAA6B;AAE7B,qDAAoD;AAEpD,MAAM,KAAK,GAAG,KAAK,EAAE,GAAY,EAAqB,EAAE;IACtD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAgB,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,2BAAa,CAAC;QAC/B,GAAG,IAAI;KACR,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG;QACd,GAAG,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;YAC1B,QAAQ,CAAC,IAAI,CAAC,mBAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;QACD,KAAK,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;YAC5B,QAAQ,CAAC,IAAI,CAAC,mBAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;IACF,IAAI,CAAC;QACH,IAAI,IAAI,GAAG,KAAK,EAAE,MAAW,EAAE,EAAE,GAAE,CAAC,CAAC;QACrC,IAAI,CAAC;QACD,IAAI;;KAEP,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,OAAO,QAAQ,CAAC,IAAI,CAAC;YACnB,MAAM;YACN,QAAQ;YACR,QAAQ;SACe,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3D,OAAO,QAAQ,CAAC,IAAI,CAClB;YACE,OAAO;SACc,EACvB,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,sBAAsB,EAAE,CACpD,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import util from 'node:util';
|
|
3
|
+
import { BeeperDesktop } from '@beeper/desktop-api';
|
|
4
|
+
const fetch = async (req) => {
|
|
5
|
+
const { opts, code } = (await req.json());
|
|
6
|
+
const client = new BeeperDesktop({
|
|
7
|
+
...opts,
|
|
8
|
+
});
|
|
9
|
+
const logLines = [];
|
|
10
|
+
const errLines = [];
|
|
11
|
+
const console = {
|
|
12
|
+
log: (...args) => {
|
|
13
|
+
logLines.push(util.format(...args));
|
|
14
|
+
},
|
|
15
|
+
error: (...args) => {
|
|
16
|
+
errLines.push(util.format(...args));
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
let run_ = async (client) => { };
|
|
21
|
+
eval(`
|
|
22
|
+
${code}
|
|
23
|
+
run_ = run;
|
|
24
|
+
`);
|
|
25
|
+
const result = await run_(client);
|
|
26
|
+
return Response.json({
|
|
27
|
+
result,
|
|
28
|
+
logLines,
|
|
29
|
+
errLines,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
const message = e instanceof Error ? e.message : undefined;
|
|
34
|
+
return Response.json({
|
|
35
|
+
message,
|
|
36
|
+
}, { status: 400, statusText: 'Code execution error' });
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export default { fetch };
|
|
40
|
+
//# sourceMappingURL=code-tool-worker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool-worker.mjs","sourceRoot":"","sources":["src/code-tool-worker.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,IAAI,MAAM,WAAW;OAErB,EAAE,aAAa,EAAE,MAAM,qBAAqB;AAEnD,MAAM,KAAK,GAAG,KAAK,EAAE,GAAY,EAAqB,EAAE;IACtD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAgB,CAAC;IACzD,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC;QAC/B,GAAG,IAAI;KACR,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG;QACd,GAAG,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;YAC1B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;QACD,KAAK,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;YAC5B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;KACF,CAAC;IACF,IAAI,CAAC;QACH,IAAI,IAAI,GAAG,KAAK,EAAE,MAAW,EAAE,EAAE,GAAE,CAAC,CAAC;QACrC,IAAI,CAAC;QACD,IAAI;;KAEP,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,OAAO,QAAQ,CAAC,IAAI,CAAC;YACnB,MAAM;YACN,QAAQ;YACR,QAAQ;SACe,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3D,OAAO,QAAQ,CAAC,IAAI,CAClB;YACE,OAAO;SACc,EACvB,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,sBAAsB,EAAE,CACpD,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,EAAE,KAAK,EAAE,CAAC"}
|
package/code-tool.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Endpoint } from "./tools/types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* A tool that runs code against a copy of the SDK.
|
|
4
|
+
*
|
|
5
|
+
* Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once,
|
|
6
|
+
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
7
|
+
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
8
|
+
*
|
|
9
|
+
* @param endpoints - The endpoints to include in the list.
|
|
10
|
+
*/
|
|
11
|
+
export declare function codeTool(): Endpoint;
|
|
12
|
+
//# sourceMappingURL=code-tool.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAKO,EAAE,QAAQ,EAA0B;AAQ3C;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,QAAQ,CAyHnC"}
|
package/code-tool.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Endpoint } from "./tools/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A tool that runs code against a copy of the SDK.
|
|
4
|
+
*
|
|
5
|
+
* Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once,
|
|
6
|
+
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
7
|
+
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
8
|
+
*
|
|
9
|
+
* @param endpoints - The endpoints to include in the list.
|
|
10
|
+
*/
|
|
11
|
+
export declare function codeTool(): Endpoint;
|
|
12
|
+
//# sourceMappingURL=code-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAKO,EAAE,QAAQ,EAA0B;AAQ3C;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,QAAQ,CAyHnC"}
|
package/code-tool.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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.codeTool = codeTool;
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const node_url_1 = require("node:url");
|
|
7
|
+
const deno_http_worker_1 = require("@valtown/deno-http-worker");
|
|
8
|
+
const code_tool_paths_cjs_1 = require("./code-tool-paths.cjs");
|
|
9
|
+
/**
|
|
10
|
+
* A tool that runs code against a copy of the SDK.
|
|
11
|
+
*
|
|
12
|
+
* Instead of exposing every endpoint as it's own tool, which uses up too many tokens for LLMs to use at once,
|
|
13
|
+
* we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
|
|
14
|
+
* a generic endpoint that can be used to invoke any endpoint with the provided arguments.
|
|
15
|
+
*
|
|
16
|
+
* @param endpoints - The endpoints to include in the list.
|
|
17
|
+
*/
|
|
18
|
+
function codeTool() {
|
|
19
|
+
const metadata = { resource: 'all', operation: 'write', tags: [] };
|
|
20
|
+
const tool = {
|
|
21
|
+
name: 'execute',
|
|
22
|
+
description: 'Runs Typescript code to interact with the API.\nYou are a skilled programmer writing code to interface with the service.\nDefine an async function named "run" that takes a single parameter of an initialized client, and it will be run.\nDo not initialize a client, but instead use the client that you are given as a parameter.\nYou will be returned anything that your function returns, plus the results of any console.log statements.\nIf any code triggers an error, the tool will return an error response, so you do not need to add error handling unless you want to output something more helpful than the raw error.\nIt is not necessary to add comments to code, unless by adding those comments you believe that you can generate better code.\nThis code will run in a container, and you will not be able to use fetch or otherwise interact with the network calls other than through the client you are given.\nAny variables you define won\'t live between successive uses of this call, so make sure to return or log any data you might need later.',
|
|
23
|
+
inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
|
|
24
|
+
};
|
|
25
|
+
const handler = async (client, args) => {
|
|
26
|
+
const baseURLHostname = new URL(client.baseURL).hostname;
|
|
27
|
+
const { code } = args;
|
|
28
|
+
const worker = await (0, deno_http_worker_1.newDenoHTTPWorker)((0, node_url_1.pathToFileURL)(code_tool_paths_cjs_1.workerPath), {
|
|
29
|
+
runFlags: [
|
|
30
|
+
`--node-modules-dir=manual`,
|
|
31
|
+
`--allow-read=code-tool-worker.mjs,${code_tool_paths_cjs_1.workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`,
|
|
32
|
+
`--allow-net=${baseURLHostname}`,
|
|
33
|
+
// Allow environment variables because instantiating the client will try to read from them,
|
|
34
|
+
// even though they are not set.
|
|
35
|
+
'--allow-env',
|
|
36
|
+
],
|
|
37
|
+
printOutput: true,
|
|
38
|
+
spawnOptions: {
|
|
39
|
+
cwd: (0, node_path_1.dirname)(code_tool_paths_cjs_1.workerPath),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
try {
|
|
43
|
+
const resp = await new Promise((resolve, reject) => {
|
|
44
|
+
worker.addEventListener('exit', (exitCode) => {
|
|
45
|
+
reject(new Error(`Worker exited with code ${exitCode}`));
|
|
46
|
+
});
|
|
47
|
+
const opts = {
|
|
48
|
+
baseURL: client.baseURL,
|
|
49
|
+
accessToken: client.accessToken,
|
|
50
|
+
defaultHeaders: {
|
|
51
|
+
'X-Stainless-MCP': 'true',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const req = worker.request('http://localhost', {
|
|
55
|
+
headers: {
|
|
56
|
+
'content-type': 'application/json',
|
|
57
|
+
},
|
|
58
|
+
method: 'POST',
|
|
59
|
+
}, (resp) => {
|
|
60
|
+
const body = [];
|
|
61
|
+
resp.on('error', (err) => {
|
|
62
|
+
reject(err);
|
|
63
|
+
});
|
|
64
|
+
resp.on('data', (chunk) => {
|
|
65
|
+
body.push(chunk);
|
|
66
|
+
});
|
|
67
|
+
resp.on('end', () => {
|
|
68
|
+
resolve(new Response(Buffer.concat(body).toString(), {
|
|
69
|
+
status: resp.statusCode ?? 200,
|
|
70
|
+
headers: resp.headers,
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
const body = JSON.stringify({
|
|
75
|
+
opts,
|
|
76
|
+
code,
|
|
77
|
+
});
|
|
78
|
+
req.write(body, (err) => {
|
|
79
|
+
if (err !== null && err !== undefined) {
|
|
80
|
+
reject(err);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
req.end();
|
|
84
|
+
});
|
|
85
|
+
if (resp.status === 200) {
|
|
86
|
+
const { result, logLines, errLines } = (await resp.json());
|
|
87
|
+
const returnOutput = result === null ? null
|
|
88
|
+
: result === undefined ? null
|
|
89
|
+
: {
|
|
90
|
+
type: 'text',
|
|
91
|
+
text: typeof result === 'string' ? result : JSON.stringify(result),
|
|
92
|
+
};
|
|
93
|
+
const logOutput = logLines.length === 0 ?
|
|
94
|
+
null
|
|
95
|
+
: {
|
|
96
|
+
type: 'text',
|
|
97
|
+
text: logLines.join('\n'),
|
|
98
|
+
};
|
|
99
|
+
const errOutput = errLines.length === 0 ?
|
|
100
|
+
null
|
|
101
|
+
: {
|
|
102
|
+
type: 'text',
|
|
103
|
+
text: 'Error output:\n' + errLines.join('\n'),
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
content: [returnOutput, logOutput, errOutput].filter((block) => block !== null),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
const { message } = (await resp.json());
|
|
111
|
+
throw new Error(message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
throw e;
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
worker.terminate();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
return { metadata, tool, handler };
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=code-tool.js.map
|
package/code-tool.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-tool.js","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;AAsBtF,4BAyHC;AA7ID,yCAAoC;AACpC,uCAAyC;AAMzC,gEAA8D;AAE9D,+DAAmD;AAEnD;;;;;;;;GAQG;AACH,SAAgB,QAAQ;IACtB,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IA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