@hamp10/agentforge 0.2.20 → 0.2.22
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/package.json +1 -1
- package/src/OllamaAgent.js +20 -2
package/package.json
CHANGED
package/src/OllamaAgent.js
CHANGED
|
@@ -418,6 +418,7 @@ B6. npm install: cd ${projectsDir}/PROJECT_NAME && /usr/local/bin/npm init -y &&
|
|
|
418
418
|
B7. After starting server, verify: sleep 3 && curl -s -o /dev/null -w '%{http_code}' http://localhost:PORT — if 000, check /tmp/server.log and fix the error.
|
|
419
419
|
B8. PORT MANAGEMENT: Check port before starting: lsof -i :PORT | head -3. If in use: kill old process, restart. If crashed: restart. If busy with something else: pick different port.
|
|
420
420
|
B9. EXPRESS WILDCARD ROUTE: NEVER write app.get('*', ...) — crashes in newer versions. Use app.use((req, res) => { ... }) instead.
|
|
421
|
+
B10a. STATIC FILE PATHS: ALWAYS use path.join(__dirname, 'public') for express.static and file reads — NEVER './public' or 'public'. Relative paths break when server starts with nohup from a different directory. __dirname is always the directory containing server.js.
|
|
421
422
|
B10. MANDATORY SCREENSHOT QA: After curl returns 200, call screenshot_and_describe with send_to_user:true. You are NOT done until the screenshot shows the real working app.
|
|
422
423
|
B11. ALWAYS open the finished app: bash open http://localhost:PORT
|
|
423
424
|
B12. CANVAS GAMES: canvas 800×600, dark background #1a1a2e, all elements clearly visible. Dark theme, styled UI.
|
|
@@ -874,6 +875,22 @@ B16. TEST LIKE A USER: Scroll, click buttons, simulate actions, check different
|
|
|
874
875
|
this.emit('agent_image', { agentId, image: result });
|
|
875
876
|
}
|
|
876
877
|
|
|
878
|
+
// ── Bash: curl returned 000 or 404 — force log read and targeted fix ──
|
|
879
|
+
if (name === 'bash') {
|
|
880
|
+
const resultStr = String(result).trim();
|
|
881
|
+
const isCurlZero = resultStr === '000' || resultStr.endsWith('\n000') || /\b000$/.test(resultStr);
|
|
882
|
+
const isCurl404 = resultStr === '404' || resultStr.endsWith('\n404') || /\b404$/.test(resultStr);
|
|
883
|
+
if (isCurlZero || isCurl404) {
|
|
884
|
+
const logRead = await this._executeTool('bash', { command: 'cat /tmp/server.log 2>/dev/null | tail -40 || echo "No server.log found"' }, workDir, agentId);
|
|
885
|
+
if (isCurlZero) {
|
|
886
|
+
messages.push({ role: 'user', content: `[bash result]: 000 (connection refused — server is NOT running)\n\nCrash log:\n${logRead}\n\nThe server crashed or never started. Fix the actual error shown above. Do NOT assume it is running. Do NOT change the port. Make a targeted fix to the code then restart.` });
|
|
887
|
+
} else {
|
|
888
|
+
messages.push({ role: 'user', content: `[bash result]: 404 (server is running but root route not found)\n\nServer log:\n${logRead}\n\nCommon cause: static files path is wrong. In server.js ALWAYS use path.join(__dirname, 'public') — NEVER './public' or 'public' — relative paths break when server is started with nohup. Fix the static file path and restart. Do NOT rewrite the whole file.` });
|
|
889
|
+
}
|
|
890
|
+
continue;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
877
894
|
// ALL models get tool results fed back — no model should run blind.
|
|
878
895
|
// This is the core of the observe → reason → act loop: every tool result
|
|
879
896
|
// must be in context so the model can see what happened and react correctly.
|
|
@@ -889,11 +906,12 @@ B16. TEST LIKE A USER: Scroll, click buttons, simulate actions, check different
|
|
|
889
906
|
if (name === 'screenshot_and_describe') {
|
|
890
907
|
const screenshotResult = String(result);
|
|
891
908
|
const isLocalhost = (parsedArgs.url || '').includes('localhost') || (parsedArgs.url || '').includes('127.0.0.1');
|
|
892
|
-
// Server unreachable on localhost —
|
|
909
|
+
// Server unreachable on localhost — read crash log and force a fix
|
|
893
910
|
if (screenshotResult.includes('SERVER IS NOT REACHABLE') && isLocalhost) {
|
|
894
911
|
const portMatch = (parsedArgs.url || '').match(/:(\d+)/);
|
|
895
912
|
const port = portMatch ? portMatch[1] : '????';
|
|
896
|
-
|
|
913
|
+
const logRead = await this._executeTool('bash', { command: 'cat /tmp/server.log 2>/dev/null | tail -40 || echo "No server.log found"' }, workDir, agentId);
|
|
914
|
+
messages.push({ role: 'user', content: `The server on port ${port} is NOT running. Here are the crash logs:\n\n${logRead}\n\nThe server crashed or failed to start. Read the error above and fix the bug in your code. Then restart:\n pkill -f 'node.*${port}' 2>/dev/null; nohup /usr/local/bin/node server.js > /tmp/server.log 2>&1 &\nDo NOT assume it is running. Do NOT change the port. Fix the actual error first.` });
|
|
897
915
|
}
|
|
898
916
|
// Public URL unreachable — try web_fetch instead
|
|
899
917
|
else if (screenshotResult.includes('SERVER IS NOT REACHABLE') && !isLocalhost) {
|