@j-o-r/hello-dave 0.0.5 → 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.
Files changed (127) hide show
  1. package/CHANGELOG.md +13 -26
  2. package/README.md +161 -522
  3. package/README.md.bak +144 -449
  4. package/{examples → agents}/ask_agent.js +5 -5
  5. package/{examples → agents}/codeserver.sh +14 -14
  6. package/{examples → agents}/daisy_agent.js +5 -5
  7. package/{examples → agents}/docs_agent.js +5 -5
  8. package/{examples → agents}/gpt_agent.js +5 -5
  9. package/{examples → agents}/grok_agent.js +5 -5
  10. package/agents/memory_agent.js +263 -0
  11. package/{examples → agents}/npm_agent.js +5 -5
  12. package/{examples → agents}/prompt_agent.js +5 -5
  13. package/agents/spawn_agent.js +137 -0
  14. package/{examples → agents}/test_agent.js +6 -8
  15. package/{examples → agents}/todo_agent.js +5 -5
  16. package/bin/codeDave +58 -0
  17. package/bin/dave.js +114 -96
  18. package/lib/AgentClient.js +111 -67
  19. package/lib/AgentManager.js +111 -80
  20. package/lib/AgentServer.js +144 -104
  21. package/lib/Cli.js +126 -93
  22. package/lib/Prompt.js +38 -5
  23. package/lib/Session.js +102 -79
  24. package/lib/ToolSet.js +79 -60
  25. package/lib/fafs.js +54 -19
  26. package/lib/genericToolset.js +109 -213
  27. package/lib/wsCli.js +50 -19
  28. package/lib/wsIO.js +11 -17
  29. package/package.json +2 -2
  30. package/types/AgentClient.d.ts +69 -35
  31. package/types/AgentManager.d.ts +50 -56
  32. package/types/AgentServer.d.ts +63 -16
  33. package/types/Cli.d.ts +56 -10
  34. package/types/Prompt.d.ts +36 -4
  35. package/types/Session.d.ts +23 -9
  36. package/types/ToolSet.d.ts +49 -32
  37. package/types/fafs.d.ts +68 -25
  38. package/types/wsCli.d.ts +14 -0
  39. package/types/wsIO.d.ts +9 -5
  40. package/utils/search_sessions.sh +100 -53
  41. package/README.md.backup +0 -269
  42. package/README.md.bak.1774780058 +0 -338
  43. package/README.md.bak2 +0 -531
  44. package/bin/spawn_agent.js +0 -293
  45. package/docs.bak.1774780058/agent-manager.md +0 -167
  46. package/docs.bak.1774780058/agent-manager.md.bak +0 -137
  47. package/docs.bak.1774780058/agent-manager.md.bak2 +0 -157
  48. package/docs.bak.1774780058/codeserver-pattern.md +0 -191
  49. package/docs.bak.1774780058/path-resolution-best-practices.md +0 -104
  50. package/docs.bak.1774780058/project-overview.md +0 -67
  51. package/docs.bak.1774780058/project-overview.md.bak +0 -67
  52. package/docs.bak.1774780058/prompt-class.md +0 -141
  53. package/docs.bak.1774780058/prompt-class.md.bak +0 -142
  54. package/docs.bak.1774780058/tools-syntax-validation.md +0 -121
  55. package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +0 -125
  56. package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +0 -125
  57. package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +0 -106
  58. package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +0 -106
  59. package/docs.bak.1774780058/toolset.md +0 -164
  60. package/docs.bak.1774780058/toolset.md.bak +0 -94
  61. package/docs.bak.1774780058/toolset.md.bak3 +0 -161
  62. package/docs.bak.1774780058/toolset.md.bak4 +0 -161
  63. package/docs.bak.1774780058/toolset.md.bak5 +0 -161
  64. package/docs.bak.1774780058/toolset.md.bak6 +0 -163
  65. package/docs.bak.1774780058/toolset.md.bak_path +0 -163
  66. package/docs.bak.1774780058/toolset.md.bak_syntax +0 -161
  67. package/docs.bak.1774780058/xai-responses.md +0 -111
  68. package/docs.bak.1774780058/xai-responses.md.bak +0 -107
  69. package/docs.bak.1774780058/xai-responses.md.bak2 +0 -107
  70. package/docs.bak.1774780058/xai_collections.md +0 -106
  71. package/examples/memory_agent.js +0 -152
  72. package/examples.bak.1774780058/ask_agent.js +0 -114
  73. package/examples.bak.1774780058/code_agent.js +0 -149
  74. package/examples.bak.1774780058/coderev_agent.js +0 -72
  75. package/examples.bak.1774780058/codeserver.sh +0 -47
  76. package/examples.bak.1774780058/daisy_agent.js +0 -177
  77. package/examples.bak.1774780058/docs_agent.js +0 -119
  78. package/examples.bak.1774780058/gpt_agent.js +0 -109
  79. package/examples.bak.1774780058/grok_agent.js +0 -98
  80. package/examples.bak.1774780058/memory_agent.js +0 -112
  81. package/examples.bak.1774780058/npm_agent.js +0 -175
  82. package/examples.bak.1774780058/prompt_agent.js +0 -112
  83. package/examples.bak.1774780058/readme_agent.js +0 -144
  84. package/examples.bak.1774780058/spawn_agent.js +0 -263
  85. package/examples.bak.1774780058/test_agent.js +0 -162
  86. package/examples.bak.1774780058/todo_agent.js +0 -138
  87. package/lib/genericToolset.js.bak_syntax +0 -402
  88. package/scenarios.bak.1774780058/data/eval_node_message.json +0 -9
  89. package/scenarios.bak.1774780058/data/hist_oa.json +0 -66
  90. package/scenarios.bak.1774780058/data/o3_response1.json +0 -96
  91. package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +0 -112
  92. package/scenarios.bak.1774780058/data/tool_oa.json +0 -96
  93. package/scenarios.bak.1774780058/data/tool_xai.json +0 -59
  94. package/scenarios.bak.1774780058/data/tool_xai2.json +0 -40
  95. package/scenarios.bak.1774780058/data/xai-response-1.json +0 -59
  96. package/scenarios.bak.1774780058/data/xai-response-2.json +0 -10
  97. package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +0 -59
  98. package/scenarios.bak.1774780058/data/xai_search_response.json +0 -58
  99. package/scenarios.bak.1774780058/environment.js +0 -10
  100. package/scenarios.bak.1774780058/example.js +0 -17
  101. package/scenarios.bak.1774780058/genericToolset.test.js +0 -182
  102. package/scenarios.bak.1774780058/grok.js +0 -113
  103. package/scenarios.bak.1774780058/memory-tools.js +0 -51
  104. package/scenarios.bak.1774780058/openai-o3.js +0 -137
  105. package/scenarios.bak.1774780058/openai-prompt.js +0 -155
  106. package/scenarios.bak.1774780058/openai-session.js +0 -148
  107. package/scenarios.bak.1774780058/openai.js +0 -102
  108. package/scenarios.bak.1774780058/prompt.js +0 -118
  109. package/scenarios.bak.1774780058/promptFishbowl.js +0 -76
  110. package/scenarios.bak.1774780058/search.brave.com.js +0 -25
  111. package/scenarios.bak.1774780058/sh.js +0 -15
  112. package/scenarios.bak.1774780058/test-wsio.js +0 -26
  113. package/scenarios.bak.1774780058/testToolset.js +0 -42
  114. package/scenarios.bak.1774780058/toolset.js +0 -16
  115. package/scenarios.bak.1774780058/toolset.test.js +0 -141
  116. package/scenarios.bak.1774780058/write_file_syntax.test.js +0 -145
  117. package/scenarios.bak.1774780058/write_file_validation/README.md +0 -30
  118. package/scenarios.bak.1774780058/write_file_validation/bad.js +0 -3
  119. package/scenarios.bak.1774780058/write_file_validation/good.js +0 -4
  120. package/scenarios.bak.1774780058/write_file_validation/test.sh +0 -43
  121. package/scenarios.bak.1774780058/wsClient.js +0 -69
  122. package/scenarios.bak.1774780058/xai_responses.integration.test.js +0 -57
  123. package/scenarios.bak.1774780058/xai_responses.test.js +0 -154
  124. package/scenarios.bak.1774780058/xaicoll.js +0 -50
  125. package/scenarios.bak.1774780058/xaifiles.js +0 -48
  126. /package/{examples → agents}/code_agent.js +0 -0
  127. /package/{examples → agents}/readme_agent.js +0 -0
