@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
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Code Extractor Utility Example
|
|
3
|
-
*
|
|
4
|
-
* This example demonstrates how to use the code extractor utility
|
|
5
|
-
* to extract code blocks from LLM responses in markdown format.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
extractCodeBlocks,
|
|
10
|
-
extractCodeBlock,
|
|
11
|
-
extractCode,
|
|
12
|
-
type CodeBlock,
|
|
13
|
-
} from '../../src/index';
|
|
14
|
-
|
|
15
|
-
async function main() {
|
|
16
|
-
// Example markdown text with multiple code blocks
|
|
17
|
-
const markdownText = `
|
|
18
|
-
Here's a TypeScript example:
|
|
19
|
-
|
|
20
|
-
\`\`\`typescript
|
|
21
|
-
function greet(name: string): string {
|
|
22
|
-
return \`Hello, \${name}!\`;
|
|
23
|
-
}
|
|
24
|
-
\`\`\`
|
|
25
|
-
|
|
26
|
-
And here's a bash command:
|
|
27
|
-
|
|
28
|
-
\`\`\`bash
|
|
29
|
-
npm install @intella/sdk
|
|
30
|
-
\`\`\`
|
|
31
|
-
|
|
32
|
-
Finally, some Python code:
|
|
33
|
-
|
|
34
|
-
\`\`\`python
|
|
35
|
-
def calculate_sum(a, b):
|
|
36
|
-
return a + b
|
|
37
|
-
\`\`\`
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
|
-
console.log('=== Example 1: Extract All Code Blocks ===\n');
|
|
41
|
-
const allBlocks = extractCodeBlocks(markdownText) as CodeBlock[];
|
|
42
|
-
console.log(`Found ${allBlocks.length} code blocks:\n`);
|
|
43
|
-
allBlocks.forEach((block, index) => {
|
|
44
|
-
console.log(`Block ${index + 1}:`);
|
|
45
|
-
console.log(` Language: ${block.language || '(none)'}`);
|
|
46
|
-
console.log(` Code:\n${block.code}\n`);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
console.log('\n=== Example 2: Extract Only TypeScript Blocks ===\n');
|
|
50
|
-
const tsBlocks = extractCodeBlocks(markdownText, {
|
|
51
|
-
languages: ['typescript'],
|
|
52
|
-
}) as CodeBlock[];
|
|
53
|
-
console.log(`Found ${tsBlocks.length} TypeScript block(s):\n`);
|
|
54
|
-
tsBlocks.forEach((block) => {
|
|
55
|
-
console.log(`Language: ${block.language}`);
|
|
56
|
-
console.log(`Code:\n${block.code}\n`);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
console.log('\n=== Example 3: Extract Code Strings Only ===\n');
|
|
60
|
-
const codeStrings = extractCodeBlocks(markdownText, {
|
|
61
|
-
codeOnly: true,
|
|
62
|
-
}) as string[];
|
|
63
|
-
console.log(`Extracted ${codeStrings.length} code strings:\n`);
|
|
64
|
-
codeStrings.forEach((code, index) => {
|
|
65
|
-
console.log(`Code ${index + 1}:\n${code}\n`);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
console.log('\n=== Example 4: Extract Single Code Block ===\n');
|
|
69
|
-
const bashBlock = extractCodeBlock(markdownText, 'bash');
|
|
70
|
-
if (bashBlock) {
|
|
71
|
-
console.log('Found bash block:');
|
|
72
|
-
console.log(`Language: ${bashBlock.language}`);
|
|
73
|
-
console.log(`Code: ${bashBlock.code}\n`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
console.log('\n=== Example 5: Extract Code String Only ===\n');
|
|
77
|
-
const pythonCode = extractCode(markdownText, 'python');
|
|
78
|
-
if (pythonCode) {
|
|
79
|
-
console.log('Python code:');
|
|
80
|
-
console.log(pythonCode);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
console.log('\n=== Example 6: Extract with Full Match ===\n');
|
|
84
|
-
const blocksWithMatch = extractCodeBlocks(markdownText, {
|
|
85
|
-
includeFullMatch: true,
|
|
86
|
-
}) as CodeBlock[];
|
|
87
|
-
console.log('First block with full match:');
|
|
88
|
-
if (blocksWithMatch[0]?.fullMatch) {
|
|
89
|
-
console.log(blocksWithMatch[0].fullMatch);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Example: Using with LLM response
|
|
93
|
-
console.log('\n=== Example 7: Real-world Usage with LLM Response ===\n');
|
|
94
|
-
const llmResponse = `
|
|
95
|
-
I'll help you create a function. Here's the code:
|
|
96
|
-
|
|
97
|
-
\`\`\`typescript
|
|
98
|
-
export function add(a: number, b: number): number {
|
|
99
|
-
return a + b;
|
|
100
|
-
}
|
|
101
|
-
\`\`\`
|
|
102
|
-
|
|
103
|
-
You can test it with:
|
|
104
|
-
|
|
105
|
-
\`\`\`bash
|
|
106
|
-
npm test
|
|
107
|
-
\`\`\`
|
|
108
|
-
`;
|
|
109
|
-
|
|
110
|
-
const extractedCode = extractCode(llmResponse, 'typescript');
|
|
111
|
-
if (extractedCode) {
|
|
112
|
-
console.log('Extracted TypeScript code from LLM response:');
|
|
113
|
-
console.log(extractedCode);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Example: Using custom wrapper
|
|
117
|
-
console.log('\n=== Example 8: Using Custom Wrapper ===\n');
|
|
118
|
-
const customMarkdown = `
|
|
119
|
-
Here's some code with custom tags:
|
|
120
|
-
|
|
121
|
-
<code>typescript
|
|
122
|
-
function hello() {
|
|
123
|
-
console.log('Hello!');
|
|
124
|
-
}
|
|
125
|
-
</code>
|
|
126
|
-
|
|
127
|
-
And another one:
|
|
128
|
-
|
|
129
|
-
<code>bash
|
|
130
|
-
echo "Hello World"
|
|
131
|
-
</code>
|
|
132
|
-
`;
|
|
133
|
-
|
|
134
|
-
const customBlocks = extractCodeBlocks(customMarkdown, {
|
|
135
|
-
customWrapper: { start: '<code>', end: '</code>' },
|
|
136
|
-
}) as CodeBlock[];
|
|
137
|
-
console.log(`Found ${customBlocks.length} code blocks with custom wrapper:\n`);
|
|
138
|
-
customBlocks.forEach((block, index) => {
|
|
139
|
-
console.log(`Block ${index + 1}:`);
|
|
140
|
-
console.log(` Language: ${block.language || '(none)'}`);
|
|
141
|
-
console.log(` Code:\n${block.code}\n`);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
main().catch(console.error);
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { IntellaSDK } from '../../src/index.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Basic example demonstrating filesystem usage with Intella SDK
|
|
5
|
-
*/
|
|
6
|
-
async function main() {
|
|
7
|
-
const sdk = new IntellaSDK();
|
|
8
|
-
|
|
9
|
-
// Initialize filesystem with AgentFS provider
|
|
10
|
-
console.log('Initializing AgentFS filesystem...');
|
|
11
|
-
await sdk.initializeFilesystem('agentfs', {
|
|
12
|
-
agentId: 'example-agent',
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// Filesystem operations
|
|
16
|
-
console.log('\n=== Filesystem Operations ===');
|
|
17
|
-
|
|
18
|
-
// Write a file
|
|
19
|
-
await sdk.writeFile('/hello.txt', 'Hello from Intella SDK!');
|
|
20
|
-
console.log('✓ Wrote /hello.txt');
|
|
21
|
-
|
|
22
|
-
// Read the file
|
|
23
|
-
const content = await sdk.readFile('/hello.txt');
|
|
24
|
-
console.log(`✓ Read /hello.txt: ${content}`);
|
|
25
|
-
|
|
26
|
-
// Create a directory
|
|
27
|
-
await sdk.createDirectory('/output', true);
|
|
28
|
-
console.log('✓ Created /output directory');
|
|
29
|
-
|
|
30
|
-
// Write a file in the directory
|
|
31
|
-
await sdk.writeFile('/output/report.txt', 'This is a report');
|
|
32
|
-
console.log('✓ Wrote /output/report.txt');
|
|
33
|
-
|
|
34
|
-
// List directory contents
|
|
35
|
-
const entries = await sdk.readDirectory('/output');
|
|
36
|
-
console.log(`✓ Directory /output contains ${entries.length} entries:`);
|
|
37
|
-
for (const entry of entries) {
|
|
38
|
-
console.log(` - ${entry.name} (${entry.stats.isDirectory ? 'dir' : 'file'})`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Key-value operations
|
|
42
|
-
console.log('\n=== Key-Value Operations ===');
|
|
43
|
-
|
|
44
|
-
await sdk.setValue('user:preferences', { theme: 'dark', language: 'en' });
|
|
45
|
-
console.log('✓ Set user preferences');
|
|
46
|
-
|
|
47
|
-
const preferences = await sdk.getValue('user:preferences');
|
|
48
|
-
console.log(`✓ Got user preferences:`, preferences);
|
|
49
|
-
|
|
50
|
-
// Tool call tracking
|
|
51
|
-
console.log('\n=== Tool Call Tracking ===');
|
|
52
|
-
|
|
53
|
-
await sdk.recordToolCall({
|
|
54
|
-
tool: 'web_search',
|
|
55
|
-
startedAt: Date.now() / 1000 - 5,
|
|
56
|
-
endedAt: Date.now() / 1000 - 4,
|
|
57
|
-
input: { query: 'AI agents' },
|
|
58
|
-
output: { results: ['result1', 'result2'] },
|
|
59
|
-
status: 'success',
|
|
60
|
-
});
|
|
61
|
-
console.log('✓ Recorded tool call');
|
|
62
|
-
|
|
63
|
-
const history = await sdk.getToolCallHistory({ limit: 10 });
|
|
64
|
-
console.log(`✓ Retrieved ${history.length} tool calls from history`);
|
|
65
|
-
|
|
66
|
-
// Using memory provider (ephemeral, in-memory)
|
|
67
|
-
console.log('\n=== Memory Provider (Ephemeral) ===');
|
|
68
|
-
|
|
69
|
-
await sdk.closeFilesystem();
|
|
70
|
-
await sdk.initializeFilesystem('memory');
|
|
71
|
-
|
|
72
|
-
await sdk.writeFile('/temp.txt', 'Temporary file');
|
|
73
|
-
console.log('✓ Wrote temporary file to memory filesystem');
|
|
74
|
-
|
|
75
|
-
const tempContent = await sdk.readFile('/temp.txt');
|
|
76
|
-
console.log(`✓ Read temporary file: ${tempContent}`);
|
|
77
|
-
|
|
78
|
-
// Cleanup
|
|
79
|
-
await sdk.closeFilesystem();
|
|
80
|
-
console.log('\n✓ Closed filesystem');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
main().catch(console.error);
|
|
84
|
-
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# Integrated Task Example
|
|
2
|
-
|
|
3
|
-
This example demonstrates how to use **Agent**, **FileSystem**, and **Sandbox** together to carry out a complete task.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
The example shows a complete workflow:
|
|
8
|
-
|
|
9
|
-
1. **Agent** generates Python code to calculate Fibonacci numbers
|
|
10
|
-
2. **FileSystem** stores the generated code and results
|
|
11
|
-
3. **Sandbox** executes the code in an isolated environment
|
|
12
|
-
4. Results are read back and analyzed by the **Agent**
|
|
13
|
-
|
|
14
|
-
## Prerequisites
|
|
15
|
-
|
|
16
|
-
- Node.js 18+ or Bun
|
|
17
|
-
- Environment variables:
|
|
18
|
-
- `E2B_API_KEY` - For E2B sandbox (or use Daytona)
|
|
19
|
-
- `ANTHROPIC_API_KEY` - For Claude agent (or use another agent)
|
|
20
|
-
|
|
21
|
-
## Running the Example
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
# Install dependencies (if not already installed)
|
|
25
|
-
cd packages/intella-sdk
|
|
26
|
-
bun install
|
|
27
|
-
|
|
28
|
-
# Run the example
|
|
29
|
-
bun run examples/integrated-task/integrated-usage.ts
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Or with Node.js:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npx tsx examples/integrated-task/integrated-usage.ts
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## What It Does
|
|
39
|
-
|
|
40
|
-
1. **Initializes Filesystem** - Sets up a memory-based filesystem for storing code and results
|
|
41
|
-
2. **Initializes Sandbox** - Creates an E2B sandbox environment for code execution
|
|
42
|
-
3. **Configures Agent** - Sets up Claude Sonnet to generate code
|
|
43
|
-
4. **Generates Code** - Agent creates a Python script for Fibonacci calculation
|
|
44
|
-
5. **Saves Code** - Code is stored in the filesystem
|
|
45
|
-
6. **Executes in Sandbox** - The script runs in the isolated sandbox environment
|
|
46
|
-
7. **Reads Results** - Results are retrieved from the sandbox
|
|
47
|
-
8. **Persists Data** - Results are saved back to filesystem
|
|
48
|
-
9. **Analyzes Results** - Agent analyzes the generated Fibonacci sequence
|
|
49
|
-
10. **Tracks Metadata** - Tool calls are recorded for audit/debugging
|
|
50
|
-
|
|
51
|
-
## Customization
|
|
52
|
-
|
|
53
|
-
You can modify this example to:
|
|
54
|
-
|
|
55
|
-
- Use different agents (intella-lite, codex, opencode)
|
|
56
|
-
- Use different sandbox providers (daytona instead of e2b)
|
|
57
|
-
- Use persistent filesystem (agentfs instead of memory)
|
|
58
|
-
- Change the task to generate different types of code
|
|
59
|
-
- Add more complex workflows with multiple agent interactions
|
|
60
|
-
|
|
61
|
-
## Key Concepts
|
|
62
|
-
|
|
63
|
-
- **Agent**: Generates code, analyzes results, provides AI capabilities
|
|
64
|
-
- **FileSystem**: Persistent storage for code, data, and metadata
|
|
65
|
-
- **Sandbox**: Isolated execution environment for running code safely
|
|
66
|
-
|
|
67
|
-
Together, these three components enable powerful AI-driven development workflows.
|
|
68
|
-
|
|
@@ -1,193 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
|