@supertools-ai/core 0.1.0 → 0.1.1

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 CHANGED
@@ -47,7 +47,7 @@ User Request → LLM generates code → Sandbox executes → Result
47
47
  ## Quick Start
48
48
 
49
49
  ```bash
50
- bun add @supertools-ai/core
50
+ bun add @supertools-ai/core @anthropic-ai/sdk e2b
51
51
  ```
52
52
 
53
53
  ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supertools-ai/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Programmatic tool calling for LLMs - let AI write code that orchestrates your tools",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,5 +0,0 @@
1
- /**
2
- * Protocol Validation Tests
3
- */
4
- export {};
5
- //# sourceMappingURL=protocol.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protocol.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/protocol.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Security Module Tests
3
- */
4
- export {};
5
- //# sourceMappingURL=security.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"security.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/security.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Tool Module Tests
3
- */
4
- export {};
5
- //# sourceMappingURL=tool.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/tool.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/dist/errors.d.ts DELETED
@@ -1,64 +0,0 @@
1
- export type ErrorCode = 'CODE_GENERATION_ERROR' | 'EXECUTION_ERROR' | 'TOOL_ERROR' | 'RELAY_CONNECTION_ERROR' | 'RELAY_TIMEOUT_ERROR' | 'PROTOCOL_ERROR' | 'SANDBOX_ERROR' | 'AUTHENTICATION_ERROR' | 'VALIDATION_ERROR' | 'CONFIGURATION_ERROR';
2
- export declare class OPTError extends Error {
3
- readonly code: ErrorCode;
4
- readonly cause?: Error;
5
- constructor(message: string, code: ErrorCode, cause?: Error);
6
- toJSON(): {
7
- name: string;
8
- code: ErrorCode;
9
- message: string;
10
- cause: string | undefined;
11
- };
12
- }
13
- export declare class CodeGenerationError extends OPTError {
14
- constructor(message: string, cause?: Error);
15
- }
16
- export declare class ExecutionError extends OPTError {
17
- readonly output?: string;
18
- constructor(message: string, output?: string, cause?: Error);
19
- toJSON(): {
20
- output: string | undefined;
21
- name: string;
22
- code: ErrorCode;
23
- message: string;
24
- cause: string | undefined;
25
- };
26
- }
27
- export declare class ToolError extends OPTError {
28
- readonly toolName: string;
29
- constructor(message: string, toolName: string, cause?: Error);
30
- toJSON(): {
31
- toolName: string;
32
- name: string;
33
- code: ErrorCode;
34
- message: string;
35
- cause: string | undefined;
36
- };
37
- }
38
- export declare class RelayConnectionError extends OPTError {
39
- constructor(message: string, cause?: Error);
40
- }
41
- export declare class RelayTimeoutError extends OPTError {
42
- constructor(message: string);
43
- }
44
- export declare class SandboxError extends OPTError {
45
- constructor(message: string, cause?: Error);
46
- }
47
- export declare class AuthenticationError extends OPTError {
48
- constructor(message: string);
49
- }
50
- export declare class ConfigurationError extends OPTError {
51
- constructor(message: string);
52
- }
53
- export declare class ValidationError extends OPTError {
54
- readonly field?: string;
55
- constructor(message: string, field?: string);
56
- toJSON(): {
57
- field: string | undefined;
58
- name: string;
59
- code: ErrorCode;
60
- message: string;
61
- cause: string | undefined;
62
- };
63
- }
64
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,uBAAuB,GACvB,iBAAiB,GACjB,YAAY,GACZ,wBAAwB,GAC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C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEZ,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAMlC,MAAM;;;;;;;CAGhB"}
package/dist/index.d.mts DELETED
@@ -1,183 +0,0 @@
1
- import { z } from 'zod';
2
- export { z } from 'zod';
3
-
4
- declare const TOOL_BRAND: unique symbol;
5
- type ZodSchema = z.ZodType;
6
- type InferInput<T extends ZodSchema> = z.infer<T>;
7
- type ExecuteFn<T extends ZodSchema> = (params: InferInput<T>) => unknown | Promise<unknown>;
8
- interface ToolDefinition<T extends ZodSchema> {
9
- readonly name: string;
10
- readonly description: string;
11
- readonly parameters: T;
12
- readonly execute: ExecuteFn<T>;
13
- }
14
- interface Tool<T extends ZodSchema = ZodSchema> {
15
- readonly name: string;
16
- readonly description: string;
17
- readonly parameters: T;
18
- readonly execute: ExecuteFn<T>;
19
- readonly [TOOL_BRAND]: true;
20
- }
21
- interface NormalizedParameter {
22
- readonly name: string;
23
- readonly type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'any';
24
- readonly description: string;
25
- readonly required: boolean;
26
- readonly default?: unknown;
27
- }
28
- interface NormalizedTool {
29
- readonly name: string;
30
- readonly description: string;
31
- readonly parameters: readonly NormalizedParameter[];
32
- readonly execute: (params: Record<string, unknown>) => unknown | Promise<unknown>;
33
- }
34
- /**
35
- * Define a tool with type-safe parameters.
36
- *
37
- * @example
38
- * const searchUsers = defineTool({
39
- * name: 'searchUsers',
40
- * description: 'Search users by name or email',
41
- * parameters: z.object({
42
- * query: z.string().describe('Search query'),
43
- * limit: z.number().optional().default(10),
44
- * }),
45
- * execute: async ({ query, limit }) => db.users.search(query).limit(limit),
46
- * });
47
- */
48
- declare function defineTool<T extends ZodSchema>(definition: ToolDefinition<T>): Tool<T>;
49
- declare function isTool(value: unknown): value is Tool;
50
- declare function normalizeTools(tools: readonly Tool[]): NormalizedTool[];
51
-
52
- type ToolCollection = readonly Tool[];
53
- interface ExecutionResult {
54
- readonly success: boolean;
55
- readonly output: string;
56
- readonly error?: string;
57
- readonly executionTimeMs: number;
58
- readonly images?: readonly string[];
59
- }
60
- interface GeneratedCode {
61
- readonly code: string;
62
- readonly explanation?: string;
63
- readonly rawResponse?: string;
64
- }
65
- interface ProgrammaticResult {
66
- readonly code: string;
67
- readonly explanation?: string;
68
- readonly result: ExecutionResult;
69
- }
70
- interface ToolCallRequest {
71
- readonly tool: string;
72
- readonly arguments: Readonly<Record<string, unknown>>;
73
- }
74
- interface ToolCallResponse {
75
- readonly success: boolean;
76
- readonly result?: unknown;
77
- readonly error?: string;
78
- }
79
- interface LLMAdapter {
80
- generateCode(userRequest: string, systemPrompt: string): Promise<GeneratedCode>;
81
- }
82
- interface ExecutorConfig {
83
- readonly tools: ToolCollection;
84
- readonly timeout?: number;
85
- readonly e2bApiKey?: string;
86
- readonly instructions?: string;
87
- readonly debug?: boolean;
88
- }
89
-
90
- /**
91
- * Programmatic Executor
92
- *
93
- * Orchestrates the complete flow:
94
- * 1. LLM generates JavaScript code
95
- * 2. Code executes in secure E2B Bun sandbox
96
- * 3. Tool calls relay back to host via WebSocket
97
- * 4. Results return to user
98
- */
99
-
100
- interface CreateExecutorOptions extends ExecutorConfig {
101
- readonly llm: LLMAdapter;
102
- }
103
- declare function createExecutor(options: CreateExecutorOptions): ProgrammaticExecutor;
104
- declare class ProgrammaticExecutor {
105
- private readonly originalTools;
106
- private readonly normalizedTools;
107
- private readonly toolsMap;
108
- private readonly llm;
109
- private readonly timeout;
110
- private readonly e2bApiKey?;
111
- private readonly instructions?;
112
- private readonly debug;
113
- constructor(options: CreateExecutorOptions);
114
- run(userRequest: string): Promise<ProgrammaticResult>;
115
- executeCode(code: string): Promise<ExecutionResult>;
116
- getTools(): readonly NormalizedTool[];
117
- getToolDocumentation(): string;
118
- private generateCode;
119
- private createSandbox;
120
- private connectRelay;
121
- private cleanup;
122
- private log;
123
- }
124
-
125
- type ErrorCode = 'CODE_GENERATION_ERROR' | 'EXECUTION_ERROR' | 'TOOL_ERROR' | 'RELAY_CONNECTION_ERROR' | 'RELAY_TIMEOUT_ERROR' | 'PROTOCOL_ERROR' | 'SANDBOX_ERROR' | 'AUTHENTICATION_ERROR' | 'VALIDATION_ERROR' | 'CONFIGURATION_ERROR';
126
- declare class OPTError extends Error {
127
- readonly code: ErrorCode;
128
- readonly cause?: Error;
129
- constructor(message: string, code: ErrorCode, cause?: Error);
130
- toJSON(): {
131
- name: string;
132
- code: ErrorCode;
133
- message: string;
134
- cause: string | undefined;
135
- };
136
- }
137
- declare class CodeGenerationError extends OPTError {
138
- constructor(message: string, cause?: Error);
139
- }
140
- declare class ExecutionError extends OPTError {
141
- readonly output?: string;
142
- constructor(message: string, output?: string, cause?: Error);
143
- toJSON(): {
144
- output: string | undefined;
145
- name: string;
146
- code: ErrorCode;
147
- message: string;
148
- cause: string | undefined;
149
- };
150
- }
151
- declare class ToolError extends OPTError {
152
- readonly toolName: string;
153
- constructor(message: string, toolName: string, cause?: Error);
154
- toJSON(): {
155
- toolName: string;
156
- name: string;
157
- code: ErrorCode;
158
- message: string;
159
- cause: string | undefined;
160
- };
161
- }
162
- declare class RelayConnectionError extends OPTError {
163
- constructor(message: string, cause?: Error);
164
- }
165
- declare class RelayTimeoutError extends OPTError {
166
- constructor(message: string);
167
- }
168
- declare class SandboxError extends OPTError {
169
- constructor(message: string, cause?: Error);
170
- }
171
- declare class AuthenticationError extends OPTError {
172
- constructor(message: string);
173
- }
174
- declare class ConfigurationError extends OPTError {
175
- constructor(message: string);
176
- }
177
-
178
- declare function buildSystemPrompt(toolDefinitions: string, additionalInstructions?: string): string;
179
- declare function extractCode(response: string): string;
180
-
181
- declare function generateTypeHints(tools: readonly Tool[]): string;
182
-
183
- export { AuthenticationError, CodeGenerationError, ConfigurationError, type CreateExecutorOptions, ExecutionError, type ExecutionResult, type ExecutorConfig, type GeneratedCode, type LLMAdapter, type NormalizedParameter, type NormalizedTool, OPTError, ProgrammaticExecutor, type ProgrammaticResult, RelayConnectionError, RelayTimeoutError, SandboxError, type Tool, type ToolCallRequest, type ToolCallResponse, type ToolCollection, type ToolDefinition, ToolError, buildSystemPrompt, createExecutor, defineTool, extractCode, generateTypeHints, isTool, normalizeTools };