@balchemyai/agent-sdk 0.1.14 → 0.1.15
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 +1 -1
- package/LICENSE +21 -0
- package/README.md +12 -12
- package/docs/DEPLOYMENT.md +3 -3
- package/docs/QUICKSTART.md +3 -3
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
All notable changes to `@
|
|
3
|
+
All notable changes to `@balchemyai/agent-sdk` are documented here.
|
|
4
4
|
|
|
5
5
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
6
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Balchemy Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @balchemyai/agent-sdk
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for Balchemy external AI agents. Handles onboarding (SIWE wallet-based or walletless Identity flow), MCP tool access, token lifecycle management, and real-time SSE event streaming.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @balchemyai/agent-sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Auth Paths
|
|
@@ -15,7 +15,7 @@ npm install @balchemy/agent-sdk
|
|
|
15
15
|
Use this when your agent controls a Solana or EVM wallet and can sign messages.
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
-
import { BalchemyAgentSdk } from "@
|
|
18
|
+
import { BalchemyAgentSdk } from "@balchemyai/agent-sdk";
|
|
19
19
|
|
|
20
20
|
const sdk = new BalchemyAgentSdk({
|
|
21
21
|
apiBaseUrl: "https://api.balchemy.ai/api",
|
|
@@ -52,7 +52,7 @@ const mcp = sdk.connectMcp({
|
|
|
52
52
|
Use this when your agent has an HMAC-signed identity token (for balchemy native) or ES256 JWT (for external providers) from a provider registered with Balchemy.
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
|
-
import { BalchemyAgentSdk } from "@
|
|
55
|
+
import { BalchemyAgentSdk } from "@balchemyai/agent-sdk";
|
|
56
56
|
|
|
57
57
|
const sdk = new BalchemyAgentSdk({
|
|
58
58
|
apiBaseUrl: "https://api.balchemy.ai/api",
|
|
@@ -124,8 +124,8 @@ Pass `scope` during onboarding to receive an MCP key with the appropriate permis
|
|
|
124
124
|
All SDK methods throw `AgentSdkError` on failure.
|
|
125
125
|
|
|
126
126
|
```ts
|
|
127
|
-
import { AgentSdkError } from "@
|
|
128
|
-
import type { AgentSdkErrorCode } from "@
|
|
127
|
+
import { AgentSdkError } from "@balchemyai/agent-sdk";
|
|
128
|
+
import type { AgentSdkErrorCode } from "@balchemyai/agent-sdk";
|
|
129
129
|
|
|
130
130
|
try {
|
|
131
131
|
const result = await mcp.agentExecute({ instruction: "..." });
|
|
@@ -142,7 +142,7 @@ try {
|
|
|
142
142
|
## Tool Response Helpers
|
|
143
143
|
|
|
144
144
|
```ts
|
|
145
|
-
import { getToolText, parseToolJson, isToolError } from "@
|
|
145
|
+
import { getToolText, parseToolJson, isToolError } from "@balchemyai/agent-sdk";
|
|
146
146
|
|
|
147
147
|
const response = await mcp.agentPortfolio();
|
|
148
148
|
|
|
@@ -157,7 +157,7 @@ if (isToolError(response)) {
|
|
|
157
157
|
## Token Management
|
|
158
158
|
|
|
159
159
|
```ts
|
|
160
|
-
import { TokenStore } from "@
|
|
160
|
+
import { TokenStore } from "@balchemyai/agent-sdk";
|
|
161
161
|
|
|
162
162
|
const store = new TokenStore({
|
|
163
163
|
// Called when the stored token nears expiry — return a fresh OnboardingResponse
|
|
@@ -175,7 +175,7 @@ const token = await store.get(); // auto-refreshes if expiry < threshold
|
|
|
175
175
|
The `OnboardingResponse` includes an `identityAccess` field when the platform issues a short-lived access token alongside the MCP key.
|
|
176
176
|
|
|
177
177
|
```ts
|
|
178
|
-
import type { IdentityAccess } from "@
|
|
178
|
+
import type { IdentityAccess } from "@balchemyai/agent-sdk";
|
|
179
179
|
|
|
180
180
|
const access: IdentityAccess | undefined = response.identityAccess;
|
|
181
181
|
if (access) {
|
|
@@ -187,8 +187,8 @@ if (access) {
|
|
|
187
187
|
## SSE Event Streaming
|
|
188
188
|
|
|
189
189
|
```ts
|
|
190
|
-
import { SseEventStream } from "@
|
|
191
|
-
import type { SseEvent } from "@
|
|
190
|
+
import { SseEventStream } from "@balchemyai/agent-sdk";
|
|
191
|
+
import type { SseEvent } from "@balchemyai/agent-sdk";
|
|
192
192
|
|
|
193
193
|
const stream = new SseEventStream(
|
|
194
194
|
"https://api.balchemy.ai/api/events",
|
|
@@ -251,7 +251,7 @@ To enable agent onboarding, the following environment variables must be configur
|
|
|
251
251
|
|
|
252
252
|
1. Install the SDK:
|
|
253
253
|
```sh
|
|
254
|
-
npm install @
|
|
254
|
+
npm install @balchemyai/agent-sdk
|
|
255
255
|
```
|
|
256
256
|
|
|
257
257
|
2. Create an MCP API key for your bot via the Hub UI: `Hub > Your Bot > API Keys > Create Key`.
|
package/docs/DEPLOYMENT.md
CHANGED
|
@@ -21,8 +21,8 @@ automatically on failure or reboot.
|
|
|
21
21
|
**1. On your local machine:**
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
npx
|
|
25
|
-
npx balchemy
|
|
24
|
+
npx balchemy # Setup wizard
|
|
25
|
+
npx balchemy docker # Generate Dockerfile + docker-compose.yml
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
This creates:
|
|
@@ -107,7 +107,7 @@ If you prefer to run the agent directly as a system service:
|
|
|
107
107
|
**1. Install globally:**
|
|
108
108
|
|
|
109
109
|
```bash
|
|
110
|
-
npm install -g
|
|
110
|
+
npm install -g balchemy @balchemyai/agent-sdk
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
**2. Create a systemd unit file:**
|
package/docs/QUICKSTART.md
CHANGED
|
@@ -26,7 +26,7 @@ Get an autonomous trading agent running in under 5 minutes.
|
|
|
26
26
|
## Step 2: Run the setup wizard
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
npx
|
|
29
|
+
npx balchemy
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
The wizard asks:
|
|
@@ -43,7 +43,7 @@ It writes `agent.config.yaml` and `.env` to the current directory.
|
|
|
43
43
|
## Step 3: Start the agent
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
|
-
npx balchemy
|
|
46
|
+
npx balchemy start
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
You should see:
|
|
@@ -80,7 +80,7 @@ The generated `docker-compose.yml` runs the agent with:
|
|
|
80
80
|
## Programmatic usage (TypeScript)
|
|
81
81
|
|
|
82
82
|
```typescript
|
|
83
|
-
import { AgentLoop } from '@
|
|
83
|
+
import { AgentLoop } from '@balchemyai/agent-sdk';
|
|
84
84
|
|
|
85
85
|
// From YAML config file
|
|
86
86
|
const loop = AgentLoop.fromConfig('./agent.config.yaml');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balchemyai/agent-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Balchemy external AI agent onboarding + MCP SDK — ERC-8004 onboarding, Solana/EVM trading, 100 tools via MCP",
|
|
@@ -38,21 +38,15 @@
|
|
|
38
38
|
"homepage": "https://balchemy.ai",
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
|
41
|
-
"url": "https://github.com/balchemy
|
|
41
|
+
"url": "https://github.com/balchemy/balchemy-agent",
|
|
42
|
+
"directory": "packages/sdk"
|
|
42
43
|
},
|
|
43
44
|
"bugs": {
|
|
44
|
-
"url": "https://github.com/balchemy
|
|
45
|
+
"url": "https://github.com/balchemy/balchemy-agent/issues"
|
|
45
46
|
},
|
|
46
47
|
"engines": {
|
|
47
48
|
"node": ">=18.0.0"
|
|
48
49
|
},
|
|
49
|
-
"scripts": {
|
|
50
|
-
"build": "tsc -p tsconfig.json",
|
|
51
|
-
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
52
|
-
"test": "jest",
|
|
53
|
-
"test:cov": "jest --coverage",
|
|
54
|
-
"prepublishOnly": "pnpm run typecheck && pnpm run build"
|
|
55
|
-
},
|
|
56
50
|
"dependencies": {
|
|
57
51
|
"js-yaml": "^4.1.0"
|
|
58
52
|
},
|
|
@@ -63,5 +57,11 @@
|
|
|
63
57
|
"jest": "^30.0.0",
|
|
64
58
|
"ts-jest": "^29.3.4",
|
|
65
59
|
"typescript": "5.8.3"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsc -p tsconfig.json",
|
|
63
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
64
|
+
"test": "jest",
|
|
65
|
+
"test:cov": "jest --coverage"
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|