@j-o-r/hello-dave 0.1.1 → 0.1.5
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 +593 -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 +10 -4
- 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 +250 -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
package/CHANGELOG.md
CHANGED
|
@@ -1,25 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Comprehensive plan for **Agent File-Socket Communication Layer** (`docs/plans/agent-file-socket-communication.md`).
|
|
12
|
+
- Enables persistent agent sessions via Unix domain sockets in `.cache/sockets/`.
|
|
13
|
+
- One-shot calls participate in live sessions (same as interactive CLI).
|
|
14
|
+
- Bi-directional control plane (queries, commands, handoff, reset, info, list_agents, etc.).
|
|
15
|
+
- Any UI/frontend can attach to a running agent.
|
|
16
|
+
- "Keep it simple" mandate: `AgentLauncher` always ensures the socket server; CLI evolves to be a socket client.
|
|
17
|
+
- Updated project documentation to reflect the new direction:
|
|
18
|
+
- `docs/project-overview.md`
|
|
19
|
+
- `docs/bin-dave.md`
|
|
20
|
+
- `TODO.md` (detailed tracking section with phases, open decisions, next actions)
|
|
21
|
+
|
|
22
|
+
### Architecture Notes
|
|
23
|
+
- Builds directly on the existing clean `Agent` + `AgentLauncher` + in-process handoff model (fresh context only).
|
|
24
|
+
- Leverages `Prompt` as EventEmitter for natural event streaming over sockets.
|
|
25
|
+
- No changes to existing agents or core behavior yet (planning + docs phase complete).
|
|
26
|
+
- Legacy WS/swarm model remains in `_legacy/` and is not revived.
|
|
27
|
+
|
|
28
|
+
See the plan document for full details, phased rollout, risks, and recommended next steps (Phase 1: minimal socket server/client + one-shot path).
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## [0.1.3] - 2026-06 (prior)
|
|
33
|
+
|
|
34
|
+
### Added / Changed
|
|
35
|
+
- Unified `Agent` class + `AgentLauncher` with clean in-process handoff (`hand_over` / `load_agent` tools).
|
|
36
|
+
- Fresh handoff semantics (no history copied; only system prompt + short task-focused context).
|
|
37
|
+
- Self-reset support for deliberate fresh starts.
|
|
38
|
+
- Dual-layer documentation model (framework vs project-local `docs/`).
|
|
39
|
+
- `dave` CLI delegates almost everything to `AgentLauncher`.
|
|
40
|
+
- Many agent improvements and toolset work.
|
|
41
|
+
|
|
42
|
+
(Older history summarized; see git log for full details.)
|
package/README.md
CHANGED
|
@@ -1,242 +1,102 @@
|
|
|
1
|
-
# hello-dave
|
|
1
|
+
# @j-o-r/hello-dave
|
|
2
|
+
|
|
3
|
+

