@j-o-r/hello-dave 0.0.6 → 0.0.7
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/CHANGELOG.md +14 -34
- package/README.md +240 -0
- package/README.md.bak +218 -0
- package/{examples → agents}/ask_agent.js +5 -5
- package/{examples → agents}/codeserver.sh +14 -14
- package/{examples → agents}/daisy_agent.js +5 -5
- package/{examples → agents}/docs_agent.js +5 -5
- package/{examples → agents}/gpt_agent.js +5 -5
- package/{examples → agents}/grok_agent.js +5 -5
- package/{examples → agents}/memory_agent.js +5 -5
- package/{examples → agents}/npm_agent.js +5 -5
- package/{examples → agents}/prompt_agent.js +5 -5
- package/agents/spawn_agent.js +137 -0
- package/{examples → agents}/test_agent.js +6 -6
- package/{examples → agents}/todo_agent.js +5 -5
- package/bin/codeDave +58 -0
- package/bin/dave.js +3 -5
- package/lib/AgentClient.js +111 -67
- package/lib/AgentManager.js +111 -80
- package/lib/AgentServer.js +144 -104
- package/lib/Cli.js +126 -93
- package/lib/Prompt.js +38 -5
- package/lib/Session.js +102 -79
- package/lib/ToolSet.js +79 -60
- package/lib/fafs.js +54 -19
- package/lib/genericToolset.js +109 -129
- package/lib/wsCli.js +50 -19
- package/lib/wsIO.js +10 -6
- package/package.json +3 -3
- package/types/AgentClient.d.ts +69 -35
- package/types/AgentManager.d.ts +50 -56
- package/types/AgentServer.d.ts +63 -16
- package/types/Cli.d.ts +56 -10
- package/types/Prompt.d.ts +36 -4
- package/types/Session.d.ts +23 -9
- package/types/ToolSet.d.ts +49 -32
- package/types/fafs.d.ts +68 -25
- package/types/wsCli.d.ts +14 -0
- package/types/wsIO.d.ts +9 -5
- package/utils/search_sessions.sh +100 -53
- package/bin/spawn_agent.js +0 -293
- package/lib/genericToolset.js.bak_syntax +0 -402
- /package/{examples → agents}/code_agent.js +0 -0
- /package/{examples → agents}/readme_agent.js +0 -0
|
@@ -52,19 +52,19 @@ function printHelp() {
|
|
|
52
52
|
## USAGE MODES:
|
|
53
53
|
|
|
54
54
|
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
55
|
-
./
|
|
55
|
+
./agents/${name}.js "Your query" [--options]
|
|
56
56
|
|
|
57
57
|
### 2. Interactive CLI (no positional arg):
|
|
58
|
-
./
|
|
58
|
+
./agents/${name}.js [--options]
|
|
59
59
|
|
|
60
60
|
### 3. WS Server (no positional arg):
|
|
61
|
-
./
|
|
61
|
+
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
62
62
|
|
|
63
63
|
### 4. WS Client (no positional arg):
|
|
64
|
-
./
|
|
64
|
+
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
65
65
|
|
|
66
66
|
### 5. Hybrid (Server + Client, no positional arg):
|
|
67
|
-
./
|
|
67
|
+
./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
68
68
|
|
|
69
69
|
## SERVER OPTIONS EXPLAINED:
|
|
70
70
|
--serve [port]: Starts WebSocket SERVER at ws://127.0.0.1:[port]/ws. Allows other agents (--connect) to connect and use this agent as a remote TOOL (e.g., 'gpt_agent'). Runs indefinitely until Ctrl+C.
|
|
@@ -64,19 +64,19 @@ function printHelp() {
|
|
|
64
64
|
## USAGE MODES:
|
|
65
65
|
|
|
66
66
|
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
67
|
-
./
|
|
67
|
+
./agents/${name}.js "What is your task?" [--options]
|
|
68
68
|
|
|
69
69
|
### 2. Interactive CLI (no positional arg):
|
|
70
|
-
./
|
|
70
|
+
./agents/${name}.js [--options]
|
|
71
71
|
|
|
72
72
|
### 3. WS Server (no positional arg):
|
|
73
|
-
./
|
|
73
|
+
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
74
74
|
|
|
75
75
|
### 4. WS Client (no positional arg):
|
|
76
|
-
./
|
|
76
|
+
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
77
77
|
|
|
78
78
|
### 5. Hybrid (Server + Client, no positional arg):
|
|
79
|
-
./
|
|
79
|
+
./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
80
80
|
|
|
81
81
|
## SERVER OPTIONS EXPLAINED:
|
|
82
82
|
--serve [port]: Starts WebSocket SERVER at ws://127.0.0.1:[port]/ws. Allows other agents (--connect) to connect and use this agent as a remote TOOL. Runs indefinitely until Ctrl+C.
|
|
@@ -56,19 +56,19 @@ function printHelp() {
|
|
|
56
56
|
## USAGE MODES:
|
|
57
57
|
|
|
58
58
|
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
59
|
-
./
|
|
59
|
+
./agents/${name}.js "Recall tasks" [--options]
|
|
60
60
|
|
|
61
61
|
### 2. Interactive CLI (no positional arg):
|
|
62
|
-
./
|
|
62
|
+
./agents/${name}.js [--options]
|
|
63
63
|
|
|
64
64
|
### 3. WS Server (no positional arg):
|
|
65
|
-
./
|
|
65
|
+
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
66
66
|
|
|
67
67
|
### 4. WS Client (no positional arg):
|
|
68
|
-
./
|
|
68
|
+
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
69
69
|
|
|
70
70
|
### 5. Hybrid (Server + Client, no positional arg):
|
|
71
|
-
./
|
|
71
|
+
./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
72
72
|
|
|
73
73
|
## SERVER OPTIONS EXPLAINED:
|
|
74
74
|
--serve [port]: Starts WebSocket SERVER at ws://127.0.0.1:[port]/ws. Allows other agents (--connect) to connect and use this agent as a remote TOOL (e.g., 'memory_agent'). Runs indefinitely until Ctrl+C.
|
|
@@ -55,19 +55,19 @@ function printHelp() {
|
|
|
55
55
|
## USAGE MODES:
|
|
56
56
|
|
|
57
57
|
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
58
|
-
./
|
|
58
|
+
./agents/${name}.js "What modules are installed?" [--options]
|
|
59
59
|
|
|
60
60
|
### 2. Interactive CLI (no positional arg):
|
|
61
|
-
./
|
|
61
|
+
./agents/${name}.js [--options]
|
|
62
62
|
|
|
63
63
|
### 3. WS Server (no positional arg):
|
|
64
|
-
./
|
|
64
|
+
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
65
65
|
|
|
66
66
|
### 4. WS Client (no positional arg):
|
|
67
|
-
./
|
|
67
|
+
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
68
68
|
|
|
69
69
|
### 5. Hybrid (Server + Client, no positional arg):
|
|
70
|
-
./
|
|
70
|
+
./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
71
71
|
|
|
72
72
|
## SERVER OPTIONS EXPLAINED:
|
|
73
73
|
--serve [port]: Starts WebSocket SERVER at ws://127.0.0.1:[port]/ws. Allows other agents (--connect) to connect and use this agent as a remote TOOL (e.g., 'npm_module_inspector'). Runs indefinitely until Ctrl+C.
|
|
@@ -54,19 +54,19 @@ function printHelp() {
|
|
|
54
54
|
## USAGE MODES:
|
|
55
55
|
|
|
56
56
|
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
57
|
-
./
|
|
57
|
+
./agents/${name}.js "Optimize this prompt: [prompt]" [--options]
|
|
58
58
|
|
|
59
59
|
### 2. Interactive CLI (no positional arg):
|
|
60
|
-
./
|
|
60
|
+
./agents/${name}.js [--options]
|
|
61
61
|
|
|
62
62
|
### 3. WS Server (no positional arg):
|
|
63
|
-
./
|
|
63
|
+
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
64
64
|
|
|
65
65
|
### 4. WS Client (no positional arg):
|
|
66
|
-
./
|
|
66
|
+
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
67
67
|
|
|
68
68
|
### 5. Hybrid (Server + Client, no positional arg):
|
|
69
|
-
./
|
|
69
|
+
./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
70
70
|
|
|
71
71
|
## SERVER OPTIONS EXPLAINED:
|
|
72
72
|
--serve [port]: Starts WebSocket SERVER at ws://127.0.0.1:[port]/ws. Allows other agents (--connect) to connect and use this agent as a remote TOOL (e.g., 'prompt_agent'). Runs indefinitely until Ctrl+C.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { AgentManager } from '@j-o-r/hello-dave';
|
|
3
|
+
import { parseArgs } from '@j-o-r/sh';
|
|
4
|
+
import fs from 'fs'; // Added for local fallback
|
|
5
|
+
|
|
6
|
+
const name = 'spawn_agent';
|
|
7
|
+
const api = 'xai';
|
|
8
|
+
let secret = '';
|
|
9
|
+
|
|
10
|
+
const args = parseArgs();
|
|
11
|
+
|
|
12
|
+
let input;
|
|
13
|
+
if (args._.length === 1 && typeof args._[0] === 'string' && args._[0].trim() !== '') {
|
|
14
|
+
input = args._[0].trim();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const help = args['help'] || false;
|
|
18
|
+
const connect = args['connect'] ? args['connect'] : undefined;
|
|
19
|
+
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
20
|
+
|
|
21
|
+
const options = { tools: [] };
|
|
22
|
+
options.tools.push({ type: 'web_search' });
|
|
23
|
+
|
|
24
|
+
if (args['secret']) {
|
|
25
|
+
secret = args['secret'];
|
|
26
|
+
}
|
|
27
|
+
if (args['model'] || true) {
|
|
28
|
+
options.model = args['model'] || 'grok-4-fast-reasoning';
|
|
29
|
+
}
|
|
30
|
+
if (args['temperature']) {
|
|
31
|
+
options.temperature = parseFloat(args['temperature']);
|
|
32
|
+
}
|
|
33
|
+
if (args['tokens']) {
|
|
34
|
+
options.max_output_tokens = parseInt(args['tokens']);
|
|
35
|
+
}
|
|
36
|
+
if (args['top_p']) {
|
|
37
|
+
options.top_p = parseFloat(args['top_p']);
|
|
38
|
+
}
|
|
39
|
+
if (true) {
|
|
40
|
+
options.reasoning = { effort: 'medium', summary: 'auto' };
|
|
41
|
+
}
|
|
42
|
+
const toolsetMode = 'auto';
|
|
43
|
+
const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
|
|
44
|
+
|
|
45
|
+
function printHelp() {
|
|
46
|
+
console.log(`'${name} --help' You are looking at it.
|
|
47
|
+
|
|
48
|
+
## USAGE MODES:
|
|
49
|
+
|
|
50
|
+
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
51
|
+
./${name}.js "Create a code agent" [--options]
|
|
52
|
+
|
|
53
|
+
### 2. Interactive CLI (no positional arg):
|
|
54
|
+
./${name}.js [--options]
|
|
55
|
+
|
|
56
|
+
### 3. WS Server (no positional arg):
|
|
57
|
+
./${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
58
|
+
|
|
59
|
+
### 4. WS Client (no positional arg):
|
|
60
|
+
./${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
61
|
+
|
|
62
|
+
### 5. Hybrid (Server + Client, no positional arg):
|
|
63
|
+
./${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
64
|
+
|
|
65
|
+
## PORTABILITY NOTES:
|
|
66
|
+
- **Tools follow YOUR CWD** (e.g., cd /tmp/proj && ./spawn_agent.js → tools in /tmp/proj).
|
|
67
|
+
- **Hybrid Modes**: PROJECT (agents/*.js exist): Auto-deploy/test. FRESH (empty agents/): Code + manual bash.
|
|
68
|
+
- **Custom Tools**: natives=web_search, generics=read_file, custom={type:'git_diff',...}
|
|
69
|
+
|
|
70
|
+
## OPTIONS:
|
|
71
|
+
--model [grok-4-fast-reasoning|...] (default: grok-4-fast-reasoning)
|
|
72
|
+
--temperature [float] (0.8)
|
|
73
|
+
--tokens [number]
|
|
74
|
+
--top_p [float]
|
|
75
|
+
--context [number] (250k)
|
|
76
|
+
|
|
77
|
+
## Examples:
|
|
78
|
+
"Create coderev: desc=Git analyzer, natives=web_search, generics=read_file execute_bash_script, custom=options.tools.push({type:'git_diff',description:'...',parameters:{...}})"
|
|
79
|
+
`);
|
|
80
|
+
process.exit();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (help) {
|
|
84
|
+
printHelp();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const tool_call_name = 'spawn_agent';
|
|
88
|
+
const tool_call_description = `Portable creator for CLI/WS agents + PM2 launchers. Tools use exec CWD (/tmp OK). PROJECT (agents/*.js >0): Full auto. FRESH: Manual code/bash.
|
|
89
|
+
|
|
90
|
+
Test new agent: ./agents/NEW.js --help | 'describe' | --serve 8081 --secret abc
|
|
91
|
+
|
|
92
|
+
Custom ex: natives=[{type:'mytool'}], generics=read_file
|
|
93
|
+
|
|
94
|
+
Live prompt: https://codeberg.org/duin/hello-dave/raw/branch/main/docs/prompt/spawn_agent.md`.trim();
|
|
95
|
+
|
|
96
|
+
const REPO_URL = 'https://codeberg.org/duin/hello-dave';
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
async function fetchLivePrompt() {
|
|
100
|
+
// Priority 1: Remote
|
|
101
|
+
const promptUrl = `${REPO_URL}/raw/branch/main/docs/prompt/spawn_agent.md`;
|
|
102
|
+
const response = await fetch(promptUrl);
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
throw new Error(`HTTP ${response.status}`);
|
|
105
|
+
}
|
|
106
|
+
return await response.text();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const agent = new AgentManager({ name, secret });
|
|
110
|
+
|
|
111
|
+
const prompt = await fetchLivePrompt();
|
|
112
|
+
|
|
113
|
+
agent.setup({
|
|
114
|
+
prompt,
|
|
115
|
+
api,
|
|
116
|
+
options,
|
|
117
|
+
toolsetMode,
|
|
118
|
+
contextWindow
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
agent.addGenericToolcall('execute_bash_script');
|
|
122
|
+
agent.addGenericToolcall('read_file');
|
|
123
|
+
agent.addGenericToolcall('write_file');
|
|
124
|
+
agent.addGenericToolcall('javascript_interpreter');
|
|
125
|
+
|
|
126
|
+
const cliIntro = `🤖 ${name} (${options.model}) ready! (context: ${contextWindow})
|
|
127
|
+
|
|
128
|
+
Portable Creator: PROJECT (agents/*.js exist): Auto. FRESH (empty): Manual code.
|
|
129
|
+
|
|
130
|
+
Ex: "Create testagent: desc=Tester, natives=web_search"`.trim();
|
|
131
|
+
|
|
132
|
+
if (input) {
|
|
133
|
+
const RES = await agent.directCall(input);
|
|
134
|
+
console.log(RES);
|
|
135
|
+
} else {
|
|
136
|
+
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|
|
137
|
+
}
|
|
@@ -55,19 +55,19 @@ function printHelp() {
|
|
|
55
55
|
## USAGE MODES:
|
|
56
56
|
|
|
57
57
|
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
58
|
-
./
|
|
58
|
+
./agents/${name}.js "Generate test for toolset.js" [--options]
|
|
59
59
|
|
|
60
60
|
### 2. Interactive CLI (no positional arg):
|
|
61
|
-
./
|
|
61
|
+
./agents/${name}.js [--options]
|
|
62
62
|
|
|
63
63
|
### 3. WS Server (no positional arg):
|
|
64
|
-
./
|
|
64
|
+
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
65
65
|
|
|
66
66
|
### 4. WS Client (no positional arg):
|
|
67
|
-
./
|
|
67
|
+
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
68
68
|
|
|
69
69
|
### 5. Hybrid (Server + Client, no positional arg):
|
|
70
|
-
./
|
|
70
|
+
./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
71
71
|
|
|
72
72
|
## SERVER OPTIONS EXPLAINED:
|
|
73
73
|
--serve [port]: Starts WebSocket SERVER at ws://127.0.0.1:[port]/ws. Allows other agents (--connect) to connect and use this agent as a remote TOOL (e.g., 'test_agent'). Runs indefinitely until Ctrl+C.
|
|
@@ -108,7 +108,7 @@ const prompt = `You are TestAgent, the specialized testing agent for CodeServer
|
|
|
108
108
|
- Tests must use: \`import { Test, assert, jsType } from '@j-o-r/sh';\`
|
|
109
109
|
- Structure: shebang \`#!/usr/bin/env node\`, fluent Test API (\`const t = new Test(); t.add('desc', () => { assert... }); await t.run();\`), exit(1) on errors.
|
|
110
110
|
- After write_file to scenarios/MODULE.test.js, ensure executable: \`chmod +x scenarios/MODULE.test.js\`
|
|
111
|
-
- Leverage project utilities: test existing files (
|
|
111
|
+
- Leverage project utilities: test existing files (agents/*.js, toolset.js, agents, SH commands, etc.) using read_file, execute_bash_script (ls/cat), npm_module_inspector.
|
|
112
112
|
|
|
113
113
|
**WHAT TO TEST** (discover dynamically):
|
|
114
114
|
1. Project scripts: e.g., parseArgs, AgentManager flows, toolsets.
|
|
@@ -55,19 +55,19 @@ function printHelp() {
|
|
|
55
55
|
## USAGE MODES:
|
|
56
56
|
|
|
57
57
|
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
58
|
-
./
|
|
58
|
+
./agents/${name}.js "List tasks" [--options]
|
|
59
59
|
|
|
60
60
|
### 2. Interactive CLI (no positional arg):
|
|
61
|
-
./
|
|
61
|
+
./agents/${name}.js [--options]
|
|
62
62
|
|
|
63
63
|
### 3. WS Server (no positional arg):
|
|
64
|
-
./
|
|
64
|
+
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
65
65
|
|
|
66
66
|
### 4. WS Client (no positional arg):
|
|
67
|
-
./
|
|
67
|
+
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
68
68
|
|
|
69
69
|
### 5. Hybrid (Server + Client, no positional arg):
|
|
70
|
-
./
|
|
70
|
+
./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
71
71
|
|
|
72
72
|
## SERVER OPTIONS EXPLAINED:
|
|
73
73
|
--serve [port]: Starts WebSocket SERVER at ws://127.0.0.1:[port]/ws. Allows other agents (--connect) to connect and use this agent as a remote TOOL (e.g., 'todo_agent'). Runs indefinitely until Ctrl+C.
|
package/bin/codeDave
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
|
|
3
|
+
echo "Usage: $0 <PORT> [SECRET] # PORT: 1024-65535, SECRET: optional (defaults to '123')"
|
|
4
|
+
exit 1
|
|
5
|
+
fi
|
|
6
|
+
|
|
7
|
+
PORT="$1"
|
|
8
|
+
SECRET="${2:-123}"
|
|
9
|
+
|
|
10
|
+
if [ -z "$SECRET" ] || [ ${#SECRET} -lt 3 ]; then
|
|
11
|
+
echo "Error: SECRET must be at least 3 characters: '$SECRET'"
|
|
12
|
+
exit 1
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
if ! [[ "$PORT" =~ ^[0-9]+$ ]] || [ "$PORT" -lt 1024 ] || [ "$PORT" -gt 65535 ]; then
|
|
16
|
+
echo "Error: Invalid port number: $PORT. Must be between 1024 and 65535."
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# Compute canonical paths relative to THIS script's real location (resolves symlinks for global npm installs)
|
|
21
|
+
SOURCE="${BASH_SOURCE[0]}"
|
|
22
|
+
while [ -h "$SOURCE" ]; do
|
|
23
|
+
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
24
|
+
SOURCE="$(readlink "$SOURCE")"
|
|
25
|
+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
|
|
26
|
+
done
|
|
27
|
+
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
28
|
+
PROJECT_DIR="$( cd -P "$( dirname "$SCRIPT_DIR" )" >/dev/null 2>&1 && pwd )"
|
|
29
|
+
|
|
30
|
+
# FOLDER: basename of CURRENT WORKING DIRECTORY (pwd) for per-project PM2 prefixes (e.g., myproject_code_8080)
|
|
31
|
+
# This allows multi-project usage without name conflicts; PROJECT_DIR remains package location for agents/
|
|
32
|
+
FOLDER=$(basename "$(pwd)")
|
|
33
|
+
|
|
34
|
+
echo "Starting codeDave on port ${PORT} in folder '${FOLDER}' (SCRIPT_DIR: ${SCRIPT_DIR}) with SECRET '${SECRET}'..."
|
|
35
|
+
|
|
36
|
+
# Delete existing processes with folder_port suffix
|
|
37
|
+
pm2 delete "${FOLDER}_code_${PORT}" 2>/dev/null || true
|
|
38
|
+
pm2 delete "${FOLDER}_todo_${PORT}" 2>/dev/null || true
|
|
39
|
+
pm2 delete "${FOLDER}_readme_${PORT}" 2>/dev/null || true
|
|
40
|
+
pm2 delete "${FOLDER}_npm_${PORT}" 2>/dev/null || true
|
|
41
|
+
pm2 delete "${FOLDER}_docs_${PORT}" 2>/dev/null || true
|
|
42
|
+
pm2 delete "${FOLDER}_test_${PORT}" 2>/dev/null || true
|
|
43
|
+
pm2 delete "${FOLDER}_memory_${PORT}" 2>/dev/null || true
|
|
44
|
+
pm2 delete "${FOLDER}_spawn_${PORT}" 2>/dev/null || true
|
|
45
|
+
|
|
46
|
+
# Spawn main Agent / server (absolute paths to scripts)
|
|
47
|
+
pm2 start "${PROJECT_DIR}/agents/code_agent.js" --name "${FOLDER}_code_${PORT}" -- --serve "${PORT}" --tools javascript --secret "${SECRET}"
|
|
48
|
+
# Attach clients
|
|
49
|
+
pm2 start "${PROJECT_DIR}/agents/todo_agent.js" --name "${FOLDER}_todo_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
|
|
50
|
+
pm2 start "${PROJECT_DIR}/agents/readme_agent.js" --name "${FOLDER}_readme_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
|
|
51
|
+
pm2 start "${PROJECT_DIR}/agents/npm_agent.js" --name "${FOLDER}_npm_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
|
|
52
|
+
pm2 start "${PROJECT_DIR}/agents/docs_agent.js" --name "${FOLDER}_docs_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
|
|
53
|
+
pm2 start "${PROJECT_DIR}/agents/test_agent.js" --name "${FOLDER}_test_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
|
|
54
|
+
pm2 start "${PROJECT_DIR}/agents/memory_agent.js" --name "${FOLDER}_memory_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
|
|
55
|
+
pm2 start "${PROJECT_DIR}/agents/spawn_agent.js" --name "${FOLDER}_spawn_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
|
|
56
|
+
|
|
57
|
+
echo "codeDave processes spawned with prefix '${FOLDER}_' and suffix _${PORT}. Check with: pm2 list | grep '${FOLDER}_${PORT}'"
|
|
58
|
+
echo "dave --connect ws://127.0.0.1:${PORT}/ws --secret '$SECRET'"
|
package/bin/dave.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env -S node
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import cli from '@j-o-r/cli';
|
|
4
|
-
import wsCli from '
|
|
5
|
-
import wsIO from '../lib/wsIO.js';
|
|
6
|
-
import { AgentManager } from '@j-o-r/hello-dave';
|
|
4
|
+
import { AgentManager, wsCli, wsIO } from '@j-o-r/hello-dave';
|
|
7
5
|
import { SH, parseArgs, readIn, bashEscape } from '@j-o-r/sh';
|
|
8
6
|
import { fileURLToPath } from 'node:url';
|
|
9
7
|
|
|
@@ -31,7 +29,7 @@ FLAGS:
|
|
|
31
29
|
Remote: bin/dave.js --ask --connect 'ws://localhost:8080' --secret '123'
|
|
32
30
|
Piped local: echo "predict the weather" | bin/dave.js --ask
|
|
33
31
|
Piped remote: echo "predict the weather" | bin/dave.js --ask --connect 'ws://...' --secret '123'
|
|
34
|
-
--code [port] [--secret "..."] : Launch CodeServer PM2 cluster via
|
|
32
|
+
--code [port] [--secret "..."] : Launch CodeServer PM2 cluster via agents/codeserver.sh
|
|
35
33
|
Usage: bin/dave.js --code 8080 --secret 123
|
|
36
34
|
`);
|
|
37
35
|
process.exit(exitCode)
|
|
@@ -193,4 +191,4 @@ ${name} (${options.model}).
|
|
|
193
191
|
const RES = await SH`${server} ${port} ${bashEscape(secret)}`.run();
|
|
194
192
|
console.log(RES);
|
|
195
193
|
process.exit(0);
|
|
196
|
-
}
|
|
194
|
+
}
|