@j-o-r/hello-dave 0.1.0 → 0.1.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 +42 -25
- package/README.md +81 -221
- package/TODO.md +173 -35
- package/agents/agent_creator.js +105 -0
- package/agents/agent_creator.prompt.md +371 -0
- package/agents/ask_agent.js +64 -127
- package/agents/claude_agent.js +68 -0
- package/agents/code_agent.js +55 -135
- package/agents/code_agent.prompt.md +50 -0
- package/agents/echo_agent.js +76 -0
- package/agents/financial_expert.js +75 -0
- package/agents/gpt_agent.js +52 -103
- package/agents/gpt_code.js +81 -0
- package/agents/grok_agent.js +58 -114
- package/agents/minimax_agent.js +92 -0
- package/agents/mureka_agent.js +77 -0
- package/agents/planner_agent.js +172 -0
- package/agents/stability_agent.js +87 -0
- package/agents/test_agent.js +75 -157
- package/agents/weather_agent.js +73 -0
- package/agents/workflow_agent.js +189 -0
- package/bin/dave.js +436 -184
- package/docs/bin-dave.md +85 -35
- package/docs/cdn-ssh.md +100 -0
- package/docs/creating-agents.md +301 -0
- package/docs/creating-toolsets.md +336 -0
- package/docs/docs-organization.md +48 -0
- package/docs/project-overview.md +86 -51
- package/lib/API/elevenlabs.io/music.compose.md +441 -0
- package/lib/API/elevenlabs.io/music.create-composition-plan.md +370 -0
- package/lib/API/elevenlabs.io/music.stream.md +425 -0
- package/lib/API/lalal.ai/lalal.js +445 -0
- package/lib/API/lalal.ai/openapi.json +2614 -0
- package/lib/API/minimax/ImageToolset.js +82 -37
- package/lib/API/minimax/MusicToolset.js +125 -79
- package/lib/API/minimax/VideoToolset.js +170 -167
- package/lib/API/minimax/image.js +5 -1
- package/lib/API/minimax/music.js +210 -23
- package/lib/API/minimax/video.js +242 -53
- package/lib/API/mureka/MusicToolset.js +646 -0
- package/lib/API/mureka/README.md +41 -0
- package/lib/API/mureka/index.js +7 -0
- package/lib/API/mureka/music.js +658 -0
- package/lib/API/openai.com/index.js +7 -0
- package/lib/API/openai.com/{reponses/text.js → responses.js} +64 -18
- package/lib/API/openai.com/video.create.character.md +40 -0
- package/lib/API/openai.com/video.create.md +219 -0
- package/lib/API/openai.com/video.delete.md +44 -0
- package/lib/API/openai.com/video.download.md +31 -0
- package/lib/API/openai.com/video.edit.md +155 -0
- package/lib/API/openai.com/video.extend.md +166 -0
- package/lib/API/openai.com/video.fetch.character.md +43 -0
- package/lib/API/openai.com/video.js +784 -0
- package/lib/API/openai.com/video.list.md +201 -0
- package/lib/API/openai.com/video.remix.md +175 -0
- package/lib/API/openai.com/video.retrieve.md +139 -0
- package/lib/API/openai.com/videoToolset.js +616 -0
- package/lib/API/stability.ai/ImageToolset.js +131 -40
- package/lib/API/stability.ai/MusicToolset.js +79 -47
- package/lib/API/stability.ai/audio.js +63 -131
- package/lib/API/x.ai/chat.responses.md +1040 -0
- package/lib/API/x.ai/image.js +229 -59
- package/lib/API/x.ai/imageToolset.js +376 -0
- package/lib/API/x.ai/index.js +1 -3
- package/lib/API/x.ai/responses.js +9 -18
- package/lib/Agent.js +271 -0
- package/lib/Agent.js.old +284 -0
- package/lib/AgentLauncher.js +562 -0
- package/lib/Cli.js +87 -13
- package/lib/Prompt.js +23 -1
- package/lib/Session.js +5 -4
- package/lib/ToolSet.js +102 -6
- package/lib/agentLoader.js +369 -0
- package/lib/cdn.js +67 -231
- package/lib/{CdnToolset.js → cdnToolset.js} +47 -64
- package/lib/defaultToolsets.js +43 -0
- package/lib/fafs.js +1 -1
- package/lib/genericToolset.js +442 -119
- package/lib/handOffToolset.js +179 -0
- package/lib/index.js +34 -27
- package/lib/toolsetLoader.js +248 -0
- package/package.json +11 -5
- package/types/API/lalal.ai/lalal.d.ts +116 -0
- package/types/API/minimax/image.d.ts +2 -1
- package/types/API/minimax/music.d.ts +189 -26
- package/types/API/minimax/video.d.ts +100 -31
- package/types/API/mureka/index.d.ts +7 -0
- package/types/API/mureka/music.d.ts +472 -0
- package/types/API/openai.com/index.d.ts +7 -0
- package/types/API/openai.com/{reponses/text.d.ts → responses.d.ts} +11 -11
- package/types/API/openai.com/video.d.ts +409 -0
- package/types/API/openai.com/videoToolset.d.ts +24 -0
- package/types/API/stability.ai/audio.d.ts +14 -103
- package/types/API/stability.ai/image.d.ts +2 -2
- package/types/API/x.ai/image.d.ts +138 -26
- package/types/API/x.ai/imageToolset.d.ts +3 -0
- package/types/API/x.ai/index.d.ts +1 -3
- package/types/API/x.ai/responses.d.ts +4 -4
- package/types/Agent.d.ts +123 -0
- package/types/AgentLauncher.d.ts +222 -0
- package/types/Cli.d.ts +28 -8
- package/types/Prompt.d.ts +23 -5
- package/types/Session.d.ts +1 -1
- package/types/ToolSet.d.ts +10 -0
- package/types/agentLoader.d.ts +78 -0
- package/types/cdn.d.ts +15 -90
- package/types/defaultToolsets.d.ts +9 -0
- package/types/fafs.d.ts +1 -1
- package/types/genericToolset.d.ts +1 -1
- package/types/handOffToolset.d.ts +28 -0
- package/types/index.d.ts +19 -16
- package/types/toolsetLoader.d.ts +114 -0
- package/utils/format_log.js +101 -23
- package/utils/launch_agent.js +18 -0
- package/utils/list_sessions.sh +13 -5
- package/utils/search_sessions.sh +65 -29
- package/utils/toolsets.js +33 -0
- package/README.md.bak.1779452127 +0 -240
- package/agents/codeserver.sh +0 -47
- package/agents/daisy_agent.js +0 -173
- package/agents/docs_agent.js +0 -148
- package/agents/memory_agent.js +0 -263
- package/agents/minimax.js +0 -173
- package/agents/npm_agent.js +0 -202
- package/agents/prompt_agent.js +0 -133
- package/agents/readme_agent.js +0 -148
- package/agents/spawn_agent.js +0 -160
- package/agents/stability.js +0 -173
- package/agents/todo_agent.js +0 -175
- package/bin/codeDave +0 -58
- package/docs/agent-dave-websocket-protocol.md +0 -180
- package/docs/agent-manager.md +0 -244
- package/docs/codeserver-pattern.md +0 -191
- package/docs/generic-toolset.md +0 -326
- package/docs/howtos/agent-networking.md +0 -253
- package/docs/howtos/spawn-agents.md.bak +0 -200
- package/docs/howtos/spawn-agents.md.bak_new +0 -200
- package/docs/multi-agent-clusters.md +0 -265
- package/docs/music-toolsets.md +0 -137
- package/docs/path-resolution-best-practices.md +0 -104
- package/docs/plans/minimax-music-generation.md +0 -80
- package/docs/plans/unified-agent-architecture.md +0 -146
- package/docs/plans/websocket-streaming-plan.md.bak +0 -317
- package/docs/prompt/spawn_agent.md +0 -175
- package/docs/prompt/spawn_agent.md.bak +0 -201
- package/docs/prompt/task_clarification_and_documentation.md +0 -35
- package/docs/prompt-class.md +0 -141
- package/docs/todo-archive-infra-2026-04-21.md +0 -15
- package/docs/todo-archive-v0.0.8.md +0 -1
- package/docs/todo-archive-v0.1.0.md +0 -32
- package/docs/todo-archive.md +0 -44
- package/docs/tools-syntax-validation.md +0 -121
- package/docs/toolset.md +0 -164
- package/docs/xai-responses.md +0 -111
- package/docs/xai_collections.md +0 -106
- package/lib/API/x.ai/ImageToolset.js +0 -165
- package/lib/API/x.ai/text.js +0 -415
- package/lib/AgentClient.js +0 -248
- package/lib/AgentManager.js +0 -245
- package/lib/AgentServer.js +0 -404
- package/lib/wsCli.js +0 -287
- package/lib/wsIO.js +0 -90
- package/types/API/x.ai/text.d.ts +0 -286
- package/types/AgentClient.d.ts +0 -109
- package/types/AgentManager.d.ts +0 -100
- package/types/AgentServer.d.ts +0 -89
- package/types/wsCli.d.ts +0 -17
- package/types/wsIO.d.ts +0 -30
- package/utils/test.sh +0 -46
- /package/docs/{suggestions.md → _notes/token-counts.md} +0 -0
- /package/lib/API/openai.com/{reponses/MESSAGES.md → MESSAGES.md} +0 -0
- /package/types/API/{x.ai/ImageToolset.d.ts → mureka/MusicToolset.d.ts} +0 -0
- /package/types/{CdnToolset.d.ts → cdnToolset.d.ts} +0 -0
package/agents/daisy_agent.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { AgentManager, API, CdnToolset } from '@j-o-r/hello-dave';
|
|
3
|
-
import * as test from '@j-o-r/hello-dave';
|
|
4
|
-
import { parseArgs } from '@j-o-r/sh';
|
|
5
|
-
|
|
6
|
-
const name = 'daisy_agent';
|
|
7
|
-
const api = 'xai';
|
|
8
|
-
let secret = '';
|
|
9
|
-
|
|
10
|
-
const args = parseArgs();
|
|
11
|
-
|
|
12
|
-
let input;
|
|
13
|
-
if (args._.length === 1 && typeof args._[0] === 'string' && args._[0].trim() !== '') {
|
|
14
|
-
input = args._[0].trim();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const help = args['help'] || false;
|
|
18
|
-
const connect = args['connect'] ? args['connect'] : undefined;
|
|
19
|
-
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
20
|
-
|
|
21
|
-
/** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
|
|
22
|
-
const options = { tools: [] };
|
|
23
|
-
options.tools.push({
|
|
24
|
-
type: 'web_search'
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
if (args['secret']) {
|
|
28
|
-
secret = args['secret'];
|
|
29
|
-
}
|
|
30
|
-
if (args['model'] || true) {
|
|
31
|
-
options.model = args['model'] || 'grok-4-fast-reasoning';
|
|
32
|
-
}
|
|
33
|
-
if (args['temperature']) {
|
|
34
|
-
options.temperature = parseFloat(args['temperature']);
|
|
35
|
-
} else {
|
|
36
|
-
options.temperature = 0.8;
|
|
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;
|
|
45
|
-
if (reasoning) {
|
|
46
|
-
options.reasoning = {
|
|
47
|
-
effort: 'medium',
|
|
48
|
-
summary: 'auto'
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const toolsetMode = 'auto';
|
|
52
|
-
const contextWindow = args['context'] ? parseInt(args['context']) : 1900000;
|
|
53
|
-
|
|
54
|
-
function printHelp() {
|
|
55
|
-
console.log(`
|
|
56
|
-
'${name} --help' You are looking at it.
|
|
57
|
-
|
|
58
|
-
## USAGE MODES:
|
|
59
|
-
|
|
60
|
-
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
61
|
-
./agents/${name}.js "Generate lyrics for pop song" [--options]
|
|
62
|
-
|
|
63
|
-
### 2. Interactive CLI (no positional arg):
|
|
64
|
-
./agents/${name}.js [--options]
|
|
65
|
-
|
|
66
|
-
### 3. WS Server (no positional arg):
|
|
67
|
-
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
68
|
-
|
|
69
|
-
### 4. WS Client (no positional arg):
|
|
70
|
-
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
71
|
-
|
|
72
|
-
### 5. Hybrid (Server + Client, no positional arg):
|
|
73
|
-
./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
74
|
-
|
|
75
|
-
## SERVER OPTIONS EXPLAINED:
|
|
76
|
-
--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.
|
|
77
|
-
|
|
78
|
-
--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.
|
|
79
|
-
|
|
80
|
-
--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.
|
|
81
|
-
|
|
82
|
-
Note: Server/Client/Hybrid IGNORES positional input arg (use CLI modes instead). Hybrid: This agent serves AND uses remote tools.
|
|
83
|
-
|
|
84
|
-
## OPTIONS:
|
|
85
|
-
--model [grok-4-fast-reasoning|...] (default: grok-4-fast-reasoning)
|
|
86
|
-
--temperature [float] (-2 to +2, default 0.8 for creativity)
|
|
87
|
-
--tokens [number] (max output tokens)
|
|
88
|
-
--top_p [float]
|
|
89
|
-
--context [number] (default: 1900000)
|
|
90
|
-
|
|
91
|
-
## SERVER TOOLS (when no input):
|
|
92
|
-
Exposes as 'daisy_agent' tool for chaining.
|
|
93
|
-
`);
|
|
94
|
-
process.exit();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (help) {
|
|
98
|
-
printHelp();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const tool_call_name = 'daisy_agent';
|
|
102
|
-
const tool_call_description = `
|
|
103
|
-
Daisy Music Assistant:
|
|
104
|
-
- "Lyrics for [theme]" → Generate lyrics.
|
|
105
|
-
- "Music minimax prompt: [style]" → Optimized prompt.
|
|
106
|
-
- "ffmpeg [task] on file.wav" → Bash script to run.
|
|
107
|
-
- web_search: Research chords/lyrics.
|
|
108
|
-
- execute_bash_script: Processes your local files safely.
|
|
109
|
-
- Create music
|
|
110
|
-
`.trim();
|
|
111
|
-
|
|
112
|
-
const prompt = `
|
|
113
|
-
You are ${name}, a helpful music creation and editing assistant for the user's computer.
|
|
114
|
-
|
|
115
|
-
Core expertise:
|
|
116
|
-
- Generate lyrics: Creative, structured (verses, chorus), themed, rhyming.
|
|
117
|
-
- niMAx 2.6 AI prompts: Detailed, vivid descriptions (genre, mood, instruments, structure, vocals).
|
|
118
|
-
- Local audio editing: Use execute_bash_script with ffmpeg/sox commands. Provide exact bash snippets first, confirm before running. Examples:
|
|
119
|
-
* Trim: ffmpeg -i input.mp3 -ss 00:00:30 -t 00:01:00 output.mp3
|
|
120
|
-
* Concat: echo "file 'a.mp3'" > list.txt; ffmpeg -f concat -i list.txt out.mp3
|
|
121
|
-
* Sox effects: sox input.wav output.wav fade 0 3 2 norm
|
|
122
|
-
* Convert: ffmpeg -i video.mp4 audio.aac
|
|
123
|
-
- Music theory: Chords, scales, BPM, EQ tips.
|
|
124
|
-
- Workflows: Step-by-step for mixing, mastering, layering tracks.
|
|
125
|
-
|
|
126
|
-
Behavior:
|
|
127
|
-
- Be creative & enthusiastic!
|
|
128
|
-
- Step-by-step: Explain, provide code, suggest files in current dir.
|
|
129
|
-
- Safety: Quote bash commands; ask confirmation for destructive ops (e.g., overwrite).
|
|
130
|
-
- Use web_search for inspiration/lyrics if needed.
|
|
131
|
-
- Output ready-to-copy bash for ffmpeg/sox.
|
|
132
|
-
- List files if unclear: Use ls *.wav *.mp3 etc. via bash.
|
|
133
|
-
|
|
134
|
-
Current env: Ubuntu, ffmpeg & sox installed
|
|
135
|
-
|
|
136
|
-
Respond concisely but completely. Use markdown for code/lyrics/prompts.
|
|
137
|
-
`.trim();
|
|
138
|
-
|
|
139
|
-
const agent = new AgentManager({ name, secret });
|
|
140
|
-
agent.setup({
|
|
141
|
-
prompt,
|
|
142
|
-
api,
|
|
143
|
-
options,
|
|
144
|
-
toolsetMode,
|
|
145
|
-
contextWindow
|
|
146
|
-
});
|
|
147
|
-
const toolset = agent.getToolset();
|
|
148
|
-
toolset?.borrow(API.minimax.musicToolset);
|
|
149
|
-
toolset?.borrow(CdnToolset);
|
|
150
|
-
if (toolset) {
|
|
151
|
-
agent.addGenericToolcall('open_link');
|
|
152
|
-
agent.addGenericToolcall('execute_bash_script');
|
|
153
|
-
agent.addGenericToolcall('read_file');
|
|
154
|
-
agent.addGenericToolcall('write_file');
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const cliIntro = `
|
|
158
|
-
${name} ${options.model} ready! (temp: ${options.temperature}, context: ${contextWindow})
|
|
159
|
-
|
|
160
|
-
Ask me to:
|
|
161
|
-
- Write lyrics
|
|
162
|
-
- Craft Music prompts
|
|
163
|
-
- Edit audio: "fade out my track.mp3" → I'll give ffmpeg cmd
|
|
164
|
-
Type /help for more.
|
|
165
|
-
${tool_call_name}
|
|
166
|
-
`.trim();
|
|
167
|
-
|
|
168
|
-
if (input) {
|
|
169
|
-
const RES = await agent.directCall(input);
|
|
170
|
-
console.log(RES);
|
|
171
|
-
} else {
|
|
172
|
-
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|
|
173
|
-
}
|
package/agents/docs_agent.js
DELETED
|
@@ -1,148 +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_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
|
-
./agents/${name}.js "Create a doc on Node.js basics" [--options]
|
|
58
|
-
|
|
59
|
-
### 2. Interactive CLI (no positional arg):
|
|
60
|
-
./agents/${name}.js [--options]
|
|
61
|
-
|
|
62
|
-
### 3. WS Server (no positional arg):
|
|
63
|
-
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
64
|
-
|
|
65
|
-
### 4. WS Client (no positional arg):
|
|
66
|
-
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
67
|
-
|
|
68
|
-
### 5. Hybrid (Server + Client, no positional arg):
|
|
69
|
-
./agents/${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
|
-
}
|
package/agents/memory_agent.js
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { AgentManager } from '@j-o-r/hello-dave';
|
|
3
|
-
import { parseArgs, SH } from '@j-o-r/sh';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { promises as fs } from 'node:fs';
|
|
6
|
-
|
|
7
|
-
const name = 'memory_agent';
|
|
8
|
-
const api = 'xai';
|
|
9
|
-
let secret = '';
|
|
10
|
-
|
|
11
|
-
const args = parseArgs();
|
|
12
|
-
|
|
13
|
-
let input; // Directcall input (positional ONLY - NO pipe)
|
|
14
|
-
if (args._.length === 1 && typeof args._[0] === 'string' && args._[0].trim() !== '') {
|
|
15
|
-
input = args._[0].trim();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const help = args['help'] || false;
|
|
19
|
-
const connect = args['connect'] ? args['connect'] : undefined;
|
|
20
|
-
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
21
|
-
|
|
22
|
-
/** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
|
|
23
|
-
const options = { tools: [] };
|
|
24
|
-
options.tools.push({
|
|
25
|
-
type: 'web_search'
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
if (args['secret']) {
|
|
29
|
-
secret = args['secret'];
|
|
30
|
-
}
|
|
31
|
-
if (args['model'] || true) {
|
|
32
|
-
options.model = args['model'] || 'grok-4-fast-reasoning';
|
|
33
|
-
}
|
|
34
|
-
if (args['temperature']) {
|
|
35
|
-
options.temperature = parseFloat(args['temperature']);
|
|
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']) : 250000;
|
|
52
|
-
|
|
53
|
-
function printHelp() {
|
|
54
|
-
console.log(`'${name} --help' You are looking at it.
|
|
55
|
-
|
|
56
|
-
## USAGE MODES:
|
|
57
|
-
|
|
58
|
-
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
59
|
-
./agents/${name}.js "Recall tasks" [--options]
|
|
60
|
-
|
|
61
|
-
### 2. Interactive CLI (no positional arg):
|
|
62
|
-
./agents/${name}.js [--options]
|
|
63
|
-
|
|
64
|
-
### 3. WS Server (no positional arg):
|
|
65
|
-
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
66
|
-
|
|
67
|
-
### 4. WS Client (no positional arg):
|
|
68
|
-
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
69
|
-
|
|
70
|
-
### 5. Hybrid (Server + Client, no positional arg):
|
|
71
|
-
./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
72
|
-
|
|
73
|
-
## SERVER OPTIONS EXPLAINED:
|
|
74
|
-
--serve [port]: Starts WebSocket SERVER at ws://127.0.0.1:[port]/ws. Allows other agents (--connect) to connect and use this agent as a remote TOOL (e.g., 'memory_agent'). Runs indefinitely until Ctrl+C.
|
|
75
|
-
|
|
76
|
-
--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.
|
|
77
|
-
|
|
78
|
-
--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.
|
|
79
|
-
|
|
80
|
-
Note: Server/Client/Hybrid IGNORES positional input arg (use CLI modes instead). Hybrid: This agent serves AND uses remote tools.
|
|
81
|
-
|
|
82
|
-
## OPTIONS:
|
|
83
|
-
--model [grok-4-fast-reasoning|...] (default: grok-4-fast-reasoning)
|
|
84
|
-
--temperature [float] (-2 to +2)
|
|
85
|
-
--tokens [number] (max output tokens)
|
|
86
|
-
--top_p [float]
|
|
87
|
-
--context [number] (default: 250000)
|
|
88
|
-
|
|
89
|
-
## SERVER TOOLS (when no input):
|
|
90
|
-
Exposes as 'memory_agent' tool for chaining.
|
|
91
|
-
`);
|
|
92
|
-
process.exit();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (help) {
|
|
96
|
-
printHelp();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const tool_call_name = 'memory_agent';
|
|
100
|
-
const tool_call_description = `Standalone Memory Agent. Manages shared agent memory (.cache/memory.ndjson) for tasks, errors, user prefs across agents or standalone use.
|
|
101
|
-
Use before/after actions: Recall relevant memories, write updates to avoid loops/repetition.
|
|
102
|
-
Categories: tasks (pending work), errors (failures to avoid), prefs (user settings).
|
|
103
|
-
Usable standalone, by users/agents via function calls or WebSocket connect. Responses handover to querying agent/user.`.trim();
|
|
104
|
-
|
|
105
|
-
const prompt = `**CRITICAL: STRICT NO-CODING RULE** - Stick to memory coordination ONLY. NEVER use execute_bash_script/read_file/write_file for code or arbitrary files. Decline coding: "Use code_agent for code. I manage memory."
|
|
106
|
-
|
|
107
|
-
You are MemoryAgent, a standalone memory manager usable by users, other agents, or as a sub-agent via function calls or WebSocket connect. Any response handovers the result to the querying agent or human user.
|
|
108
|
-
|
|
109
|
-
**CORE TOOLS (local self-contained)**:
|
|
110
|
-
- \`memory_recall [query]\`: Retrieve stored memories (tasks/errors/prefs). ALWAYS recall before acting (e.g., "tasks", "errors", "" for recent).
|
|
111
|
-
- \`memory_write {category: "tasks|errors|prefs", content: "details"}\`: Persist info to avoid repetition/loops/token burn.
|
|
112
|
-
- \`optimize_memory\`: Optimize .cache/memory.ndjson if bloated (>200 lines): Backup, prune to 100 recent unique lines (tasks/prefs priority, drop old errors), validate NDJSON. Call periodically or on heavy recalls.
|
|
113
|
-
|
|
114
|
-
**SHARED STORAGE**: .cache/memory.ndjson in project CWD (all agents share).
|
|
115
|
-
|
|
116
|
-
**ALWAYS**:
|
|
117
|
-
1. **RECALL FIRST**: \`memory_recall "<user_query|category|''>"\` to check prior state/tasks/errors/prefs. Auto-optimize if >200 lines.
|
|
118
|
-
2. **ACT**: Analyze + decide (write if new info).
|
|
119
|
-
3. **WRITE IF CHANGED**: Use \`memory_write\` for decisions/tasks/errors/prefs.
|
|
120
|
-
4. Respond: Summarize memories used/updated + action taken.
|
|
121
|
-
|
|
122
|
-
**USER QUERIES** (handle naturally, use tools):
|
|
123
|
-
- "Recall tasks" → List + suggest next.
|
|
124
|
-
- "Store task: Fix auth bug" → Parse + memory_write.
|
|
125
|
-
- "Clear old errors" → Recall + optimize.
|
|
126
|
-
- Coordinate: "Check if code agent has pending tasks" → Recall + advise.
|
|
127
|
-
|
|
128
|
-
Current date: April 03, 2026.`.trim();
|
|
129
|
-
|
|
130
|
-
const agent = new AgentManager({ name, secret });
|
|
131
|
-
agent.setup({
|
|
132
|
-
prompt,
|
|
133
|
-
api,
|
|
134
|
-
options,
|
|
135
|
-
toolsetMode,
|
|
136
|
-
contextWindow
|
|
137
|
-
});
|
|
138
|
-
const toolset = agent.getToolset();
|
|
139
|
-
|
|
140
|
-
// Self-contained local memory tools (copied from genericToolset.js)
|
|
141
|
-
const memoryPath = path.join(process.cwd(), '.cache', 'memory.ndjson');
|
|
142
|
-
|
|
143
|
-
toolset.add(
|
|
144
|
-
'memory_recall',
|
|
145
|
-
`Retrieve stored agent memories (tasks, errors, prefs) from .cache/memory.ndjson in CWD. Use before acting to check prior decisions/tasks/errors/prefs. Query by keyword or category; empty lists recent.`,
|
|
146
|
-
{
|
|
147
|
-
type: 'object',
|
|
148
|
-
properties: {
|
|
149
|
-
query: {
|
|
150
|
-
type: 'string',
|
|
151
|
-
description: 'Keyword, category (tasks/errors/prefs), or phrase to filter (case-insensitive). Empty/omit lists last 20.'
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
required: []
|
|
155
|
-
},
|
|
156
|
-
async (params = {}) => {
|
|
157
|
-
let content;
|
|
158
|
-
try {
|
|
159
|
-
content = await fs.readFile(memoryPath, 'utf8');
|
|
160
|
-
} catch (e) {
|
|
161
|
-
return 'No memories stored yet. Use memory_write first.';
|
|
162
|
-
}
|
|
163
|
-
const lines = content.trim().split('\n').filter(l => l.trim());
|
|
164
|
-
const memories = [];
|
|
165
|
-
for (const line of lines) {
|
|
166
|
-
try {
|
|
167
|
-
memories.push(JSON.parse(line));
|
|
168
|
-
} catch {
|
|
169
|
-
// Skip invalid lines
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (!params.query || !params.query.toString().trim()) {
|
|
173
|
-
const recent = memories.slice(-20).reverse();
|
|
174
|
-
return recent.length
|
|
175
|
-
? 'Recent memories:\n' + recent.map(m => `• ${m.timestamp.slice(0, 19).replace('T', ' ')} [${m.category}] ${m.content}`).join('\n')
|
|
176
|
-
: 'No memories stored.';
|
|
177
|
-
}
|
|
178
|
-
const q = params.query.toString().toLowerCase();
|
|
179
|
-
const matches = memories.filter(m =>
|
|
180
|
-
m.category.toLowerCase().includes(q) || m.content.toLowerCase().includes(q)
|
|
181
|
-
);
|
|
182
|
-
return matches.length
|
|
183
|
-
? `Matches for "${params.query}":\n` + matches.slice(0, 20).map(m => `• ${m.timestamp.slice(0, 19).replace('T', ' ')} [${m.category}] ${m.content}`).join('\n')
|
|
184
|
-
: `No memories match "${params.query}".`;
|
|
185
|
-
}
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
toolset.add(
|
|
189
|
-
'memory_write',
|
|
190
|
-
`Persist agent memory for tasks, errors, or user preferences to .cache/memory.ndjson in CWD. Use to store decisions, tasks, errors, or prefs for later recall. Agent should use this to avoid repeating work or token burn on loops.`,
|
|
191
|
-
{
|
|
192
|
-
type: 'object',
|
|
193
|
-
properties: {
|
|
194
|
-
category: {
|
|
195
|
-
type: 'string',
|
|
196
|
-
enum: ['tasks', 'errors', 'prefs'],
|
|
197
|
-
description: 'Category: one of "tasks", "errors", "prefs"'
|
|
198
|
-
},
|
|
199
|
-
content: {
|
|
200
|
-
type: 'string',
|
|
201
|
-
description: 'Detailed content (e.g., "Pending task: implement runWithMemory optimization", "Error: loop burning tokens", "Pref: temperature=0.2 for decisions")'
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
required: ['category', 'content']
|
|
205
|
-
},
|
|
206
|
-
async ({ category, content }) => {
|
|
207
|
-
if (!['tasks', 'errors', 'prefs'].includes(category)) {
|
|
208
|
-
throw new Error(`Invalid category '${category}'. Must be 'tasks', 'errors', or 'prefs'.`);
|
|
209
|
-
}
|
|
210
|
-
const dir = path.dirname(memoryPath);
|
|
211
|
-
try {
|
|
212
|
-
await fs.mkdir(dir, { recursive: true });
|
|
213
|
-
} catch (e) {
|
|
214
|
-
// Dir likely exists
|
|
215
|
-
}
|
|
216
|
-
const entry = {
|
|
217
|
-
timestamp: new Date().toISOString(),
|
|
218
|
-
category,
|
|
219
|
-
content: content.trim()
|
|
220
|
-
};
|
|
221
|
-
await fs.appendFile(memoryPath, JSON.stringify(entry) + '\n', 'utf8');
|
|
222
|
-
return `✓ Memory stored: [${category}] ${content.length > 50 ? content.slice(0, 47) + '...' : content}`;
|
|
223
|
-
}
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
// optimize_memory tool
|
|
227
|
-
toolset.add(
|
|
228
|
-
'memory_optimize',
|
|
229
|
-
'Optimize .cache/memory.ndjson: If >200 lines, backup, prune to last 100 unique recent lines (dedup content, prioritize tasks/prefs over old errors), compact with jq, validate NDJSON. Returns status/prune summary.',
|
|
230
|
-
{ type: 'object', properties: {} },
|
|
231
|
-
async () => {
|
|
232
|
-
let content = '';
|
|
233
|
-
try {
|
|
234
|
-
content = (await SH`cat .cache/memory.ndjson 2>/dev/null || echo ''`.run()).trim();
|
|
235
|
-
} catch (e) {
|
|
236
|
-
return 'No memory file found yet. Optimal (0 lines).';
|
|
237
|
-
}
|
|
238
|
-
const lines = content.split('\n').filter(l => l.trim()).length;
|
|
239
|
-
if (lines <= 200) {
|
|
240
|
-
return `Optimal: ${lines} lines. No action needed.`;
|
|
241
|
-
}
|
|
242
|
-
const timestamp = Date.now();
|
|
243
|
-
const backup = `.cache/memory.ndjson.bak-${timestamp}`;
|
|
244
|
-
const pruneCmd = `mkdir -p .cache && cp .cache/memory.ndjson ${backup} && tail -n 100 .cache/memory.ndjson | awk '!seen[$0]++' | jq -c . > .cache/memory.ndjson.tmp && mv .cache/memory.ndjson.tmp .cache/memory.ndjson && POST_LINES=$(wc -l < .cache/memory.ndjson | cut -d' ' -f1) && echo "Pruned ${lines}→$POST_LINES lines. Backup: ${backup}. Valid: $(cat .cache/memory.ndjson | jq empty >/dev/null 2>&1 && echo OK || echo FAIL)"`;
|
|
245
|
-
try {
|
|
246
|
-
const result = await SH`${pruneCmd}`.run();
|
|
247
|
-
return result.trim();
|
|
248
|
-
} catch (e) {
|
|
249
|
-
return `Prune failed: ${e.message}`;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
);
|
|
253
|
-
|
|
254
|
-
const cliIntro = `${name} ${options.model}.
|
|
255
|
-
- context: ${contextWindow}. Shared memory manager ready (self-contained local tools).
|
|
256
|
-
${tool_call_name}`.trim();
|
|
257
|
-
|
|
258
|
-
if (input) {
|
|
259
|
-
const RES = await agent.directCall(input);
|
|
260
|
-
console.log(RES);
|
|
261
|
-
} else {
|
|
262
|
-
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|
|
263
|
-
}
|