@supertools-ai/core 0.1.2 → 0.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/README.md +14 -12
- package/dist/executor.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +16036 -13637
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/relay/client.d.ts +13 -14
- package/dist/relay/client.d.ts.map +1 -1
- package/dist/relay/index.d.ts +2 -2
- package/dist/relay/index.d.ts.map +1 -1
- package/dist/relay/proto/codec.d.ts +24 -0
- package/dist/relay/proto/codec.d.ts.map +1 -0
- package/dist/relay/proto/index.d.ts +3 -0
- package/dist/relay/proto/index.d.ts.map +1 -0
- package/dist/supertools.d.ts +4 -4
- package/dist/types.d.ts +8 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -2
- package/dist/relay/utils/protocol.d.ts +0 -92
- package/dist/relay/utils/protocol.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -50,10 +50,10 @@ User Request → LLM generates code → Sandbox executes → Result
|
|
|
50
50
|
bun add @supertools-ai/core @anthropic-ai/sdk e2b
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Create a `.env` file with your API keys:
|
|
54
54
|
```bash
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
ANTHROPIC_API_KEY=your-key # Get at console.anthropic.com
|
|
56
|
+
E2B_API_KEY=your-key # Get at e2b.dev
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
Create `index.ts` and run with `bun run index.ts`:
|
|
@@ -88,8 +88,11 @@ const getOrders = defineTool({
|
|
|
88
88
|
status ? orders.filter(o => o.status === status) : orders,
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
// Main
|
|
92
|
-
const sandbox = await Sandbox.create('supertools-bun')
|
|
91
|
+
// Main - use "supertools-bun-014" E2B template - should match your supertools version
|
|
92
|
+
const sandbox = await Sandbox.create('supertools-bun-014').catch((e) => {
|
|
93
|
+
console.error('Failed to create sandbox:', e);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
});
|
|
93
96
|
|
|
94
97
|
try {
|
|
95
98
|
const client = supertools(new Anthropic(), {
|
|
@@ -102,7 +105,7 @@ try {
|
|
|
102
105
|
});
|
|
103
106
|
|
|
104
107
|
await client.messages.create({
|
|
105
|
-
model: 'claude-sonnet-4-5
|
|
108
|
+
model: 'claude-sonnet-4-5',
|
|
106
109
|
max_tokens: 1024,
|
|
107
110
|
messages: [{
|
|
108
111
|
role: 'user',
|
|
@@ -128,6 +131,7 @@ const states = ['AL', 'AK', 'AZ', /* ... all 50 */];
|
|
|
128
131
|
const results = {};
|
|
129
132
|
|
|
130
133
|
for (const state of states) {
|
|
134
|
+
// be careful with this - using raw sql tool call can lead to injection or dangerous queries
|
|
131
135
|
const data = await query_database({
|
|
132
136
|
sql: `SELECT SUM(revenue) FROM sales WHERE state = '${state}'`
|
|
133
137
|
});
|
|
@@ -179,7 +183,7 @@ import { supertools, defineTool, z } from '@supertools-ai/core';
|
|
|
179
183
|
import { Sandbox } from 'e2b';
|
|
180
184
|
import Anthropic from '@anthropic-ai/sdk';
|
|
181
185
|
|
|
182
|
-
const sandbox = await Sandbox.create('supertools-bun');
|
|
186
|
+
const sandbox = await Sandbox.create('supertools-bun-014');
|
|
183
187
|
const client = supertools(new Anthropic(), {
|
|
184
188
|
// Required
|
|
185
189
|
tools: [defineTool({ name, description, parameters, execute })],
|
|
@@ -196,8 +200,6 @@ const client = supertools(new Anthropic(), {
|
|
|
196
200
|
// - 'tool_result': Tool completed (includes result and durationMs)
|
|
197
201
|
// - 'tool_error': Tool execution failed
|
|
198
202
|
// - 'result': Final execution result
|
|
199
|
-
// - 'stdout': Standard output from sandbox
|
|
200
|
-
// - 'stderr': Standard error from sandbox
|
|
201
203
|
// - 'complete': Execution finished (success or error)
|
|
202
204
|
if (event.type === 'tool_call') console.log(`Calling ${event.tool}...`);
|
|
203
205
|
if (event.type === 'tool_result') console.log(`${event.tool} done in ${event.durationMs}ms`);
|
|
@@ -207,7 +209,7 @@ const client = supertools(new Anthropic(), {
|
|
|
207
209
|
|
|
208
210
|
// Use exactly like the original SDK
|
|
209
211
|
const response = await client.messages.create({
|
|
210
|
-
model: 'claude-haiku-4-5
|
|
212
|
+
model: 'claude-haiku-4-5',
|
|
211
213
|
max_tokens: 1024,
|
|
212
214
|
messages: [{ role: 'user', content: 'Your request here' }],
|
|
213
215
|
});
|
|
@@ -268,7 +270,7 @@ const myAdapter = {
|
|
|
268
270
|
},
|
|
269
271
|
};
|
|
270
272
|
|
|
271
|
-
const sandbox = await Sandbox.create('supertools-bun');
|
|
273
|
+
const sandbox = await Sandbox.create('supertools-bun-014');
|
|
272
274
|
const executor = createExecutor({
|
|
273
275
|
llm: myAdapter,
|
|
274
276
|
tools: [/* your tools */],
|
|
@@ -342,7 +344,7 @@ console.log(result.result.output); // stdout from execution
|
|
|
342
344
|
7. Results flow back to the sandbox, code continues executing
|
|
343
345
|
8. Final output returns in the expected SDK response format
|
|
344
346
|
|
|
345
|
-
> **Note:** The Relay Server runs inside the pre-built `supertools-bun` E2B template. The Relay Client is included in the `@supertools-ai/core` package and runs on your host.
|
|
347
|
+
> **Note:** The Relay Server runs inside the pre-built `supertools-bun-014` E2B template. The Relay Client is included in the `@supertools-ai/core` package and runs on your host.
|
|
346
348
|
|
|
347
349
|
**Security:**
|
|
348
350
|
- LLM-generated code runs in isolated cloud containers
|
package/dist/executor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,OAAO,KAAK,EAAE,cAAc,EAAW,MAAM,QAAQ,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,UAAU,EAAkB,MAAM,SAAS,CAAC;AAE/G,MAAM,WAAW,qBAAsB,SAAQ,cAA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Aa;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAkC;gBAE/C,OAAO,EAAE,qBAAqB;IAW1C,OAAO,CAAC,IAAI;IAIN,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA+CrD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;YAW3C,oBAAoB;IA8ClC,QAAQ,IAAI,SAAS,cAAc,EAAE;IAIrC,oBAAoB,IAAI,MAAM;YAIhB,YAAY;YA6BZ,YAAY;YA2BZ,OAAO;IAcrB,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,SAAS;CAMlB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
* });
|
|
21
21
|
*
|
|
22
22
|
* // Create sandbox and wrap your SDK client
|
|
23
|
-
* const sandbox = await Sandbox.create('supertools-bun');
|
|
23
|
+
* const sandbox = await Sandbox.create('supertools-bun-014');
|
|
24
24
|
* const client = supertools(new Anthropic(), { tools: [queryDb], sandbox });
|
|
25
25
|
*
|
|
26
26
|
* // Use exactly like normal - tools execute automatically
|
|
27
27
|
* const response = await client.messages.create({
|
|
28
|
-
* model: 'claude-
|
|
28
|
+
* model: 'claude-sonnet-4-5',
|
|
29
29
|
* max_tokens: 1024,
|
|
30
30
|
* messages: [{ role: 'user', content: 'List all admin users' }],
|
|
31
31
|
* });
|