|
|
2
4
|
|
|
3
5
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
6
|
[](https://nodejs.org/)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
##
|
|
21
|
-
|
|
22
|
-
**hello-dave** is an ESM (ECMAScript Modules) toolkit for building AI agents with unified access to endpoints from Grok (xAI), OpenAI, and Anthropic. It provides CLI tools for interacting with agents locally or via WebSocket servers, along with pre-built agent scripts for various tasks like code generation, documentation, testing, and more.
|
|
23
|
-
|
|
24
|
-
The project emphasizes modular agent management, tool integration (e.g., web search, file operations), and session handling with memory and caching. With v0.0.8, enhanced portability allows spawning agents in isolated environments like `/tmp` while maintaining tool functionality relative to the current working directory (CWD).
|
|
25
|
-
|
|
26
|
-
## Features
|
|
27
|
-
|
|
28
|
-
- **Unified API Access**: Seamless integration with xAI (Grok), OpenAI, and Anthropic models.
|
|
29
|
-
- **CLI Tools**: `dave` for querying agents, `agentDave` for spawning servers, `codeDave` for code servers.
|
|
30
|
-
- **Agent Scripts**: Specialized agents for code, docs, npm, todo, readme, memory, and more.
|
|
31
|
-
- **WebSocket Support**: Connect to remote agent servers for interactive or one-shot interactions.
|
|
32
|
-
- **Toolsets**: Built-in tools for search, file I/O, email, and custom toolcalls.
|
|
33
|
-
- **Music Toolsets**: Dedicated Stability AI (Stable Audio 3) and Minimax (Music 2.6/Cover) toolsets for text-to-music, audio transformation, inpainting, covers, lyrics, and more. See [docs/music-toolsets.md](docs/music-toolsets.md) for full details, tools, and agent examples.
|
|
34
|
-
- **Session Management**: Cache history, search sessions, reset, and inspect logs.
|
|
35
|
-
- **ESM-First**: Modern Node.js modules with TypeScript definitions.
|
|
36
|
-
- **Portable Agent Spawning**: `spawn_agent.js` enables creating and deploying agents anywhere (project dirs or fresh `/tmp`). Supports auto-deploy in existing projects (detects `./agents/*.js`), manual code+bash in isolated setups. Tools adapt to CWD for portability. Hybrid modes combine server/client for chaining. See [docs/prompt/spawn_agent.md](docs/prompt/spawn_agent.md) for blueprint and validation.
|
|
37
|
-
- **Multi-Agent Clusters**: PM2-powered CodeServer for scalable, clustered agent deployments (e.g., code_agent + todo_agent). Defaults to port 9000/secret '123'. See [docs/multi-agent-clusters.md](docs/multi-agent-clusters.md) for configuration.
|
|
38
|
-
|
|
39
|
-
## Folder Structure
|
|
40
|
-
|
|
41
|
-
- **bin/**: Executables for CLI tools.
|
|
42
|
-
- `dave.js`: Main CLI for asking agents or connecting to WebSocket servers.
|
|
43
|
-
- `spawn_agent.js`: Spawns agent instances (binary: `agentDave`).
|
|
44
|
-
- `codeDave`: Launches code servers (via PM2 clusters). References [docs/multi-agent-clusters.md](docs/multi-agent-clusters.md) for setup and scaling.
|
|
45
|
-
|
|
46
|
-
- **agents/**: Agent scripts (`*_agent.js`) for specific tasks. These can be run directly with `node agents/<script>.js`.
|
|
47
|
-
- `ask_agent.js`: General query agent.
|
|
48
|
-
- `code_agent.js`: Code generation and execution agent (serves as main server in code clusters).
|
|
49
|
-
- `daisy_agent.js`: Specialized agent (details in script).
|
|
50
|
-
- `docs_agent.js`: Documentation-focused agent.
|
|
51
|
-
- `gpt_agent.js`: OpenAI GPT integration agent.
|
|
52
|
-
- `grok_agent.js`: xAI Grok-specific agent.
|
|
53
|
-
- `memory_agent.js`: Agent with enhanced memory and context handling.
|
|
54
|
-
- `npm_agent.js`: NPM package management agent.
|
|
55
|
-
- `prompt_agent.js`: Prompt engineering and testing agent.
|
|
56
|
-
- `readme_agent.js`: README.md management agent.
|
|
57
|
-
- `spawn_agent.js`: Agent spawner (also in bin/). Creates portable CLI/WS agents + PM2 launchers. Validates/tests/deploys to `./agents/<name>.js`. Supports hybrid server/client modes. Portable to `/tmp` (tools follow CWD). Blueprint: [docs/prompt/spawn_agent.md](docs/prompt/spawn_agent.md).
|
|
58
|
-
- `test_agent.js`: Testing and validation agent.
|
|
59
|
-
- `todo_agent.js`: TODO list and task management agent.
|
|
60
|
-
- `codeserver.sh`: Shell script for launching PM2-based code server clusters (uses agents above). See [docs/multi-agent-clusters.md](docs/multi-agent-clusters.md).
|
|
61
|
-
|
|
62
|
-
- **lib/**: Core library modules (e.g., `index.js`, `wsCli.js`, `wsIO.js`, API integrations).
|
|
63
|
-
- **scenarios/**: Test and example scenarios (e.g., toolset tests, integration scripts).
|
|
64
|
-
- **types/**: TypeScript definitions.
|
|
65
|
-
- **utils/**: Utility scripts (e.g., session management, testing).
|
|
66
|
-
- **docs/**: Additional documentation, including agent blueprints (e.g., [prompt/spawn_agent.md](docs/prompt/spawn_agent.md)) and multi-agent guides (e.g., [multi-agent-clusters.md](docs/multi-agent-clusters.md)).
|
|
67
|
-
- New: [music-toolsets.md](docs/music-toolsets.md) — Documentation for Stability and Minimax MusicToolsets with usage examples from agents/stability.js and agents/minimax.js.
|
|
68
|
-
- **release/**: Build artifacts.
|
|
69
|
-
|
|
70
|
-
Other files: `package.json`, `CHANGELOG.md`, `TODO.md`, `LICENSE`.
|
|
71
|
-
|
|
72
|
-
## Installation
|
|
73
|
-
|
|
74
|
-
1. **Prerequisites**: Node.js >= 20. PM2 for multi-agent clusters: `npm install -g pm2`.
|
|
75
|
-
|
|
76
|
-
2. **Local Development**:
|
|
77
|
-
```bash
|
|
78
|
-
git clone https://codeberg.org/duin/hello-dave.git
|
|
79
|
-
cd hello-dave
|
|
80
|
-
npm install
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
3. **Global CLI Installation** (for `dave`, `agentDave`, `codeDave`):
|
|
84
|
-
```bash
|
|
85
|
-
npm install -g .
|
|
86
|
-
# Or link for dev: npm run link-self
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
4. **API Keys**: Set environment variables (e.g., `XAIKEY` for xAI, `OPENAI_API_KEY` for OpenAI).
|
|
90
|
-
|
|
91
|
-
## Usage
|
|
92
|
-
|
|
93
|
-
### CLI Tools
|
|
94
|
-
|
|
95
|
-
- **dave**: Interact with agents locally or remotely.
|
|
96
|
-
- Local query: `dave --ask "Predict the weather"`
|
|
97
|
-
- One-shot remote: `echo "Hello" | dave --connect 'ws://127.0.0.1:8080' --secret '123'`
|
|
98
|
-
- Interactive remote: `dave --connect 'ws://127.0.0.1:8080' --secret '123'`
|
|
99
|
-
- Other: `dave --list` (sessions), `dave --clear` (cache), `dave --help`.
|
|
100
|
-
|
|
101
|
-
- **agentDave**: Spawn an agent server (powered by `spawn_agent.js`).
|
|
102
|
-
```bash
|
|
103
|
-
agentDave --serve 8080 --secret '123' # Starts WebSocket server
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
- **codeDave**: Launch a PM2 code server cluster.
|
|
107
|
-
```bash
|
|
108
|
-
codeDave 8080 --secret '123' # Or: dave --code 8080 --secret '123'
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Running Agents
|
|
112
|
-
|
|
113
|
-
Run agent scripts directly:
|
|
7
|
+
|
|
8
|
+
**'Hello, Dave.'** — A calm, reliable ESM toolkit for building and running AI agents with unified access to Grok (xAI), OpenAI, and Anthropic.
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g @j-o-r/hello-dave
|
|
14
|
+
|
|
15
|
+
dave --help
|
|
16
|
+
dave --list-agents
|
|
17
|
+
dave ask_agent
|
|
18
|
+
dave code_agent "Refactor lib/Session.js"
|
|
19
|
+
echo "Explain this error" | dave ask_agent
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Core Usage
|
|
23
|
+
|
|
114
24
|
```bash
|
|
115
|
-
|
|
116
|
-
|
|
25
|
+
dave <agent_name> # interactive
|
|
26
|
+
dave <agent_name> "your message" # one-shot
|
|
27
|
+
echo "message" | dave <agent_name>
|
|
28
|
+
dave <agent_name> --info
|
|
29
|
+
dave --list-agents
|
|
117
30
|
```
|
|
118
31
|
|
|
119
|
-
|
|
32
|
+
Agents are `*_agent.js` files discovered via `AgentLauncher`.
|
|
33
|
+
|
|
34
|
+
## Agent Handoffs (Current Multi-Agent Model)
|
|
35
|
+
|
|
36
|
+
Use the built-in `hand_over` / `load_agent` tools for clean in-process delegation to specialists (or self-reset with fresh context).
|
|
37
|
+
|
|
38
|
+
- Always fresh: target gets only its own system prompt + short task-focused context.
|
|
39
|
+
- No history is copied.
|
|
40
|
+
- Use `list_agents` first when unsure.
|
|
41
|
+
|
|
42
|
+
This replaced the older WebSocket server/client/swarm/CodeServer model (which has been abandoned).
|
|
43
|
+
|
|
44
|
+
See `docs/creating-agents.md` for details.
|
|
120
45
|
|
|
121
|
-
|
|
46
|
+
## Creating Agents
|
|
122
47
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// Setup and run agent...
|
|
48
|
+
```bash
|
|
49
|
+
dave agent_creator "Create a weather_agent..."
|
|
50
|
+
dave agent_creator "Improve code_agent..."
|
|
127
51
|
```
|
|
128
52
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
`spawn_agent.js` (executable as `agentDave`) creates and deploys portable agents in CLI, WebSocket server, client, or **hybrid** modes (server + client for tool chaining). It fetches live prompts from [docs/prompt/spawn_agent.md](docs/prompt/spawn_agent.md) and validates new agents via blueprint (temp files, syntax checks, grep for modes/tools).
|
|
132
|
-
|
|
133
|
-
- **Modes**:
|
|
134
|
-
- **Direct (One-Shot)**: Positional input, e.g., `node agents/spawn_agent.js "Create a tester"`.
|
|
135
|
-
- **Interactive CLI**: No input; runs REPL-like session.
|
|
136
|
-
- **Server**: `--serve <port>` – Exposes as remote tool (e.g., for other agents to call `spawn_agent`).
|
|
137
|
-
- **Client**: `--connect <ws_url>` – Connects to remote server for tool access.
|
|
138
|
-
- **Hybrid**: `--serve <port> --connect <ws_url>` – Serves locally while using remote tools.
|
|
139
|
-
|
|
140
|
-
- **Portability**:
|
|
141
|
-
- **In Project**: Auto-deploys to `./agents/<name>.js` if `./agents/*.js` exist (uses existing structure).
|
|
142
|
-
- **Fresh /tmp**: Manual code generation + bash setup (e.g., `mkdir /tmp/myproj/agents; cd /tmp/myproj; node spawn_agent.js ...`). Tools (e.g., `read_file`) follow CWD, ensuring isolation without fixed paths.
|
|
143
|
-
- Works in any dir; no repo deps beyond Node.js + npm installs.
|
|
144
|
-
|
|
145
|
-
- **Custom Tools**: Specify in prompt, e.g., "name=coderev, tools=read_file,web_search,execute_bash_script".
|
|
146
|
-
|
|
147
|
-
For validation/testing: See blueprint in [docs/prompt/spawn_agent.md](docs/prompt/spawn_agent.md) (includes bash examples like `node agents/NEW_AGENT.js --help` or server connect tests).
|
|
148
|
-
|
|
149
|
-
### CodeServer & PM2 Multi-Agent (v0.0.8)
|
|
150
|
-
|
|
151
|
-
CodeServer (via `bin/codeDave` or `agents/codeserver.sh`) launches scalable, PM2-clustered multi-agent environments for collaborative tasks (e.g., code generation + task management). It deploys agents like `code_agent`, `todo_agent`, and `readme_agent` on a WebSocket server, enabling chaining and load balancing.
|
|
152
|
-
|
|
153
|
-
- **Defaults**: Port 9000, secret '123' (customizable via args).
|
|
154
|
-
- **Prerequisites**: Install PM2 globally (`npm install -g pm2`).
|
|
155
|
-
- **Quickstart**:
|
|
156
|
-
```bash
|
|
157
|
-
codeDave 9000 --secret 123 # Launches PM2 cluster on ws://127.0.0.1:9000/ws
|
|
158
|
-
pm2 list # Verify processes (e.g., code_agent, todo_agent instances)
|
|
159
|
-
echo "task" | bin/dave.js --connect ws://127.0.0.1:9000/ws --secret 123 # One-shot query to cluster
|
|
160
|
-
```
|
|
161
|
-
This starts the cluster, lists running agents, and sends a test task (response routed to available agents).
|
|
162
|
-
|
|
163
|
-
- **Scaling & Management**: Use PM2 commands (e.g., `pm2 scale <app> 4`, `pm2 stop all`). For ecosystem config, PM2 JSON files, or agent orchestration, see the [full guide in docs/multi-agent-clusters.md](docs/multi-agent-clusters.md).
|
|
164
|
-
|
|
165
|
-
- **Integration**: Combine with `spawn_agent.js` for dynamic agent addition to clusters (e.g., spawn new agents and connect via `--connect ws://127.0.0.1:9000/ws`).
|
|
166
|
-
|
|
167
|
-
## Usage Examples
|
|
168
|
-
|
|
169
|
-
- **Direct Spawn (Project)**:
|
|
170
|
-
```bash
|
|
171
|
-
cd hello-dave # Or any project with ./agents/
|
|
172
|
-
node agents/spawn_agent.js "Create code-review agent: name=coderev, desc=Git diff analyzer, tools=read_file,execute_bash_script,web_search"
|
|
173
|
-
# Deploys to ./agents/coderev_agent.js; test: node agents/coderev_agent.js "Review this diff"
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
- **/tmp Workflow (Portable, Fresh Setup)**:
|
|
177
|
-
```bash
|
|
178
|
-
mkdir -p /tmp/myportable/agents
|
|
179
|
-
cd /tmp/myportable
|
|
180
|
-
# Copy or fetch spawn_agent.js (e.g., curl from repo or npm install @j-o-r/hello-dave)
|
|
181
|
-
npm init -y && npm i @j-o-r/hello-dave @j-o-r/sh
|
|
182
|
-
node spawn_agent.js "Create todo agent: name=todo, desc=Task manager, tools=read_file,write_file"
|
|
183
|
-
# Deploys to ./agents/todo_agent.js; tools use /tmp/myportable as CWD
|
|
184
|
-
node agents/todo_agent.js --serve 8081 --secret abc # Test server mode
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
- **Hybrid Mode with Custom Tools**:
|
|
188
|
-
```bash
|
|
189
|
-
node agents/spawn_agent.js --serve 8081 --connect ws://127.0.0.1:8080/ws --secret abc "Spawn a docs agent with custom email tool"
|
|
190
|
-
# Serves on 8081 (exposes new agent), connects to 8080 (gains remote tools like email)
|
|
191
|
-
# Test: In another term, node agents/spawn_agent.js --connect ws://127.0.0.1:8081/ws --secret abc "Use the new docs agent"
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
- **Spawn a Server**:
|
|
195
|
-
```bash
|
|
196
|
-
node agents/spawn_agent.js --serve 8080 --secret '123'
|
|
197
|
-
# Then connect: echo "Task" | dave --connect 'ws://127.0.0.1:8080' --secret '123'
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
- **Launch Code Cluster** (includes multiple agents):
|
|
201
|
-
```bash
|
|
202
|
-
node agents/codeserver.sh 9000 '123' # Or use codeDave 9000 --secret 123
|
|
203
|
-
# Connects code_agent, todo_agent, readme_agent, etc., to the server on ws://127.0.0.1:9000/ws.
|
|
204
|
-
# Test: pm2 list; echo "Optimize this code" | dave --connect ws://127.0.0.1:9000/ws --secret 123
|
|
205
|
-
# For advanced config: See [docs/multi-agent-clusters.md](docs/multi-agent-clusters.md).
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
- **Local Agent Query** (no server):
|
|
209
|
-
```bash
|
|
210
|
-
dave --ask --model 'grok-4-1-fast-reasoning' "Write a function"
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
- **Custom Agent**:
|
|
214
|
-
```bash
|
|
215
|
-
node agents/docs_agent.js --connect 'ws://127.0.0.1:8080' --secret '123'
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
See `scenarios/` for more test scenarios.
|
|
53
|
+
**Follow the current standard**: [docs/creating-agents.md](docs/creating-agents.md)
|
|
219
54
|
|
|
220
|
-
|
|
55
|
+
Key pattern:
|
|
56
|
+
- `export default agent;`
|
|
57
|
+
- `new Agent({ prompt, api, call_name, call_description, ... })`
|
|
58
|
+
- Register tools + `toolset.borrow(API.toolset.generic.handoff)`
|
|
59
|
+
|
|
60
|
+
## Documentation
|
|
61
|
+
|
|
62
|
+
- **[docs/creating-agents.md](docs/creating-agents.md)** — Canonical guide (read this first for agent work).
|
|
63
|
+
- `docs/bin-dave.md`
|
|
64
|
+
- `docs/project-overview.md`
|
|
65
|
+
- `docs/docs-organization.md`
|
|
66
|
+
- `docs/toolset.md` etc.
|
|
221
67
|
|
|
222
|
-
|
|
223
|
-
- **Test**: `npm run tests` (runs `utils/test.sh`)
|
|
224
|
-
- **Release**: `npm run release` then `npm run publish`
|
|
225
|
-
- **Local Linking**: `npm run link-self` / `npm run unlink-self`
|
|
68
|
+
**Legacy docs** (old WS/swarm/CodeServer patterns) live in `docs/_legacy/`. They are retained for historical reference only.
|
|
226
69
|
|
|
227
|
-
|
|
70
|
+
## Programmatic Usage
|
|
228
71
|
|
|
229
|
-
|
|
72
|
+
```js
|
|
73
|
+
import { Agent, API, AgentLauncher } from '@j-o-r/hello-dave';
|
|
230
74
|
|
|
231
|
-
|
|
75
|
+
const agent = new Agent({
|
|
76
|
+
prompt: "...",
|
|
77
|
+
api: API.chat.xai,
|
|
78
|
+
call_name: 'my_agent',
|
|
79
|
+
call_description: '...'
|
|
80
|
+
});
|
|
232
81
|
|
|
233
|
-
|
|
234
|
-
|
|
82
|
+
const launcher = new AgentLauncher();
|
|
83
|
+
await launcher.load('code_agent');
|
|
84
|
+
await launcher.run();
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Development
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm install
|
|
91
|
+
npm run link-self
|
|
92
|
+
```
|
|
235
93
|
|
|
236
94
|
## License
|
|
237
95
|
|
|
238
|
-
|
|
96
|
+
Apache-2.0
|
|
97
|
+
|
|
98
|
+
Repository: https://codeberg.org/duin/hello-dave
|
|
239
99
|
|
|
240
100
|
---
|
|
241
|
-
|
|
242
|
-
|
|
101
|
+
|
|
102
|
+
*Putting itself to the fullest possible use.*
|
package/TODO.md
CHANGED
|
@@ -1,35 +1,173 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- [ ]
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- [ ]
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- [ ]
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- [ ]
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
# TODO
|
|
2
|
+
|
|
3
|
+
[ ] [investigate openshell](https://docs.nvidia.com/openshell/about/overview)
|
|
4
|
+
|
|
5
|
+
## Agent Loader Review Follow-up (`lib/agentLoader.js`) — TODO
|
|
6
|
+
|
|
7
|
+
Context: Review of `lib/agentLoader.js` identified several correctness and maintainability issues around agent instance freshness, discovery side effects, path containment, and API/schema consistency.
|
|
8
|
+
|
|
9
|
+
### Priority 1 — Fresh agent instances for handoff/reset correctness
|
|
10
|
+
|
|
11
|
+
**Problem**:
|
|
12
|
+
- `loadAgent()` imports ESM modules directly and returns singleton default exports as-is.
|
|
13
|
+
- Because ESM modules are cached, repeated loads of singleton-exported agents return the same object.
|
|
14
|
+
- This conflicts with the intended fresh handoff / self-reset behavior in `AgentLauncher`.
|
|
15
|
+
- Verified behavior during review:
|
|
16
|
+
- `loadAgent('echo_agent')` twice returned the same object.
|
|
17
|
+
- Both calls shared the same prompt and session objects.
|
|
18
|
+
|
|
19
|
+
**Tasks**:
|
|
20
|
+
- [ ] Decide and document the official agent module contract:
|
|
21
|
+
- Recommended: loadable agents should export a factory that creates a fresh `Agent` instance.
|
|
22
|
+
- Example: `export default function createAgent() { return new Agent(...) }`.
|
|
23
|
+
- Optional named form: `export function createAgent() { ... }`.
|
|
24
|
+
- [ ] Update `lib/agentLoader.js` to prefer fresh factories:
|
|
25
|
+
- [ ] Prefer `mod.createAgent` when present.
|
|
26
|
+
- [ ] Then support function default exports as factories.
|
|
27
|
+
- [ ] Treat singleton object exports as legacy compatibility only.
|
|
28
|
+
- [ ] Decide whether singleton object exports should:
|
|
29
|
+
- [ ] Produce a warning in development / verbose mode, or
|
|
30
|
+
- [ ] Continue silently for backward compatibility, or
|
|
31
|
+
- [ ] Be rejected in a future breaking release.
|
|
32
|
+
- [ ] Update bundled agents that currently export singleton `Agent` instances to export factories instead.
|
|
33
|
+
- [ ] Audit all files in `agents/*.js` and any example/custom agents in docs.
|
|
34
|
+
- [ ] Update documentation in `docs/creating-agents.md` to clearly show the factory export pattern.
|
|
35
|
+
- [ ] Update any README/examples that currently show singleton agent exports.
|
|
36
|
+
|
|
37
|
+
**Suggested tests**:
|
|
38
|
+
- [ ] Add a `node:test` case proving two calls to `loadAgent('some_agent')` return different `Agent` instances.
|
|
39
|
+
- [ ] Add assertions that their prompt/session instances are also distinct where applicable.
|
|
40
|
+
- [ ] Add a regression test for same-agent reset / handoff to confirm no old session object is reused.
|
|
41
|
+
|
|
42
|
+
**Acceptance criteria**:
|
|
43
|
+
- [ ] Repeated `loadAgent(name)` calls produce fresh instances for factory-based agents.
|
|
44
|
+
- [ ] Same-agent handoff/reset does not reuse the previous `Agent`, `Prompt`, or `Session` object.
|
|
45
|
+
- [ ] Legacy singleton behavior, if retained, is explicitly documented as non-fresh.
|
|
46
|
+
|
|
47
|
+
### Priority 2 — Make `listAgents()` side-effect-light
|
|
48
|
+
|
|
49
|
+
**Problem**:
|
|
50
|
+
- `listAgents()` currently imports candidate agent modules and may call exported functions to get descriptions.
|
|
51
|
+
- This can execute top-level module code, construct full agents, run top-level await, perform I/O, hang, or seed the ESM module cache before actual loading.
|
|
52
|
+
- Discovery should ideally be cheap and not instantiate agents.
|
|
53
|
+
|
|
54
|
+
**Tasks**:
|
|
55
|
+
- [ ] Define a lightweight metadata contract for agent descriptions.
|
|
56
|
+
- Recommended exports:
|
|
57
|
+
- `export const call_description = '...'`
|
|
58
|
+
- `export const description = call_description`
|
|
59
|
+
- [ ] Update `listAgents()` so it reads exported metadata without calling agent factories.
|
|
60
|
+
- [ ] Avoid invoking default exports during discovery.
|
|
61
|
+
- [ ] Decide fallback behavior when metadata is missing:
|
|
62
|
+
- [ ] Return `[NO DESCRIPTION]`, or
|
|
63
|
+
- [ ] Return `[ERROR]`, or
|
|
64
|
+
- [ ] Use filename-derived fallback text.
|
|
65
|
+
- [ ] Update bundled agents to export metadata constants directly.
|
|
66
|
+
- [ ] Update docs to tell agent authors that descriptions used by `dave --agents` / `list_agents` must be exported as metadata.
|
|
67
|
+
|
|
68
|
+
**Suggested tests**:
|
|
69
|
+
- [ ] Add a fixture agent whose factory throws if called.
|
|
70
|
+
- [ ] Confirm `listAgents()` still lists it from metadata without calling the factory.
|
|
71
|
+
- [ ] Add a fixture with top-level metadata and ensure the listed description matches exactly.
|
|
72
|
+
- [ ] Add a fixture with missing metadata and verify the selected fallback behavior.
|
|
73
|
+
|
|
74
|
+
**Acceptance criteria**:
|
|
75
|
+
- [ ] `listAgents()` does not call agent factories.
|
|
76
|
+
- [ ] Discovery remains fast and predictable.
|
|
77
|
+
- [ ] Listing agents does not accidentally create or cache live agent instances.
|
|
78
|
+
|
|
79
|
+
### Priority 3 — Harden name-based path resolution against symlink escapes
|
|
80
|
+
|
|
81
|
+
**Problem**:
|
|
82
|
+
- Direct path loading performs realpath/root containment checks.
|
|
83
|
+
- Name-based resolution currently checks readability of candidate files but does not apply equivalent realpath containment validation.
|
|
84
|
+
- A symlink inside an allowed agent directory could point outside the intended search roots and still be imported.
|
|
85
|
+
|
|
86
|
+
**Tasks**:
|
|
87
|
+
- [ ] Add shared helper logic for path containment checks so direct-path and name-based loading use the same security rule.
|
|
88
|
+
- [ ] Realpath each configured agent directory once where practical.
|
|
89
|
+
- [ ] When resolving by agent name, verify the resolved candidate file is inside one of the allowed real agent directories.
|
|
90
|
+
- [ ] Decide whether symlinked files inside the allowed tree are permitted when their real target also remains inside an allowed root.
|
|
91
|
+
- [ ] Improve error messages for symlink escape attempts.
|
|
92
|
+
|
|
93
|
+
**Suggested tests**:
|
|
94
|
+
- [ ] Add a temporary test fixture with an agent symlink that points outside the allowed agent directory.
|
|
95
|
+
- [ ] Confirm `loadAgent(name)` rejects the symlink escape.
|
|
96
|
+
- [ ] Add a positive test for a normal in-tree agent.
|
|
97
|
+
- [ ] If in-tree symlinks are allowed, add a positive test for a symlink whose real target remains inside the allowed root.
|
|
98
|
+
|
|
99
|
+
**Acceptance criteria**:
|
|
100
|
+
- [ ] Name-based loading cannot import files outside configured agent roots via symlinks.
|
|
101
|
+
- [ ] Direct-path and name-based resolution enforce consistent containment semantics.
|
|
102
|
+
|
|
103
|
+
### Priority 4 — Align agent-name validation rules across loader and handoff tool schema
|
|
104
|
+
|
|
105
|
+
**Problem**:
|
|
106
|
+
- `lib/agentLoader.js` allows names matching `^[a-z0-9_]{2,}$`.
|
|
107
|
+
- `lib/handOffToolset.js` advertises `^[a-z0-9_]{2,64}$`.
|
|
108
|
+
- This means some names are loadable/discoverable but cannot be called through `hand_over` / `load_agent`.
|
|
109
|
+
|
|
110
|
+
**Tasks**:
|
|
111
|
+
- [ ] Centralize the public agent-name regex in a shared module or exported constant.
|
|
112
|
+
- [ ] Decide the canonical limit; recommended: `^[a-z0-9_]{2,64}$`.
|
|
113
|
+
- [ ] Update `lib/agentLoader.js` to use the shared rule.
|
|
114
|
+
- [ ] Update `lib/handOffToolset.js` to use the same source of truth or generate the schema pattern from it.
|
|
115
|
+
- [ ] Update docs for allowed agent names.
|
|
116
|
+
|
|
117
|
+
**Suggested tests**:
|
|
118
|
+
- [ ] Add tests for too-short, valid, invalid-character, and too-long agent names.
|
|
119
|
+
- [ ] Confirm loader and handoff schema accept/reject the same examples.
|
|
120
|
+
|
|
121
|
+
**Acceptance criteria**:
|
|
122
|
+
- [ ] There is one canonical public agent-name rule.
|
|
123
|
+
- [ ] Loader behavior and tool schema behavior are consistent.
|
|
124
|
+
|
|
125
|
+
### Priority 5 — Clarify or improve direct relative path resolution
|
|
126
|
+
|
|
127
|
+
**Problem**:
|
|
128
|
+
- Direct relative paths are currently resolved against `process.cwd()`.
|
|
129
|
+
- That is reasonable for CLI use, but may surprise callers using `createAgentLoader({ from: import.meta.url })`, who may expect relative paths to resolve from the caller package root.
|
|
130
|
+
|
|
131
|
+
**Tasks**:
|
|
132
|
+
- [ ] Decide whether direct relative paths should remain CWD-relative or become caller-package-root-relative when `from` is provided.
|
|
133
|
+
- [ ] If keeping current behavior:
|
|
134
|
+
- [ ] Document clearly that direct relative paths are always CWD-relative.
|
|
135
|
+
- [ ] Add tests proving that behavior.
|
|
136
|
+
- [ ] If changing behavior:
|
|
137
|
+
- [ ] Resolve relative direct paths from the `from` package root when provided.
|
|
138
|
+
- [ ] Preserve current CLI behavior where no `from` is provided.
|
|
139
|
+
- [ ] Add migration notes for any compatibility impact.
|
|
140
|
+
|
|
141
|
+
**Suggested tests**:
|
|
142
|
+
- [ ] Add tests for direct relative path loading from the project CWD.
|
|
143
|
+
- [ ] Add tests for `createAgentLoader({ from: import.meta.url })` from a nested fixture package.
|
|
144
|
+
- [ ] Add tests for invalid relative direct paths and outside-root attempts.
|
|
145
|
+
|
|
146
|
+
**Acceptance criteria**:
|
|
147
|
+
- [ ] Path resolution behavior is intentional, documented, and covered by tests.
|
|
148
|
+
|
|
149
|
+
### Priority 6 — Documentation and examples cleanup
|
|
150
|
+
|
|
151
|
+
**Tasks**:
|
|
152
|
+
- [ ] Update agent creation docs to show fresh factory exports and metadata exports together.
|
|
153
|
+
- [ ] Include a minimal recommended agent template:
|
|
154
|
+
- [ ] `export const call_description = '...'`
|
|
155
|
+
- [ ] `export const description = call_description`
|
|
156
|
+
- [ ] `export default function createAgent() { return new Agent(...) }`
|
|
157
|
+
- [ ] Add a short compatibility note for legacy singleton exports if they remain supported.
|
|
158
|
+
- [ ] Update CLI/help docs that mention `list_agents`, `hand_over`, or agent naming constraints.
|
|
159
|
+
- [ ] Add a short security note about agent path resolution and symlink containment.
|
|
160
|
+
|
|
161
|
+
### Priority 7 — Validation checklist after implementation
|
|
162
|
+
|
|
163
|
+
Run and record results for the following after changes are made:
|
|
164
|
+
|
|
165
|
+
- [ ] `node --check lib/agentLoader.js`
|
|
166
|
+
- [ ] `node --check lib/handOffToolset.js`
|
|
167
|
+
- [ ] Project test script from `package.json`, if available.
|
|
168
|
+
- [ ] Focused `node:test` suite for agent loader behavior.
|
|
169
|
+
- [ ] Manual smoke test:
|
|
170
|
+
- [ ] `dave --agents` or equivalent listing command.
|
|
171
|
+
- [ ] Load the same factory-based agent twice and confirm fresh objects.
|
|
172
|
+
- [ ] Trigger same-agent handoff/reset and confirm the old session object is not reused.
|
|
173
|
+
|