@j-o-r/hello-dave 0.0.2 → 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 +445 -160
- package/README.md.backup +269 -0
- package/README.md.bak +481 -0
- package/README.md.bak.1774780058 +338 -0
- package/README.md.bak2 +455 -0
- package/bin/dave.js +165 -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.bak.1774780058/ask_agent.js +114 -0
- package/examples.bak.1774780058/code_agent.js +149 -0
- package/examples.bak.1774780058/coderev_agent.js +72 -0
- package/examples.bak.1774780058/codeserver.sh +47 -0
- package/examples.bak.1774780058/daisy_agent.js +177 -0
- package/examples.bak.1774780058/docs_agent.js +119 -0
- package/{bin/hdAsk.js → examples.bak.1774780058/gpt_agent.js} +46 -40
- package/examples.bak.1774780058/grok_agent.js +98 -0
- package/examples.bak.1774780058/memory_agent.js +112 -0
- package/examples.bak.1774780058/npm_agent.js +175 -0
- package/examples.bak.1774780058/prompt_agent.js +112 -0
- package/examples.bak.1774780058/readme_agent.js +144 -0
- package/examples.bak.1774780058/spawn_agent.js +263 -0
- package/examples.bak.1774780058/test_agent.js +162 -0
- package/examples.bak.1774780058/todo_agent.js +138 -0
- package/lib/API/openai.com/reponses/text.js +12 -18
- package/lib/API/x.ai/collections.js +354 -0
- package/lib/API/x.ai/files.js +218 -0
- package/lib/API/x.ai/responses.js +492 -0
- package/lib/API/x.ai/text.js +1 -1
- package/lib/AgentClient.js +13 -6
- package/lib/AgentManager.js +80 -10
- package/lib/AgentServer.js +50 -22
- package/lib/Cli.js +7 -1
- package/lib/Prompt.js +4 -2
- package/lib/ToolSet.js +2 -1
- package/lib/genericToolset.js +258 -88
- package/lib/genericToolset.js.bak_syntax +402 -0
- package/lib/index.js +4 -2
- package/lib/wsCli.js +256 -0
- package/lib/wsIO.js +96 -0
- package/package.json +26 -21
- 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/API/openai.com/reponses/text.d.ts +17 -3
- package/types/API/x.ai/collections.d.ts +167 -0
- package/types/API/x.ai/files.d.ts +84 -0
- package/types/API/x.ai/responses.d.ts +379 -0
- package/types/AgentClient.d.ts +5 -0
- package/types/AgentManager.d.ts +25 -31
- package/types/AgentServer.d.ts +5 -1
- package/types/Prompt.d.ts +4 -2
- package/types/ToolSet.d.ts +1 -0
- package/types/index.d.ts +4 -3
- package/types/wsCli.d.ts +3 -0
- package/types/wsIO.d.ts +26 -0
- package/utils/bars.js +40 -0
- package/utils/clear_sessions.sh +54 -0
- package/{bin/hdInspect.js → utils/format_log.js} +5 -0
- package/utils/list_sessions.sh +46 -0
- package/utils/search_sessions.sh +73 -0
- package/utils/syntax_check.sh +61 -0
- package/utils/test.sh +46 -0
- package/bin/hdClear.js +0 -13
- package/bin/hdCode.js +0 -115
- package/bin/hdConnect.js +0 -230
- package/bin/hdNpm.js +0 -114
- package/bin/hdPrompt.js +0 -108
- package/examples/claude-test.js +0 -89
- package/examples/claude.js +0 -143
- package/examples/gpt.js +0 -127
- package/examples/gpt_code.js +0 -125
- package/examples/gpt_note_keeping.js +0 -117
- package/examples/grok.js +0 -119
- package/examples/grok_code.js +0 -114
- package/examples/grok_note_keeping.js +0 -111
- package/module.md +0 -189
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* --- The blueprint for an Agent ---
|
|
4
|
+
* deps "@j-o-r/hello-dave" `npm i @j-o-r/hello-dave`
|
|
5
|
+
*
|
|
6
|
+
* Meet Daisy , your music producer companion .
|
|
7
|
+
*/
|
|
8
|
+
import { AgentManager } from '@j-o-r/hello-dave';
|
|
9
|
+
import { parseArgs } from '@j-o-r/sh';
|
|
10
|
+
|
|
11
|
+
// The assistants name
|
|
12
|
+
const name = 'daisy';
|
|
13
|
+
// The Api to use 'xai|claude|gpt'
|
|
14
|
+
const api = 'xai';
|
|
15
|
+
// Optional secret for authentication on websocket server/client
|
|
16
|
+
let secret = '';
|
|
17
|
+
// Get command line arguments
|
|
18
|
+
/** @type {import('@j-o-r/sh').ArgsObject} */
|
|
19
|
+
const args = parseArgs();
|
|
20
|
+
// Show help flag
|
|
21
|
+
const help = args['help'] || false;
|
|
22
|
+
// Connect to websocket server e.g. 'ws://127.0.0.1:8081/ws'
|
|
23
|
+
const connect = args['connect'] ? args['connect'] : undefined;
|
|
24
|
+
// Create a websocket server Agent (where agents can connect)
|
|
25
|
+
// (It is possible to create a websocket server and connect it as a client to another websocket server with '--connect [url]')
|
|
26
|
+
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
27
|
+
// Define request options 'ANTHOptions|XAIOptions|OAOptions' depending on the api name in use
|
|
28
|
+
/** @type {import('@j-o-r/hello-dave').XAIOptions} */
|
|
29
|
+
const options = {
|
|
30
|
+
tools: []
|
|
31
|
+
};
|
|
32
|
+
// Add the websearch tool for XAI for online search
|
|
33
|
+
options.tools.push({
|
|
34
|
+
type: 'web_search' // Useful for lyrics research, Suno prompt ideas, music theory
|
|
35
|
+
});
|
|
36
|
+
if (args['secret']) {
|
|
37
|
+
secret= args['secret'];
|
|
38
|
+
}
|
|
39
|
+
// Set properties only if provided via command line (model has default)
|
|
40
|
+
if (args['model'] || true) {
|
|
41
|
+
options.model = args['model'] || 'grok-4-1-fast-reasoning'; // Good for creative music tasks
|
|
42
|
+
}
|
|
43
|
+
if (args['temperature']) {
|
|
44
|
+
options.temperature = parseFloat(args['temperature']);
|
|
45
|
+
} else {
|
|
46
|
+
options.temperature = 0.8; // Slightly higher default for creativity in lyrics/prompts
|
|
47
|
+
}
|
|
48
|
+
if (args['tokens']) {
|
|
49
|
+
options.max_output_tokens = parseInt(args['tokens']);
|
|
50
|
+
}
|
|
51
|
+
if (args['top_p']) {
|
|
52
|
+
options.top_p = parseFloat(args['top_p']);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const reasoning = true; // Enable for step-by-step music editing/planning
|
|
56
|
+
if (reasoning) {
|
|
57
|
+
options.reasoning = {
|
|
58
|
+
effort: 'medium',
|
|
59
|
+
summary: 'auto'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Large context for song lyrics, multi-step editing sessions
|
|
64
|
+
const contextWindow = args['context'] ? parseInt(args['context']) : 1900000;
|
|
65
|
+
const toolsetMode = 'auto';
|
|
66
|
+
// Help for the `--help` flag
|
|
67
|
+
function printHelp() {
|
|
68
|
+
console.log(`
|
|
69
|
+
${name} --help: Music Creation & Editing Assistant
|
|
70
|
+
|
|
71
|
+
Daisy helps:
|
|
72
|
+
- Edit audio with ffmpeg & sox (installed on your system)
|
|
73
|
+
- Write lyrics & generate prompts for Suno AI
|
|
74
|
+
- Research music theory, chords, genres via web_search
|
|
75
|
+
- Execute bash scripts for audio processing
|
|
76
|
+
|
|
77
|
+
OPTIONS:
|
|
78
|
+
--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'} [model='grok-4-fast-non-reasoning'] - Model version to use.
|
|
79
|
+
--temperature [0-2] (default: 0.8 for creativity)
|
|
80
|
+
--tokens [number]: max output tokens
|
|
81
|
+
--context [number]: truncate history (default: 1.9M)
|
|
82
|
+
--top_p [float]: 0-1
|
|
83
|
+
--reasoning [low|high|true|false] (default: true)
|
|
84
|
+
|
|
85
|
+
SERVER TOOLS:
|
|
86
|
+
--serve [number]: create a Agent server on port number ws://127.0.0.1:[serve]/ws
|
|
87
|
+
--connect [url]: connect to a Server Agent e.g ws://127.0.0.1:8080/ws (https://my.domain/ws) ...
|
|
88
|
+
--secret [string] : limit access to websocket server with a secret
|
|
89
|
+
|
|
90
|
+
EXAMPLES:
|
|
91
|
+
daisy "Generate lyrics for a upbeat pop song about summer"
|
|
92
|
+
daisy "Create a Suno prompt for electronic chill track with synths"
|
|
93
|
+
daisy "Mix input.wav: fade in 2s, normalize, output to mixed.wav"
|
|
94
|
+
daisy "Convert video.mp4 to audio.mp3 at 320kbps"
|
|
95
|
+
|
|
96
|
+
Tools available:
|
|
97
|
+
- execute_bash_script: Run ffmpeg/sox commands (e.g., "ffmpeg -i input.mp3 output.wav")
|
|
98
|
+
- web_search: Find lyrics, chords, Suno tips
|
|
99
|
+
- send_email: Share your tracks
|
|
100
|
+
|
|
101
|
+
Start chatting!
|
|
102
|
+
`);
|
|
103
|
+
process.exit();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (help) {
|
|
107
|
+
printHelp();
|
|
108
|
+
}
|
|
109
|
+
// LLM prompt instructions
|
|
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/daisy
|
|
133
|
+
|
|
134
|
+
Respond concisely but completely. Use markdown for code/lyrics/prompts.
|
|
135
|
+
`.trim();
|
|
136
|
+
// Create the Agent
|
|
137
|
+
const agent = new AgentManager({ name, secret });
|
|
138
|
+
// Tailormade set up
|
|
139
|
+
agent.setup({
|
|
140
|
+
prompt, // Instructions
|
|
141
|
+
api, // API name to use
|
|
142
|
+
options, // Request options, overwrites defaults
|
|
143
|
+
toolsetMode, // 'auto'
|
|
144
|
+
contextWindow // The max size of the context/session
|
|
145
|
+
});
|
|
146
|
+
// Add toolcalls
|
|
147
|
+
// - "javascript_interpreter" Run javascript code with nodejs
|
|
148
|
+
// - "open_link" Open an url or file in the local user environment
|
|
149
|
+
// - "send_email" Send an email from the users environment
|
|
150
|
+
// - "execute_bash_script" Execute bash commands and script on the local machine
|
|
151
|
+
// - "execute_remote_script" Execute commands or scripts on a remote machine via ssh
|
|
152
|
+
agent.addGenericToolcall('open_link');
|
|
153
|
+
agent.addGenericToolcall('send_email');
|
|
154
|
+
agent.addGenericToolcall('execute_bash_script'); // Key for music editing!
|
|
155
|
+
agent.addGenericToolcall('read_file');
|
|
156
|
+
agent.addGenericToolcall('write_file');
|
|
157
|
+
// A welcome message to the user
|
|
158
|
+
const cliIntro = `
|
|
159
|
+
🎵 ${name} ${options.model} ready! (temp: ${options.temperature}, context: ${contextWindow})
|
|
160
|
+
|
|
161
|
+
Ask me to:
|
|
162
|
+
- Write lyrics
|
|
163
|
+
- Craft Suno prompts
|
|
164
|
+
- Edit audio: "fade out my track.mp3" → I'll give ffmpeg cmd
|
|
165
|
+
Type /help for more.
|
|
166
|
+
`.trim();
|
|
167
|
+
|
|
168
|
+
const toolName = `agent_${name}`
|
|
169
|
+
const toolDescription = `
|
|
170
|
+
Daisy Music Assistant:
|
|
171
|
+
- "Lyrics for [theme]" → Generate lyrics.
|
|
172
|
+
- "Suno prompt: [style]" → Optimized Suno prompt.
|
|
173
|
+
- "ffmpeg [task] on file.wav" → Bash script to run.
|
|
174
|
+
- web_search: Research chords/lyrics.
|
|
175
|
+
- execute_bash_script: Processes your local files safely.
|
|
176
|
+
`.trim();
|
|
177
|
+
await agent.start(serve, connect, cliIntro, toolName, toolDescription);
|
|
@@ -0,0 +1,119 @@
|
|
|
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_dave';
|
|
6
|
+
const api = 'xai';
|
|
7
|
+
let secret = '';
|
|
8
|
+
|
|
9
|
+
// Read input/args
|
|
10
|
+
const input = ''; //await readIn();
|
|
11
|
+
const args = parseArgs();
|
|
12
|
+
const help = args['help'] || false;
|
|
13
|
+
const connect = args['connect'] ? args['connect'] : undefined;
|
|
14
|
+
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
15
|
+
|
|
16
|
+
/** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses').XAIOptions} */
|
|
17
|
+
const options = { tools: [] };
|
|
18
|
+
|
|
19
|
+
// Explicitly add web_search for research
|
|
20
|
+
options.tools.push({ type: 'web_search' });
|
|
21
|
+
|
|
22
|
+
if (args['secret']) { // model gets default value
|
|
23
|
+
secret = args['secret'];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (args['model'] || true) {
|
|
27
|
+
options.model = args['model'] || 'grok-4-1-fast-reasoning';
|
|
28
|
+
}
|
|
29
|
+
if (args['temperature']) {
|
|
30
|
+
options.temperature = parseFloat(args['temperature']);
|
|
31
|
+
}
|
|
32
|
+
if (args['tokens']) {
|
|
33
|
+
options.max_output_tokens = parseInt(args['tokens']);
|
|
34
|
+
}
|
|
35
|
+
if (args['top_p']) {
|
|
36
|
+
options.top_p = parseFloat(args['top_p']);
|
|
37
|
+
}
|
|
38
|
+
if (args['reasoning']) {
|
|
39
|
+
options.reasoning = { effort: 'medium', summary: 'auto' };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
|
|
43
|
+
const toolsetMode = 'auto';
|
|
44
|
+
|
|
45
|
+
function printHelp() {
|
|
46
|
+
console.log(`
|
|
47
|
+
docs --help: documentation maintainer that creates, updates, retrieves, and organizes Markdown files in ./docs/ for any subject.
|
|
48
|
+
|
|
49
|
+
Usage: npx ./bin/docsDave.js [input] [options]
|
|
50
|
+
|
|
51
|
+
Commands (via input):
|
|
52
|
+
- "Create a doc on [topic]" → Generates new .md file with descriptive name.
|
|
53
|
+
- "Update [filename] with [content]" → Appends/edits Markdown safely (backs up first).
|
|
54
|
+
- "Show [topic or filename]" → Retrieves and displays content.
|
|
55
|
+
- "Organize docs on [subject]" → Lists, suggests structure, or refactors files.
|
|
56
|
+
|
|
57
|
+
OPTIONS:
|
|
58
|
+
--model [name] Model (default: grok-beta)
|
|
59
|
+
--temperature [0-2] Creativity (default: 0.7)
|
|
60
|
+
--tokens [num] Max output tokens
|
|
61
|
+
--context [num] Context window (default: 250000)
|
|
62
|
+
--help Show this help
|
|
63
|
+
|
|
64
|
+
SERVER TOOLS:
|
|
65
|
+
--serve [number]: create a Agent server on port number ws://127.0.0.1:[serve]/ws
|
|
66
|
+
--connect [url]: connect to a Server Agent e.g ws://127.0.0.1:8080/ws (https://my.domain/ws) ...
|
|
67
|
+
--secret [string] : limit access to websocket server with a secret
|
|
68
|
+
|
|
69
|
+
EXAMPLES:
|
|
70
|
+
\$ npx ./bin/docsDave.js "Create a guide on Markdown best practices"
|
|
71
|
+
\$ npx ./bin/docsDave.js "Update nodejs-basics.md with async/await section"
|
|
72
|
+
\$ npx ./bin/docsDave.js --serve 8080
|
|
73
|
+
|
|
74
|
+
Type /help in interactive mode for more.
|
|
75
|
+
`);
|
|
76
|
+
process.exit();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (help) printHelp();
|
|
80
|
+
|
|
81
|
+
const prompt = `
|
|
82
|
+
You are docs, 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).
|
|
83
|
+
|
|
84
|
+
Behaviors:
|
|
85
|
+
- 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\`.
|
|
86
|
+
- RESEARCH: Use web_search or browse_page to gather accurate info before creating/updating.
|
|
87
|
+
- STRUCTURE: Markdown best practices—use # Headings, ## Subheadings, - Lists, \`code\` inline, \`\`\`blocks\`\`\`, links [text](url). Keep concise yet comprehensive.
|
|
88
|
+
- RETRIEVAL: Display full file content in Markdown format when asked.
|
|
89
|
+
- SAFETY: Never delete files. Confirm overwrites via backup. If unsure, ask for clarification.
|
|
90
|
+
- FILENAME SUGGESTION: Propose and use logical names based on topic (e.g., for "AI agents", use "ai-agents-overview.md").
|
|
91
|
+
- OUTPUT: Respond in Markdown. For file ops, show before/after diffs if changed.
|
|
92
|
+
|
|
93
|
+
Use tools proactively: execute_bash_script for all file I/O (quote commands safely), web_search for topics, browse_page for deep sources. Reason step-by-step.
|
|
94
|
+
`.trim();
|
|
95
|
+
|
|
96
|
+
const agent = new AgentManager({ name, secret });
|
|
97
|
+
agent.setup({
|
|
98
|
+
prompt,
|
|
99
|
+
api,
|
|
100
|
+
options,
|
|
101
|
+
toolsetMode,
|
|
102
|
+
contextWindow
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Add generic tools for file ops and research
|
|
106
|
+
agent.addGenericToolcall('execute_bash_script');
|
|
107
|
+
|
|
108
|
+
const cliIntro = `
|
|
109
|
+
Welcome to docsDave! I manage your ./docs/ folder autonomously.
|
|
110
|
+
- Ask me to create/update/retrieve Markdown docs on any topic.
|
|
111
|
+
- I'll use descriptive .md filenames and keep everything organized.
|
|
112
|
+
|
|
113
|
+
Example: "Create a doc on building CLI agents with Node.js"
|
|
114
|
+
`.trim();
|
|
115
|
+
|
|
116
|
+
const toolName = 'agent_docs';
|
|
117
|
+
const toolDescription = `documentation maintainer that creates, updates, retrieves, and organizes Markdown files in ./docs/ for any subject.`.trim();
|
|
118
|
+
|
|
119
|
+
await agent.start(serve, connect, cliIntro, toolName, toolDescription);
|
|
@@ -1,40 +1,49 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import AgentManager from '
|
|
2
|
+
import { AgentManager } from '@j-o-r/hello-dave';
|
|
3
3
|
import { parseArgs, readIn } from '@j-o-r/sh';
|
|
4
4
|
|
|
5
|
-
const name = '
|
|
6
|
-
const api = '
|
|
5
|
+
const name = 'chat_gpt';
|
|
6
|
+
const api = 'gpt';
|
|
7
|
+
let secret = '';
|
|
7
8
|
|
|
8
|
-
const input = await readIn();
|
|
9
|
+
// const input = await readIn();
|
|
9
10
|
const args = parseArgs();
|
|
10
11
|
const help = args['help'] || false;
|
|
11
12
|
const connect = args['connect'] ? args['connect'] : undefined;
|
|
12
13
|
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
13
14
|
|
|
14
|
-
/** @type {import('
|
|
15
|
-
const options = {
|
|
15
|
+
/** @type {import('@j-o-r/hello-dave/types/API/openai.com/reponses/text').OAOptions} */
|
|
16
|
+
const options = {
|
|
17
|
+
tools: []
|
|
18
|
+
}
|
|
19
|
+
options.tools.push({
|
|
20
|
+
type: 'web_search'
|
|
21
|
+
});
|
|
22
|
+
if (args['secret']) { // model gets default value
|
|
23
|
+
secret = args['secret'];
|
|
24
|
+
}
|
|
16
25
|
// Set properties only if provided via command line (except model which has default)
|
|
17
26
|
if (args['model'] || true) { // model gets default value
|
|
18
|
-
|
|
19
|
-
options.model = args['model'] || 'grok-4-fast';
|
|
27
|
+
options.model = args['model'] || 'gpt-5.4';
|
|
20
28
|
}
|
|
21
29
|
if (args['temperature']) {
|
|
22
30
|
options.temperature = parseFloat(args['temperature']);
|
|
23
31
|
}
|
|
24
32
|
if (args['tokens']) {
|
|
25
|
-
options.
|
|
33
|
+
options.max_output_tokens = parseInt(args['tokens']);
|
|
26
34
|
}
|
|
27
35
|
if (args['top_p']) {
|
|
28
36
|
options.top_p = parseFloat(args['top_p']);
|
|
29
37
|
}
|
|
30
|
-
|
|
31
|
-
const reasoning = args['reasoning'] ? args['reasoning'] : null;
|
|
38
|
+
const reasoning = true // args['reasoning'] ? args['reasoning'] : null;
|
|
32
39
|
if (reasoning) {
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
options.reasoning = {
|
|
41
|
+
effort: 'medium',
|
|
42
|
+
summary: 'auto'
|
|
43
|
+
}
|
|
35
44
|
}
|
|
36
45
|
// Large context on grok-4-fast
|
|
37
|
-
const contextWindow = args['context'] ? parseInt(args['context']) :
|
|
46
|
+
const contextWindow = args['context'] ? parseInt(args['context']) : 100000;
|
|
38
47
|
const toolsetMode = 'auto';
|
|
39
48
|
|
|
40
49
|
function printHelp() {
|
|
@@ -45,12 +54,15 @@ OPTIONS:
|
|
|
45
54
|
--tokens [number]: max generated tokens
|
|
46
55
|
--context [number] : truncate message history to context-windows size default 130000
|
|
47
56
|
--temperature [float] : -2 / +2
|
|
48
|
-
--model [grok-4|grok-
|
|
57
|
+
--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']
|
|
49
58
|
--top_p [float]: number > 0, 0.1 means no top_p
|
|
50
59
|
--reasoning [low|high]
|
|
51
60
|
--tools [javascript,bash] comma seperated list
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
|
|
62
|
+
SERVER TOOLS:
|
|
63
|
+
--serve [number]: create a Agent server on port number ws://127.0.0.1:[serve]/ws
|
|
64
|
+
--connect [url]: connect to a Server Agent e.g ws://127.0.0.1:8080/ws (https://my.domain/ws) ...
|
|
65
|
+
--secret [string] : limit access to websocket server with a secret
|
|
54
66
|
|
|
55
67
|
`);
|
|
56
68
|
process.exit()
|
|
@@ -61,11 +73,9 @@ if (help) {
|
|
|
61
73
|
|
|
62
74
|
const prompt = `
|
|
63
75
|
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.
|
|
64
|
-
- open_link: [url] — open in local browser.
|
|
65
|
-
- send_email: send to [email_address]; message: [message].
|
|
66
76
|
`.trim();
|
|
67
77
|
|
|
68
|
-
const agent = new AgentManager({ name });
|
|
78
|
+
const agent = new AgentManager({ name, secret });
|
|
69
79
|
agent.setup({
|
|
70
80
|
prompt,
|
|
71
81
|
api,
|
|
@@ -73,31 +83,27 @@ agent.setup({
|
|
|
73
83
|
toolsetMode,
|
|
74
84
|
contextWindow
|
|
75
85
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
// agent.addGenericToolcall('open_link');
|
|
87
|
+
// agent.addGenericToolcall('send_email');
|
|
88
|
+
// agent.addGenericToolcall('history_search');
|
|
89
|
+
//
|
|
90
|
+
// const addTools = (args['tools']) ? args['tools'].split(',') : ['bash'];
|
|
91
|
+
// if (addTools.includes('javascript')) {
|
|
92
|
+
// agent.addGenericToolcall('javascript_interpreter');
|
|
93
|
+
// }
|
|
94
|
+
// if (addTools.includes('bash')) {
|
|
95
|
+
// agent.addGenericToolcall('execute_bash_script');
|
|
96
|
+
// }
|
|
97
|
+
// if (addTools.includes('ssh')) {
|
|
98
|
+
// agent.addGenericToolcall('execute_remote_script');
|
|
99
|
+
// }
|
|
79
100
|
const cliIntro = `
|
|
80
101
|
${name} ${options.model}.
|
|
81
|
-
- search ${options.search_parameters.mode}
|
|
82
102
|
- context: ${contextWindow}
|
|
83
103
|
`.trim();
|
|
84
104
|
const description = `
|
|
85
105
|
Guide for this smart online AI Agent:
|
|
86
|
-
- query: Formulate ONE efficient, comprehensive search query in natural language, combining multiple sources/subjects/domains; mention optional sources if needed. Avoid multiple queries—
|
|
87
|
-
lidate into a single one.
|
|
88
|
-
- open_link: [URL] — Open in local browser.
|
|
89
|
-
- send_email: Send to [email_address]; Message: [message].
|
|
106
|
+
- query: Formulate ONE efficient, comprehensive search query in natural language, combining multiple sources/subjects/domains; mention optional sources if needed. Avoid multiple queries—consolidate into a single one.
|
|
90
107
|
`.trim();
|
|
91
108
|
|
|
92
|
-
|
|
93
|
-
agent.enableServer(name, description, serve);
|
|
94
|
-
}
|
|
95
|
-
if (input !== '') {
|
|
96
|
-
// Direct input output
|
|
97
|
-
const res = await agent.directCall(input);
|
|
98
|
-
console.log(res);
|
|
99
|
-
} else if(connect) {
|
|
100
|
-
agent.attach('online_agent', description, connect)
|
|
101
|
-
} else {
|
|
102
|
-
agent.startCli(cliIntro);
|
|
103
|
-
}
|
|
109
|
+
await agent.start(serve, connect, cliIntro, "search_agent", description);
|
|
@@ -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.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);
|
|
@@ -0,0 +1,112 @@
|
|
|
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 = 'memory_dave';
|
|
6
|
+
const api = 'xai';
|
|
7
|
+
let secret = '';
|
|
8
|
+
|
|
9
|
+
const args = parseArgs();
|
|
10
|
+
const help = args['help'] || false;
|
|
11
|
+
const connect = args['connect'] ? args['connect'] : undefined;
|
|
12
|
+
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
13
|
+
|
|
14
|
+
/** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
|
|
15
|
+
const options = { tools: [] };
|
|
16
|
+
options.tools.push({ type: 'web_search' });
|
|
17
|
+
|
|
18
|
+
if (args['secret']) {
|
|
19
|
+
secret = args['secret'];
|
|
20
|
+
}
|
|
21
|
+
if (args['model'] || true) {
|
|
22
|
+
options.model = args['model'] || 'grok-4-fast-reasoning';
|
|
23
|
+
}
|
|
24
|
+
if (args['temperature']) {
|
|
25
|
+
options.temperature = parseFloat(args['temperature']);
|
|
26
|
+
}
|
|
27
|
+
if (args['tokens']) {
|
|
28
|
+
options.max_output_tokens = parseInt(args['tokens']);
|
|
29
|
+
}
|
|
30
|
+
if (args['top_p']) {
|
|
31
|
+
options.top_p = parseFloat(args['top_p']);
|
|
32
|
+
}
|
|
33
|
+
options.reasoning = { effort: 'medium', summary: 'auto' };
|
|
34
|
+
|
|
35
|
+
const toolsetMode = 'auto';
|
|
36
|
+
const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
|
|
37
|
+
|
|
38
|
+
function printHelp() {
|
|
39
|
+
console.log(`
|
|
40
|
+
'${name} --help' You are looking at it.
|
|
41
|
+
|
|
42
|
+
Project Memory manager for CodeServer multi-agent setup. Stores/retrieves shared memories in .cache/memory.ndjson (tasks/errors/prefs).
|
|
43
|
+
|
|
44
|
+
OPTIONS: --model ... --temp ... --secret ...
|
|
45
|
+
SERVER: --serve PORT | --connect ws://host:PORT/ws
|
|
46
|
+
`);
|
|
47
|
+
process.exit();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (help) printHelp();
|
|
51
|
+
|
|
52
|
+
const tool_call_description = `
|
|
53
|
+
CodeServer Memory Agent. Manages shared agent memory (.cache/memory.ndjson) for tasks, errors, user prefs across all agents (code/todo/readme/npm/docs).
|
|
54
|
+
Use before/after actions: Recall relevant memories, write updates to avoid loops/repetition.
|
|
55
|
+
Categories: tasks (pending work), errors (failures to avoid), prefs (user settings).
|
|
56
|
+
`.trim();
|
|
57
|
+
|
|
58
|
+
const tool_call_name = 'memory_agent';
|
|
59
|
+
|
|
60
|
+
const prompt = `
|
|
61
|
+
You are MemoryDave, the dedicated memory manager for CodeServer multi-agent setup (code/todo/readme/npm/docs agents).
|
|
62
|
+
|
|
63
|
+
**CORE TOOLS (from lib/genericToolset.js)**:
|
|
64
|
+
- \`memory_recall [query]\`: Retrieve stored memories (tasks/errors/prefs). ALWAYS recall before acting (e.g., "tasks", "errors", "" for recent).
|
|
65
|
+
- \`memory_write {category: "tasks|errors|prefs", content: "details"}\`: Persist info to avoid repetition/loops/token burn.
|
|
66
|
+
|
|
67
|
+
**SHARED STORAGE**: .cache/memory.ndjson in project CWD (all agents share).
|
|
68
|
+
|
|
69
|
+
**ALWAYS**:
|
|
70
|
+
1. **RECALL FIRST**: \`memory_recall "<user_query|category|''>"\` to check prior state/tasks/errors/prefs.
|
|
71
|
+
2. **ACT**: Analyze + decide (write if new info, delegate via server if needed).
|
|
72
|
+
3. **WRITE IF CHANGED**: Use \`memory_write\` for decisions/tasks/errors/prefs (e.g., "Pending: review npm deps", "Error: loop in git", "Pref: low temp for code").
|
|
73
|
+
4. Respond: Summarize memories used/updated + action taken.
|
|
74
|
+
|
|
75
|
+
**USER QUERIES**:
|
|
76
|
+
- "Recall tasks" → List + suggest next.
|
|
77
|
+
- "Store task: Fix auth bug" → Write + confirm.
|
|
78
|
+
- "Clear old errors" → Recall + write cleaned.
|
|
79
|
+
- Coordinate: "Check if code agent has pending tasks" → Recall + advise.
|
|
80
|
+
|
|
81
|
+
Use other tools (bash/read_file) only if needed for context. Focus on memory coordination to boost multi-agent efficiency.
|
|
82
|
+
|
|
83
|
+
Current date: March 27, 2026.
|
|
84
|
+
`.trim();
|
|
85
|
+
|
|
86
|
+
const agent = new AgentManager({ name, secret });
|
|
87
|
+
agent.setup({
|
|
88
|
+
prompt,
|
|
89
|
+
api,
|
|
90
|
+
options,
|
|
91
|
+
toolsetMode,
|
|
92
|
+
contextWindow
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Ensure memory tools are available (auto + explicit for emphasis)
|
|
96
|
+
const toolset = agent.getToolset();
|
|
97
|
+
if (toolset) {
|
|
98
|
+
// Core memory tools (already in 'auto', but explicit)
|
|
99
|
+
agent.addGenericToolcall('memory_recall');
|
|
100
|
+
agent.addGenericToolcall('memory_write');
|
|
101
|
+
// Helpers for inspection
|
|
102
|
+
agent.addGenericToolcall('execute_bash_script');
|
|
103
|
+
agent.addGenericToolcall('read_file');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const cliIntro = `
|
|
107
|
+
🤖 ${name} (${options.model}) ready! Shared CodeServer memory manager (.cache/memory.ndjson).
|
|
108
|
+
- context: ${contextWindow} tokens
|
|
109
|
+
- Recall: "tasks" | Write: "store task: XYZ"
|
|
110
|
+
`.trim();
|
|
111
|
+
|
|
112
|
+
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|