@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
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integrated Task Example
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates how to use Agent, FileSystem, and Sandbox together
|
|
5
|
+
* to carry out a complete task:
|
|
6
|
+
* 1. Use an Agent to generate code
|
|
7
|
+
* 2. Save the code to FileSystem
|
|
8
|
+
* 3. Execute the code in a Sandbox
|
|
9
|
+
* 4. Read and process results
|
|
10
|
+
*
|
|
11
|
+
* Prerequisites:
|
|
12
|
+
* - For E2B: Set E2B_API_KEY environment variable
|
|
13
|
+
* - For AgentFS: Configure your agent backend
|
|
14
|
+
* - For Claude: Set ANTHROPIC_API_KEY environment variable
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { IntellaSDK } from '../../src/index.js';
|
|
18
|
+
import 'dotenv/config';
|
|
19
|
+
|
|
20
|
+
async function main() {
|
|
21
|
+
const sdk = new IntellaSDK();
|
|
22
|
+
|
|
23
|
+
console.log('🚀 Starting Integrated Task Example\n');
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// Step 1: Initialize Filesystem
|
|
27
|
+
console.log('📁 Step 1: Initializing Filesystem...');
|
|
28
|
+
await sdk.initializeFilesystem('memory', {
|
|
29
|
+
// Using memory provider for this example
|
|
30
|
+
// You can also use 'agentfs' for persistent storage
|
|
31
|
+
});
|
|
32
|
+
console.log('✓ Filesystem initialized\n');
|
|
33
|
+
|
|
34
|
+
// Step 2: Initialize Sandbox
|
|
35
|
+
console.log('🏖️ Step 2: Initializing Sandbox...');
|
|
36
|
+
await sdk.initializeSandbox('e2b', {
|
|
37
|
+
templateId: 'base', // Use 'base' template or your custom template ID
|
|
38
|
+
env: {
|
|
39
|
+
NODE_ENV: 'development',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
console.log('✓ Sandbox initialized\n');
|
|
43
|
+
|
|
44
|
+
// Step 3: Configure Agent
|
|
45
|
+
console.log('🤖 Step 3: Configuring Agent...');
|
|
46
|
+
sdk.selectAgent('claude', {
|
|
47
|
+
model: 'sonnet', // or 'haiku', 'opus'
|
|
48
|
+
temperature: 0.7,
|
|
49
|
+
});
|
|
50
|
+
console.log('✓ Agent configured (Claude Sonnet)\n');
|
|
51
|
+
|
|
52
|
+
// Step 4: Task - Generate a Python script that calculates Fibonacci numbers
|
|
53
|
+
console.log('📝 Step 4: Generating code with Agent...');
|
|
54
|
+
const taskPrompt = `Write a Python script that:
|
|
55
|
+
1. Calculates the first 20 Fibonacci numbers
|
|
56
|
+
2. Saves them to a file called 'fibonacci.txt'
|
|
57
|
+
3. Prints each number as it calculates
|
|
58
|
+
|
|
59
|
+
Make the code clean and well-commented.`;
|
|
60
|
+
|
|
61
|
+
const agentResponse = await sdk.executeTask({
|
|
62
|
+
prompt: taskPrompt,
|
|
63
|
+
systemPrompt: 'You are a helpful coding assistant. Generate clean, working code.',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
console.log('✓ Code generated by agent');
|
|
67
|
+
console.log('Agent response preview:', agentResponse.text.substring(0, 200) + '...\n');
|
|
68
|
+
|
|
69
|
+
// Step 5: Extract and save code to filesystem
|
|
70
|
+
console.log('💾 Step 5: Saving code to Filesystem...');
|
|
71
|
+
|
|
72
|
+
// Extract Python code from the agent response (simple extraction)
|
|
73
|
+
// In a real scenario, you might use more sophisticated parsing
|
|
74
|
+
const codeMatch = agentResponse.text.match(/```python\n([\s\S]*?)\n```/) ||
|
|
75
|
+
agentResponse.text.match(/```\n([\s\S]*?)\n```/);
|
|
76
|
+
|
|
77
|
+
if (!codeMatch) {
|
|
78
|
+
throw new Error('Could not extract code from agent response');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const pythonCode = codeMatch[1];
|
|
82
|
+
const scriptPath = '/tmp/fibonacci.py';
|
|
83
|
+
|
|
84
|
+
// Save to filesystem
|
|
85
|
+
await sdk.writeFile(scriptPath, pythonCode);
|
|
86
|
+
console.log(`✓ Code saved to ${scriptPath} in filesystem\n`);
|
|
87
|
+
|
|
88
|
+
// Step 6: Copy code from filesystem to sandbox
|
|
89
|
+
console.log('📤 Step 6: Copying code to Sandbox...');
|
|
90
|
+
const sandbox = sdk.getActiveSandbox();
|
|
91
|
+
if (!sandbox) {
|
|
92
|
+
throw new Error('No active sandbox');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Read from filesystem and write to sandbox
|
|
96
|
+
const codeContent = await sdk.readFile(scriptPath);
|
|
97
|
+
// Convert to string if it's a Buffer
|
|
98
|
+
const codeString = typeof codeContent === 'string' ? codeContent : codeContent.toString('utf-8');
|
|
99
|
+
await sandbox.writeFile('/tmp/fibonacci.py', codeString);
|
|
100
|
+
console.log('✓ Code copied to sandbox\n');
|
|
101
|
+
|
|
102
|
+
// Step 7: Execute the script in sandbox
|
|
103
|
+
console.log('⚡ Step 7: Executing script in Sandbox...');
|
|
104
|
+
const executionResult = await sdk.executeInSandbox('python3 /tmp/fibonacci.py', {
|
|
105
|
+
cwd: '/tmp',
|
|
106
|
+
timeout: 30000, // 30 seconds
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
console.log('✓ Script executed');
|
|
110
|
+
console.log('Exit code:', executionResult.result.exitCode);
|
|
111
|
+
console.log('Output:', executionResult.result.stdout);
|
|
112
|
+
if (executionResult.result.stderr) {
|
|
113
|
+
console.log('Errors:', executionResult.result.stderr);
|
|
114
|
+
}
|
|
115
|
+
console.log();
|
|
116
|
+
|
|
117
|
+
// Step 8: Read results from sandbox
|
|
118
|
+
console.log('📥 Step 8: Reading results from Sandbox...');
|
|
119
|
+
const resultFile = await sandbox.readFile('/tmp/fibonacci.txt');
|
|
120
|
+
console.log('✓ Results file read');
|
|
121
|
+
console.log('Fibonacci numbers:', resultFile);
|
|
122
|
+
console.log();
|
|
123
|
+
|
|
124
|
+
// Step 9: Save results back to filesystem for persistence
|
|
125
|
+
console.log('💾 Step 9: Saving results to Filesystem...');
|
|
126
|
+
await sdk.writeFile('/results/fibonacci.txt', resultFile);
|
|
127
|
+
await sdk.setValue('task:fibonacci:completed', {
|
|
128
|
+
timestamp: new Date().toISOString(),
|
|
129
|
+
count: 20,
|
|
130
|
+
status: 'success',
|
|
131
|
+
});
|
|
132
|
+
console.log('✓ Results saved to filesystem\n');
|
|
133
|
+
|
|
134
|
+
// Step 10: Use agent to analyze results
|
|
135
|
+
console.log('🔍 Step 10: Analyzing results with Agent...');
|
|
136
|
+
const analysisResponse = await sdk.executeTask({
|
|
137
|
+
prompt: `Analyze these Fibonacci numbers: ${resultFile}\n\nProvide insights about the sequence.`,
|
|
138
|
+
});
|
|
139
|
+
console.log('✓ Analysis complete');
|
|
140
|
+
console.log('Analysis:', analysisResponse.text);
|
|
141
|
+
console.log();
|
|
142
|
+
|
|
143
|
+
// Step 11: Record tool call metadata
|
|
144
|
+
console.log('📊 Step 11: Recording tool call metadata...');
|
|
145
|
+
await sdk.recordToolCall({
|
|
146
|
+
tool: 'python_execution',
|
|
147
|
+
startedAt: Date.now() / 1000 - 10,
|
|
148
|
+
endedAt: Date.now() / 1000,
|
|
149
|
+
input: { script: scriptPath, command: 'python3 /tmp/fibonacci.py' },
|
|
150
|
+
output: { result: resultFile, exitCode: executionResult.result.exitCode },
|
|
151
|
+
status: executionResult.result.exitCode === 0 ? 'success' : 'error',
|
|
152
|
+
});
|
|
153
|
+
console.log('✓ Tool call recorded\n');
|
|
154
|
+
|
|
155
|
+
// Step 12: Retrieve tool call history
|
|
156
|
+
console.log('📜 Step 12: Retrieving tool call history...');
|
|
157
|
+
const history = await sdk.getToolCallHistory({ limit: 5 });
|
|
158
|
+
console.log(`✓ Retrieved ${history.length} tool calls`);
|
|
159
|
+
history.forEach((call, index) => {
|
|
160
|
+
console.log(` ${index + 1}. ${call.tool} - ${call.status} (${new Date(call.startedAt * 1000).toLocaleTimeString()})`);
|
|
161
|
+
});
|
|
162
|
+
console.log();
|
|
163
|
+
|
|
164
|
+
console.log('✅ Task completed successfully!');
|
|
165
|
+
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error('❌ Error during task execution:', error);
|
|
168
|
+
throw error;
|
|
169
|
+
} finally {
|
|
170
|
+
// Cleanup
|
|
171
|
+
console.log('\n🧹 Cleaning up...');
|
|
172
|
+
try {
|
|
173
|
+
await sdk.closeSandbox();
|
|
174
|
+
console.log('✓ Sandbox closed');
|
|
175
|
+
} catch (error) {
|
|
176
|
+
console.warn('Warning: Error closing sandbox:', error);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
await sdk.closeFilesystem();
|
|
181
|
+
console.log('✓ Filesystem closed');
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.warn('Warning: Error closing filesystem:', error);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Run the example
|
|
189
|
+
main().catch((error) => {
|
|
190
|
+
console.error('Fatal error:', error);
|
|
191
|
+
process.exit(1);
|
|
192
|
+
});
|
|
193
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple Integrated Example
|
|
3
|
+
*
|
|
4
|
+
* A concise example showing Agent + FileSystem + Sandbox integration
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { IntellaSDK } from '../../src/index.js';
|
|
8
|
+
import 'dotenv/config';
|
|
9
|
+
|
|
10
|
+
async function simpleTask() {
|
|
11
|
+
const sdk = new IntellaSDK();
|
|
12
|
+
|
|
13
|
+
// 1. Initialize all components
|
|
14
|
+
await sdk.initializeFilesystem('memory');
|
|
15
|
+
await sdk.initializeSandbox('e2b', { templateId: 'base' });
|
|
16
|
+
sdk.selectAgent('intella-lite', { model: 'gpt-4o' });
|
|
17
|
+
|
|
18
|
+
// 2. Generate code with Agent
|
|
19
|
+
const { text } = await sdk.executeTask({
|
|
20
|
+
prompt: 'Write a Python script that prints "Hello from integrated SDK!"',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
console.log('Text:', text);
|
|
24
|
+
|
|
25
|
+
// 3. Extract and save code
|
|
26
|
+
const code = text.match(/```python\n([\s\S]*?)\n```/)?.[1] || text;
|
|
27
|
+
await sdk.writeFile('/script.py', code);
|
|
28
|
+
|
|
29
|
+
// 4. Copy to sandbox and execute
|
|
30
|
+
const codeContent = await sdk.readFile('/script.py');
|
|
31
|
+
console.log('Code content:', codeContent);
|
|
32
|
+
const codeString = typeof codeContent === 'string' ? codeContent : codeContent.toString('utf-8');
|
|
33
|
+
|
|
34
|
+
console.log('Code string:', codeString);
|
|
35
|
+
|
|
36
|
+
const sandbox = sdk.getActiveSandbox()!;
|
|
37
|
+
await sandbox.writeFile('/tmp/script.py', codeString);
|
|
38
|
+
console.log('Script written to sandbox');
|
|
39
|
+
|
|
40
|
+
console.log('Executing script in sandbox', sandbox);
|
|
41
|
+
const result = await sdk.executeInSandbox('python3 /tmp/script.py')
|
|
42
|
+
console.log('Result:', result);
|
|
43
|
+
console.log('Output:', result.result.stdout);
|
|
44
|
+
|
|
45
|
+
// 5. Cleanup
|
|
46
|
+
await sdk.closeSandbox();
|
|
47
|
+
await sdk.closeFilesystem();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
simpleTask().catch(console.error);
|
|
51
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"rootDir": "../..",
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"types": ["node"],
|
|
10
|
+
"lib": ["ES2020"],
|
|
11
|
+
"baseUrl": "../..",
|
|
12
|
+
"paths": {
|
|
13
|
+
"@intella/sdk": ["./src/index.ts"]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"include": ["*.ts", "../../src/**/*.ts"],
|
|
17
|
+
"exclude": ["node_modules", "dist"]
|
|
18
|
+
}
|
|
19
|
+
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic Sandbox Usage Example
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates how to use the sandbox functionality
|
|
5
|
+
* with E2B, Daytona, and Modal providers.
|
|
6
|
+
*
|
|
7
|
+
* Prerequisites:
|
|
8
|
+
* - For E2B: Set E2B_API_KEY environment variable
|
|
9
|
+
* - For Daytona: Set DAYTONA_API_KEY and DAYTONA_API_URL environment variables
|
|
10
|
+
* - For Modal: Set MODAL_TOKEN_ID and MODAL_TOKEN_SECRET environment variables
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { IntellaSDK } from '../../src/index.js';
|
|
14
|
+
import 'dotenv/config';
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
const sdk = new IntellaSDK();
|
|
18
|
+
|
|
19
|
+
console.log('Available sandbox providers:', sdk.listSandboxProviders());
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
// Example 1: Using E2B Sandbox
|
|
23
|
+
console.log('\n=== E2B Sandbox Example ===');
|
|
24
|
+
|
|
25
|
+
await sdk.initializeSandbox('e2b', {
|
|
26
|
+
templateId: 'base', // Use 'base' template or your custom template ID
|
|
27
|
+
env: {
|
|
28
|
+
NODE_ENV: 'development',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
console.log('E2B Sandbox initialized');
|
|
33
|
+
|
|
34
|
+
// Execute a command
|
|
35
|
+
const result = await sdk.executeInSandbox('echo "Hello from E2B Sandbox!"');
|
|
36
|
+
console.log('Command result:', result.result.stdout);
|
|
37
|
+
console.log('Exit code:', result.result.exitCode);
|
|
38
|
+
|
|
39
|
+
// Write a file
|
|
40
|
+
const sandbox = sdk.getActiveSandbox();
|
|
41
|
+
if (sandbox) {
|
|
42
|
+
await sandbox.writeFile('/tmp/test.txt', 'Hello, World!');
|
|
43
|
+
const content = await sandbox.readFile('/tmp/test.txt');
|
|
44
|
+
console.log('File content:', content);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Close the sandbox
|
|
48
|
+
await sdk.closeSandbox();
|
|
49
|
+
console.log('E2B Sandbox closed');
|
|
50
|
+
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('E2B Error:', error);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
// Example 2: Using Daytona Sandbox
|
|
57
|
+
console.log('\n=== Daytona Sandbox Example ===');
|
|
58
|
+
|
|
59
|
+
await sdk.initializeSandbox('daytona', {
|
|
60
|
+
templateId: 'default', // Workspace template ID
|
|
61
|
+
baseURL: process.env.DAYTONA_API_URL || 'http://localhost:3000',
|
|
62
|
+
env: {
|
|
63
|
+
NODE_ENV: 'development',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
console.log('Daytona Sandbox initialized');
|
|
68
|
+
|
|
69
|
+
// Execute a command
|
|
70
|
+
const result = await sdk.executeInSandbox('echo "Hello from Daytona Sandbox!"');
|
|
71
|
+
console.log('Command result:', result.result.stdout);
|
|
72
|
+
console.log('Exit code:', result.result.exitCode);
|
|
73
|
+
|
|
74
|
+
// Get sandbox status
|
|
75
|
+
const sandbox = sdk.getActiveSandbox();
|
|
76
|
+
if (sandbox) {
|
|
77
|
+
const status = await sandbox.getStatus();
|
|
78
|
+
console.log('Sandbox status:', status);
|
|
79
|
+
|
|
80
|
+
// Get detailed sandbox information
|
|
81
|
+
const info = await sandbox.getInfo();
|
|
82
|
+
console.log('Sandbox info:', {
|
|
83
|
+
sandboxId: info.sandboxId,
|
|
84
|
+
provider: info.provider,
|
|
85
|
+
isRunning: info.isRunning,
|
|
86
|
+
isInitialized: info.isInitialized,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Close the sandbox
|
|
91
|
+
await sdk.closeSandbox();
|
|
92
|
+
console.log('Daytona Sandbox closed');
|
|
93
|
+
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error('Daytona Error:', error);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Example 3: Execute task with sandbox
|
|
99
|
+
console.log('\n=== Task Execution with Sandbox ===');
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
await sdk.initializeSandbox('e2b', {
|
|
103
|
+
templateId: 'base',
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Configure an agent
|
|
107
|
+
sdk.selectAgent('claude', {
|
|
108
|
+
model: 'sonnet',
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Execute a task and then run it in sandbox
|
|
112
|
+
const combinedResult = await sdk.executeTaskInSandbox(
|
|
113
|
+
'Write a simple Python script that prints "Hello, World!"',
|
|
114
|
+
'python3 /tmp/script.py',
|
|
115
|
+
'claude',
|
|
116
|
+
{
|
|
117
|
+
cwd: '/tmp',
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
console.log('Agent response:', combinedResult.agentResponse.text);
|
|
122
|
+
console.log('Sandbox execution:', combinedResult.sandboxResult.result.stdout);
|
|
123
|
+
|
|
124
|
+
await sdk.closeSandbox();
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.error('Combined execution error:', error);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Example 4: Connecting to existing sandbox and getting info
|
|
130
|
+
console.log('\n=== Connecting to Existing Sandbox ===');
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
// First, create a sandbox and get its ID
|
|
134
|
+
await sdk.initializeSandbox('e2b', {
|
|
135
|
+
templateId: 'base',
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const initialSandbox = sdk.getActiveSandbox();
|
|
139
|
+
if (initialSandbox) {
|
|
140
|
+
const sandboxId = initialSandbox.getSandboxId();
|
|
141
|
+
console.log('Created sandbox ID:', sandboxId);
|
|
142
|
+
|
|
143
|
+
// Get info for the active sandbox
|
|
144
|
+
const info = await initialSandbox.getInfo();
|
|
145
|
+
console.log('Sandbox info:', {
|
|
146
|
+
sandboxId: info.sandboxId,
|
|
147
|
+
provider: info.provider,
|
|
148
|
+
isRunning: info.isRunning,
|
|
149
|
+
createdAt: info.createdAt,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
await sdk.closeSandbox();
|
|
153
|
+
|
|
154
|
+
// Now connect to the same sandbox (if it still exists)
|
|
155
|
+
// Note: E2B sandboxes are ephemeral, so this may not work
|
|
156
|
+
// This example is more useful for Modal and Daytona
|
|
157
|
+
try {
|
|
158
|
+
await sdk.initializeSandbox('e2b', {
|
|
159
|
+
fromSandboxId: sandboxId || '',
|
|
160
|
+
});
|
|
161
|
+
console.log('Reconnected to existing sandbox');
|
|
162
|
+
await sdk.closeSandbox();
|
|
163
|
+
} catch (reconnectError) {
|
|
164
|
+
console.log('Could not reconnect (sandbox may have expired):', reconnectError);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.error('Existing sandbox example error:', error);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
main().catch(console.error);
|
|
173
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intella/sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Agent orchestrator SDK for managing tasks across multiple AI agents using AI SDK v6",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"clean": "rm -rf dist",
|
|
18
|
+
"example:basic": "tsx examples/claude-code/basic-usage.ts",
|
|
19
|
+
"example:streaming": "tsx examples/claude-code/streaming.ts",
|
|
20
|
+
"example:orchestration": "tsx examples/claude-code/orchestration.ts",
|
|
21
|
+
"example:model-comparison": "tsx examples/claude-code/model-comparison.ts",
|
|
22
|
+
"example:integrated-task": "tsx examples/integrated-task/integrated-usage.ts",
|
|
23
|
+
"example:simple-example": "tsx examples/integrated-task/simple-example.ts",
|
|
24
|
+
"example:sandbox": "tsx examples/sandbox/basic-usage.ts"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"ai",
|
|
28
|
+
"sdk",
|
|
29
|
+
"agent",
|
|
30
|
+
"orchestrator",
|
|
31
|
+
"ai-sdk"
|
|
32
|
+
],
|
|
33
|
+
"author": "hi@mielto.com",
|
|
34
|
+
"license": "ISC",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@daytonaio/sdk": "^0.129.0",
|
|
37
|
+
"@e2b/code-interpreter": "^2.3.3",
|
|
38
|
+
"agentfs-sdk": "^0.5.0",
|
|
39
|
+
"ai": "^6.0.0",
|
|
40
|
+
"ai-sdk-provider-claude-code": "^3.1.0",
|
|
41
|
+
"ai-sdk-provider-codex-cli": "^1.0.4",
|
|
42
|
+
"ai-sdk-provider-opencode-sdk": "^1.0.0",
|
|
43
|
+
"dotenv": "^17.2.3",
|
|
44
|
+
"modal": "^0.6.0",
|
|
45
|
+
"ts-node": "^10.9.2",
|
|
46
|
+
"tsx": "^4.21.0",
|
|
47
|
+
"zod": "^3.25.76"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@ai-sdk/openai": "*"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^22.19.3",
|
|
54
|
+
"typescript": "^5.8.3"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { AgentType, AgentConfig, IAgent } from './types.js';
|
|
2
|
+
import { IntellaLiteAgent } from './agents/intella-lite-agent.js';
|
|
3
|
+
import { ClaudeAgent } from './agents/claude-agent.js';
|
|
4
|
+
import { CodexAgent } from './agents/codex-agent.js';
|
|
5
|
+
import { OpenCodeAgent } from './agents/opencode-agent.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Agent Manager
|
|
9
|
+
* Manages agent instances and configurations
|
|
10
|
+
*/
|
|
11
|
+
export class AgentManager {
|
|
12
|
+
private agents: Map<AgentType, IAgent> = new Map();
|
|
13
|
+
private defaultAgentType: AgentType = 'intella-lite';
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
// Initialize default agents
|
|
17
|
+
this.registerAgent('intella-lite', new IntellaLiteAgent());
|
|
18
|
+
this.registerAgent('claude', new ClaudeAgent());
|
|
19
|
+
this.registerAgent('codex', new CodexAgent());
|
|
20
|
+
this.registerAgent('opencode', new OpenCodeAgent());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Register or update an agent instance
|
|
25
|
+
*/
|
|
26
|
+
registerAgent(type: AgentType, agent: IAgent): void {
|
|
27
|
+
if (agent.type !== type) {
|
|
28
|
+
throw new Error(`Agent type mismatch: expected ${type}, got ${agent.type}`);
|
|
29
|
+
}
|
|
30
|
+
this.agents.set(type, agent);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get an agent instance
|
|
35
|
+
*/
|
|
36
|
+
getAgent(type?: AgentType): IAgent {
|
|
37
|
+
const agentType = type || this.defaultAgentType;
|
|
38
|
+
const agent = this.agents.get(agentType);
|
|
39
|
+
|
|
40
|
+
if (!agent) {
|
|
41
|
+
throw new Error(`Agent ${agentType} is not registered`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return agent;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* List all available agents
|
|
49
|
+
*/
|
|
50
|
+
listAgents(): AgentType[] {
|
|
51
|
+
return Array.from(this.agents.keys());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Check if an agent is registered
|
|
56
|
+
*/
|
|
57
|
+
hasAgent(type: AgentType): boolean {
|
|
58
|
+
return this.agents.has(type);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Update agent configuration
|
|
63
|
+
*/
|
|
64
|
+
updateConfig(type: AgentType, config: AgentConfig): void {
|
|
65
|
+
const agent = this.getAgent(type);
|
|
66
|
+
agent.configure(config);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get agent configuration
|
|
71
|
+
*/
|
|
72
|
+
getConfig(type: AgentType): AgentConfig {
|
|
73
|
+
const agent = this.getAgent(type);
|
|
74
|
+
return agent.getConfig();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Set the default agent type
|
|
79
|
+
*/
|
|
80
|
+
setDefaultAgent(type: AgentType): void {
|
|
81
|
+
if (!this.agents.has(type)) {
|
|
82
|
+
throw new Error(`Agent ${type} is not registered`);
|
|
83
|
+
}
|
|
84
|
+
this.defaultAgentType = type;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get the default agent type
|
|
89
|
+
*/
|
|
90
|
+
getDefaultAgentType(): AgentType {
|
|
91
|
+
return this.defaultAgentType;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Remove an agent (cannot remove default agent)
|
|
96
|
+
*/
|
|
97
|
+
removeAgent(type: AgentType): void {
|
|
98
|
+
if (type === this.defaultAgentType) {
|
|
99
|
+
throw new Error('Cannot remove the default agent');
|
|
100
|
+
}
|
|
101
|
+
this.agents.delete(type);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|