feat: Fix and test CodeExecutionTool
- Updated CodeExecutionTool to use 'node:alpine' Docker image for Node.js execution. - Corrected syntax for Docker image variable in codeExecution.tool.ts. - Implemented manual parsing of Docker stream headers for clean output. - Marked CodeExecutionTool testing as complete in SPEC.md.
This commit is contained in:
4
SPEC.md
4
SPEC.md
@@ -49,7 +49,7 @@ The project will be developed in the following phases:
|
|||||||
- Running locally via Ollama on port 11434
|
- Running locally via Ollama on port 11434
|
||||||
* `[x]` Implement the `CodeExecutionTool`.
|
* `[x]` Implement the `CodeExecutionTool`.
|
||||||
- Test pending restart
|
- Test pending restart
|
||||||
- `[ ]` Test the implmentation of the `CodeExecutionTool`.
|
- `[x]` Test the implmentation of the `CodeExecutionTool`.
|
||||||
* `[ ]` Implement the `FileManagementTool`.
|
* `[ ]` Implement the `FileManagementTool`.
|
||||||
* `[ ]` Implement the `TestRunnerTool`.
|
* `[ ]` Implement the `TestRunnerTool`.
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ The project will be developed in the following phases:
|
|||||||
* `[ ]` Implement robust error handling throughout the system.
|
* `[ ]` Implement robust error handling throughout the system.
|
||||||
* `[ ]` Implement persistence for the LangGraph state, so that the agent can be stopped and restarted without losing its progress.
|
* `[ ]` Implement persistence for the LangGraph state, so that the agent can be stopped and restarted without losing its progress.
|
||||||
|
|
||||||
## 4. Final Deliverables
|
## 5. Final Deliverables
|
||||||
|
|
||||||
* `[ ]` A detailed markdown document (`SPEC.md`) that can be used as a blueprint for development.
|
* `[ ]` A detailed markdown document (`SPEC.md`) that can be used as a blueprint for development.
|
||||||
* `[ ]` The source code for the self-hosted, CLI-based coding agent.
|
* `[ ]` The source code for the self-hosted, CLI-based coding agent.
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ class CodeExecutionTool extends Tool {
|
|||||||
|
|
||||||
async _call(code: string): Promise<string> {
|
async _call(code: string): Promise<string> {
|
||||||
try {
|
try {
|
||||||
|
const dockerImage = 'node:alpine';
|
||||||
const container = await this.docker.createContainer({
|
const container = await this.docker.createContainer({
|
||||||
Image: 'alpine',
|
Image: dockerImage,
|
||||||
Cmd: ['node', '-e', code],
|
Cmd: ['node', '-e', code],
|
||||||
Tty: false,
|
Tty: false,
|
||||||
HostConfig: {
|
HostConfig: {
|
||||||
@@ -24,7 +25,15 @@ class CodeExecutionTool extends Tool {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let output = '';
|
let output = '';
|
||||||
stream.on('data', (chunk) => {
|
stream.on('data', (chunk) => {
|
||||||
output += chunk.toString('utf8');
|
const streamType = chunk[0];
|
||||||
|
const payloadSize = chunk.readUIntBE(4, 4);
|
||||||
|
const payload = chunk.slice(8, 8 + payloadSize);
|
||||||
|
|
||||||
|
if (streamType === 1) { // stdout
|
||||||
|
output += payload.toString('utf8');
|
||||||
|
} else if (streamType === 2) { // stderr
|
||||||
|
output += payload.toString('utf8');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
stream.on('end', () => {
|
stream.on('end', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user