@hamp10/agentforge 0.2.16 → 0.2.17
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/bin/agentforge.js +25 -2
- package/package.json +5 -1
- package/scripts/postinstall.js +62 -0
- package/src/OllamaAgent.js +923 -201
- package/src/hampagent/browser.js +209 -73
- package/src/selfUpdate.js +7 -2
- package/src/worker.js +68 -36
- package/templates/agent/AGENTFORGE.md +120 -0
package/bin/agentforge.js
CHANGED
|
@@ -51,10 +51,12 @@ function saveConfig(config) {
|
|
|
51
51
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
const _pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
55
|
+
|
|
54
56
|
program
|
|
55
57
|
.name('agentforge')
|
|
56
58
|
.description('AgentForge worker - connect your machine to agentforge.ai')
|
|
57
|
-
.version(
|
|
59
|
+
.version(_pkg.version);
|
|
58
60
|
|
|
59
61
|
program
|
|
60
62
|
.command('login')
|
|
@@ -282,7 +284,28 @@ program
|
|
|
282
284
|
await worker.initialize();
|
|
283
285
|
await worker.connect();
|
|
284
286
|
|
|
285
|
-
//
|
|
287
|
+
// Auto-start AgentForge Browser so every machine gets browser tools without a separate setup step.
|
|
288
|
+
// On macOS: install the Chrome wrapper app, seed sessions, and launch it.
|
|
289
|
+
// On other platforms: skip silently — agents fall back to web_fetch / screenshot_and_describe.
|
|
290
|
+
if (process.platform === 'darwin') {
|
|
291
|
+
try {
|
|
292
|
+
if (isBrowserRunning()) {
|
|
293
|
+
console.log('🌐 AgentForge Browser already running (port 9223)');
|
|
294
|
+
} else {
|
|
295
|
+
const browserBin = findBrowser();
|
|
296
|
+
if (browserBin) {
|
|
297
|
+
installAgentBrowserApp();
|
|
298
|
+
seedBrowserProfile();
|
|
299
|
+
installLaunchAgent(browserBin);
|
|
300
|
+
console.log('🌐 AgentForge Browser started (port 9223)');
|
|
301
|
+
} else {
|
|
302
|
+
console.warn('⚠️ No browser found — install Chrome for full browser tool support');
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
} catch (browserErr) {
|
|
306
|
+
console.warn(`⚠️ Could not start AgentForge Browser: ${browserErr.message}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
286
309
|
|
|
287
310
|
console.log('');
|
|
288
311
|
console.log('✅ Worker running');
|
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hamp10/agentforge",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "AgentForge worker — connect your machine to agentforge.ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"agentforge": "./bin/agentforge.js"
|
|
8
8
|
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node ./scripts/postinstall.js"
|
|
11
|
+
},
|
|
9
12
|
"files": [
|
|
10
13
|
"bin",
|
|
11
14
|
"src",
|
|
15
|
+
"scripts",
|
|
12
16
|
"templates"
|
|
13
17
|
],
|
|
14
18
|
"dependencies": {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs automatically after `npm install -g @hamp10/agentforge`.
|
|
3
|
+
// Ensures the npm global bin directory is on PATH so users can just type:
|
|
4
|
+
// agentforge start
|
|
5
|
+
// Works on macOS, Linux (including Raspberry Pi).
|
|
6
|
+
|
|
7
|
+
import { existsSync, readFileSync, appendFileSync } from 'fs';
|
|
8
|
+
import { homedir } from 'os';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
|
|
11
|
+
// The bin directory is wherever node lives — npm links `agentforge` there too.
|
|
12
|
+
const binDir = path.dirname(process.execPath);
|
|
13
|
+
|
|
14
|
+
// If already on PATH, nothing to do.
|
|
15
|
+
const pathDirs = (process.env.PATH || '').split(path.delimiter).map(d => d.replace(/\/$/, ''));
|
|
16
|
+
if (pathDirs.includes(binDir.replace(/\/$/, ''))) process.exit(0);
|
|
17
|
+
|
|
18
|
+
// If running under sudo, target the real user's home — not /root.
|
|
19
|
+
const realUser = process.env.SUDO_USER;
|
|
20
|
+
const home = realUser
|
|
21
|
+
? (process.platform === 'darwin'
|
|
22
|
+
? `/Users/${realUser}`
|
|
23
|
+
: `/home/${realUser}`)
|
|
24
|
+
: homedir();
|
|
25
|
+
|
|
26
|
+
// Pick the right shell profile.
|
|
27
|
+
const shell = process.env.SHELL || '';
|
|
28
|
+
let profileFile;
|
|
29
|
+
if (shell.includes('zsh')) {
|
|
30
|
+
profileFile = path.join(home, '.zshrc');
|
|
31
|
+
} else if (shell.includes('bash')) {
|
|
32
|
+
profileFile = existsSync(path.join(home, '.bashrc'))
|
|
33
|
+
? path.join(home, '.bashrc')
|
|
34
|
+
: path.join(home, '.bash_profile');
|
|
35
|
+
} else {
|
|
36
|
+
profileFile = path.join(home, '.profile');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const exportLine = `\nexport PATH="${binDir}:$PATH" # Added by AgentForge\n`;
|
|
40
|
+
|
|
41
|
+
// Avoid adding a duplicate line if we've already patched this file.
|
|
42
|
+
if (existsSync(profileFile)) {
|
|
43
|
+
const existing = readFileSync(profileFile, 'utf8');
|
|
44
|
+
if (existing.includes(binDir)) process.exit(0);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
appendFileSync(profileFile, exportLine);
|
|
49
|
+
console.log('');
|
|
50
|
+
console.log(`✅ AgentForge: added to PATH in ${profileFile}`);
|
|
51
|
+
console.log(` Open a new terminal (or run: source ${profileFile})`);
|
|
52
|
+
console.log(' Then type: agentforge start');
|
|
53
|
+
console.log('');
|
|
54
|
+
} catch (err) {
|
|
55
|
+
// Non-fatal — just tell the user what to add manually.
|
|
56
|
+
console.log('');
|
|
57
|
+
console.log(`⚠️ AgentForge: could not update ${profileFile} automatically.`);
|
|
58
|
+
console.log(' Add this line to your shell profile manually:');
|
|
59
|
+
console.log(` export PATH="${binDir}:$PATH"`);
|
|
60
|
+
console.log(' Then open a new terminal and type: agentforge start');
|
|
61
|
+
console.log('');
|
|
62
|
+
}
|