@intella/sdk 0.0.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 +492 -0
- package/examples/claude-code/README.md +178 -0
- package/examples/claude-code/advanced-config.ts +55 -0
- package/examples/claude-code/basic-usage.ts +56 -0
- package/examples/claude-code/model-comparison.ts +50 -0
- package/examples/claude-code/orchestration.ts +70 -0
- package/examples/claude-code/streaming.ts +69 -0
- package/examples/claude-code/tsconfig.json +19 -0
- package/examples/code-extractor/README.md +77 -0
- package/examples/code-extractor/example.ts +145 -0
- package/examples/filesystem/basic-usage.ts +84 -0
- package/examples/integrated-task/README.md +68 -0
- package/examples/integrated-task/integrated-usage.ts +193 -0
- package/examples/integrated-task/simple-example.ts +51 -0
- package/examples/integrated-task/tsconfig.json +19 -0
- package/examples/sandbox/basic-usage.ts +173 -0
- package/package.json +56 -0
- package/src/agent-manager.ts +104 -0
- package/src/agents/base-agent.ts +166 -0
- package/src/agents/claude-agent.ts +77 -0
- package/src/agents/codex-agent.ts +72 -0
- package/src/agents/intella-lite-agent.ts +55 -0
- package/src/agents/opencode-agent.ts +45 -0
- package/src/filesystem/agentfs-provider.ts +328 -0
- package/src/filesystem/base-provider.ts +98 -0
- package/src/filesystem/index.ts +5 -0
- package/src/filesystem/memory-provider.ts +267 -0
- package/src/filesystem-manager.ts +213 -0
- package/src/index.ts +66 -0
- package/src/orchestrator.ts +177 -0
- package/src/sandbox/base-provider.ts +184 -0
- package/src/sandbox/daytona-provider.ts +462 -0
- package/src/sandbox/e2b-provider.ts +419 -0
- package/src/sandbox/modal-provider.ts +597 -0
- package/src/sandbox-manager.ts +175 -0
- package/src/sdk.ts +401 -0
- package/src/types.ts +451 -0
- package/src/utils/code-extractor.ts +194 -0
- package/tsconfig.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
# Intella SDK
|
|
2
|
+
|
|
3
|
+
An agent orchestrator SDK for managing tasks across multiple AI agents using AI SDK v6 as a consistent interface.
|
|
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
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @intella/sdk ai
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Peer Dependencies
|
|
27
|
+
|
|
28
|
+
The SDK requires the following peer dependencies for specific agents:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# For Claude Agent
|
|
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');
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Agent Configuration
|
|
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
|
+
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Claude Code Agent Examples
|
|
2
|
+
|
|
3
|
+
This folder contains examples demonstrating how to use the Claude Code agent through the Intella SDK.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
1. **Install dependencies:**
|
|
8
|
+
```bash
|
|
9
|
+
npm install @intella/sdk ai ai-sdk-provider-claude-code
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
2. **Install Claude Code CLI:**
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @anthropic-ai/claude-code
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
3. **Authenticate:**
|
|
18
|
+
```bash
|
|
19
|
+
claude login
|
|
20
|
+
```
|
|
21
|
+
This will open a browser window for authentication. You need a Claude Pro or Max subscription.
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
### 1. Basic Usage (`basic-usage.ts`)
|
|
26
|
+
|
|
27
|
+
Demonstrates the simplest way to use the Claude Code agent:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx tsx examples/claude-code/basic-usage.ts
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Features:**
|
|
34
|
+
- Basic agent configuration
|
|
35
|
+
- Simple task execution
|
|
36
|
+
- Response handling
|
|
37
|
+
|
|
38
|
+
### 2. Advanced Configuration (`advanced-config.ts`)
|
|
39
|
+
|
|
40
|
+
Shows how to configure the Claude Code agent with advanced options:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx tsx examples/claude-code/advanced-config.ts
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Features:**
|
|
47
|
+
- Tool permissions (allowedTools, disallowedTools)
|
|
48
|
+
- Permission modes
|
|
49
|
+
- MCP server configuration
|
|
50
|
+
- Custom working directory
|
|
51
|
+
- Verbose logging
|
|
52
|
+
|
|
53
|
+
### 3. Streaming (`streaming.ts`)
|
|
54
|
+
|
|
55
|
+
Demonstrates streaming responses from the Claude Code agent:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx tsx examples/claude-code/streaming.ts
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Features:**
|
|
62
|
+
- Real-time response streaming
|
|
63
|
+
- Chunk-by-chunk output
|
|
64
|
+
- Completion detection
|
|
65
|
+
|
|
66
|
+
### 4. Orchestration (`orchestration.ts`)
|
|
67
|
+
|
|
68
|
+
Shows how to orchestrate multiple agents including Claude Code:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npx tsx examples/claude-code/orchestration.ts
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Features:**
|
|
75
|
+
- Sequential orchestration (agents work in sequence)
|
|
76
|
+
- Parallel orchestration (agents work simultaneously)
|
|
77
|
+
- Result combination strategies
|
|
78
|
+
|
|
79
|
+
### 5. Model Comparison (`model-comparison.ts`)
|
|
80
|
+
|
|
81
|
+
Compares different Claude models (Opus, Sonnet, Haiku) on the same task:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npx tsx examples/claude-code/model-comparison.ts
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Features:**
|
|
88
|
+
- Model performance comparison
|
|
89
|
+
- Response time analysis
|
|
90
|
+
- Token usage tracking
|
|
91
|
+
|
|
92
|
+
## Claude Code Models
|
|
93
|
+
|
|
94
|
+
The Claude Code provider supports three model shortcuts:
|
|
95
|
+
|
|
96
|
+
- **`opus`**: Claude Opus - Most capable model, best for complex reasoning
|
|
97
|
+
- **`sonnet`**: Claude Sonnet - Balanced performance and capability (default)
|
|
98
|
+
- **`haiku`**: Claude Haiku - Fastest model, good for simple tasks
|
|
99
|
+
|
|
100
|
+
You can also use full model identifiers:
|
|
101
|
+
- `claude-opus-4-5`
|
|
102
|
+
- `claude-sonnet-4-5-20250929`
|
|
103
|
+
- `claude-haiku-4-5`
|
|
104
|
+
|
|
105
|
+
## Configuration Options
|
|
106
|
+
|
|
107
|
+
### Basic Configuration
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
sdk.configureAgent('claude', {
|
|
111
|
+
model: 'sonnet', // Model shortcut or full ID
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Advanced Configuration
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
sdk.configureAgent('claude', {
|
|
119
|
+
model: 'opus',
|
|
120
|
+
allowedTools: ['Read', 'Write', 'Edit'],
|
|
121
|
+
disallowedTools: ['Bash'],
|
|
122
|
+
permissionMode: 'default',
|
|
123
|
+
maxTurns: 10,
|
|
124
|
+
cwd: process.cwd(),
|
|
125
|
+
verbose: true,
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Tool Permissions
|
|
130
|
+
|
|
131
|
+
Claude Code has built-in tools (Bash, Edit, Read, Write, etc.) that execute autonomously. You can control which tools are available:
|
|
132
|
+
|
|
133
|
+
- **`allowedTools`**: Array of tool names to allow (whitelist)
|
|
134
|
+
- **`disallowedTools`**: Array of tool names to disallow (blacklist)
|
|
135
|
+
- **`permissionMode`**: How to handle tool permissions
|
|
136
|
+
- `'default'`: Standard permission handling
|
|
137
|
+
- `'acceptEdits'`: Automatically accept file edits
|
|
138
|
+
- `'bypassPermissions'`: Skip permission prompts
|
|
139
|
+
- `'plan'`: Show plan before execution
|
|
140
|
+
|
|
141
|
+
## MCP Servers
|
|
142
|
+
|
|
143
|
+
You can configure Model Context Protocol (MCP) servers for extended functionality:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
sdk.configureAgent('claude', {
|
|
147
|
+
mcpServers: {
|
|
148
|
+
'my-server': {
|
|
149
|
+
command: 'node',
|
|
150
|
+
args: ['server.js'],
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Authentication
|
|
157
|
+
|
|
158
|
+
Claude Code uses CLI authentication. After running `claude login`, your Claude Pro or Max subscription is automatically used. No API keys are needed in your code.
|
|
159
|
+
|
|
160
|
+
## More Information
|
|
161
|
+
|
|
162
|
+
- [Claude Code Provider Documentation](https://ai-sdk.dev/providers/community-providers/claude-code)
|
|
163
|
+
- [Intella SDK Documentation](../../README.md)
|
|
164
|
+
- [Claude Code CLI Documentation](https://github.com/anthropics/claude-code)
|
|
165
|
+
|
|
166
|
+
## Running Examples
|
|
167
|
+
|
|
168
|
+
Make sure you have TypeScript execution support. You can use:
|
|
169
|
+
|
|
170
|
+
- `tsx` (recommended): `npm install -g tsx`
|
|
171
|
+
- `ts-node`: `npm install -g ts-node`
|
|
172
|
+
- Or compile first: `tsc` then `node dist/example.js`
|
|
173
|
+
|
|
174
|
+
Example:
|
|
175
|
+
```bash
|
|
176
|
+
npx tsx examples/claude-code/basic-usage.ts
|
|
177
|
+
```
|
|
178
|
+
|