sequentum-mcp 1.0.2 → 1.1.4
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/CHANGELOG.md +38 -1
- package/README.md +153 -70
- package/dist/api-client.d.ts +67 -3
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +134 -4
- package/dist/api-client.js.map +1 -1
- package/dist/index.d.ts +20 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1215 -581
- package/dist/index.js.map +1 -1
- package/dist/oauth-metadata.d.ts +16 -0
- package/dist/oauth-metadata.d.ts.map +1 -0
- package/dist/oauth-metadata.js +37 -0
- package/dist/oauth-metadata.js.map +1 -0
- package/dist/types.d.ts +74 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -1
- package/dist/validation.d.ts +26 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +91 -0
- package/dist/validation.js.map +1 -1
- package/docs/tool-reference.md +300 -53
- package/docs/troubleshooting.md +111 -38
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.1.4] - 2026-03-04
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `delete_run` tool for deleting runs and associated data (PII compliance)
|
|
8
|
+
- **Billing & Cost Analysis** tools for detailed agent cost tracking:
|
|
9
|
+
- `get_agents_usage` - Get all agents with their costs for a date range, with filtering and sorting options
|
|
10
|
+
- `get_agent_cost_breakdown` - Get cost breakdown by usage type for a specific agent over time (for charting)
|
|
11
|
+
- `get_agent_runs_cost` - Get individual run costs for a specific agent with detailed run information
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Replaced Claude Desktop setup instructions with Custom Connectors approach (config file method caused Claude Desktop to break). Added plan-specific steps for Free/Pro/Max and Team/Enterprise accounts, with a link to [Claude's custom connectors documentation](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp).
|
|
16
|
+
|
|
17
|
+
## [1.1.3] - 2026-02-17
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
- `kill_agent` tool for forceful agent termination (as a last resort when `stop_agent` fails)
|
|
23
|
+
- OAuth 2.1 support with HTTP Streamable transport and RFC 8707 resource parameters
|
|
24
|
+
- OAuth2 Protected Resource Metadata endpoint for MCP client authentication
|
|
25
|
+
- Support for Dynamic Client Registration (DCR) and Client Instance Metadata Discovery (CIMD)
|
|
26
|
+
- New `oauth-metadata.ts` module for OAuth metadata handling
|
|
27
|
+
- Dockerfile for containerized deployment
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Enhanced `kill_agent` tool with improved functionality
|
|
32
|
+
- Improved 401 authentication error handling on the `/mcp` endpoint
|
|
33
|
+
- Refactored OAuth-related logic out of `index.ts` into dedicated `oauth-metadata.ts` module
|
|
34
|
+
- Shortened MCP tool descriptions to save tokens
|
|
35
|
+
- Removed unnecessary logging from authentication flow
|
|
36
|
+
- Updated README with OAuth server setup instructions and improved readability
|
|
37
|
+
- Improved `docs/tool-reference.md` and `docs/troubleshooting.md` documentation
|
|
38
|
+
|
|
3
39
|
## [1.0.2] - 2026-01-20
|
|
4
40
|
|
|
5
41
|
### Fixed
|
|
@@ -56,7 +92,8 @@
|
|
|
56
92
|
|
|
57
93
|
---
|
|
58
94
|
|
|
59
|
-
[
|
|
95
|
+
[1.1.4]: https://github.com/Sequentum/sequentum-mcp/compare/v1.1.3...v1.1.4
|
|
96
|
+
[1.1.3]: https://github.com/Sequentum/sequentum-mcp/compare/v1.0.2...v1.1.3
|
|
60
97
|
[1.0.2]: https://github.com/Sequentum/sequentum-mcp/compare/v1.0.1...v1.0.2
|
|
61
98
|
[1.0.1]: https://github.com/Sequentum/sequentum-mcp/compare/v1.0.0...v1.0.1
|
|
62
99
|
[1.0.0]: https://github.com/Sequentum/sequentum-mcp/releases/tag/v1.0.0
|
package/README.md
CHANGED
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/sequentum-mcp)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
control and manage your Sequentum web scraping agents. It acts as a Model Context Protocol
|
|
8
|
-
(MCP) server, giving your AI assistant access to the full power of the Sequentum platform
|
|
9
|
-
for agent automation, monitoring, and data extraction.
|
|
6
|
+
The [Sequentum MCP Server](https://mcp.sequentum.com) connects your AI coding assistant to Sequentum using the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction), giving your AI tools direct access to web scraping agents, run management, scheduling, analytics, and more. Sequentum hosts and manages a remote MCP server with OAuth authentication, so there's nothing to install.
|
|
10
7
|
|
|
11
8
|
## [Tool Reference](./docs/tool-reference.md) | [Troubleshooting](./docs/troubleshooting.md) | [Changelog](./CHANGELOG.md)
|
|
12
9
|
|
|
@@ -21,16 +18,119 @@ for agent automation, monitoring, and data extraction.
|
|
|
21
18
|
## Disclaimers
|
|
22
19
|
|
|
23
20
|
`sequentum-mcp` exposes your Sequentum account data to MCP clients, allowing them to
|
|
24
|
-
view, run, and manage your web scraping agents. Keep your
|
|
21
|
+
view, run, and manage your web scraping agents. Keep your credentials secure and avoid
|
|
25
22
|
sharing sensitive information that you don't want accessible to MCP clients.
|
|
26
23
|
|
|
27
|
-
##
|
|
24
|
+
## Getting Started
|
|
25
|
+
|
|
26
|
+
Add the Sequentum MCP server to your client with this configuration:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"mcpServers": {
|
|
31
|
+
"sequentum": {
|
|
32
|
+
"url": "https://mcp.sequentum.com/mcp"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Most clients support the OAuth configuration.** Claude Desktop uses a different setup via Custom Connectors — see [Claude Desktop](#claude-desktop) below. For other clients, when you first connect, you'll be prompted to:
|
|
39
|
+
|
|
40
|
+
1. Log in with your Sequentum account
|
|
41
|
+
2. Accept the OAuth authorization
|
|
42
|
+
3. Grant access to the necessary permissions
|
|
43
|
+
|
|
44
|
+
Once authenticated, all tools become available in your client. For client-specific setup details, see [Set Up Your Client](#set-up-your-client) below.
|
|
45
|
+
|
|
46
|
+
## Set Up Your Client
|
|
47
|
+
|
|
48
|
+
Select your client below for specific setup instructions. All clients use the remote OAuth server at `https://mcp.sequentum.com/mcp` unless noted otherwise.
|
|
49
|
+
|
|
50
|
+
### Cursor
|
|
51
|
+
|
|
52
|
+
Go to `Cursor` > `Settings` > `Cursor Settings` > `MCP` and follow the prompts to add the Sequentum MCP server. Cursor 1.0+ includes native OAuth and Streamable HTTP support.
|
|
53
|
+
|
|
54
|
+
You can also add the server manually by editing your `mcp.json` file using the [configuration above](#getting-started).
|
|
55
|
+
|
|
56
|
+
### Claude Desktop
|
|
57
|
+
|
|
58
|
+
> **Note:** Custom connectors are currently in beta. Free plan users are limited to one custom connector.
|
|
59
|
+
|
|
60
|
+
Claude Desktop connects to remote MCP servers using **Custom Connectors** rather than the config file. The setup differs based on your plan type. For full details, see [Claude's custom connectors documentation](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp).
|
|
61
|
+
|
|
62
|
+
**Free, Pro, and Max plans:**
|
|
63
|
+
|
|
64
|
+
1. Navigate to **Settings** > **Connectors**.
|
|
65
|
+
2. Click **"Add custom connector"** at the bottom of the section.
|
|
66
|
+
3. Enter the Sequentum MCP server URL: `https://mcp.sequentum.com/mcp`
|
|
67
|
+
4. Click **"Add"** to finish.
|
|
68
|
+
|
|
69
|
+
**Team and Enterprise plans:**
|
|
70
|
+
|
|
71
|
+
An Owner or Primary Owner must first add the connector to the organization:
|
|
72
|
+
|
|
73
|
+
1. Navigate to **Organization settings** > **Connectors**.
|
|
74
|
+
2. Click **"Add custom connector"** at the bottom of the section.
|
|
75
|
+
3. Enter the Sequentum MCP server URL: `https://mcp.sequentum.com/mcp`
|
|
76
|
+
4. Click **"Add"** to finish.
|
|
77
|
+
|
|
78
|
+
Then, each team member connects individually:
|
|
79
|
+
|
|
80
|
+
1. Navigate to **Settings** > **Connectors**.
|
|
81
|
+
2. Find the Sequentum connector in the list (it will have a "Custom" label).
|
|
82
|
+
3. Click **"Connect"** to authenticate.
|
|
83
|
+
|
|
84
|
+
**Enabling per conversation:**
|
|
85
|
+
|
|
86
|
+
Once configured, enable the Sequentum connector in individual conversations via the **"+"** button on the lower left of the chat interface, then select **"Connectors"**.
|
|
87
|
+
|
|
88
|
+
### Claude Code
|
|
89
|
+
|
|
90
|
+
Run the following command in your terminal:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
claude mcp add --transport http sequentum https://mcp.sequentum.com/mcp
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Then launch Claude Code with `claude`. You'll be prompted to authenticate with OAuth to Sequentum.
|
|
97
|
+
|
|
98
|
+
### VS Code / GitHub Copilot
|
|
99
|
+
|
|
100
|
+
Open the Command Palette with `Ctrl+Shift+P` (or `Cmd+Shift+P` on macOS) and select `MCP: Add Server`. Enter the Sequentum MCP server URL:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
https://mcp.sequentum.com/mcp
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Windsurf
|
|
107
|
+
|
|
108
|
+
Configure via the `Configure MCP` option in Cascade (`Cmd+L` or `Ctrl+L`). Add the Sequentum MCP server URL:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
https://mcp.sequentum.com/mcp
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Other Clients
|
|
115
|
+
|
|
116
|
+
The Sequentum MCP Server follows standard MCP protocols and works with any client that supports:
|
|
117
|
+
|
|
118
|
+
- **OAuth authentication** (recommended)
|
|
119
|
+
- **Streamable HTTP** with automatic SSE fallback
|
|
120
|
+
|
|
121
|
+
Use the server URL `https://mcp.sequentum.com/mcp` in your client's MCP configuration.
|
|
122
|
+
|
|
123
|
+
The server supports [Client ID Metadata Documents (CIMD)](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-client-id-metadata-document-00) as the preferred client identification method, with [Dynamic Client Registration (RFC 7591)](https://datatracker.ietf.org/doc/html/rfc7591) as a fallback. MCP clients that support CIMD (such as Cursor) can use their own URL as a `client_id` without any prior registration.
|
|
124
|
+
|
|
125
|
+
## Alternative: Local Setup (API Key)
|
|
126
|
+
|
|
127
|
+
If you prefer to run the MCP server locally (e.g., for custom deployments, offline use, or CI/CD pipelines), you can use `npx` with an API key instead of the hosted OAuth server.
|
|
128
|
+
|
|
129
|
+
**Requirements for local setup:**
|
|
28
130
|
|
|
29
131
|
- [Node.js](https://nodejs.org/) v18 or higher
|
|
30
132
|
- [npm](https://www.npmjs.com/)
|
|
31
|
-
- Sequentum
|
|
32
|
-
|
|
33
|
-
## Getting Started
|
|
133
|
+
- Sequentum API key
|
|
34
134
|
|
|
35
135
|
Add the following config to your MCP client:
|
|
36
136
|
|
|
@@ -51,41 +151,58 @@ Add the following config to your MCP client:
|
|
|
51
151
|
### Get Your API Key
|
|
52
152
|
|
|
53
153
|
1. Log in to the [Sequentum Control Center](https://dashboard.sequentum.com)
|
|
54
|
-
2. Go to **Settings**
|
|
154
|
+
2. Go to **Settings** > **API Keys**
|
|
55
155
|
3. Click **Create API Key** and copy the generated key (starts with `sk-`)
|
|
56
156
|
|
|
57
|
-
###
|
|
157
|
+
### Custom Sequentum Instance
|
|
58
158
|
|
|
59
|
-
|
|
60
|
-
|--------|---------------------|
|
|
61
|
-
| Claude Desktop (Windows) | `%APPDATA%\Claude\claude_desktop_config.json` |
|
|
62
|
-
| Claude Desktop (macOS) | `~/Library/Application Support/Claude/claude_desktop_config.json` |
|
|
63
|
-
| Cursor | `Cursor Settings` → `MCP` → `New MCP Server` |
|
|
159
|
+
To connect to a custom Sequentum deployment, add the `SEQUENTUM_API_URL` environment variable:
|
|
64
160
|
|
|
65
|
-
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"mcpServers": {
|
|
164
|
+
"sequentum": {
|
|
165
|
+
"command": "npx",
|
|
166
|
+
"args": ["-y", "sequentum-mcp"],
|
|
167
|
+
"env": {
|
|
168
|
+
"SEQUENTUM_API_KEY": "sk-your-api-key-here",
|
|
169
|
+
"SEQUENTUM_API_URL": "https://your-custom-instance.sequentum.com"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
66
175
|
|
|
67
|
-
|
|
176
|
+
### Local Environment Variables
|
|
68
177
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
178
|
+
| Variable | Required | Default | Description |
|
|
179
|
+
|----------|----------|---------|-------------|
|
|
180
|
+
| `SEQUENTUM_API_KEY` | Yes | -- | Your Sequentum API key (format: `sk-...`). Get this from the Sequentum Control Center under Settings > API Keys. |
|
|
181
|
+
| `SEQUENTUM_API_URL` | No | `https://dashboard.sequentum.com` | The base URL of your Sequentum instance. Override if using a custom deployment. |
|
|
72
182
|
|
|
73
|
-
|
|
183
|
+
## Example Usage
|
|
74
184
|
|
|
75
|
-
|
|
185
|
+
Once connected, try these prompts to start using Sequentum context in your AI assistant:
|
|
76
186
|
|
|
77
187
|
```
|
|
188
|
+
What agents ran yesterday?
|
|
78
189
|
Run agent <agent name> now.
|
|
79
190
|
Is agent <agent name> still running?
|
|
80
191
|
What agents are scheduled to run today?
|
|
81
192
|
Download the extracted data from agent <agent name>.
|
|
82
193
|
How many records were found the last time <agent name> was run?
|
|
83
194
|
What is my current balance?
|
|
195
|
+
Which agents cost the most this month?
|
|
84
196
|
Schedule agent <agent name> to run every Monday at 9am.
|
|
85
197
|
Look at the run log for <agent name> run at 9:22am. What caused the agent to fail?
|
|
198
|
+
Show me the cost breakdown for agent <agent name> in January.
|
|
199
|
+
What were the most expensive runs for agent <agent name>?
|
|
200
|
+
How much did I spend on server time vs exports last week?
|
|
86
201
|
```
|
|
87
202
|
|
|
88
|
-
## Tools
|
|
203
|
+
## Available Tools
|
|
204
|
+
|
|
205
|
+
The Sequentum MCP Server provides tools across 8 categories for interacting with the Sequentum platform. See the [Tool Reference](./docs/tool-reference.md) for detailed documentation.
|
|
89
206
|
|
|
90
207
|
<!-- BEGIN AUTO GENERATED TOOLS -->
|
|
91
208
|
|
|
@@ -93,11 +210,13 @@ Look at the run log for <agent name> run at 9:22am. What caused the agent to fai
|
|
|
93
210
|
- [`list_agents`](docs/tool-reference.md#list_agents)
|
|
94
211
|
- [`get_agent`](docs/tool-reference.md#get_agent)
|
|
95
212
|
- [`search_agents`](docs/tool-reference.md#search_agents)
|
|
96
|
-
- **Run Management** (
|
|
213
|
+
- **Run Management** (6 tools)
|
|
97
214
|
- [`get_agent_runs`](docs/tool-reference.md#get_agent_runs)
|
|
98
215
|
- [`get_run_status`](docs/tool-reference.md#get_run_status)
|
|
99
216
|
- [`start_agent`](docs/tool-reference.md#start_agent)
|
|
100
217
|
- [`stop_agent`](docs/tool-reference.md#stop_agent)
|
|
218
|
+
- [`kill_agent`](docs/tool-reference.md#kill_agent)
|
|
219
|
+
- [`delete_run`](docs/tool-reference.md#delete_run)
|
|
101
220
|
- **File Management** (2 tools)
|
|
102
221
|
- [`get_run_files`](docs/tool-reference.md#get_run_files)
|
|
103
222
|
- [`get_file_download_url`](docs/tool-reference.md#get_file_download_url)
|
|
@@ -109,10 +228,13 @@ Look at the run log for <agent name> run at 9:22am. What caused the agent to fai
|
|
|
109
228
|
- [`create_agent_schedule`](docs/tool-reference.md#create_agent_schedule)
|
|
110
229
|
- [`delete_agent_schedule`](docs/tool-reference.md#delete_agent_schedule)
|
|
111
230
|
- [`get_scheduled_runs`](docs/tool-reference.md#get_scheduled_runs)
|
|
112
|
-
- **Billing & Credits** (
|
|
231
|
+
- **Billing & Credits** (6 tools)
|
|
113
232
|
- [`get_credits_balance`](docs/tool-reference.md#get_credits_balance)
|
|
114
233
|
- [`get_spending_summary`](docs/tool-reference.md#get_spending_summary)
|
|
115
234
|
- [`get_credit_history`](docs/tool-reference.md#get_credit_history)
|
|
235
|
+
- [`get_agents_usage`](docs/tool-reference.md#get_agents_usage)
|
|
236
|
+
- [`get_agent_cost_breakdown`](docs/tool-reference.md#get_agent_cost_breakdown)
|
|
237
|
+
- [`get_agent_runs_cost`](docs/tool-reference.md#get_agent_runs_cost)
|
|
116
238
|
- **Space Management** (5 tools)
|
|
117
239
|
- [`list_spaces`](docs/tool-reference.md#list_spaces)
|
|
118
240
|
- [`get_space`](docs/tool-reference.md#get_space)
|
|
@@ -127,54 +249,14 @@ Look at the run log for <agent name> run at 9:22am. What caused the agent to fai
|
|
|
127
249
|
|
|
128
250
|
<!-- END AUTO GENERATED TOOLS -->
|
|
129
251
|
|
|
130
|
-
## Configuration
|
|
131
|
-
|
|
132
|
-
The Sequentum MCP server supports the following environment variables:
|
|
133
|
-
|
|
134
|
-
| Variable | Required | Default | Description |
|
|
135
|
-
|----------|----------|---------|-------------|
|
|
136
|
-
| `SEQUENTUM_API_KEY` | Yes | — | Your Sequentum API key (format: `sk-...`). Get this from the Sequentum Control Center under Settings → API Keys. |
|
|
137
|
-
| `SEQUENTUM_API_URL` | No | `https://dashboard.sequentum.com` | The base URL of your Sequentum instance. Override if using a custom deployment. |
|
|
138
|
-
|
|
139
|
-
Pass them via the `env` property in the JSON configuration:
|
|
140
|
-
|
|
141
|
-
```json
|
|
142
|
-
{
|
|
143
|
-
"mcpServers": {
|
|
144
|
-
"sequentum": {
|
|
145
|
-
"command": "npx",
|
|
146
|
-
"args": ["-y", "sequentum-mcp"],
|
|
147
|
-
"env": {
|
|
148
|
-
"SEQUENTUM_API_KEY": "sk-your-api-key-here"
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
To use a custom Sequentum instance, add the `SEQUENTUM_API_URL`:
|
|
156
|
-
|
|
157
|
-
```json
|
|
158
|
-
{
|
|
159
|
-
"mcpServers": {
|
|
160
|
-
"sequentum": {
|
|
161
|
-
"command": "npx",
|
|
162
|
-
"args": ["-y", "sequentum-mcp"],
|
|
163
|
-
"env": {
|
|
164
|
-
"SEQUENTUM_API_KEY": "sk-your-api-key-here",
|
|
165
|
-
"SEQUENTUM_API_URL": "https://your-custom-instance.sequentum.com"
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
252
|
## Troubleshooting
|
|
173
253
|
|
|
174
254
|
| Error | Solution |
|
|
175
255
|
|-------|----------|
|
|
176
|
-
|
|
|
177
|
-
|
|
|
256
|
+
| OAuth login not opening | Ensure your client supports OAuth and Streamable HTTP. Try restarting the client. For Claude Desktop, use [Custom Connectors](#claude-desktop) instead of the config file. |
|
|
257
|
+
| Connection refused | Verify the URL is `https://mcp.sequentum.com/mcp` and check your network connection. |
|
|
258
|
+
| `SEQUENTUM_API_KEY required` | Local mode only. Add your API key to the `env` section of the MCP config. |
|
|
259
|
+
| `API Error 401: Unauthorized` | Your API key or OAuth token is invalid or expired. Re-authenticate or generate a new key. |
|
|
178
260
|
| `API Error 404: Not Found` | The agent, run, or file doesn't exist, or you don't have access to it. |
|
|
179
261
|
| `API Error 429: Too Many Requests` | Rate limit exceeded. Wait a moment and try again. |
|
|
180
262
|
|
|
@@ -182,6 +264,7 @@ For more troubleshooting help, see the [Troubleshooting Guide](./docs/troublesho
|
|
|
182
264
|
|
|
183
265
|
## Links
|
|
184
266
|
|
|
267
|
+
- [Sequentum MCP Server](https://mcp.sequentum.com)
|
|
185
268
|
- [Sequentum Dashboard](https://dashboard.sequentum.com)
|
|
186
269
|
- [Sequentum API Documentation](https://dashboard.sequentum.com/api-docs/index.html)
|
|
187
270
|
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
package/dist/api-client.d.ts
CHANGED
|
@@ -2,18 +2,32 @@
|
|
|
2
2
|
* Sequentum API Client
|
|
3
3
|
* Handles all HTTP communication with the Sequentum Control Center API
|
|
4
4
|
*/
|
|
5
|
-
import { AgentApiModel, AgentRunApiModel, AgentRunFileApiModel, AgentVersionModel, StartAgentRequest, AgentScheduleApiModel, CreateScheduleRequest, UpcomingScheduleApiModel, CreditsBalanceApiModel, SpendingSummaryApiModel, CreditHistoryApiModel, SpaceApiModel, SpaceAgentApiModel, RunSpaceAgentsResultApiModel, RunsSummaryApiModel, RecordsSummaryApiModel, RunDiagnosticsApiModel, ListAgentsRequest, PaginatedAgentsResponse } from "./types.js";
|
|
5
|
+
import { AgentApiModel, AgentRunApiModel, AgentRunFileApiModel, AgentVersionModel, StartAgentRequest, AgentScheduleApiModel, CreateScheduleRequest, UpcomingScheduleApiModel, CreditsBalanceApiModel, SpendingSummaryApiModel, CreditHistoryApiModel, AgentsUsageApiResponse, AgentCostBreakdownApiModel, AgentRunsApiResponse, SpaceApiModel, SpaceAgentApiModel, RunSpaceAgentsResultApiModel, RunsSummaryApiModel, RecordsSummaryApiModel, RunDiagnosticsApiModel, ListAgentsRequest, PaginatedAgentsResponse, RunRemoveMethod } from "./types.js";
|
|
6
6
|
export declare class SequentumApiClient {
|
|
7
7
|
private baseUrl;
|
|
8
8
|
private apiKey;
|
|
9
|
+
private accessToken;
|
|
9
10
|
private requestTimeoutMs;
|
|
10
11
|
/**
|
|
11
12
|
* Create a new Sequentum API client
|
|
12
13
|
* @param baseUrl - The base URL of the Sequentum API (e.g., https://dashboard.sequentum.com)
|
|
13
|
-
* @param apiKey - The API key (sk-...) for authentication
|
|
14
|
+
* @param apiKey - The API key (sk-...) for authentication (optional if using OAuth2)
|
|
14
15
|
* @param requestTimeoutMs - Request timeout in milliseconds (default: 30000)
|
|
15
16
|
*/
|
|
16
|
-
constructor(baseUrl: string, apiKey
|
|
17
|
+
constructor(baseUrl: string, apiKey?: string | null, requestTimeoutMs?: number);
|
|
18
|
+
/**
|
|
19
|
+
* Set the OAuth2 access token for Bearer authentication
|
|
20
|
+
* @param token - The access token
|
|
21
|
+
*/
|
|
22
|
+
setAccessToken(token: string | null): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get the current access token
|
|
25
|
+
*/
|
|
26
|
+
getAccessToken(): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Build the Authorization header based on available credentials
|
|
29
|
+
*/
|
|
30
|
+
private getAuthorizationHeader;
|
|
17
31
|
/**
|
|
18
32
|
* Make an authenticated request to the API
|
|
19
33
|
*/
|
|
@@ -64,6 +78,23 @@ export declare class SequentumApiClient {
|
|
|
64
78
|
* @param runId - The ID of the run to stop
|
|
65
79
|
*/
|
|
66
80
|
stopAgent(agentId: number, runId: number): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Forcefully kill a running agent instance
|
|
83
|
+
* First call: Initiates graceful stop (same as Stop)
|
|
84
|
+
* Second call: Forces immediate termination if still stopping
|
|
85
|
+
* @param agentId - The ID of the agent
|
|
86
|
+
* @param runId - The ID of the run to kill
|
|
87
|
+
*/
|
|
88
|
+
killAgent(agentId: number, runId: number): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Delete a run and all its associated data, including files and storage.
|
|
91
|
+
* Primarily used for PII compliance when an agent extracts personally identifiable information.
|
|
92
|
+
* The run can be in either the active Runs table or the RunHistory table.
|
|
93
|
+
* @param agentId - The ID of the agent that contains the run
|
|
94
|
+
* @param runId - The ID of the run to delete
|
|
95
|
+
* @param removeMethod - The deletion method: RemoveEntireRun (default), RemoveAllFiles, or RemoveAllFilesAndAgentInput
|
|
96
|
+
*/
|
|
97
|
+
deleteRun(agentId: number, runId: number, removeMethod?: RunRemoveMethod): Promise<void>;
|
|
67
98
|
/**
|
|
68
99
|
* Get all output files from a run
|
|
69
100
|
* @param agentId - The ID of the agent
|
|
@@ -131,6 +162,39 @@ export declare class SequentumApiClient {
|
|
|
131
162
|
* @param recordsPerPage - Records per page (default: 50, max: 100)
|
|
132
163
|
*/
|
|
133
164
|
getCreditHistory(pageIndex?: number, recordsPerPage?: number): Promise<CreditHistoryApiModel>;
|
|
165
|
+
/**
|
|
166
|
+
* Get all agents with their costs for a date range
|
|
167
|
+
* @param startDate - Start date (ISO format, required)
|
|
168
|
+
* @param endDate - End date (ISO format, required)
|
|
169
|
+
* @param pageIndex - Page number (1-based, default: 1)
|
|
170
|
+
* @param recordsPerPage - Records per page (default: 50, max: 1000)
|
|
171
|
+
* @param sortColumn - Column to sort by (name, cost)
|
|
172
|
+
* @param sortOrder - Sort order (0 = ascending, 1 = descending)
|
|
173
|
+
* @param name - Filter by agent name (contains match)
|
|
174
|
+
* @param usageTypes - Filter by usage types (comma-separated)
|
|
175
|
+
*/
|
|
176
|
+
getAgentsUsage(startDate: string, endDate: string, pageIndex?: number, recordsPerPage?: number, sortColumn?: string, sortOrder?: number, name?: string, usageTypes?: string): Promise<AgentsUsageApiResponse>;
|
|
177
|
+
/**
|
|
178
|
+
* Get cost breakdown for a specific agent over time
|
|
179
|
+
* @param agentId - The agent ID
|
|
180
|
+
* @param startDate - Start date (ISO format, required)
|
|
181
|
+
* @param endDate - End date (ISO format, required)
|
|
182
|
+
* @param timeUnit - Time unit for grouping (day, month)
|
|
183
|
+
* @param usageTypes - Filter by usage types (comma-separated)
|
|
184
|
+
*/
|
|
185
|
+
getAgentCostBreakdown(agentId: number, startDate: string, endDate: string, timeUnit?: string, usageTypes?: string): Promise<AgentCostBreakdownApiModel>;
|
|
186
|
+
/**
|
|
187
|
+
* Get individual run costs for a specific agent
|
|
188
|
+
* @param agentId - The agent ID
|
|
189
|
+
* @param startDate - Start date (ISO format, required)
|
|
190
|
+
* @param endDate - End date (ISO format, required)
|
|
191
|
+
* @param pageIndex - Page number (1-based, default: 1)
|
|
192
|
+
* @param recordsPerPage - Records per page (default: 50, max: 1000)
|
|
193
|
+
* @param sortColumn - Column to sort by (date, cost, duration)
|
|
194
|
+
* @param sortOrder - Sort order (0 = ascending, 1 = descending)
|
|
195
|
+
* @param usageTypes - Filter by usage types (comma-separated)
|
|
196
|
+
*/
|
|
197
|
+
getAgentRunsCost(agentId: number, startDate: string, endDate: string, pageIndex?: number, recordsPerPage?: number, sortColumn?: string, sortOrder?: number, usageTypes?: string): Promise<AgentRunsApiResponse>;
|
|
134
198
|
/**
|
|
135
199
|
* Get all spaces accessible to the user
|
|
136
200
|
*/
|
package/dist/api-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EAEjB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,4BAA4B,EAC5B,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EAEjB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,4BAA4B,EAC5B,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,EAEvB,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,g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IACG,cAAc,CAClB,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,4BAA4B,CAAC;IAgBxC;;;;;;OAMG;IACG,cAAc,CAClB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,OAAO,GACvB,OAAO,CAAC,mBAAmB,CAAC;IAa/B;;;;;OAKG;IACG,iBAAiB,CACrB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,sBAAsB,CAAC;IAWlC;;;;OAIG;IACG,iBAAiB,CACrB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC;IAMlC;;;OAGG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAKzE"}
|
package/dist/api-client.js
CHANGED
|
@@ -2,28 +2,55 @@
|
|
|
2
2
|
* Sequentum API Client
|
|
3
3
|
* Handles all HTTP communication with the Sequentum Control Center API
|
|
4
4
|
*/
|
|
5
|
+
import { AuthenticationError, } from "./types.js";
|
|
5
6
|
export class SequentumApiClient {
|
|
6
7
|
baseUrl;
|
|
7
8
|
apiKey;
|
|
9
|
+
accessToken = null;
|
|
8
10
|
requestTimeoutMs;
|
|
9
11
|
/**
|
|
10
12
|
* Create a new Sequentum API client
|
|
11
13
|
* @param baseUrl - The base URL of the Sequentum API (e.g., https://dashboard.sequentum.com)
|
|
12
|
-
* @param apiKey - The API key (sk-...) for authentication
|
|
14
|
+
* @param apiKey - The API key (sk-...) for authentication (optional if using OAuth2)
|
|
13
15
|
* @param requestTimeoutMs - Request timeout in milliseconds (default: 30000)
|
|
14
16
|
*/
|
|
15
|
-
constructor(baseUrl, apiKey, requestTimeoutMs = 30000) {
|
|
17
|
+
constructor(baseUrl, apiKey = null, requestTimeoutMs = 30000) {
|
|
16
18
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
17
19
|
this.apiKey = apiKey;
|
|
18
20
|
this.requestTimeoutMs = requestTimeoutMs;
|
|
19
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Set the OAuth2 access token for Bearer authentication
|
|
24
|
+
* @param token - The access token
|
|
25
|
+
*/
|
|
26
|
+
setAccessToken(token) {
|
|
27
|
+
this.accessToken = token;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the current access token
|
|
31
|
+
*/
|
|
32
|
+
getAccessToken() {
|
|
33
|
+
return this.accessToken;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build the Authorization header based on available credentials
|
|
37
|
+
*/
|
|
38
|
+
getAuthorizationHeader() {
|
|
39
|
+
if (this.accessToken) {
|
|
40
|
+
return `Bearer ${this.accessToken}`;
|
|
41
|
+
}
|
|
42
|
+
if (this.apiKey) {
|
|
43
|
+
return `ApiKey ${this.apiKey}`;
|
|
44
|
+
}
|
|
45
|
+
throw new AuthenticationError("No authentication configured. Set either an API key or OAuth2 access token.");
|
|
46
|
+
}
|
|
20
47
|
/**
|
|
21
48
|
* Make an authenticated request to the API
|
|
22
49
|
*/
|
|
23
50
|
async request(endpoint, options = {}) {
|
|
24
51
|
const url = `${this.baseUrl}${endpoint}`;
|
|
25
52
|
const headers = {
|
|
26
|
-
Authorization:
|
|
53
|
+
Authorization: this.getAuthorizationHeader(),
|
|
27
54
|
"Content-Type": "application/json",
|
|
28
55
|
Accept: "application/json",
|
|
29
56
|
...options.headers,
|
|
@@ -84,7 +111,7 @@ export class SequentumApiClient {
|
|
|
84
111
|
async requestVoid(endpoint, options = {}) {
|
|
85
112
|
const url = `${this.baseUrl}${endpoint}`;
|
|
86
113
|
const headers = {
|
|
87
|
-
Authorization:
|
|
114
|
+
Authorization: this.getAuthorizationHeader(),
|
|
88
115
|
"Content-Type": "application/json",
|
|
89
116
|
Accept: "application/json",
|
|
90
117
|
...options.headers,
|
|
@@ -241,6 +268,32 @@ export class SequentumApiClient {
|
|
|
241
268
|
method: "POST",
|
|
242
269
|
});
|
|
243
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Forcefully kill a running agent instance
|
|
273
|
+
* First call: Initiates graceful stop (same as Stop)
|
|
274
|
+
* Second call: Forces immediate termination if still stopping
|
|
275
|
+
* @param agentId - The ID of the agent
|
|
276
|
+
* @param runId - The ID of the run to kill
|
|
277
|
+
*/
|
|
278
|
+
async killAgent(agentId, runId) {
|
|
279
|
+
await this.requestVoid(`/api/v1/agent/${agentId}/run/${runId}/kill`, {
|
|
280
|
+
method: "POST",
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Delete a run and all its associated data, including files and storage.
|
|
285
|
+
* Primarily used for PII compliance when an agent extracts personally identifiable information.
|
|
286
|
+
* The run can be in either the active Runs table or the RunHistory table.
|
|
287
|
+
* @param agentId - The ID of the agent that contains the run
|
|
288
|
+
* @param runId - The ID of the run to delete
|
|
289
|
+
* @param removeMethod - The deletion method: RemoveEntireRun (default), RemoveAllFiles, or RemoveAllFilesAndAgentInput
|
|
290
|
+
*/
|
|
291
|
+
async deleteRun(agentId, runId, removeMethod) {
|
|
292
|
+
const query = removeMethod ? `?removeMethod=${encodeURIComponent(removeMethod)}` : "";
|
|
293
|
+
await this.requestVoid(`/api/v1/agent/${agentId}/run/${runId}${query}`, {
|
|
294
|
+
method: "DELETE",
|
|
295
|
+
});
|
|
296
|
+
}
|
|
244
297
|
// ==========================================
|
|
245
298
|
// File Operations
|
|
246
299
|
// ==========================================
|
|
@@ -375,6 +428,83 @@ export class SequentumApiClient {
|
|
|
375
428
|
const query = params.toString() ? `?${params.toString()}` : "";
|
|
376
429
|
return this.request(`/api/v1/billing/history${query}`);
|
|
377
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* Get all agents with their costs for a date range
|
|
433
|
+
* @param startDate - Start date (ISO format, required)
|
|
434
|
+
* @param endDate - End date (ISO format, required)
|
|
435
|
+
* @param pageIndex - Page number (1-based, default: 1)
|
|
436
|
+
* @param recordsPerPage - Records per page (default: 50, max: 1000)
|
|
437
|
+
* @param sortColumn - Column to sort by (name, cost)
|
|
438
|
+
* @param sortOrder - Sort order (0 = ascending, 1 = descending)
|
|
439
|
+
* @param name - Filter by agent name (contains match)
|
|
440
|
+
* @param usageTypes - Filter by usage types (comma-separated)
|
|
441
|
+
*/
|
|
442
|
+
async getAgentsUsage(startDate, endDate, pageIndex, recordsPerPage, sortColumn, sortOrder, name, usageTypes) {
|
|
443
|
+
const params = new URLSearchParams();
|
|
444
|
+
params.append("startDate", startDate);
|
|
445
|
+
params.append("endDate", endDate);
|
|
446
|
+
if (pageIndex !== undefined)
|
|
447
|
+
params.append("pageIndex", String(pageIndex));
|
|
448
|
+
if (recordsPerPage !== undefined)
|
|
449
|
+
params.append("recordsPerPage", String(recordsPerPage));
|
|
450
|
+
if (sortColumn)
|
|
451
|
+
params.append("sortColumn", sortColumn);
|
|
452
|
+
if (sortOrder !== undefined)
|
|
453
|
+
params.append("sortOrder", String(sortOrder));
|
|
454
|
+
if (name)
|
|
455
|
+
params.append("name", name);
|
|
456
|
+
if (usageTypes)
|
|
457
|
+
params.append("usageTypes", usageTypes);
|
|
458
|
+
const query = params.toString() ? `?${params.toString()}` : "";
|
|
459
|
+
return this.request(`/api/v1/billing/agents${query}`);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Get cost breakdown for a specific agent over time
|
|
463
|
+
* @param agentId - The agent ID
|
|
464
|
+
* @param startDate - Start date (ISO format, required)
|
|
465
|
+
* @param endDate - End date (ISO format, required)
|
|
466
|
+
* @param timeUnit - Time unit for grouping (day, month)
|
|
467
|
+
* @param usageTypes - Filter by usage types (comma-separated)
|
|
468
|
+
*/
|
|
469
|
+
async getAgentCostBreakdown(agentId, startDate, endDate, timeUnit, usageTypes) {
|
|
470
|
+
const params = new URLSearchParams();
|
|
471
|
+
params.append("startDate", startDate);
|
|
472
|
+
params.append("endDate", endDate);
|
|
473
|
+
if (timeUnit)
|
|
474
|
+
params.append("timeUnit", timeUnit);
|
|
475
|
+
if (usageTypes)
|
|
476
|
+
params.append("usageTypes", usageTypes);
|
|
477
|
+
const query = params.toString() ? `?${params.toString()}` : "";
|
|
478
|
+
return this.request(`/api/v1/billing/agents/${agentId}${query}`);
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Get individual run costs for a specific agent
|
|
482
|
+
* @param agentId - The agent ID
|
|
483
|
+
* @param startDate - Start date (ISO format, required)
|
|
484
|
+
* @param endDate - End date (ISO format, required)
|
|
485
|
+
* @param pageIndex - Page number (1-based, default: 1)
|
|
486
|
+
* @param recordsPerPage - Records per page (default: 50, max: 1000)
|
|
487
|
+
* @param sortColumn - Column to sort by (date, cost, duration)
|
|
488
|
+
* @param sortOrder - Sort order (0 = ascending, 1 = descending)
|
|
489
|
+
* @param usageTypes - Filter by usage types (comma-separated)
|
|
490
|
+
*/
|
|
491
|
+
async getAgentRunsCost(agentId, startDate, endDate, pageIndex, recordsPerPage, sortColumn, sortOrder, usageTypes) {
|
|
492
|
+
const params = new URLSearchParams();
|
|
493
|
+
params.append("startDate", startDate);
|
|
494
|
+
params.append("endDate", endDate);
|
|
495
|
+
if (pageIndex !== undefined)
|
|
496
|
+
params.append("pageIndex", String(pageIndex));
|
|
497
|
+
if (recordsPerPage !== undefined)
|
|
498
|
+
params.append("recordsPerPage", String(recordsPerPage));
|
|
499
|
+
if (sortColumn)
|
|
500
|
+
params.append("sortColumn", sortColumn);
|
|
501
|
+
if (sortOrder !== undefined)
|
|
502
|
+
params.append("sortOrder", String(sortOrder));
|
|
503
|
+
if (usageTypes)
|
|
504
|
+
params.append("usageTypes", usageTypes);
|
|
505
|
+
const query = params.toString() ? `?${params.toString()}` : "";
|
|
506
|
+
return this.request(`/api/v1/billing/agents/${agentId}/runs${query}`);
|
|
507
|
+
}
|
|
378
508
|
// ==========================================
|
|
379
509
|
// Space Operations
|
|
380
510
|
// ==========================================
|