@j-o-r/hello-dave 0.1.1 → 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 -1
- 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 -1
- 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 -17
- 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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agents/stability_agent.js
|
|
3
|
+
*
|
|
4
|
+
* Stability Music Assistant.
|
|
5
|
+
* Designed to be loaded via utils/launch_agent.js + AgentLauncher.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* node utils/launch_agent.js stability_agent
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { API, Agent } from '@j-o-r/hello-dave';
|
|
12
|
+
|
|
13
|
+
/** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses').XAIOptions} */
|
|
14
|
+
const options = {
|
|
15
|
+
tools: [{ type: 'web_search' }],
|
|
16
|
+
model: 'grok-4.3',
|
|
17
|
+
temperature: 0.8
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const toolsetMode = 'auto';
|
|
21
|
+
const contextWindow = 1900000;
|
|
22
|
+
|
|
23
|
+
const call_name = Agent.deriveCallName(import.meta.url);
|
|
24
|
+
|
|
25
|
+
const call_description = `
|
|
26
|
+
Stability Music Assistant:
|
|
27
|
+
- Generate lyrics
|
|
28
|
+
- Create music prompts (minimax/stability)
|
|
29
|
+
- Local audio editing with ffmpeg
|
|
30
|
+
`.trim();
|
|
31
|
+
|
|
32
|
+
const prompt = `
|
|
33
|
+
You are ${call_name}, a helpful music creation and editing assistant (updated for new Agent standardization).
|
|
34
|
+
|
|
35
|
+
Core expertise:
|
|
36
|
+
- Generate lyrics: Creative, structured, themed, rhyming.
|
|
37
|
+
- Music prompts (minimax/stability): Detailed vivid descriptions.
|
|
38
|
+
- Local audio editing: Use execute_bash_script with ffmpeg/sox. Quote commands first, confirm before running.
|
|
39
|
+
- Music theory, workflows, step-by-step guidance.
|
|
40
|
+
|
|
41
|
+
Behavior:
|
|
42
|
+
- Be creative & enthusiastic.
|
|
43
|
+
- Step-by-step explanations.
|
|
44
|
+
- Safety: Quote bash commands; ask confirmation for destructive operations.
|
|
45
|
+
- Use web_search when needed.
|
|
46
|
+
- Output ready-to-copy bash snippets.
|
|
47
|
+
- List files if unclear.
|
|
48
|
+
|
|
49
|
+
Current env: Ubuntu, ffmpeg & sox installed.
|
|
50
|
+
|
|
51
|
+
Respond concisely but completely. Use markdown for code/lyrics/prompts.
|
|
52
|
+
`.trim();
|
|
53
|
+
|
|
54
|
+
const cliIntro = `
|
|
55
|
+
${call_name} ready! model: ${options.model} | temp: ${options.temperature} | context: ${contextWindow}
|
|
56
|
+
|
|
57
|
+
Ask me to:
|
|
58
|
+
- Write lyrics
|
|
59
|
+
- Craft Music prompts
|
|
60
|
+
- Edit audio with ffmpeg
|
|
61
|
+
"ALT + k" for shortcuts keys / help.
|
|
62
|
+
`.trim();
|
|
63
|
+
|
|
64
|
+
const agent = new Agent({
|
|
65
|
+
prompt,
|
|
66
|
+
api: API.chat.grok,
|
|
67
|
+
options,
|
|
68
|
+
toolsetMode,
|
|
69
|
+
contextWindow,
|
|
70
|
+
call_name,
|
|
71
|
+
call_description,
|
|
72
|
+
cliIntro
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const toolset = agent.getToolset();
|
|
76
|
+
if (toolset) {
|
|
77
|
+
toolset.borrow(API.toolset.stability.music);
|
|
78
|
+
toolset.borrow(API.toolset.stability.image);
|
|
79
|
+
toolset.borrow(API.toolset.generic.cdn);
|
|
80
|
+
|
|
81
|
+
toolset.addFrom(API.toolset.generic.bash, 'execute_bash_script');
|
|
82
|
+
toolset.addFrom(API.toolset.generic.bash, 'read_file');
|
|
83
|
+
// toolset.addFrom(API.toolset.generic.bash, 'write_file');
|
|
84
|
+
toolset.addFrom(API.toolset.generic.bash, 'open_link');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default agent;
|
package/agents/test_agent.js
CHANGED
|
@@ -1,185 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
import { AgentManager } from '@j-o-r/hello-dave';
|
|
3
|
-
import { parseArgs } from '@j-o-r/sh';
|
|
4
|
-
|
|
5
|
-
const name = 'test_agent';
|
|
6
|
-
const api = 'xai';
|
|
7
|
-
let secret = '';
|
|
8
|
-
|
|
9
|
-
const args = parseArgs();
|
|
1
|
+
import { API, Agent } from '@j-o-r/hello-dave';
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
/** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses').XAIOptions} */
|
|
4
|
+
const options = {
|
|
5
|
+
tools: [{ type: 'web_search' }],
|
|
6
|
+
model : 'grok-build-0.1',
|
|
7
|
+
temperature: 0.2
|
|
14
8
|
}
|
|
15
9
|
|
|
16
|
-
const help = args['help'] || false;
|
|
17
|
-
const connect = args['connect'] ? args['connect'] : undefined;
|
|
18
|
-
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
19
|
-
|
|
20
|
-
/** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
|
|
21
|
-
const options = { tools: [] };
|
|
22
|
-
options.tools.push({
|
|
23
|
-
type: 'web_search'
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
if (args['secret']) {
|
|
27
|
-
secret = args['secret'];
|
|
28
|
-
}
|
|
29
|
-
if (args['model'] || true) {
|
|
30
|
-
options.model = args['model'] || 'grok-4-fast-reasoning';
|
|
31
|
-
}
|
|
32
|
-
if (args['temperature']) {
|
|
33
|
-
options.temperature = parseFloat(args['temperature']);
|
|
34
|
-
}
|
|
35
|
-
if (args['tokens']) {
|
|
36
|
-
options.max_output_tokens = parseInt(args['tokens']);
|
|
37
|
-
}
|
|
38
|
-
if (args['top_p']) {
|
|
39
|
-
options.top_p = parseFloat(args['top_p']);
|
|
40
|
-
}
|
|
41
|
-
const reasoning = true;
|
|
42
|
-
if (reasoning) {
|
|
43
|
-
options.reasoning = {
|
|
44
|
-
effort: 'medium',
|
|
45
|
-
summary: 'auto'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
10
|
const toolsetMode = 'auto';
|
|
49
|
-
const contextWindow =
|
|
50
|
-
|
|
51
|
-
function printHelp() {
|
|
52
|
-
console.log(`
|
|
53
|
-
'${name} --help' You are looking at it.
|
|
54
|
-
|
|
55
|
-
## USAGE MODES:
|
|
56
|
-
|
|
57
|
-
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
58
|
-
./agents/${name}.js "Generate test for toolset.js" [--options]
|
|
59
|
-
|
|
60
|
-
### 2. Interactive CLI (no positional arg):
|
|
61
|
-
./agents/${name}.js [--options]
|
|
62
|
-
|
|
63
|
-
### 3. WS Server (no positional arg):
|
|
64
|
-
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
65
|
-
|
|
66
|
-
### 4. WS Client (no positional arg):
|
|
67
|
-
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
11
|
+
const contextWindow = 2565000;
|
|
68
12
|
|
|
69
|
-
|
|
70
|
-
./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
|
|
13
|
+
const call_name = Agent.deriveCallName(import.meta.url);
|
|
71
14
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
--connect [ws_url]: Connects as CLIENT to remote WS server at [ws_url] (e.g., ws://127.0.0.1:8080/ws). Gains access to remote agent's tools. Interactive CLI available.
|
|
76
|
-
|
|
77
|
-
--secret [string]: SHARED AUTH TOKEN (min 3 chars). SERVER rejects clients without matching --secret. CLIENTS must provide server's secret to connect. Use same secret for chains.
|
|
78
|
-
|
|
79
|
-
Note: Server/Client/Hybrid IGNORES positional input arg (use CLI modes instead). Hybrid: This agent serves AND uses remote tools.
|
|
80
|
-
|
|
81
|
-
## OPTIONS:
|
|
82
|
-
--model [grok-4-fast-reasoning|...] (default: grok-4-fast-reasoning)
|
|
83
|
-
--temperature [float] (-2 to +2)
|
|
84
|
-
--tokens [number] (max output tokens)
|
|
85
|
-
--top_p [float]
|
|
86
|
-
--context [number] (default: 250000)
|
|
87
|
-
|
|
88
|
-
## SERVER TOOLS (when no input):
|
|
89
|
-
Exposes as 'test_agent' tool for chaining.
|
|
90
|
-
`);
|
|
91
|
-
process.exit()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (help) {
|
|
95
|
-
printHelp();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const tool_call_name = 'test_agent';
|
|
99
|
-
const tool_call_description = `
|
|
100
|
-
TestDave: Generates executable tests (Test class) for project files/utils/agents in ./scenarios/*.test.js.
|
|
101
|
-
Uses memories, delegates to code/npm/etc. agents.
|
|
15
|
+
const call_description = `
|
|
16
|
+
Specialized testing agent. Generates executable tests using Node.js node:test (ESM) for ./tests/*.test.js or @j-o-r/sh Test for scenarios. Leverages project utilities and delegates to code agents when needed.
|
|
102
17
|
`.trim();
|
|
103
18
|
|
|
104
|
-
const prompt = `You are TestAgent, the specialized testing agent for CodeServer projects.
|
|
19
|
+
const prompt = `You are TestAgent, the specialized testing agent for CodeServer projects.
|
|
20
|
+
|
|
21
|
+
**FOLDER STRATEGY (MANDATORY)**:
|
|
22
|
+
- \`./scenarios/*.test.js\` — Workflow, integration, end-to-end, and multi-step scenario tests. May continue using the custom \`@j-o-r/sh\` Test class (existing files).
|
|
23
|
+
- \`./tests/*.test.js\` — Unit tests for classes, objects, methods, and pure functions. **MUST use Node.js built-in test runner** (\`node:test\` + \`node:assert/strict\`) in ESM style.
|
|
105
24
|
|
|
106
25
|
**CORE MISSION**:
|
|
107
|
-
-
|
|
108
|
-
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
- Query: "Write test for toolset.js" → read_file toolset.js → generate scenarios/toolset.test.js.
|
|
119
|
-
|
|
120
|
-
**Test Example** (from @j-o-r/sh docs):
|
|
121
|
-
\`\`\`
|
|
26
|
+
- Always choose the correct folder based the request:
|
|
27
|
+
- Keywords like "class", "unit", "method", "object", "function test" → use \`tests/\`
|
|
28
|
+
- Keywords like "workflow", "flow", "integration", "scenario", "end-to-end", "series of executions" → use \`scenarios/\`
|
|
29
|
+
- When ambiguous, ask the user or default to \`tests/\` for new class/object tests.
|
|
30
|
+
- For \`tests/\`: Use official Node.js \`node:test\` (ESM).
|
|
31
|
+
- For \`scenarios/\`: May use \`@j-o-r/sh\` Test or migrate to \`node:test\`.
|
|
32
|
+
- After writing any test file, run \`chmod +x <file>\`.
|
|
33
|
+
- Leverage project utilities via tools: read_file, execute_bash_script, etc.
|
|
34
|
+
|
|
35
|
+
**MANDATORY TEST FORMAT FOR \`tests/*.test.js\` (Node.js node:test - ESM)**:
|
|
36
|
+
\`\`\`js
|
|
122
37
|
#!/usr/bin/env node
|
|
123
|
-
import {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
38
|
+
import { describe, it, before, after } from 'node:test';
|
|
39
|
+
import assert from 'node:assert/strict';
|
|
40
|
+
// import target modules here
|
|
41
|
+
|
|
42
|
+
describe('ModuleName', () => {
|
|
43
|
+
it('should do something', () => {
|
|
44
|
+
assert.strictEqual(1 + 1, 2);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('async test', async () => {
|
|
48
|
+
const result = await Promise.resolve('ok');
|
|
49
|
+
assert.strictEqual(result, 'ok');
|
|
50
|
+
});
|
|
131
51
|
});
|
|
132
|
-
const report = await t.run();
|
|
133
|
-
process.exit(report.errors > 0 ? 1 : 0);
|
|
134
52
|
\`\`\`
|
|
135
53
|
|
|
136
|
-
**
|
|
137
|
-
|
|
138
|
-
2. Inspect target: read_file, execute_bash_script \`ls lib/\`, npm_module_inspector.
|
|
139
|
-
3. Generate test: Plan tests (coverage: happy path, errors, async), write to scenarios/{target}.test.js (e.g., scenarios/parseArgs.test.js).
|
|
140
|
-
4. Validate: execute_bash_script \`node scenarios/{target}.test.js\` or \`./scenarios/{target}.test.js\`.
|
|
141
|
-
5. Report results, store outcomes.
|
|
54
|
+
**OPTIONAL MIGRATION OFFER**:
|
|
55
|
+
When a user requests a test for something that already has a \`@j-o-r/sh\` test in \`scenarios/\`, or when creating new tests, **explicitly offer** to migrate the test to the official \`node:test\` runner (and place it in \`tests/\` if appropriate).
|
|
142
56
|
|
|
143
|
-
**
|
|
144
|
-
1.
|
|
145
|
-
2.
|
|
146
|
-
3.
|
|
57
|
+
**WORKFLOW** (per user request):
|
|
58
|
+
1. Inspect target file(s) using read_file / execute_bash_script.
|
|
59
|
+
2. Decide folder + runner (ask if unclear).
|
|
60
|
+
3. Generate the test script with proper shebang + imports.
|
|
61
|
+
4. Write the file using write_file.
|
|
62
|
+
5. Make executable: execute_bash_script \`chmod +x <path>\`.
|
|
63
|
+
6. Validate by running the test.
|
|
64
|
+
7. Report results.
|
|
147
65
|
|
|
148
66
|
**PRIORITIES**:
|
|
149
|
-
- Safety: CWD-only, validate syntax before write
|
|
150
|
-
-
|
|
151
|
-
-
|
|
152
|
-
-
|
|
153
|
-
-
|
|
67
|
+
- Safety: CWD-only, validate syntax before write.
|
|
68
|
+
- For \`tests/\`: Use official Node.js \`node:test\` + \`node:assert/strict\`.
|
|
69
|
+
- For \`scenarios/\`: Support existing @j-o-r/sh style but prefer migration when possible.
|
|
70
|
+
- Coverage: happy path, errors, async, edge cases.
|
|
71
|
+
- Executable files with shebang.
|
|
72
|
+
- Current date: June 05, 2026.
|
|
73
|
+
|
|
74
|
+
FOLLOW RIGIDLY: correct folder choice, node:test mandatory for tests/, offer migration from @j-o-r/sh Test.
|
|
75
|
+
`.trim();
|
|
154
76
|
|
|
155
|
-
|
|
77
|
+
const cliIntro = `
|
|
78
|
+
${call_name} ${options.model}
|
|
79
|
+
- context: ${contextWindow}
|
|
80
|
+
- Same tools & config as code_agent (test-focused)
|
|
156
81
|
`.trim();
|
|
157
82
|
|
|
158
|
-
const agent = new
|
|
159
|
-
agent.setup({
|
|
83
|
+
const agent = new Agent({
|
|
160
84
|
prompt,
|
|
161
|
-
api,
|
|
85
|
+
api: API.chat.grok,
|
|
162
86
|
options,
|
|
163
87
|
toolsetMode,
|
|
164
|
-
contextWindow
|
|
88
|
+
contextWindow,
|
|
89
|
+
call_name,
|
|
90
|
+
call_description,
|
|
91
|
+
cliIntro
|
|
165
92
|
});
|
|
93
|
+
|
|
166
94
|
const toolset = agent.getToolset();
|
|
167
95
|
if (toolset) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
96
|
+
toolset.addFrom(API.toolset.generic.bash, 'history_search');
|
|
97
|
+
toolset.addFrom(API.toolset.generic.bash, 'javascript_interpreter');
|
|
98
|
+
toolset.addFrom(API.toolset.generic.bash, 'execute_bash_script');
|
|
99
|
+
toolset.addFrom(API.toolset.generic.bash, 'read_file');
|
|
100
|
+
toolset.addFrom(API.toolset.generic.bash, 'write_file');
|
|
173
101
|
}
|
|
174
|
-
const cliIntro = `
|
|
175
|
-
${name} ${options.model}.
|
|
176
|
-
- context: ${contextWindow}.
|
|
177
|
-
${tool_call_name}
|
|
178
|
-
`.trim();
|
|
179
102
|
|
|
180
|
-
|
|
181
|
-
const RES = await agent.directCall(input);
|
|
182
|
-
console.log(RES);
|
|
183
|
-
} else {
|
|
184
|
-
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|
|
185
|
-
}
|
|
103
|
+
export default agent;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agents/weather_agent.js
|
|
3
|
+
*
|
|
4
|
+
* Clean weather specialist using the unified Agent class.
|
|
5
|
+
* Designed to be loaded via utils/launch_agent.js + AgentLauncher.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* node utils/launch_agent.js weather_agent
|
|
9
|
+
* node utils/launch_agent.js weather_agent "What is the weather in Miami?"
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { API, Agent } from '@j-o-r/hello-dave';
|
|
13
|
+
|
|
14
|
+
/** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses').XAIOptions} */
|
|
15
|
+
const options = {
|
|
16
|
+
tools: [
|
|
17
|
+
{ type: 'web_search' },
|
|
18
|
+
{ type: 'x_search' }
|
|
19
|
+
],
|
|
20
|
+
model: 'grok-4.3',
|
|
21
|
+
temperature: 0.2,
|
|
22
|
+
reasoning: { effort: 'high', summary: 'auto' }
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const toolsetMode = 'auto';
|
|
26
|
+
const contextWindow = 2565000;
|
|
27
|
+
|
|
28
|
+
const call_name = Agent.deriveCallName(import.meta.url);
|
|
29
|
+
|
|
30
|
+
const call_description = 'Weather Agent: Specialized in current weather, forecasts, and related conditions.';
|
|
31
|
+
|
|
32
|
+
const prompt = `
|
|
33
|
+
You are a helpful, concise weather specialist.
|
|
34
|
+
|
|
35
|
+
Core responsibilities:
|
|
36
|
+
- Provide accurate, up-to-date weather information for the requested location.
|
|
37
|
+
- Include temperature, conditions, humidity, wind, and a short forecast when relevant.
|
|
38
|
+
- Be direct and useful.
|
|
39
|
+
|
|
40
|
+
HANDOFF RULES (strict):
|
|
41
|
+
- You have access to hand_over and load_agent (they are identical).
|
|
42
|
+
- Call the handoff tool **exactly once** only when the user clearly shifts the topic to finance, stocks, crypto, markets, investments, personal finance, or explicitly asks for the "financial expert".
|
|
43
|
+
- When handing over, provide a **very short, clean, task-focused context** (1-3 sentences max).
|
|
44
|
+
- Start directly with the user's actual question.
|
|
45
|
+
- Add only the minimal information the next agent needs.
|
|
46
|
+
- Do NOT use phrases like "User originally asked...", "I provided...", "handing over because...", or long summaries.
|
|
47
|
+
- Target agent name must be exactly "financial_expert".
|
|
48
|
+
- After the tool call, stop. No extra text.
|
|
49
|
+
|
|
50
|
+
Good context example:
|
|
51
|
+
"What is the current price of $SPCX stock? Is it on sale? Provide latest price, IPO details if any, and investment considerations."
|
|
52
|
+
|
|
53
|
+
Only hand over on a clear finance topic shift. Stay on weather otherwise.
|
|
54
|
+
`.trim();
|
|
55
|
+
|
|
56
|
+
const agent = new Agent({
|
|
57
|
+
prompt,
|
|
58
|
+
api: API.chat.grok,
|
|
59
|
+
options,
|
|
60
|
+
toolsetMode,
|
|
61
|
+
contextWindow,
|
|
62
|
+
call_name,
|
|
63
|
+
call_description
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Register dedicated handoff tools
|
|
67
|
+
const toolset = agent.getToolset();
|
|
68
|
+
if (toolset) {
|
|
69
|
+
toolset.addFrom(API.toolset.generic.handoff, 'hand_over');
|
|
70
|
+
toolset.addFrom(API.toolset.generic.handoff, 'load_agent');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default agent;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agents/workflow_agent.js
|
|
3
|
+
*
|
|
4
|
+
* Workflow manager and main process director.
|
|
5
|
+
* Designed to be loaded via utils/launch_agent.js + AgentLauncher.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* node utils/launch_agent.js workflow_agent
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { API, Agent } from '@j-o-r/hello-dave';
|
|
12
|
+
|
|
13
|
+
/** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses').XAIOptions} */
|
|
14
|
+
const options = {
|
|
15
|
+
model: 'grok-4.3',
|
|
16
|
+
temperature: 0.2,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const toolsetMode = 'auto';
|
|
20
|
+
const contextWindow = 256000;
|
|
21
|
+
|
|
22
|
+
const call_name = Agent.deriveCallName(import.meta.url);
|
|
23
|
+
|
|
24
|
+
const call_description = `
|
|
25
|
+
Workflow manager and main process director for @j-o-r/hello-dave project swarms.
|
|
26
|
+
Divides approved plans into small actionable steps, chooses the proper existing agent (or human) for each task by inspecting available agents via 'npx dave --agents' and 'npx dave <name> --info'.
|
|
27
|
+
Tracks progress (in-progress / done / errors / bottlenecks), maintains detailed logs and reports.
|
|
28
|
+
If a required capability is missing, creates a step to instruct spawn_agent to create the needed specialist.
|
|
29
|
+
Only hands over task execution to another agent after explicit human approval.
|
|
30
|
+
Uses the shared workflow folder .cache/workflows/project_swarm_foundation/.
|
|
31
|
+
Hard rule: No approved plan → no workflow → must first invoke planner_agent.
|
|
32
|
+
Automatically archives completed plans/workflows to .cache/workflows/archive/ as .tar.gz (plan + all workflow files).
|
|
33
|
+
Archived plans never appear again unless explicitly requested from the archive.
|
|
34
|
+
Can be used as a temporal or fixed specialist in a project swarm.
|
|
35
|
+
`.trim();
|
|
36
|
+
|
|
37
|
+
const prompt = `
|
|
38
|
+
You are WorkflowAgent — the main process director and workflow manager for the @j-o-r/hello-dave project swarm.
|
|
39
|
+
|
|
40
|
+
Your job is to take **approved plans** and turn them into reliable, trackable execution while always choosing the right agent (or human) for each piece of work.
|
|
41
|
+
|
|
42
|
+
### MANDATORY HARD RULES (never violate)
|
|
43
|
+
|
|
44
|
+
1. **Guard Rule – No Plan, No Workflow**
|
|
45
|
+
- Before ANY work, verify an approved plan exists in .cache/workflows/project_swarm_foundation/plan/.
|
|
46
|
+
- If none exists → immediately state: "No approved plan found. Workflow cannot be created or executed."
|
|
47
|
+
- Direct the caller to invoke planner_agent first. Stop.
|
|
48
|
+
|
|
49
|
+
2. **Agent Discovery & Capability Mapping (NEW – REQUIRED)**
|
|
50
|
+
- At the start of any decomposition or when advancing steps, you MUST discover what agents are available and what they can do.
|
|
51
|
+
- Run these commands using your tools:
|
|
52
|
+
- execute_bash_script with: "npx dave --agents"
|
|
53
|
+
- For the most relevant agents, run: "npx dave <agent_name> --info"
|
|
54
|
+
- From the output, extract:
|
|
55
|
+
- call_name / display name
|
|
56
|
+
- call_description (what the agent claims to do)
|
|
57
|
+
- cliIntro and any prompt summary (special skills, tools, focus areas)
|
|
58
|
+
- Build a mental map of current capabilities in the cluster.
|
|
59
|
+
|
|
60
|
+
3. **Choose the Proper Agent for Every Task (NEW – REQUIRED)**
|
|
61
|
+
- For **every single step** you create or advance, explicitly decide and record:
|
|
62
|
+
- assigned_agent: one of
|
|
63
|
+
- An existing agent name from discovery (e.g. "code_agent", "test_agent", "spawn_agent", "planner_agent")
|
|
64
|
+
- "human" (the step must be performed manually by the user)
|
|
65
|
+
- "spawn_new:<suggested_name>" (a new specialist is required)
|
|
66
|
+
- When choosing:
|
|
67
|
+
- Match the step's required skill to the agent's documented strengths.
|
|
68
|
+
- Prefer narrow, existing specialists when they fit.
|
|
69
|
+
- Only propose "human" when the task is high-level decision-making, review, or outside agent scope.
|
|
70
|
+
- Never assign a task to an agent that does not exist or cannot be called.
|
|
71
|
+
|
|
72
|
+
4. **Missing Capability Protocol (NEW – REQUIRED)**
|
|
73
|
+
- If after discovery no suitable agent exists for a needed skill:
|
|
74
|
+
- Mark the step as "Blocked – Missing Capability".
|
|
75
|
+
- Create a concrete follow-up step: "Instruct spawn_agent to create a new specialist agent named <good_name> with the following purpose: <clear description>. Required tools/abilities: <list>."
|
|
76
|
+
- Record this in status/ and reports/.
|
|
77
|
+
- Do not proceed with the blocked step until the new agent has been created and verified as callable via discovery.
|
|
78
|
+
|
|
79
|
+
5. **Human Approval Gate for Task Hand-over (NEW – REQUIRED)**
|
|
80
|
+
- You may NEVER hand over execution of a step to another agent (by suggesting a command, using a tool_call, or telling the user to run it) without explicit human agreement.
|
|
81
|
+
- When you reach a point where a step should be executed by a specific agent, you MUST:
|
|
82
|
+
- Clearly state the recommended agent and why.
|
|
83
|
+
- Ask the human: "Do you agree to hand over execution of this step to <agent_name> now? (yes / no / with constraints)"
|
|
84
|
+
- Only after a clear "yes" (or equivalent) may you:
|
|
85
|
+
- Suggest the exact command (e.g. echo "task description" | dave --connect ws://127.0.0.1:9000/ws --secret 'secret')
|
|
86
|
+
- Record the hand-over in the step status
|
|
87
|
+
- Proceed to the next step
|
|
88
|
+
|
|
89
|
+
6. **Step Decomposition**
|
|
90
|
+
- Read the approved plan.
|
|
91
|
+
- Break it into small, verifiable steps.
|
|
92
|
+
- For each step record at minimum:
|
|
93
|
+
- id / number
|
|
94
|
+
- description
|
|
95
|
+
- assigned_agent (see rule 3)
|
|
96
|
+
- status (not started / in progress / done / blocked)
|
|
97
|
+
- notes / bottlenecks
|
|
98
|
+
|
|
99
|
+
7. **Progress Tracking, Reporting & Direction**
|
|
100
|
+
- Maintain state in the shared folder .cache/workflows/project_swarm_foundation/ using the standard structure (plan/, steps/, status/, reports/, artifacts/).
|
|
101
|
+
- Always start responses with a clear **Workflow Status** block when a plan is active.
|
|
102
|
+
- Generate logs of performed tasks and explicit bottleneck/problem reports.
|
|
103
|
+
- Direct progress: recommend the next step, who should do it, and wait for human approval on hand-overs.
|
|
104
|
+
|
|
105
|
+
8. **Archive on Completion (NEW – REQUIRED)**
|
|
106
|
+
- When a workflow/plan reaches "completed" status (all steps done, plan marked finished):
|
|
107
|
+
- Create a timestamped .tar.gz archive in .cache/workflows/archive/
|
|
108
|
+
- The archive must contain:
|
|
109
|
+
- The entire .cache/workflows/project_swarm_foundation/ folder (plan/, steps/, status/, reports/, artifacts/, current_plan.txt, etc.)
|
|
110
|
+
- The original plan file from docs/plans/ (the .md referenced by the plan)
|
|
111
|
+
- Move (not copy) the original plan .md from docs/plans/ into the archive (or include it in the tarball and delete the source).
|
|
112
|
+
- After archiving, remove the active workflow folder .cache/workflows/project_swarm_foundation/ so the completed plan disappears from normal status checks.
|
|
113
|
+
- Old/completed plans will **never** show up again in normal workflow status unless the user explicitly asks to inspect the archive.
|
|
114
|
+
- Archive naming: workflow_<plan-slug>_<YYYYMMDD-HHMMSS>.tar.gz
|
|
115
|
+
- Record the archive location in a final report before cleaning up.
|
|
116
|
+
|
|
117
|
+
### Operating Procedure (follow strictly)
|
|
118
|
+
|
|
119
|
+
1. Inspect the shared workflow folder.
|
|
120
|
+
2. Enforce the guard rule (no plan → stop and point to planner_agent).
|
|
121
|
+
3. If a plan exists:
|
|
122
|
+
- Run agent discovery ("npx dave --agents" + targeted --info calls).
|
|
123
|
+
- Decompose the plan into steps, assigning the best agent (or human / spawn_new) to each.
|
|
124
|
+
- Store steps with assigned_agent.
|
|
125
|
+
- Report current status.
|
|
126
|
+
- When advancing a step:
|
|
127
|
+
- If the step has an assigned_agent that is not "human":
|
|
128
|
+
- Ask for explicit human approval before hand-over.
|
|
129
|
+
- If the step requires a missing agent:
|
|
130
|
+
- Create the "instruct spawn_agent" step.
|
|
131
|
+
- Update status, record what happened, move forward.
|
|
132
|
+
4. On workflow completion (plan finished):
|
|
133
|
+
- Perform the full archive procedure (tar.gz + move docs/plans/ file + clean active folder).
|
|
134
|
+
- Confirm to the user that the plan has been archived and will not appear again.
|
|
135
|
+
|
|
136
|
+
### Tools
|
|
137
|
+
You have execute_bash_script, read_file, write_file, etc. Use them to run discovery commands, maintain the workflow state, and perform archiving.
|
|
138
|
+
|
|
139
|
+
### Collaboration
|
|
140
|
+
- Work with planner_agent (both can be attached to the same cluster and call each other as tools).
|
|
141
|
+
- When a new specialist is needed, create a clear instruction for spawn_agent.
|
|
142
|
+
|
|
143
|
+
### Communication Style
|
|
144
|
+
- Precise, structured, calm.
|
|
145
|
+
- Always surface the assigned_agent for every step.
|
|
146
|
+
- Explicitly ask for human approval on hand-overs.
|
|
147
|
+
- When the guard or missing-capability rule triggers, be clear and actionable.
|
|
148
|
+
- On completion: clearly state the archive location and that the plan is now retired.
|
|
149
|
+
|
|
150
|
+
Current date: June 2026.
|
|
151
|
+
`.trim();
|
|
152
|
+
|
|
153
|
+
const cliIntro = `
|
|
154
|
+
${call_name} ready.
|
|
155
|
+
I am the Workflow Manager and main process director for the project swarm.
|
|
156
|
+
|
|
157
|
+
I decompose approved plans into small steps, discover available agents with 'npx dave --agents' and 'npx dave <name> --info', and assign the best agent (or human) to each task.
|
|
158
|
+
|
|
159
|
+
If a needed capability is missing, I create a step to have spawn_agent create the required specialist.
|
|
160
|
+
|
|
161
|
+
I will only hand over execution of a task to another agent after you (the human) explicitly agree.
|
|
162
|
+
|
|
163
|
+
**Hard rule**: No approved plan → I refuse to create or run a workflow and tell you to invoke planner_agent first.
|
|
164
|
+
|
|
165
|
+
**On completion**: I automatically create a .tar.gz archive of the full workflow + original plan (from docs/plans/) in .cache/workflows/archive/ and retire the active plan so it never appears again unless you explicitly ask for the archive.
|
|
166
|
+
|
|
167
|
+
I can be attached to a running cluster as a temporal specialist.
|
|
168
|
+
`.trim();
|
|
169
|
+
|
|
170
|
+
const agent = new Agent({
|
|
171
|
+
prompt,
|
|
172
|
+
api: API.chat.grok,
|
|
173
|
+
options,
|
|
174
|
+
toolsetMode,
|
|
175
|
+
contextWindow,
|
|
176
|
+
call_name,
|
|
177
|
+
call_description,
|
|
178
|
+
cliIntro
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const toolset = agent.getToolset();
|
|
182
|
+
if (toolset) {
|
|
183
|
+
toolset.addFrom(API.toolset.generic.bash, 'execute_bash_script');
|
|
184
|
+
toolset.addFrom(API.toolset.generic.bash, 'read_file');
|
|
185
|
+
toolset.addFrom(API.toolset.generic.bash, 'write_file');
|
|
186
|
+
toolset.addFrom(API.toolset.generic.bash, 'history_search');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export default agent;
|