@@ -1,177 +0,0 @@
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);
@@ -1,119 +0,0 @@
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,109 +0,0 @@
1
- #!/usr/bin/env node
2
- import { AgentManager } from '@j-o-r/hello-dave';
3
- import { parseArgs, readIn } from '@j-o-r/sh';
4
-
5
- const name = 'chat_gpt';
6
- const api = 'gpt';
7
- let secret = '';
8
-
9
- // const input = await readIn();
10
- const args = parseArgs();
11
- const help = args['help'] || false;
12
- const connect = args['connect'] ? args['connect'] : undefined;
13
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
14
-
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
- }
25
- // Set properties only if provided via command line (except model which has default)
26
- if (args['model'] || true) { // model gets default value
27
- options.model = args['model'] || 'gpt-5.4';
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
- const reasoning = true // args['reasoning'] ? args['reasoning'] : null;
39
- if (reasoning) {
40
- options.reasoning = {
41
- effort: 'medium',
42
- summary: 'auto'
43
- }
44
- }
45
- // Large context on grok-4-fast
46
- const contextWindow = args['context'] ? parseInt(args['context']) : 100000;
47
- const toolsetMode = 'auto';
48
-
49
- function printHelp() {
50
- console.log(`
51
- '${name} --help' You are looking at it.
52
- '
53
- OPTIONS:
54
- --tokens [number]: max generated tokens
55
- --context [number] : truncate message history to context-windows size default 130000
56
- --temperature [float] : -2 / +2
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']
58
- --top_p [float]: number > 0, 0.1 means no top_p
59
- --reasoning [low|high]
60
- --tools [javascript,bash] comma seperated list
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
66
-
67
- `);
68
- process.exit()
69
- }
70
- if (help) {
71
- printHelp();
72
- }
73
-
74
- const prompt = `
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.
76
- `.trim();
77
-
78
- const agent = new AgentManager({ name, secret });
79
- agent.setup({
80
- prompt,
81
- api,
82
- options,
83
- toolsetMode,
84
- contextWindow
85
- });
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
- // }
100
- const cliIntro = `
101
- ${name} ${options.model}.
102
- - context: ${contextWindow}
103
- `.trim();
104
- const description = `
105
- Guide for this smart online AI Agent:
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.
107
- `.trim();
108
-
109
- await agent.start(serve, connect, cliIntro, "search_agent", description);
@@ -1,98 +0,0 @@
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);
@@ -1,112 +0,0 @@
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);