@intella/sdk 0.0.1 → 0.0.3
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 +6 -483
- package/dist/agent-manager.d.ts +47 -0
- package/dist/agent-manager.d.ts.map +1 -0
- package/dist/agent-manager.js +90 -0
- package/dist/agent-manager.js.map +1 -0
- package/dist/agents/base-agent.d.ts +41 -0
- package/dist/agents/base-agent.d.ts.map +1 -0
- package/dist/agents/base-agent.js +148 -0
- package/dist/agents/base-agent.js.map +1 -0
- package/dist/agents/claude-agent.d.ts +24 -0
- package/dist/agents/claude-agent.d.ts.map +1 -0
- package/dist/agents/claude-agent.js +65 -0
- package/dist/agents/claude-agent.js.map +1 -0
- package/dist/agents/codex-agent.d.ts +25 -0
- package/dist/agents/codex-agent.d.ts.map +1 -0
- package/dist/agents/codex-agent.js +62 -0
- package/dist/agents/codex-agent.js.map +1 -0
- package/dist/agents/intella-lite-agent.d.ts +21 -0
- package/dist/agents/intella-lite-agent.d.ts.map +1 -0
- package/dist/agents/intella-lite-agent.js +43 -0
- package/dist/agents/intella-lite-agent.js.map +1 -0
- package/dist/agents/opencode-agent.d.ts +20 -0
- package/dist/agents/opencode-agent.d.ts.map +1 -0
- package/dist/agents/opencode-agent.js +36 -0
- package/dist/agents/opencode-agent.js.map +1 -0
- package/dist/filesystem/base-provider.d.ts +55 -0
- package/dist/filesystem/base-provider.d.ts.map +1 -0
- package/dist/filesystem/base-provider.js +45 -0
- package/dist/filesystem/base-provider.js.map +1 -0
- package/dist/filesystem/index.d.ts +3 -0
- package/dist/filesystem/index.d.ts.map +1 -0
- package/{src/filesystem/index.ts → dist/filesystem/index.js} +1 -2
- package/dist/filesystem/index.js.map +1 -0
- package/dist/filesystem/memory-provider.d.ts +44 -0
- package/dist/filesystem/memory-provider.d.ts.map +1 -0
- package/dist/filesystem/memory-provider.js +227 -0
- package/dist/filesystem/memory-provider.js.map +1 -0
- package/dist/filesystem-manager.d.ts +75 -0
- package/dist/filesystem-manager.d.ts.map +1 -0
- package/dist/filesystem-manager.js +162 -0
- package/dist/filesystem-manager.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/index.ts → dist/index.js} +4 -47
- package/dist/index.js.map +1 -0
- package/dist/orchestrator.d.ts +32 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +137 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/sandbox/base-provider.d.ts +106 -0
- package/dist/sandbox/base-provider.d.ts.map +1 -0
- package/dist/sandbox/base-provider.js +74 -0
- package/dist/sandbox/base-provider.js.map +1 -0
- package/dist/sandbox/daytona-provider.d.ts +93 -0
- package/dist/sandbox/daytona-provider.d.ts.map +1 -0
- package/dist/sandbox/daytona-provider.js +378 -0
- package/dist/sandbox/daytona-provider.js.map +1 -0
- package/dist/sandbox/e2b-provider.d.ts +85 -0
- package/dist/sandbox/e2b-provider.d.ts.map +1 -0
- package/dist/sandbox/e2b-provider.js +363 -0
- package/dist/sandbox/e2b-provider.js.map +1 -0
- package/dist/sandbox/modal-provider.d.ts +92 -0
- package/dist/sandbox/modal-provider.d.ts.map +1 -0
- package/dist/sandbox/modal-provider.js +516 -0
- package/dist/sandbox/modal-provider.js.map +1 -0
- package/dist/sandbox-manager.d.ts +59 -0
- package/dist/sandbox-manager.d.ts.map +1 -0
- package/dist/sandbox-manager.js +141 -0
- package/dist/sandbox-manager.js.map +1 -0
- package/dist/sdk.d.ts +173 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +277 -0
- package/dist/sdk.js.map +1 -0
- package/dist/types.d.ts +423 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/code-extractor.d.ts +103 -0
- package/dist/utils/code-extractor.d.ts.map +1 -0
- package/dist/utils/code-extractor.js +133 -0
- package/dist/utils/code-extractor.js.map +1 -0
- package/package.json +23 -11
- package/examples/claude-code/README.md +0 -178
- package/examples/claude-code/advanced-config.ts +0 -55
- package/examples/claude-code/basic-usage.ts +0 -56
- package/examples/claude-code/model-comparison.ts +0 -50
- package/examples/claude-code/orchestration.ts +0 -70
- package/examples/claude-code/streaming.ts +0 -69
- package/examples/claude-code/tsconfig.json +0 -19
- package/examples/code-extractor/README.md +0 -77
- package/examples/code-extractor/example.ts +0 -145
- package/examples/filesystem/basic-usage.ts +0 -84
- package/examples/integrated-task/README.md +0 -68
- package/examples/integrated-task/integrated-usage.ts +0 -193
- package/examples/integrated-task/simple-example.ts +0 -51
- package/examples/integrated-task/tsconfig.json +0 -19
- package/examples/sandbox/basic-usage.ts +0 -173
- package/src/agent-manager.ts +0 -104
- package/src/agents/base-agent.ts +0 -166
- package/src/agents/claude-agent.ts +0 -77
- package/src/agents/codex-agent.ts +0 -72
- package/src/agents/intella-lite-agent.ts +0 -55
- package/src/agents/opencode-agent.ts +0 -45
- package/src/filesystem/agentfs-provider.ts +0 -328
- package/src/filesystem/base-provider.ts +0 -98
- package/src/filesystem/memory-provider.ts +0 -267
- package/src/filesystem-manager.ts +0 -213
- package/src/orchestrator.ts +0 -177
- package/src/sandbox/base-provider.ts +0 -184
- package/src/sandbox/daytona-provider.ts +0 -462
- package/src/sandbox/e2b-provider.ts +0 -419
- package/src/sandbox/modal-provider.ts +0 -597
- package/src/sandbox-manager.ts +0 -175
- package/src/sdk.ts +0 -401
- package/src/types.ts +0 -451
- package/src/utils/code-extractor.ts +0 -194
- package/tsconfig.json +0 -25
package/README.md
CHANGED
|
@@ -1,492 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# intella-sdk
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Unified Interface**: Consistent API for interacting with multiple AI providers
|
|
8
|
-
- **Agent Management**: Easy selection and configuration of different agents
|
|
9
|
-
- **Multi-Agent Orchestration**: Coordinate multiple agents working on a single task
|
|
10
|
-
- **Framework Agnostic**: Works in Node.js, React, and other TypeScript/JavaScript environments
|
|
11
|
-
- **Type Safe**: Full TypeScript support with comprehensive type definitions
|
|
12
|
-
|
|
13
|
-
## Supported Agents
|
|
14
|
-
|
|
15
|
-
- **Intella Lite**: Default lightweight agent (OpenAI-compatible)
|
|
16
|
-
- **Claude Agent**: Powered by Claude Code provider
|
|
17
|
-
- **Codex Agent**: Powered by Codex CLI provider
|
|
18
|
-
- **OpenCode Agent**: Powered by OpenCode SDK provider
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
3
|
+
To install dependencies:
|
|
21
4
|
|
|
22
5
|
```bash
|
|
23
|
-
|
|
6
|
+
bun install
|
|
24
7
|
```
|
|
25
8
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
The SDK requires the following peer dependencies for specific agents:
|
|
9
|
+
To run:
|
|
29
10
|
|
|
30
11
|
```bash
|
|
31
|
-
|
|
32
|
-
npm install ai-sdk-provider-claude-code
|
|
33
|
-
|
|
34
|
-
# For Codex Agent
|
|
35
|
-
npm install ai-sdk-provider-codex-cli
|
|
36
|
-
|
|
37
|
-
# For OpenCode Agent
|
|
38
|
-
npm install ai-sdk-provider-opencode-sdk
|
|
39
|
-
|
|
40
|
-
# For Intella Lite Agent
|
|
41
|
-
npm install @ai-sdk/openai
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Note**: These providers use CLI authentication. Make sure you have the respective CLI tools installed and authenticated:
|
|
45
|
-
- Claude Code: `npm install -g @anthropic-ai/claude-code && claude login`
|
|
46
|
-
- Codex CLI: Ensure Codex CLI is installed and authenticated
|
|
47
|
-
- OpenCode: `npm install -g opencode && opencode login`
|
|
48
|
-
|
|
49
|
-
## Quick Start
|
|
50
|
-
|
|
51
|
-
### Basic Usage
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
import { IntellaSDK } from '@intella/sdk';
|
|
55
|
-
|
|
56
|
-
const sdk = new IntellaSDK();
|
|
57
|
-
|
|
58
|
-
// Configure an agent (Claude Code uses CLI authentication)
|
|
59
|
-
sdk.configureAgent('claude', {
|
|
60
|
-
model: 'sonnet', // Shortcuts: 'opus', 'sonnet', 'haiku'
|
|
61
|
-
// Optional: allowedTools, disallowedTools, mcpServers, permissionMode, etc.
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// Execute a task
|
|
65
|
-
const response = await sdk.executeTask('Write a summary of AI SDK v6');
|
|
66
|
-
console.log(response.text);
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Streaming Responses
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
// Stream a task execution
|
|
73
|
-
for await (const chunk of sdk.streamTask('Explain quantum computing')) {
|
|
74
|
-
process.stdout.write(chunk.text);
|
|
75
|
-
if (chunk.isDone) {
|
|
76
|
-
console.log('\nDone!');
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Multi-Agent Orchestration
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
// Sequential orchestration: agents work in sequence
|
|
85
|
-
const result = await sdk.orchestrateTask(
|
|
86
|
-
'Analyze this code and generate tests',
|
|
87
|
-
['claude', 'codex'],
|
|
88
|
-
'sequential',
|
|
89
|
-
{
|
|
90
|
-
passResults: true, // Pass previous results to next agent
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
console.log(result.result);
|
|
95
|
-
console.log('Agent responses:', result.agentResponses);
|
|
96
|
-
|
|
97
|
-
// Parallel orchestration: agents work simultaneously
|
|
98
|
-
const parallelResult = await sdk.orchestrateTask(
|
|
99
|
-
'Write a blog post about AI',
|
|
100
|
-
['claude', 'opencode'],
|
|
101
|
-
'parallel',
|
|
102
|
-
{
|
|
103
|
-
combineStrategy: 'merge', // Combine all responses
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// Conditional orchestration: route based on task
|
|
108
|
-
const conditionalResult = await sdk.orchestrateTask(
|
|
109
|
-
'Fix this bug',
|
|
110
|
-
['claude', 'codex'],
|
|
111
|
-
'conditional',
|
|
112
|
-
{
|
|
113
|
-
router: (task) => {
|
|
114
|
-
// Custom routing logic
|
|
115
|
-
return task.prompt.includes('code') ? 'codex' : 'claude';
|
|
116
|
-
},
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## API Reference
|
|
122
|
-
|
|
123
|
-
### IntellaSDK
|
|
124
|
-
|
|
125
|
-
Main SDK class for orchestrating agents.
|
|
126
|
-
|
|
127
|
-
#### Methods
|
|
128
|
-
|
|
129
|
-
##### `configureAgent(agentType, config)`
|
|
130
|
-
|
|
131
|
-
Configure an agent with model settings and provider-specific options.
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
// Claude Code agent (uses CLI authentication)
|
|
135
|
-
sdk.configureAgent('claude', {
|
|
136
|
-
model: 'sonnet', // or 'opus', 'haiku', or full model ID
|
|
137
|
-
allowedTools: ['Read', 'Write', 'Edit'],
|
|
138
|
-
permissionMode: 'default',
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// Codex CLI agent (uses CLI auth or OPENAI_API_KEY env var)
|
|
142
|
-
sdk.configureAgent('codex', {
|
|
143
|
-
model: 'gpt-5.2-codex',
|
|
144
|
-
reasoningEffort: 'high',
|
|
145
|
-
approvalMode: 'on-failure',
|
|
146
|
-
sandboxMode: 'workspace-write',
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// OpenCode agent (uses CLI authentication)
|
|
150
|
-
sdk.configureAgent('opencode', {
|
|
151
|
-
model: 'anthropic/claude-sonnet-4-5-20250929',
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// Intella Lite agent (uses OpenAI API key)
|
|
155
|
-
sdk.configureAgent('intella-lite', {
|
|
156
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
157
|
-
model: 'gpt-4o-mini',
|
|
158
|
-
temperature: 0.7,
|
|
159
|
-
maxTokens: 1000,
|
|
160
|
-
});
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
##### `selectAgent(agentType, config?)`
|
|
164
|
-
|
|
165
|
-
Select and configure an agent as the default.
|
|
166
|
-
|
|
167
|
-
```typescript
|
|
168
|
-
sdk.selectAgent('claude', { apiKey: 'your-api-key' });
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
##### `executeTask(task, agentType?)`
|
|
172
|
-
|
|
173
|
-
Execute a task with the specified agent (or default).
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
// Simple string prompt
|
|
177
|
-
const response = await sdk.executeTask('Hello, world!');
|
|
178
|
-
|
|
179
|
-
// Full task request
|
|
180
|
-
const response = await sdk.executeTask({
|
|
181
|
-
prompt: 'Write a function',
|
|
182
|
-
systemPrompt: 'You are a helpful coding assistant',
|
|
183
|
-
temperature: 0.8,
|
|
184
|
-
}, 'codex');
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
##### `streamTask(task, agentType?)`
|
|
188
|
-
|
|
189
|
-
Stream a task execution.
|
|
190
|
-
|
|
191
|
-
```typescript
|
|
192
|
-
for await (const chunk of sdk.streamTask('Explain recursion')) {
|
|
193
|
-
console.log(chunk.text);
|
|
194
|
-
}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
##### `orchestrateTask(task, agents, strategy, options?)`
|
|
198
|
-
|
|
199
|
-
Orchestrate a task across multiple agents.
|
|
200
|
-
|
|
201
|
-
**Strategies:**
|
|
202
|
-
- `sequential`: Agents work in sequence, optionally passing results
|
|
203
|
-
- `parallel`: Agents work simultaneously, results combined
|
|
204
|
-
- `conditional`: Route to agents based on task characteristics
|
|
205
|
-
|
|
206
|
-
```typescript
|
|
207
|
-
const result = await sdk.orchestrateTask(
|
|
208
|
-
'Complex task',
|
|
209
|
-
['claude', 'codex'],
|
|
210
|
-
'sequential',
|
|
211
|
-
{ passResults: true }
|
|
212
|
-
);
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
##### `listAgents()`
|
|
216
|
-
|
|
217
|
-
List all available agent types.
|
|
218
|
-
|
|
219
|
-
```typescript
|
|
220
|
-
const agents = sdk.listAgents();
|
|
221
|
-
// ['intella-lite', 'claude', 'codex', 'opencode']
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
##### `getAgentConfig(agentType)`
|
|
225
|
-
|
|
226
|
-
Get the current configuration for an agent.
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
const config = sdk.getAgentConfig('claude');
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
##### `setDefaultAgent(agentType)`
|
|
233
|
-
|
|
234
|
-
Set the default agent type.
|
|
235
|
-
|
|
236
|
-
```typescript
|
|
237
|
-
sdk.setDefaultAgent('intella-lite');
|
|
12
|
+
bun run index.ts
|
|
238
13
|
```
|
|
239
14
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
Each agent supports the following configuration options:
|
|
243
|
-
|
|
244
|
-
```typescript
|
|
245
|
-
interface AgentConfig {
|
|
246
|
-
apiKey?: string; // Provider API key (for Intella Lite)
|
|
247
|
-
model?: string; // Model identifier
|
|
248
|
-
temperature?: number; // Generation temperature (0-2)
|
|
249
|
-
maxTokens?: number; // Maximum tokens to generate
|
|
250
|
-
headers?: Record<string, string>; // Custom headers
|
|
251
|
-
baseURL?: string; // Custom base URL
|
|
252
|
-
[key: string]: unknown; // Provider-specific options
|
|
253
|
-
}
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
### Provider-Specific Options
|
|
257
|
-
|
|
258
|
-
#### Claude Code Agent
|
|
259
|
-
- `model`: Model shortcut ('opus', 'sonnet', 'haiku') or full model ID
|
|
260
|
-
- `allowedTools`: Array of allowed tool names
|
|
261
|
-
- `disallowedTools`: Array of disallowed tool names
|
|
262
|
-
- `mcpServers`: MCP server configurations
|
|
263
|
-
- `permissionMode`: 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan'
|
|
264
|
-
- `maxTurns`: Maximum conversation turns
|
|
265
|
-
- `cwd`: Working directory
|
|
266
|
-
- `verbose`: Enable debug logging
|
|
267
|
-
|
|
268
|
-
See [Claude Code Provider docs](https://ai-sdk.dev/providers/community-providers/claude-code)
|
|
269
|
-
|
|
270
|
-
#### Codex CLI Agent
|
|
271
|
-
- `model`: Model ID ('gpt-5.2-codex', 'gpt-5.2', 'gpt-5.1-codex-max', etc.)
|
|
272
|
-
- `reasoningEffort`: 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
|
|
273
|
-
- `approvalMode`: 'untrusted' | 'on-failure' | 'on-request' | 'never'
|
|
274
|
-
- `sandboxMode`: 'read-only' | 'workspace-write' | 'danger-full-access'
|
|
275
|
-
- `mcpServers`: MCP server configurations
|
|
276
|
-
- `verbose`: Enable verbose logging
|
|
277
|
-
- `logger`: Custom logger instance
|
|
278
|
-
|
|
279
|
-
See [Codex CLI Provider docs](https://ai-sdk.dev/providers/community-providers/codex-cli)
|
|
280
|
-
|
|
281
|
-
#### OpenCode Agent
|
|
282
|
-
- `model`: Model ID in format 'provider/model-id' (e.g., 'anthropic/claude-sonnet-4-5-20250929')
|
|
283
|
-
|
|
284
|
-
See [OpenCode Provider docs](https://ai-sdk.dev/providers/community-providers/opencode-sdk)
|
|
285
|
-
|
|
286
|
-
### Environment Variables
|
|
287
|
-
|
|
288
|
-
- `OPENAI_API_KEY` - For Intella Lite (OpenAI-compatible) and Codex CLI (optional)
|
|
289
|
-
|
|
290
|
-
**Note**: Claude Code, Codex CLI, and OpenCode providers primarily use CLI authentication. Make sure you're logged in via their respective CLI tools:
|
|
291
|
-
- Claude Code: `npm install -g @anthropic-ai/claude-code && claude login`
|
|
292
|
-
- Codex CLI: `npm install -g @openai/codex && codex` (follow interactive setup)
|
|
293
|
-
- OpenCode: `npm install -g opencode && opencode login`
|
|
294
|
-
|
|
295
|
-
## Advanced Usage
|
|
296
|
-
|
|
297
|
-
### Direct Agent Access
|
|
298
|
-
|
|
299
|
-
```typescript
|
|
300
|
-
import { AgentManager, ClaudeAgent } from '@intella/sdk';
|
|
301
|
-
|
|
302
|
-
const manager = new AgentManager();
|
|
303
|
-
const claudeAgent = new ClaudeAgent({
|
|
304
|
-
apiKey: 'your-key',
|
|
305
|
-
model: 'claude-sonnet-4-5-20250929',
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
manager.registerAgent('claude', claudeAgent);
|
|
309
|
-
const agent = manager.getAgent('claude');
|
|
310
|
-
const response = await agent.execute({ prompt: 'Hello!' });
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
### Custom Orchestration
|
|
314
|
-
|
|
315
|
-
```typescript
|
|
316
|
-
import { Orchestrator, AgentManager } from '@intella/sdk';
|
|
317
|
-
|
|
318
|
-
const manager = new AgentManager();
|
|
319
|
-
const orchestrator = new Orchestrator(manager);
|
|
320
|
-
|
|
321
|
-
const result = await orchestrator.orchestrate({
|
|
322
|
-
task: { prompt: 'Complex task' },
|
|
323
|
-
agents: ['claude', 'codex'],
|
|
324
|
-
strategy: 'parallel',
|
|
325
|
-
options: {
|
|
326
|
-
combineStrategy: 'merge',
|
|
327
|
-
},
|
|
328
|
-
});
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
## Sandbox Support
|
|
332
|
-
|
|
333
|
-
The SDK supports multiple sandbox providers for executing code in isolated environments.
|
|
334
|
-
|
|
335
|
-
### Supported Sandbox Providers
|
|
336
|
-
|
|
337
|
-
- **E2B**: Cloud sandbox environment for code execution
|
|
338
|
-
- **Daytona**: Development environment sandboxes
|
|
339
|
-
- **Modal**: Serverless sandbox execution
|
|
340
|
-
|
|
341
|
-
### Basic Sandbox Usage
|
|
342
|
-
|
|
343
|
-
```typescript
|
|
344
|
-
// Initialize a sandbox
|
|
345
|
-
await sdk.initializeSandbox('e2b', {
|
|
346
|
-
templateId: 'base',
|
|
347
|
-
env: {
|
|
348
|
-
NODE_ENV: 'development',
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
// Execute a command
|
|
353
|
-
const result = await sdk.executeInSandbox('echo "Hello, World!"');
|
|
354
|
-
console.log(result.result.stdout);
|
|
355
|
-
|
|
356
|
-
// Get active sandbox and use directly
|
|
357
|
-
const sandbox = sdk.getActiveSandbox();
|
|
358
|
-
if (sandbox) {
|
|
359
|
-
await sandbox.writeFile('/tmp/test.txt', 'Hello!');
|
|
360
|
-
const content = await sandbox.readFile('/tmp/test.txt');
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// Close sandbox
|
|
364
|
-
await sdk.closeSandbox();
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
### Connecting to Existing Sandboxes
|
|
368
|
-
|
|
369
|
-
You can connect to an existing sandbox using the `fromSandboxId` config option or by calling `fromSandbox` directly:
|
|
370
|
-
|
|
371
|
-
```typescript
|
|
372
|
-
// Option 1: Using fromSandboxId in config (recommended)
|
|
373
|
-
await sdk.initializeSandbox('modal', {
|
|
374
|
-
fromSandboxId: 'existing-sandbox-id',
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
// Option 2: Direct fromSandbox call
|
|
378
|
-
const sandbox = sdk.getActiveSandbox();
|
|
379
|
-
if (sandbox) {
|
|
380
|
-
const sandboxInstance = await sandbox.fromSandbox('existing-sandbox-id');
|
|
381
|
-
}
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
### Getting Sandbox Information
|
|
385
|
-
|
|
386
|
-
The `getInfo` method provides detailed information about a sandbox:
|
|
387
|
-
|
|
388
|
-
```typescript
|
|
389
|
-
const sandbox = sdk.getActiveSandbox();
|
|
390
|
-
if (sandbox) {
|
|
391
|
-
// Get info for active sandbox
|
|
392
|
-
const info = await sandbox.getInfo();
|
|
393
|
-
console.log(info);
|
|
394
|
-
// {
|
|
395
|
-
// sandboxId: 'sb-123',
|
|
396
|
-
// provider: 'e2b',
|
|
397
|
-
// isRunning: true,
|
|
398
|
-
// isInitialized: true,
|
|
399
|
-
// createdAt: Date,
|
|
400
|
-
// metadata: { ... },
|
|
401
|
-
// info: { ... } // Raw provider-specific info
|
|
402
|
-
// }
|
|
403
|
-
|
|
404
|
-
// Get info for a specific sandbox by ID
|
|
405
|
-
const otherInfo = await sandbox.getInfo('another-sandbox-id');
|
|
406
|
-
}
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
### Sandbox Configuration
|
|
410
|
-
|
|
411
|
-
```typescript
|
|
412
|
-
interface SandboxConfig {
|
|
413
|
-
fromSandboxId?: string; // Connect to existing sandbox
|
|
414
|
-
provider?: SandboxProviderType;
|
|
415
|
-
apiKey?: string; // Provider API key
|
|
416
|
-
templateId?: string; // Template/workspace ID
|
|
417
|
-
baseURL?: string; // Provider base URL
|
|
418
|
-
env?: Record<string, string>; // Environment variables
|
|
419
|
-
timeout?: number; // Timeout in milliseconds
|
|
420
|
-
[key: string]: unknown; // Provider-specific options
|
|
421
|
-
}
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
### Provider-Specific Configuration
|
|
425
|
-
|
|
426
|
-
#### E2B
|
|
427
|
-
- Requires `E2B_API_KEY` environment variable or `apiKey` in config
|
|
428
|
-
- Supports `templateId` for selecting sandbox templates
|
|
429
|
-
- Use `fromSandboxId` to reconnect to existing sandboxes
|
|
430
|
-
|
|
431
|
-
#### Daytona
|
|
432
|
-
- Requires `DAYTONA_API_KEY` or `DAYTONA_API_TOKEN` environment variable
|
|
433
|
-
- Supports `templateId` for workspace templates
|
|
434
|
-
- Optional `baseURL` for custom Daytona server
|
|
435
|
-
|
|
436
|
-
#### Modal
|
|
437
|
-
- Requires `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` environment variables
|
|
438
|
-
- Supports `appName` and `imageName` for custom app/image configuration
|
|
439
|
-
- Use `fromSandboxId` to connect to existing sandboxes
|
|
440
|
-
|
|
441
|
-
### Sandbox Operations
|
|
442
|
-
|
|
443
|
-
All sandbox providers support:
|
|
444
|
-
|
|
445
|
-
- **Command Execution**: `executeCommand(command, options?)`
|
|
446
|
-
- **Code Execution**: `runCode(code, options?)`
|
|
447
|
-
- **File Operations**: `readFile`, `writeFile`, `uploadFile`, `downloadFile`, `listFiles`, `fileExists`, `deleteFile`
|
|
448
|
-
- **Status & Info**: `getStatus()`, `getInfo(sandboxId?)`
|
|
449
|
-
- **Management**: `close()`, `getSandboxId()`, `isInitialized()`
|
|
450
|
-
|
|
451
|
-
## Type Definitions
|
|
452
|
-
|
|
453
|
-
The SDK exports comprehensive TypeScript types:
|
|
454
|
-
|
|
455
|
-
```typescript
|
|
456
|
-
import type {
|
|
457
|
-
AgentType,
|
|
458
|
-
AgentConfig,
|
|
459
|
-
TaskRequest,
|
|
460
|
-
TaskResponse,
|
|
461
|
-
OrchestrationRequest,
|
|
462
|
-
OrchestrationResponse,
|
|
463
|
-
IAgent,
|
|
464
|
-
SandboxProviderType,
|
|
465
|
-
SandboxConfig,
|
|
466
|
-
SandboxInfo,
|
|
467
|
-
ISandboxProvider,
|
|
468
|
-
} from '@intella/sdk';
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
## Error Handling
|
|
472
|
-
|
|
473
|
-
The SDK throws descriptive errors for common issues:
|
|
474
|
-
|
|
475
|
-
```typescript
|
|
476
|
-
try {
|
|
477
|
-
const response = await sdk.executeTask('Hello', 'unknown-agent');
|
|
478
|
-
} catch (error) {
|
|
479
|
-
if (error.message.includes('not registered')) {
|
|
480
|
-
console.error('Agent not found');
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
## Examples
|
|
486
|
-
|
|
487
|
-
See the `/examples` directory for more detailed usage examples.
|
|
488
|
-
|
|
489
|
-
## License
|
|
490
|
-
|
|
491
|
-
ISC
|
|
492
|
-
|
|
15
|
+
This project was created using `bun init` in bun v1.1.30. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AgentType, AgentConfig, IAgent } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Agent Manager
|
|
4
|
+
* Manages agent instances and configurations
|
|
5
|
+
*/
|
|
6
|
+
export declare class AgentManager {
|
|
7
|
+
private agents;
|
|
8
|
+
private defaultAgentType;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Register or update an agent instance
|
|
12
|
+
*/
|
|
13
|
+
registerAgent(type: AgentType, agent: IAgent): void;
|
|
14
|
+
/**
|
|
15
|
+
* Get an agent instance
|
|
16
|
+
*/
|
|
17
|
+
getAgent(type?: AgentType): IAgent;
|
|
18
|
+
/**
|
|
19
|
+
* List all available agents
|
|
20
|
+
*/
|
|
21
|
+
listAgents(): AgentType[];
|
|
22
|
+
/**
|
|
23
|
+
* Check if an agent is registered
|
|
24
|
+
*/
|
|
25
|
+
hasAgent(type: AgentType): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Update agent configuration
|
|
28
|
+
*/
|
|
29
|
+
updateConfig(type: AgentType, config: AgentConfig): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get agent configuration
|
|
32
|
+
*/
|
|
33
|
+
getConfig(type: AgentType): AgentConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Set the default agent type
|
|
36
|
+
*/
|
|
37
|
+
setDefaultAgent(type: AgentType): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the default agent type
|
|
40
|
+
*/
|
|
41
|
+
getDefaultAgentType(): AgentType;
|
|
42
|
+
/**
|
|
43
|
+
* Remove an agent (cannot remove default agent)
|
|
44
|
+
*/
|
|
45
|
+
removeAgent(type: AgentType): void;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=agent-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-manager.d.ts","sourceRoot":"","sources":["../src/agent-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAMjE;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,gBAAgB,CAA6B;;IAUrD;;OAEG;IACH,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAOnD;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM;IAWlC;;OAEG;IACH,UAAU,IAAI,SAAS,EAAE;IAIzB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO;IAIlC;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;IAKxD;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW;IAKvC;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAOtC;;OAEG;IACH,mBAAmB,IAAI,SAAS;IAIhC;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;CAMnC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { IntellaLiteAgent } from './agents/intella-lite-agent.js';
|
|
2
|
+
import { ClaudeAgent } from './agents/claude-agent.js';
|
|
3
|
+
import { CodexAgent } from './agents/codex-agent.js';
|
|
4
|
+
import { OpenCodeAgent } from './agents/opencode-agent.js';
|
|
5
|
+
/**
|
|
6
|
+
* Agent Manager
|
|
7
|
+
* Manages agent instances and configurations
|
|
8
|
+
*/
|
|
9
|
+
export class AgentManager {
|
|
10
|
+
agents = new Map();
|
|
11
|
+
defaultAgentType = 'intella-lite';
|
|
12
|
+
constructor() {
|
|
13
|
+
// Initialize default agents
|
|
14
|
+
this.registerAgent('intella-lite', new IntellaLiteAgent());
|
|
15
|
+
this.registerAgent('claude', new ClaudeAgent());
|
|
16
|
+
this.registerAgent('codex', new CodexAgent());
|
|
17
|
+
this.registerAgent('opencode', new OpenCodeAgent());
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Register or update an agent instance
|
|
21
|
+
*/
|
|
22
|
+
registerAgent(type, agent) {
|
|
23
|
+
if (agent.type !== type) {
|
|
24
|
+
throw new Error(`Agent type mismatch: expected ${type}, got ${agent.type}`);
|
|
25
|
+
}
|
|
26
|
+
this.agents.set(type, agent);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get an agent instance
|
|
30
|
+
*/
|
|
31
|
+
getAgent(type) {
|
|
32
|
+
const agentType = type || this.defaultAgentType;
|
|
33
|
+
const agent = this.agents.get(agentType);
|
|
34
|
+
if (!agent) {
|
|
35
|
+
throw new Error(`Agent ${agentType} is not registered`);
|
|
36
|
+
}
|
|
37
|
+
return agent;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* List all available agents
|
|
41
|
+
*/
|
|
42
|
+
listAgents() {
|
|
43
|
+
return Array.from(this.agents.keys());
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if an agent is registered
|
|
47
|
+
*/
|
|
48
|
+
hasAgent(type) {
|
|
49
|
+
return this.agents.has(type);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Update agent configuration
|
|
53
|
+
*/
|
|
54
|
+
updateConfig(type, config) {
|
|
55
|
+
const agent = this.getAgent(type);
|
|
56
|
+
agent.configure(config);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get agent configuration
|
|
60
|
+
*/
|
|
61
|
+
getConfig(type) {
|
|
62
|
+
const agent = this.getAgent(type);
|
|
63
|
+
return agent.getConfig();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Set the default agent type
|
|
67
|
+
*/
|
|
68
|
+
setDefaultAgent(type) {
|
|
69
|
+
if (!this.agents.has(type)) {
|
|
70
|
+
throw new Error(`Agent ${type} is not registered`);
|
|
71
|
+
}
|
|
72
|
+
this.defaultAgentType = type;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the default agent type
|
|
76
|
+
*/
|
|
77
|
+
getDefaultAgentType() {
|
|
78
|
+
return this.defaultAgentType;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Remove an agent (cannot remove default agent)
|
|
82
|
+
*/
|
|
83
|
+
removeAgent(type) {
|
|
84
|
+
if (type === this.defaultAgentType) {
|
|
85
|
+
throw new Error('Cannot remove the default agent');
|
|
86
|
+
}
|
|
87
|
+
this.agents.delete(type);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=agent-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-manager.js","sourceRoot":"","sources":["../src/agent-manager.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type LanguageModel, type ModelMessage } from 'ai';
|
|
2
|
+
import type { AgentType, AgentConfig, TaskRequest, TaskResponse, StreamChunk, IAgent } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base class for all agents
|
|
5
|
+
* Provides common functionality using AI SDK v6
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class BaseAgent implements IAgent {
|
|
8
|
+
protected config: AgentConfig;
|
|
9
|
+
readonly type: AgentType;
|
|
10
|
+
constructor(type: AgentType, config?: AgentConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Get the language model instance
|
|
13
|
+
* Must be implemented by subclasses
|
|
14
|
+
*/
|
|
15
|
+
abstract getModel(): LanguageModel | Promise<LanguageModel>;
|
|
16
|
+
/**
|
|
17
|
+
* Execute a task and return the response
|
|
18
|
+
*/
|
|
19
|
+
execute(request: TaskRequest): Promise<TaskResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Stream a task execution
|
|
22
|
+
*/
|
|
23
|
+
stream(request: TaskRequest): AsyncIterable<StreamChunk>;
|
|
24
|
+
/**
|
|
25
|
+
* Configure the agent
|
|
26
|
+
*/
|
|
27
|
+
configure(config: AgentConfig): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get current configuration
|
|
30
|
+
*/
|
|
31
|
+
getConfig(): AgentConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Convert TaskRequest content to AI SDK ModelMessage content format
|
|
34
|
+
*/
|
|
35
|
+
private convertContent;
|
|
36
|
+
/**
|
|
37
|
+
* Build messages array from request
|
|
38
|
+
*/
|
|
39
|
+
protected buildMessages(request: TaskRequest): ModelMessage[];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=base-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-agent.d.ts","sourceRoot":"","sources":["../../src/agents/base-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,IAAI,CAAC;AACrF,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAkB,MAAM,aAAa,CAAC;AAE1H;;;GAGG;AACH,8BAAsB,SAAU,YAAW,MAAM;IAC/C,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;IAC9B,SAAgB,IAAI,EAAE,SAAS,CAAC;gBAEpB,IAAI,EAAE,SAAS,EAAE,MAAM,GAAE,WAAgB;IAKrD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,IAAI,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAE3D;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAqB1D;;OAEG;IACI,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;IAoC/D;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAIpC;;OAEG;IACH,SAAS,IAAI,WAAW;IAIxB;;OAEG;IACH,OAAO,CAAC,cAAc;IA6BtB;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,YAAY,EAAE;CAqC9D"}
|