@j-o-r/hello-dave 0.0.3 → 0.0.4
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 +21 -0
- package/README.md +216 -56
- package/README.md.bak +481 -0
- package/README.md.bak.1774780058 +338 -0
- package/README.md.bak2 +455 -0
- package/docs.bak.1774780058/agent-manager.md +167 -0
- package/docs.bak.1774780058/agent-manager.md.bak +137 -0
- package/docs.bak.1774780058/agent-manager.md.bak2 +157 -0
- package/docs.bak.1774780058/codeserver-pattern.md +191 -0
- package/docs.bak.1774780058/path-resolution-best-practices.md +104 -0
- package/docs.bak.1774780058/project-overview.md +67 -0
- package/docs.bak.1774780058/project-overview.md.bak +67 -0
- package/docs.bak.1774780058/prompt-class.md +141 -0
- package/docs.bak.1774780058/prompt-class.md.bak +142 -0
- package/docs.bak.1774780058/tools-syntax-validation.md +121 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +125 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +125 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +106 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +106 -0
- package/docs.bak.1774780058/toolset.md +164 -0
- package/docs.bak.1774780058/toolset.md.bak +94 -0
- package/docs.bak.1774780058/toolset.md.bak3 +161 -0
- package/docs.bak.1774780058/toolset.md.bak4 +161 -0
- package/docs.bak.1774780058/toolset.md.bak5 +161 -0
- package/docs.bak.1774780058/toolset.md.bak6 +163 -0
- package/docs.bak.1774780058/toolset.md.bak_path +163 -0
- package/docs.bak.1774780058/toolset.md.bak_syntax +161 -0
- package/docs.bak.1774780058/xai-responses.md +111 -0
- package/docs.bak.1774780058/xai-responses.md.bak +107 -0
- package/docs.bak.1774780058/xai-responses.md.bak2 +107 -0
- package/docs.bak.1774780058/xai_collections.md +106 -0
- package/examples/ask_agent.js +137 -0
- package/examples/code_agent.js +149 -0
- package/examples/coderev_agent.js +136 -0
- package/examples/codeserver.sh +47 -0
- package/examples/daisy_agent.js +170 -0
- package/examples/docs_agent.js +148 -0
- package/examples/gpt_agent.js +125 -0
- package/examples/grok_agent.js +132 -0
- package/examples/grok_agent.js.bak +98 -0
- package/examples/grok_agent.js.bak.2 +99 -0
- package/examples/grok_agent.js.bak.3 +1 -0
- package/examples/grok_agent.js.bak.4 +124 -0
- package/examples/grok_agent.js.bak.5 +1 -0
- package/examples/grok_agent.js.bak.6 +1 -0
- package/examples/memory_agent.js +152 -0
- package/examples/npm_agent.js +202 -0
- package/examples/npm_agent.js.bak.3 +2 -0
- package/examples/npm_agent.js.bak.4 +205 -0
- package/examples/npm_agent.js.bak.5 +1 -0
- package/examples/npm_agent.js.bak.6 +1 -0
- package/examples/prompt_agent.js +133 -0
- package/examples/readme_agent.js +148 -0
- package/examples/spawn_agent.js +293 -0
- package/examples/test_agent.js +187 -0
- package/examples/todo_agent.js +175 -0
- package/{examples/codeDave.js → examples.bak.1774780058/code_agent.js} +40 -6
- package/{examples/CodeServer → examples.bak.1774780058/codeserver.sh} +9 -5
- package/examples.bak.1774780058/memory_agent.js +112 -0
- package/{examples/spawndave.js → examples.bak.1774780058/spawn_agent.js} +29 -6
- package/examples.bak.1774780058/test_agent.js +162 -0
- package/{examples/todoDave.js → examples.bak.1774780058/todo_agent.js} +8 -2
- package/lib/API/x.ai/responses.js +7 -9
- package/lib/AgentManager.js +3 -2
- package/lib/AgentServer.js +23 -19
- package/lib/genericToolset.js +159 -26
- package/lib/genericToolset.js.bak_syntax +402 -0
- package/lib/wsCli.js +0 -1
- package/package.json +4 -5
- package/scenarios.bak.1774780058/data/eval_node_message.json +9 -0
- package/scenarios.bak.1774780058/data/hist_oa.json +66 -0
- package/scenarios.bak.1774780058/data/o3_response1.json +96 -0
- package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +112 -0
- package/scenarios.bak.1774780058/data/tool_oa.json +96 -0
- package/scenarios.bak.1774780058/data/tool_xai.json +59 -0
- package/scenarios.bak.1774780058/data/tool_xai2.json +40 -0
- package/scenarios.bak.1774780058/data/xai-response-1.json +59 -0
- package/scenarios.bak.1774780058/data/xai-response-2.json +10 -0
- package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +59 -0
- package/scenarios.bak.1774780058/data/xai_search_response.json +58 -0
- package/scenarios.bak.1774780058/environment.js +10 -0
- package/scenarios.bak.1774780058/example.js +17 -0
- package/scenarios.bak.1774780058/genericToolset.test.js +182 -0
- package/scenarios.bak.1774780058/grok.js +113 -0
- package/scenarios.bak.1774780058/memory-tools.js +51 -0
- package/scenarios.bak.1774780058/openai-o3.js +137 -0
- package/scenarios.bak.1774780058/openai-prompt.js +155 -0
- package/scenarios.bak.1774780058/openai-session.js +148 -0
- package/scenarios.bak.1774780058/openai.js +102 -0
- package/scenarios.bak.1774780058/prompt.js +118 -0
- package/scenarios.bak.1774780058/promptFishbowl.js +76 -0
- package/scenarios.bak.1774780058/search.brave.com.js +25 -0
- package/scenarios.bak.1774780058/sh.js +15 -0
- package/scenarios.bak.1774780058/test-wsio.js +26 -0
- package/scenarios.bak.1774780058/testToolset.js +42 -0
- package/scenarios.bak.1774780058/toolset.js +16 -0
- package/scenarios.bak.1774780058/toolset.test.js +141 -0
- package/scenarios.bak.1774780058/write_file_syntax.test.js +145 -0
- package/scenarios.bak.1774780058/write_file_validation/README.md +30 -0
- package/scenarios.bak.1774780058/write_file_validation/bad.js +3 -0
- package/scenarios.bak.1774780058/write_file_validation/good.js +4 -0
- package/scenarios.bak.1774780058/write_file_validation/test.sh +43 -0
- package/scenarios.bak.1774780058/wsClient.js +69 -0
- package/scenarios.bak.1774780058/xai_responses.integration.test.js +57 -0
- package/scenarios.bak.1774780058/xai_responses.test.js +154 -0
- package/scenarios.bak.1774780058/xaicoll.js +50 -0
- package/scenarios.bak.1774780058/xaifiles.js +48 -0
- package/types/AgentManager.d.ts +4 -3
- package/utils/syntax_check.sh +61 -0
- package/utils/test.sh +46 -0
- /package/{examples/askDave.js → examples.bak.1774780058/ask_agent.js} +0 -0
- /package/{examples/coderev.js → examples.bak.1774780058/coderev_agent.js} +0 -0
- /package/{examples/daisy.js → examples.bak.1774780058/daisy_agent.js} +0 -0
- /package/{examples/docsDave.js → examples.bak.1774780058/docs_agent.js} +0 -0
- /package/{examples/gpt.js → examples.bak.1774780058/gpt_agent.js} +0 -0
- /package/{examples/grok.js → examples.bak.1774780058/grok_agent.js} +0 -0
- /package/{examples/npmDave.js → examples.bak.1774780058/npm_agent.js} +0 -0
- /package/{examples/promptDave.js → examples.bak.1774780058/prompt_agent.js} +0 -0
- /package/{examples/readmeDave.js → examples.bak.1774780058/readme_agent.js} +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { AgentManager } from '@j-o-r/hello-dave';
|
|
3
|
+
import { parseArgs } from '@j-o-r/sh';
|
|
4
|
+
|
|
5
|
+
const name = 'daisy_agent';
|
|
6
|
+
const api = 'xai';
|
|
7
|
+
let secret = '';
|
|
8
|
+
|
|
9
|
+
const args = parseArgs();
|
|
10
|
+
|
|
11
|
+
let input;
|
|
12
|
+
if (args._.length === 1 && typeof args._[0] === 'string' && args._[0].trim() !== '') {
|
|
13
|
+
input = args._[0].trim();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const help = args['help'] || false;
|
|
17
|
+
const connect = args['connect'] ? args['connect'] : undefined;
|
|
18
|
+
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
19
|
+
|
|
20
|
+
/** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
|
|
21
|
+
const options = { tools: [] };
|
|
22
|
+
options.tools.push({
|
|
23
|
+
type: 'web_search'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (args['secret']) {
|
|
27
|
+
secret = args['secret'];
|
|
28
|
+
}
|
|
29
|
+
if (args['model'] || true) {
|
|
30
|
+
options.model = args['model'] || 'grok-4-fast-reasoning';
|
|
31
|
+
}
|
|
32
|
+
if (args['temperature']) {
|
|
33
|
+
options.temperature = parseFloat(args['temperature']);
|
|
34
|
+
} else {
|
|
35
|
+
options.temperature = 0.8;
|
|
36
|
+
}
|
|
37
|
+
if (args['tokens']) {
|
|
38
|
+
options.max_output_tokens = parseInt(args['tokens']);
|
|
39
|
+
}
|
|
40
|
+
if (args['top_p']) {
|
|
41
|
+
options.top_p = parseFloat(args['top_p']);
|
|
42
|
+
}
|
|
43
|
+
const reasoning = true;
|
|
44
|
+
if (reasoning) {
|
|
45
|
+
options.reasoning = {
|
|
46
|
+
effort: 'medium',
|
|
47
|
+
summary: 'auto'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const toolsetMode = 'auto';
|
|
51
|
+
const contextWindow = args['context'] ? parseInt(args['context']) : 1900000;
|
|
52
|
+
|
|
53
|
+
function printHelp() {
|
|
54
|
+
console.log(`
|
|
55
|
+
'${name} --help' You are looking at it.
|
|
56
|
+
|
|
57
|
+
## USAGE MODES:
|
|
58
|
+
|
|
59
|
+
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
60
|
+
./examples/${name}.js "Generate lyrics for pop song" [--options]
|
|
61
|
+
|
|
62
|
+
### 2. Interactive CLI (no positional arg):
|
|
63
|
+
./examples/${name}.js [--options]
|
|
64
|
+
|
|
65
|
+
### 3. WS Server (no positional arg):
|
|
66
|
+
./examples/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
67
|
+
|
|
68
|
+
### 4. WS Client (no positional arg):
|
|
69
|
+
./examples/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
70
|
+
|
|
71
|
+
### 5. Hybrid (Server + Client, no positional arg):
|
|
72
|
+
./examples/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
73
|
+
|
|
74
|
+
## SERVER OPTIONS EXPLAINED:
|
|
75
|
+
--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., 'daisy_agent'). Runs indefinitely until Ctrl+C.
|
|
76
|
+
|
|
77
|
+
--connect [ws_url]: Connects as CLIENT to remote WS server at [ws_url] (e.g., ws://127.0.0.1:8080/ws). Gains access to remote agent's tools. Interactive CLI available.
|
|
78
|
+
|
|
79
|
+
--secret [string]: SHARED AUTH TOKEN (min 3 chars). SERVER rejects clients without matching --secret. CLIENTS must provide server's secret to connect. Use same secret for chains.
|
|
80
|
+
|
|
81
|
+
Note: Server/Client/Hybrid IGNORES positional input arg (use CLI modes instead). Hybrid: This agent serves AND uses remote tools.
|
|
82
|
+
|
|
83
|
+
## OPTIONS:
|
|
84
|
+
--model [grok-4-fast-reasoning|...] (default: grok-4-fast-reasoning)
|
|
85
|
+
--temperature [float] (-2 to +2, default 0.8 for creativity)
|
|
86
|
+
--tokens [number] (max output tokens)
|
|
87
|
+
--top_p [float]
|
|
88
|
+
--context [number] (default: 1900000)
|
|
89
|
+
|
|
90
|
+
## SERVER TOOLS (when no input):
|
|
91
|
+
Exposes as 'daisy_agent' tool for chaining.
|
|
92
|
+
`);
|
|
93
|
+
process.exit();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (help) {
|
|
97
|
+
printHelp();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const tool_call_name = 'daisy_agent';
|
|
101
|
+
const tool_call_description = `
|
|
102
|
+
Daisy Music Assistant:
|
|
103
|
+
- "Lyrics for [theme]" → Generate lyrics.
|
|
104
|
+
- "Suno prompt: [style]" → Optimized Suno prompt.
|
|
105
|
+
- "ffmpeg [task] on file.wav" → Bash script to run.
|
|
106
|
+
- web_search: Research chords/lyrics.
|
|
107
|
+
- execute_bash_script: Processes your local files safely.
|
|
108
|
+
`.trim();
|
|
109
|
+
|
|
110
|
+
const prompt = `
|
|
111
|
+
You are ${name}, a helpful music creation and editing assistant for the user's computer.
|
|
112
|
+
|
|
113
|
+
Core expertise:
|
|
114
|
+
- Generate lyrics: Creative, structured (verses, chorus), themed, rhyming.
|
|
115
|
+
- Suno AI prompts: Detailed, vivid descriptions (genre, mood, instruments, structure, vocals).
|
|
116
|
+
- Local audio editing: Use execute_bash_script with ffmpeg/sox commands. Provide exact bash snippets first, confirm before running. Examples:
|
|
117
|
+
* Trim: ffmpeg -i input.mp3 -ss 00:00:30 -t 00:01:00 output.mp3
|
|
118
|
+
* Concat: echo "file 'a.mp3'" > list.txt; ffmpeg -f concat -i list.txt out.mp3
|
|
119
|
+
* Sox effects: sox input.wav output.wav fade 0 3 2 norm
|
|
120
|
+
* Convert: ffmpeg -i video.mp4 audio.aac
|
|
121
|
+
- Music theory: Chords, scales, BPM, EQ tips.
|
|
122
|
+
- Workflows: Step-by-step for mixing, mastering, layering tracks.
|
|
123
|
+
|
|
124
|
+
Behavior:
|
|
125
|
+
- Be creative & enthusiastic!
|
|
126
|
+
- Step-by-step: Explain, provide code, suggest files in current dir.
|
|
127
|
+
- Safety: Quote bash commands; ask confirmation for destructive ops (e.g., overwrite).
|
|
128
|
+
- Use web_search for inspiration/lyrics if needed.
|
|
129
|
+
- Output ready-to-copy bash for ffmpeg/sox.
|
|
130
|
+
- List files if unclear: Use ls *.wav *.mp3 etc. via bash.
|
|
131
|
+
|
|
132
|
+
Current env: Ubuntu, ffmpeg & sox installed, cwd: /home/jd/devpri/js/hello-dave
|
|
133
|
+
|
|
134
|
+
Respond concisely but completely. Use markdown for code/lyrics/prompts.
|
|
135
|
+
`.trim();
|
|
136
|
+
|
|
137
|
+
const agent = new AgentManager({ name, secret });
|
|
138
|
+
agent.setup({
|
|
139
|
+
prompt,
|
|
140
|
+
api,
|
|
141
|
+
options,
|
|
142
|
+
toolsetMode,
|
|
143
|
+
contextWindow
|
|
144
|
+
});
|
|
145
|
+
const toolset = agent.getToolset();
|
|
146
|
+
if (toolset) {
|
|
147
|
+
agent.addGenericToolcall('open_link');
|
|
148
|
+
agent.addGenericToolcall('send_email');
|
|
149
|
+
agent.addGenericToolcall('execute_bash_script');
|
|
150
|
+
agent.addGenericToolcall('read_file');
|
|
151
|
+
agent.addGenericToolcall('write_file');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const cliIntro = `
|
|
155
|
+
${name} ${options.model} ready! (temp: ${options.temperature}, context: ${contextWindow})
|
|
156
|
+
|
|
157
|
+
Ask me to:
|
|
158
|
+
- Write lyrics
|
|
159
|
+
- Craft Suno prompts
|
|
160
|
+
- Edit audio: "fade out my track.mp3" → I'll give ffmpeg cmd
|
|
161
|
+
Type /help for more.
|
|
162
|
+
${tool_call_name}
|
|
163
|
+
`.trim();
|
|
164
|
+
|
|
165
|
+
if (input) {
|
|
166
|
+
const RES = await agent.directCall(input);
|
|
167
|
+
console.log(RES);
|
|
168
|
+
} else {
|
|
169
|
+
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|
|
170
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { AgentManager } from '@j-o-r/hello-dave';
|
|
3
|
+
import { parseArgs } from '@j-o-r/sh';
|
|
4
|
+
|
|
5
|
+
const name = 'docs_agent';
|
|
6
|
+
const api = 'xai';
|
|
7
|
+
let secret = '';
|
|
8
|
+
|
|
9
|
+
const args = parseArgs();
|
|
10
|
+
|
|
11
|
+
let input;
|
|
12
|
+
if (args._.length === 1 && typeof args._[0] === 'string' && args._[0].trim() !== '') {
|
|
13
|
+
input = args._[0].trim();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const help = args['help'] || false;
|
|
17
|
+
const connect = args['connect'] ? args['connect'] : undefined;
|
|
18
|
+
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
19
|
+
|
|
20
|
+
const options = { tools: [] };
|
|
21
|
+
options.tools.push({
|
|
22
|
+
type: 'web_search'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (args['secret']) {
|
|
26
|
+
secret = args['secret'];
|
|
27
|
+
}
|
|
28
|
+
if (args['model'] || true) {
|
|
29
|
+
options.model = args['model'] || 'grok-4-fast-reasoning';
|
|
30
|
+
}
|
|
31
|
+
if (args['temperature']) {
|
|
32
|
+
options.temperature = parseFloat(args['temperature']);
|
|
33
|
+
}
|
|
34
|
+
if (args['tokens']) {
|
|
35
|
+
options.max_output_tokens = parseInt(args['tokens']);
|
|
36
|
+
}
|
|
37
|
+
if (args['top_p']) {
|
|
38
|
+
options.top_p = parseFloat(args['top_p']);
|
|
39
|
+
}
|
|
40
|
+
const reasoning = true;
|
|
41
|
+
if (reasoning) {
|
|
42
|
+
options.reasoning = {
|
|
43
|
+
effort: 'medium',
|
|
44
|
+
summary: 'auto'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const toolsetMode = 'auto';
|
|
48
|
+
const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
|
|
49
|
+
|
|
50
|
+
function printHelp() {
|
|
51
|
+
console.log(`
|
|
52
|
+
'${name} --help' You are looking at it.
|
|
53
|
+
|
|
54
|
+
## USAGE MODES:
|
|
55
|
+
|
|
56
|
+
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
57
|
+
./examples/${name}.js "Create a doc on Node.js basics" [--options]
|
|
58
|
+
|
|
59
|
+
### 2. Interactive CLI (no positional arg):
|
|
60
|
+
./examples/${name}.js [--options]
|
|
61
|
+
|
|
62
|
+
### 3. WS Server (no positional arg):
|
|
63
|
+
./examples/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
64
|
+
|
|
65
|
+
### 4. WS Client (no positional arg):
|
|
66
|
+
./examples/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
67
|
+
|
|
68
|
+
### 5. Hybrid (Server + Client, no positional arg):
|
|
69
|
+
./examples/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
70
|
+
|
|
71
|
+
## SERVER OPTIONS EXPLAINED:
|
|
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., 'agent_docs'). Runs indefinitely until Ctrl+C.
|
|
73
|
+
|
|
74
|
+
--connect [ws_url]: Connects as CLIENT to remote WS server at [ws_url] (e.g., ws://127.0.0.1:8080/ws). Gains access to remote agent's tools. Interactive CLI available.
|
|
75
|
+
|
|
76
|
+
--secret [string]: SHARED AUTH TOKEN (min 3 chars). SERVER rejects clients without matching --secret. CLIENTS must provide server's secret to connect. Use same secret for chains.
|
|
77
|
+
|
|
78
|
+
Note: Server/Client/Hybrid IGNORES positional input arg (use CLI modes instead). Hybrid: This agent serves AND uses remote tools.
|
|
79
|
+
|
|
80
|
+
## OPTIONS:
|
|
81
|
+
--model [grok-4-fast-reasoning|...] (default: grok-4-fast-reasoning)
|
|
82
|
+
--temperature [float] (-2 to +2)
|
|
83
|
+
--tokens [number] (max output tokens)
|
|
84
|
+
--top_p [float]
|
|
85
|
+
--context [number] (default: 250000)
|
|
86
|
+
|
|
87
|
+
## SERVER TOOLS (when no input):
|
|
88
|
+
Exposes as 'agent_docs' tool for chaining.
|
|
89
|
+
`);
|
|
90
|
+
process.exit();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (help) {
|
|
94
|
+
printHelp();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const tool_call_name = 'agent_docs';
|
|
98
|
+
const tool_call_description = `
|
|
99
|
+
documentation maintainer that creates, updates, retrieves, and organizes Markdown files in ./docs/ for any subject.
|
|
100
|
+
`.trim();
|
|
101
|
+
|
|
102
|
+
const prompt = `
|
|
103
|
+
You are docs_agent, a documentation maintainer that creates, updates, retrieves, and organizes Markdown files in ./docs/ (relative to cwd). You own this folder—create it if missing. All content is in clean Markdown (.md files only). Filenames must descriptively indicate content (e.g., "introduction-to-nodejs.md", "react-hooks-guide.md"—kebab-case, no spaces).
|
|
104
|
+
|
|
105
|
+
**CRITICAL: STRICT NO-CODING RULE** - Stick to docs management ONLY. NEVER:
|
|
106
|
+
- Use coding tools (e.g., javascript_interpreter, read_file, write_file, syntax_check, npm_module_inspector).
|
|
107
|
+
- Generate, execute, or edit code (JS/Python/Bash beyond safe docs ops).
|
|
108
|
+
- Misuse bash for anything beyond safe ./docs/*.md ops (e.g., ls docs/, cat docs/file.md, echo > docs/file.md, cp docs/file.md docs/file.md.bak).
|
|
109
|
+
- Touch files outside ./docs/.
|
|
110
|
+
If asked to code or edit non-docs files, decline: "For coding or other tasks, use specialized agents like code_agent. I'll handle ./docs/ only."
|
|
111
|
+
|
|
112
|
+
Behaviors:
|
|
113
|
+
- AUTONOMOUS: Use tools to manage files without user intervention. For reading: \`ls docs/*.md\` then \`cat docs/[filename].md\`. For writing/updating: Backup first (\`cp docs/old.md docs/old.md.bak\`), then \`echo "[full Markdown content]" > docs/[filename].md\`.
|
|
114
|
+
- RESEARCH: Use web_search or browse_page to gather accurate info before creating/updating.
|
|
115
|
+
- STRUCTURE: Markdown best practices—use # Headings, ## Subheadings, - Lists, \`code\` inline, \`\`\`blocks\`\`\`, links [text](url). Keep concise yet comprehensive.
|
|
116
|
+
- RETRIEVAL: Display full file content in Markdown format when asked.
|
|
117
|
+
- SAFETY: Never delete files. Confirm overwrites via backup. If unsure, ask for clarification.
|
|
118
|
+
- FILENAME SUGGESTION: Propose and use logical names based on topic (e.g., for "AI agents", use "ai-agents-overview.md").
|
|
119
|
+
- OUTPUT: Respond in Markdown. For file ops, show before/after diffs if changed.
|
|
120
|
+
|
|
121
|
+
Use execute_bash_script ONLY for safe ./docs/ ops and inspections (ls, cat, cp, echo >). Use web_search/browse_page for research. Reason step-by-step.
|
|
122
|
+
`.trim();
|
|
123
|
+
|
|
124
|
+
const agent = new AgentManager({ name, secret });
|
|
125
|
+
agent.setup({
|
|
126
|
+
prompt,
|
|
127
|
+
api,
|
|
128
|
+
options,
|
|
129
|
+
toolsetMode,
|
|
130
|
+
contextWindow
|
|
131
|
+
});
|
|
132
|
+
const toolset = agent.getToolset();
|
|
133
|
+
if (toolset) {
|
|
134
|
+
agent.addGenericToolcall('execute_bash_script');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const cliIntro = `
|
|
138
|
+
${name} ${options.model}.
|
|
139
|
+
- context: ${contextWindow}
|
|
140
|
+
${tool_call_name}
|
|
141
|
+
`.trim();
|
|
142
|
+
|
|
143
|
+
if (input) {
|
|
144
|
+
const RES = await agent.directCall(input);
|
|
145
|
+
console.log(RES);
|
|
146
|
+
} else {
|
|
147
|
+
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|
|
148
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { AgentManager } from '@j-o-r/hello-dave';
|
|
3
|
+
import { parseArgs } from '@j-o-r/sh';
|
|
4
|
+
|
|
5
|
+
const name = 'gpt_agent';
|
|
6
|
+
const api = 'gpt';
|
|
7
|
+
let secret = '';
|
|
8
|
+
|
|
9
|
+
const args = parseArgs();
|
|
10
|
+
|
|
11
|
+
let input; // Directcall input (positional ONLY - NO pipe)
|
|
12
|
+
if (args._.length === 1 && typeof args._[0] === 'string' && args._[0].trim() !== '') {
|
|
13
|
+
input = args._[0].trim();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const help = args['help'] || false;
|
|
17
|
+
const connect = args['connect'] ? args['connect'] : undefined;
|
|
18
|
+
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
19
|
+
|
|
20
|
+
/** @type {import('@j-o-r/hello-dave/types/API/openai.com/reponses/text').OAOptions} */
|
|
21
|
+
const options = { tools: [] };
|
|
22
|
+
options.tools.push({
|
|
23
|
+
type: 'web_search'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (args['secret']) {
|
|
27
|
+
secret = args['secret'];
|
|
28
|
+
}
|
|
29
|
+
if (args['model'] || true) {
|
|
30
|
+
options.model = args['model'] || 'gpt-5.4';
|
|
31
|
+
}
|
|
32
|
+
if (args['temperature']) {
|
|
33
|
+
options.temperature = parseFloat(args['temperature']);
|
|
34
|
+
}
|
|
35
|
+
if (args['tokens']) {
|
|
36
|
+
options.max_output_tokens = parseInt(args['tokens']);
|
|
37
|
+
}
|
|
38
|
+
if (args['top_p']) {
|
|
39
|
+
options.top_p = parseFloat(args['top_p']);
|
|
40
|
+
}
|
|
41
|
+
const reasoning = true;
|
|
42
|
+
if (reasoning) {
|
|
43
|
+
options.reasoning = {
|
|
44
|
+
effort: 'medium',
|
|
45
|
+
summary: 'auto'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const contextWindow = args['context'] ? parseInt(args['context']) : 100000;
|
|
49
|
+
const toolsetMode = 'auto';
|
|
50
|
+
|
|
51
|
+
function printHelp() {
|
|
52
|
+
console.log(`
|
|
53
|
+
'${name} --help' You are looking at it.
|
|
54
|
+
|
|
55
|
+
## USAGE MODES:
|
|
56
|
+
|
|
57
|
+
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
58
|
+
./examples/${name}.js "Your query" [--options]
|
|
59
|
+
|
|
60
|
+
### 2. Interactive CLI (no positional arg):
|
|
61
|
+
./examples/${name}.js [--options]
|
|
62
|
+
|
|
63
|
+
### 3. WS Server (no positional arg):
|
|
64
|
+
./examples/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
65
|
+
|
|
66
|
+
### 4. WS Client (no positional arg):
|
|
67
|
+
./examples/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
68
|
+
|
|
69
|
+
### 5. Hybrid (Server + Client, no positional arg):
|
|
70
|
+
./examples/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
71
|
+
|
|
72
|
+
## SERVER OPTIONS EXPLAINED:
|
|
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., 'gpt_agent'). Runs indefinitely until Ctrl+C.
|
|
74
|
+
|
|
75
|
+
--connect [ws_url]: Connects as CLIENT to remote WS server at [ws_url] (e.g., ws://127.0.0.1:8080/ws). Gains access to remote agent's tools. Interactive CLI available.
|
|
76
|
+
|
|
77
|
+
--secret [string]: SHARED AUTH TOKEN (min 3 chars). SERVER rejects clients without matching --secret. CLIENTS must provide server's secret to connect. Use same secret for chains.
|
|
78
|
+
|
|
79
|
+
Note: Server/Client/Hybrid IGNORES positional input arg (use CLI modes instead). Hybrid: This agent serves AND uses remote tools.
|
|
80
|
+
|
|
81
|
+
## OPTIONS:
|
|
82
|
+
--model ['gpt-5.4'|...] (default: gpt-5.4)
|
|
83
|
+
--temperature [float] (-2 to +2)
|
|
84
|
+
--tokens [number] (max output tokens)
|
|
85
|
+
--top_p [float]
|
|
86
|
+
--context [number] (default: 100000)
|
|
87
|
+
|
|
88
|
+
## SERVER TOOLS (when no input):
|
|
89
|
+
Exposes as 'gpt_agent' tool for chaining.
|
|
90
|
+
`);
|
|
91
|
+
process.exit()
|
|
92
|
+
}
|
|
93
|
+
if (help) {
|
|
94
|
+
printHelp();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const prompt = `
|
|
98
|
+
Respond briefly and directly, using minimal words. Reason step-by-step first. Focus solely on core point; avoid elaboration or follow-ups. If unclear, ask clarifying questions before proceeding.
|
|
99
|
+
`.trim();
|
|
100
|
+
|
|
101
|
+
const tool_call_name = 'gpt_agent';
|
|
102
|
+
const tool_call_description = `
|
|
103
|
+
GPT Agent for quick responses and web search.
|
|
104
|
+
`.trim();
|
|
105
|
+
|
|
106
|
+
const agent = new AgentManager({ name, secret });
|
|
107
|
+
agent.setup({
|
|
108
|
+
prompt,
|
|
109
|
+
api,
|
|
110
|
+
options,
|
|
111
|
+
toolsetMode,
|
|
112
|
+
contextWindow
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const cliIntro = `
|
|
116
|
+
${name} ${options.model}.
|
|
117
|
+
- context: ${contextWindow}
|
|
118
|
+
`.trim();
|
|
119
|
+
|
|
120
|
+
if (input) {
|
|
121
|
+
const RES = await agent.directCall(input);
|
|
122
|
+
console.log(RES);
|
|
123
|
+
} else {
|
|
124
|
+
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|
|
125
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* Full modes: Direct call (one-shot positional ONLY), CLI interactive (no args), WS Server (--serve), Client (--connect).
|
|
4
|
+
* Direct: grok_agent.js "What is your task?"
|
|
5
|
+
* CLI: grok_agent.js
|
|
6
|
+
* Server: grok_agent.js --serve 8080
|
|
7
|
+
*/
|
|
8
|
+
import { AgentManager } from '@j-o-r/hello-dave';
|
|
9
|
+
import { parseArgs } from '@j-o-r/sh';
|
|
10
|
+
|
|
11
|
+
const name = 'grok_agent';
|
|
12
|
+
const api = 'xai';
|
|
13
|
+
let secret = '';
|
|
14
|
+
|
|
15
|
+
const args = parseArgs();
|
|
16
|
+
|
|
17
|
+
let input; // Directcall input (positional ONLY - NO pipe)
|
|
18
|
+
if (args._.length === 1 && typeof args._[0] === 'string' && args._[0].trim() !== '') {
|
|
19
|
+
input = args._[0].trim();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const help = args['help'] || false;
|
|
23
|
+
const connect = args['connect'] ? args['connect'] : undefined;
|
|
24
|
+
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
25
|
+
|
|
26
|
+
/** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
|
|
27
|
+
const options = { tools: [] };
|
|
28
|
+
options.tools.push({
|
|
29
|
+
type: 'web_search'
|
|
30
|
+
});
|
|
31
|
+
options.tools.push({
|
|
32
|
+
type: 'x_search'
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (args['secret']) {
|
|
36
|
+
secret = args['secret'];
|
|
37
|
+
}
|
|
38
|
+
if (args['model'] || true) {
|
|
39
|
+
options.model = args['model'] || 'grok-4-fast-reasoning';
|
|
40
|
+
}
|
|
41
|
+
if (args['temperature']) {
|
|
42
|
+
options.temperature = parseFloat(args['temperature']);
|
|
43
|
+
}
|
|
44
|
+
if (args['tokens']) {
|
|
45
|
+
options.max_output_tokens = parseInt(args['tokens']);
|
|
46
|
+
}
|
|
47
|
+
if (args['top_p']) {
|
|
48
|
+
options.top_p = parseFloat(args['top_p']);
|
|
49
|
+
}
|
|
50
|
+
const reasoning = true;
|
|
51
|
+
if (reasoning) {
|
|
52
|
+
options.reasoning = {
|
|
53
|
+
effort: 'medium',
|
|
54
|
+
summary: 'auto'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const toolsetMode = 'auto';
|
|
58
|
+
const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
|
|
59
|
+
|
|
60
|
+
function printHelp() {
|
|
61
|
+
console.log(`
|
|
62
|
+
'${name} --help' You are looking at it.
|
|
63
|
+
|
|
64
|
+
## USAGE MODES:
|
|
65
|
+
|
|
66
|
+
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
67
|
+
./examples/${name}.js "What is your task?" [--options]
|
|
68
|
+
|
|
69
|
+
### 2. Interactive CLI (no positional arg):
|
|
70
|
+
./examples/${name}.js [--options]
|
|
71
|
+
|
|
72
|
+
### 3. WS Server (no positional arg):
|
|
73
|
+
./examples/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
74
|
+
|
|
75
|
+
### 4. WS Client (no positional arg):
|
|
76
|
+
./examples/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
77
|
+
|
|
78
|
+
### 5. Hybrid (Server + Client, no positional arg):
|
|
79
|
+
./examples/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
80
|
+
|
|
81
|
+
## SERVER OPTIONS EXPLAINED:
|
|
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.
|
|
83
|
+
|
|
84
|
+
--connect [ws_url]: Connects as CLIENT to remote WS server at [ws_url] (e.g., ws://127.0.0.1:8080/ws). Gains access to remote agent's tools. Interactive CLI available.
|
|
85
|
+
|
|
86
|
+
--secret [string]: SHARED AUTH TOKEN (min 3 chars). SERVER rejects clients without matching --secret. CLIENTS must provide server's secret to connect. Use same secret for chains.
|
|
87
|
+
|
|
88
|
+
Note: Server/Client/Hybrid IGNORES positional input arg (use CLI modes instead). Hybrid: This agent serves AND uses remote tools.
|
|
89
|
+
|
|
90
|
+
## OPTIONS:
|
|
91
|
+
--model [grok-4-fast-reasoning|...] (default: grok-4-fast-reasoning)
|
|
92
|
+
--temperature [float] (-2 to +2)
|
|
93
|
+
--tokens [number] (max output tokens)
|
|
94
|
+
--top_p [float]
|
|
95
|
+
--context [number] (default: 250000)
|
|
96
|
+
|
|
97
|
+
## SERVER TOOLS (when no input):
|
|
98
|
+
Exposes as brief responder tool for chaining.
|
|
99
|
+
`);
|
|
100
|
+
process.exit()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (help) {
|
|
104
|
+
printHelp();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const prompt = `
|
|
108
|
+
Respond briefly and directly, using minimal words. Reason step-by-step first. Focus solely on core point; avoid elaboration or follow-ups. If unclear, ask clarifying questions before proceeding.
|
|
109
|
+
`.trim();
|
|
110
|
+
|
|
111
|
+
const agent = new AgentManager({ name, secret });
|
|
112
|
+
agent.setup({
|
|
113
|
+
prompt,
|
|
114
|
+
api,
|
|
115
|
+
options,
|
|
116
|
+
toolsetMode,
|
|
117
|
+
contextWindow
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const cliIntro = `
|
|
121
|
+
${name} ${options.model}.
|
|
122
|
+
- context: ${contextWindow}. Tools: web_search, x_search.
|
|
123
|
+
Brief responder ready for CLI/Server/Client modes.
|
|
124
|
+
`.trim();
|
|
125
|
+
|
|
126
|
+
if (input) {
|
|
127
|
+
// one-shot
|
|
128
|
+
const RES = await agent.directCall(input);
|
|
129
|
+
console.log(RES);
|
|
130
|
+
} else {
|
|
131
|
+
await agent.start(serve, connect, cliIntro);
|
|
132
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* ONE SHOT , direct call example
|
|
4
|
+
* ```bash
|
|
5
|
+
* echo "What is your task?" | examples/grok.js
|
|
6
|
+
* ```
|
|
7
|
+
*/
|
|
8
|
+
import { AgentManager } from '@j-o-r/hello-dave';
|
|
9
|
+
import { parseArgs, readIn } from '@j-o-r/sh';
|
|
10
|
+
|
|
11
|
+
const name = 'ask_grok';
|
|
12
|
+
const api = 'xai';
|
|
13
|
+
let secret = '';
|
|
14
|
+
|
|
15
|
+
const input = await readIn();
|
|
16
|
+
const args = parseArgs();
|
|
17
|
+
const help = args['help'] || false;
|
|
18
|
+
|
|
19
|
+
/** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
|
|
20
|
+
const options = {
|
|
21
|
+
tools: []
|
|
22
|
+
}
|
|
23
|
+
options.tools.push({
|
|
24
|
+
type: 'web_search'
|
|
25
|
+
});
|
|
26
|
+
options.tools.push({
|
|
27
|
+
type: 'x_search'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Set properties only if provided via command line (except model which has default)
|
|
31
|
+
if (args['model'] || true) { // model gets default value
|
|
32
|
+
// @ts-ignore || grok-4-1-fast-non-reasoning
|
|
33
|
+
options.model = args['model'] || 'grok-4.20-multi-agent-0309';
|
|
34
|
+
}
|
|
35
|
+
if (args['temperature']) {
|
|
36
|
+
options.temperature = parseFloat(args['temperature']);
|
|
37
|
+
}
|
|
38
|
+
if (args['tokens']) {
|
|
39
|
+
options.max_output_tokens = parseInt(args['tokens']);
|
|
40
|
+
}
|
|
41
|
+
if (args['top_p']) {
|
|
42
|
+
options.top_p = parseFloat(args['top_p']);
|
|
43
|
+
}
|
|
44
|
+
const reasoning = true // args['reasoning'] ? args['reasoning'] : null;
|
|
45
|
+
if (reasoning) {
|
|
46
|
+
options.reasoning = {
|
|
47
|
+
effort: 'medium',
|
|
48
|
+
summary: 'auto'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Large context on grok-4-fast
|
|
52
|
+
const contextWindow = args['context'] ? parseInt(args['context']) : 1900000;
|
|
53
|
+
const toolsetMode = 'auto';
|
|
54
|
+
|
|
55
|
+
function printHelp() {
|
|
56
|
+
console.log(`
|
|
57
|
+
'${name} --help' You are looking at it.
|
|
58
|
+
'
|
|
59
|
+
OPTIONS:
|
|
60
|
+
--tokens [number]: max generated tokens
|
|
61
|
+
--context [number] : truncate message history to context-windows size default 130000
|
|
62
|
+
--temperature [float] : -2 / +2
|
|
63
|
+
--model ['grok-4-1-fast-reasoning'|'grok-4-1-fast-non-reasoning'|'grok-code-fast-1'|'grok-4-fast-reasoning'|'grok-4-fast-non-reasoning']
|
|
64
|
+
--top_p [float]: number > 0, 0.1 means no top_p
|
|
65
|
+
--reasoning [low|high]
|
|
66
|
+
|
|
67
|
+
USAGE:
|
|
68
|
+
|
|
69
|
+
\`\`\`bash
|
|
70
|
+
echo "What is ..." | grok.js
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+
`);
|
|
74
|
+
process.exit()
|
|
75
|
+
}
|
|
76
|
+
if (help) {
|
|
77
|
+
printHelp();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!input || input.trim() === '') {
|
|
81
|
+
printHelp();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const prompt = `
|
|
85
|
+
Respond briefly and directly, using minimal words. Reason step-by-step first. Focus solely on core point; avoid elaboration or follow-ups. If unclear, ask clarifying questions before proceeding.
|
|
86
|
+
`.trim();
|
|
87
|
+
|
|
88
|
+
const agent = new AgentManager({ name, secret });
|
|
89
|
+
agent.setup({
|
|
90
|
+
prompt,
|
|
91
|
+
api,
|
|
92
|
+
options,
|
|
93
|
+
toolsetMode,
|
|
94
|
+
contextWindow
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const res = await agent.directCall(input);
|
|
98
|
+
console.log(res);
|