@j-o-r/hello-dave 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -26
- package/README.md +161 -522
- package/README.md.bak +144 -449
- package/{examples → agents}/ask_agent.js +5 -5
- package/{examples → agents}/codeserver.sh +14 -14
- package/{examples → agents}/daisy_agent.js +5 -5
- package/{examples → agents}/docs_agent.js +5 -5
- package/{examples → agents}/gpt_agent.js +5 -5
- package/{examples → agents}/grok_agent.js +5 -5
- package/agents/memory_agent.js +263 -0
- package/{examples → agents}/npm_agent.js +5 -5
- package/{examples → agents}/prompt_agent.js +5 -5
- package/agents/spawn_agent.js +137 -0
- package/{examples → agents}/test_agent.js +6 -8
- package/{examples → agents}/todo_agent.js +5 -5
- package/bin/codeDave +58 -0
- package/bin/dave.js +114 -96
- package/lib/AgentClient.js +111 -67
- package/lib/AgentManager.js +111 -80
- package/lib/AgentServer.js +144 -104
- package/lib/Cli.js +126 -93
- package/lib/Prompt.js +38 -5
- package/lib/Session.js +102 -79
- package/lib/ToolSet.js +79 -60
- package/lib/fafs.js +54 -19
- package/lib/genericToolset.js +109 -213
- package/lib/wsCli.js +50 -19
- package/lib/wsIO.js +11 -17
- package/package.json +2 -2
- package/types/AgentClient.d.ts +69 -35
- package/types/AgentManager.d.ts +50 -56
- package/types/AgentServer.d.ts +63 -16
- package/types/Cli.d.ts +56 -10
- package/types/Prompt.d.ts +36 -4
- package/types/Session.d.ts +23 -9
- package/types/ToolSet.d.ts +49 -32
- package/types/fafs.d.ts +68 -25
- package/types/wsCli.d.ts +14 -0
- package/types/wsIO.d.ts +9 -5
- package/utils/search_sessions.sh +100 -53
- package/README.md.backup +0 -269
- package/README.md.bak.1774780058 +0 -338
- package/README.md.bak2 +0 -531
- package/bin/spawn_agent.js +0 -293
- package/docs.bak.1774780058/agent-manager.md +0 -167
- package/docs.bak.1774780058/agent-manager.md.bak +0 -137
- package/docs.bak.1774780058/agent-manager.md.bak2 +0 -157
- package/docs.bak.1774780058/codeserver-pattern.md +0 -191
- package/docs.bak.1774780058/path-resolution-best-practices.md +0 -104
- package/docs.bak.1774780058/project-overview.md +0 -67
- package/docs.bak.1774780058/project-overview.md.bak +0 -67
- package/docs.bak.1774780058/prompt-class.md +0 -141
- package/docs.bak.1774780058/prompt-class.md.bak +0 -142
- package/docs.bak.1774780058/tools-syntax-validation.md +0 -121
- package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +0 -125
- package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +0 -125
- package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +0 -106
- package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +0 -106
- package/docs.bak.1774780058/toolset.md +0 -164
- package/docs.bak.1774780058/toolset.md.bak +0 -94
- package/docs.bak.1774780058/toolset.md.bak3 +0 -161
- package/docs.bak.1774780058/toolset.md.bak4 +0 -161
- package/docs.bak.1774780058/toolset.md.bak5 +0 -161
- package/docs.bak.1774780058/toolset.md.bak6 +0 -163
- package/docs.bak.1774780058/toolset.md.bak_path +0 -163
- package/docs.bak.1774780058/toolset.md.bak_syntax +0 -161
- package/docs.bak.1774780058/xai-responses.md +0 -111
- package/docs.bak.1774780058/xai-responses.md.bak +0 -107
- package/docs.bak.1774780058/xai-responses.md.bak2 +0 -107
- package/docs.bak.1774780058/xai_collections.md +0 -106
- package/examples/memory_agent.js +0 -152
- package/examples.bak.1774780058/ask_agent.js +0 -114
- package/examples.bak.1774780058/code_agent.js +0 -149
- package/examples.bak.1774780058/coderev_agent.js +0 -72
- package/examples.bak.1774780058/codeserver.sh +0 -47
- package/examples.bak.1774780058/daisy_agent.js +0 -177
- package/examples.bak.1774780058/docs_agent.js +0 -119
- package/examples.bak.1774780058/gpt_agent.js +0 -109
- package/examples.bak.1774780058/grok_agent.js +0 -98
- package/examples.bak.1774780058/memory_agent.js +0 -112
- package/examples.bak.1774780058/npm_agent.js +0 -175
- package/examples.bak.1774780058/prompt_agent.js +0 -112
- package/examples.bak.1774780058/readme_agent.js +0 -144
- package/examples.bak.1774780058/spawn_agent.js +0 -263
- package/examples.bak.1774780058/test_agent.js +0 -162
- package/examples.bak.1774780058/todo_agent.js +0 -138
- package/lib/genericToolset.js.bak_syntax +0 -402
- package/scenarios.bak.1774780058/data/eval_node_message.json +0 -9
- package/scenarios.bak.1774780058/data/hist_oa.json +0 -66
- package/scenarios.bak.1774780058/data/o3_response1.json +0 -96
- package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +0 -112
- package/scenarios.bak.1774780058/data/tool_oa.json +0 -96
- package/scenarios.bak.1774780058/data/tool_xai.json +0 -59
- package/scenarios.bak.1774780058/data/tool_xai2.json +0 -40
- package/scenarios.bak.1774780058/data/xai-response-1.json +0 -59
- package/scenarios.bak.1774780058/data/xai-response-2.json +0 -10
- package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +0 -59
- package/scenarios.bak.1774780058/data/xai_search_response.json +0 -58
- package/scenarios.bak.1774780058/environment.js +0 -10
- package/scenarios.bak.1774780058/example.js +0 -17
- package/scenarios.bak.1774780058/genericToolset.test.js +0 -182
- package/scenarios.bak.1774780058/grok.js +0 -113
- package/scenarios.bak.1774780058/memory-tools.js +0 -51
- package/scenarios.bak.1774780058/openai-o3.js +0 -137
- package/scenarios.bak.1774780058/openai-prompt.js +0 -155
- package/scenarios.bak.1774780058/openai-session.js +0 -148
- package/scenarios.bak.1774780058/openai.js +0 -102
- package/scenarios.bak.1774780058/prompt.js +0 -118
- package/scenarios.bak.1774780058/promptFishbowl.js +0 -76
- package/scenarios.bak.1774780058/search.brave.com.js +0 -25
- package/scenarios.bak.1774780058/sh.js +0 -15
- package/scenarios.bak.1774780058/test-wsio.js +0 -26
- package/scenarios.bak.1774780058/testToolset.js +0 -42
- package/scenarios.bak.1774780058/toolset.js +0 -16
- package/scenarios.bak.1774780058/toolset.test.js +0 -141
- package/scenarios.bak.1774780058/write_file_syntax.test.js +0 -145
- package/scenarios.bak.1774780058/write_file_validation/README.md +0 -30
- package/scenarios.bak.1774780058/write_file_validation/bad.js +0 -3
- package/scenarios.bak.1774780058/write_file_validation/good.js +0 -4
- package/scenarios.bak.1774780058/write_file_validation/test.sh +0 -43
- package/scenarios.bak.1774780058/wsClient.js +0 -69
- package/scenarios.bak.1774780058/xai_responses.integration.test.js +0 -57
- package/scenarios.bak.1774780058/xai_responses.test.js +0 -154
- package/scenarios.bak.1774780058/xaicoll.js +0 -50
- package/scenarios.bak.1774780058/xaifiles.js +0 -48
- /package/{examples → agents}/code_agent.js +0 -0
- /package/{examples → agents}/readme_agent.js +0 -0
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
# AgentManager (`lib/AgentManager.js`)
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
**AgentManager** is the central orchestrator class in the hello-dave framework. It manages agent lifecycle: setup (prompts, API, tools, sessions), execution modes (CLI, direct calls, WebSocket server/client), and tool integration. Designed for simplicity and extensibility, it abstracts LLM providers (`xai`, `gpt`, `claude`), `Prompt.js`, `ToolSet.js`, and `Session.js`.
|
|
5
|
-
|
|
6
|
-
Key Features:
|
|
7
|
-
- **Modes**: Interactive CLI, one-shot `directCall`, WS **server** (expose agent as tool), **client** (attach to remote server), hybrid (server + client).
|
|
8
|
-
- **Tool Handling**: Pre-configured (`toolsetMode: 'auto'`/`'required'`), generics (`addGenericToolcall`), custom `ToolSet`.
|
|
9
|
-
- **Persistence**: Sessions in `.cache/[name]/` (NDJSON logs).
|
|
10
|
-
- **Networking**: WS with optional `secret` auth (base64-encoded).
|
|
11
|
-
- **Validation**: Strict name regex `/^[a-z_0-9_]{2,}$/`.
|
|
12
|
-
- **Events**: Leverages `Prompt` events (e.g., `reset` → server resetAll).
|
|
13
|
-
|
|
14
|
-
Exports: `default AgentManager`.
|
|
15
|
-
|
|
16
|
-
## Agent Naming Rules ⚠️
|
|
17
|
-
**CRITICAL**: The `name` (constructor) and `toolName` (in `start()`) **MUST** match regex `/^[a-z_0-9_]{2,}$/`:
|
|
18
|
-
- Lowercase `a-z`, digits `0-9`, `_` **only**.
|
|
19
|
-
- **Minimum 2 characters**.
|
|
20
|
-
|
|
21
|
-
**Valid ✅**:
|
|
22
|
-
- `myagent`
|
|
23
|
-
- `chatbot`
|
|
24
|
-
- `weather_agent`
|
|
25
|
-
- `tool123`
|
|
26
|
-
- `ws_client`
|
|
27
|
-
|
|
28
|
-
**Invalid ❌ (throws `Error`)**:
|
|
29
|
-
- `MyAgent` (uppercase)
|
|
30
|
-
- `agent-v1` (hyphen)
|
|
31
|
-
- `a` (too short)
|
|
32
|
-
- `agent#tool` (`#` invalid)
|
|
33
|
-
- `Agent_` (uppercase)
|
|
34
|
-
|
|
35
|
-
**Why?** Safe for folders, tool names, filesystems (no specials/caps/spaces).
|
|
36
|
-
|
|
37
|
-
## Quick Usage
|
|
38
|
-
```javascript
|
|
39
|
-
import AgentManager from '../lib/AgentManager.js'; // or '@j-o-r/hello-dave'
|
|
40
|
-
|
|
41
|
-
const agent = new AgentManager({ name: 'myagent', secret: 'mysecret' });
|
|
42
|
-
agent.setup({
|
|
43
|
-
prompt: 'You are a helpful coding assistant.',
|
|
44
|
-
api: 'xai',
|
|
45
|
-
options: { model: 'grok-4-fast-reasoning' },
|
|
46
|
-
toolsetMode: 'auto',
|
|
47
|
-
contextWindow: 128000
|
|
48
|
-
});
|
|
49
|
-
agent.addGenericToolcall('execute_bash_script');
|
|
50
|
-
|
|
51
|
-
await agent.start(); // CLI mode
|
|
52
|
-
// Or: await agent.directCall('Write a Bash script'); // One-shot
|
|
53
|
-
// Or: await agent.start(8000); // WS server on port 8000
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Constructor Options
|
|
57
|
-
| Property | Type | Default | Description |
|
|
58
|
-
|----------|------|---------|-------------|
|
|
59
|
-
| `name` | string | `'agent'` | **Agent ID (session folder, tool name). MUST match `/^[a-z_0-9_]{2,}$/` (lowercase a-z0-9_; ≥2 chars).** |
|
|
60
|
-
| `secret` | string | `''` | WS auth (base64-encoded; optional, match server/client). |
|
|
61
|
-
| `cachePath` | string | `'.cache/hello-dave'` | Session storage root. |
|
|
62
|
-
|
|
63
|
-
## setup(setup) → `this` (chainable)
|
|
64
|
-
Configures the agent. Must call before `start()`/`directCall()`.
|
|
65
|
-
|
|
66
|
-
| Property | Type | Default | Description |
|
|
67
|
-
|----------|------|---------|-------------|
|
|
68
|
-
| `prompt` | string | - | **Required**: System prompt. |
|
|
69
|
-
| `api` | `'xai'|'gpt'|'claude'` | `'gpt'` | LLM provider (uses `lib/API/[provider]/text.js`). |
|
|
70
|
-
| `options` | `XAIOptions`/`OAOptions`/etc. | `{}` | Provider-specific (model, temperature, tools, reasoning). |
|
|
71
|
-
| `contextWindow` | number | `300000` | Token limit for `Prompt`. |
|
|
72
|
-
| `toolsetMode` | `'auto'|'required'` | `null` | `'auto'`: Generic tools; `'required'`: Empty `ToolSet` (add manually). |
|
|
73
|
-
| `debug` | boolean | `false` | Verbose logging. |
|
|
74
|
-
|
|
75
|
-
Internals: Creates `Prompt`, `Session`, sets `Prompt.setAdaptor(API.text[api], toolset, options)`.
|
|
76
|
-
|
|
77
|
-
## Key Methods
|
|
78
|
-
| Method | Args | Returns | Description |
|
|
79
|
-
|--------|------|---------|-------------|
|
|
80
|
-
| `directCall(input)` | `string` | `Promise<string>` | One-shot query (via `prompt.call()`). |
|
|
81
|
-
| `getPrompt()` | - | `Prompt` | Access internal `Prompt`. |
|
|
82
|
-
| `getToolset()` | - | `ToolSet\|void` | Access tools. |
|
|
83
|
-
| `environment()` | - | `Promise<EnvironmentInfo>` | System info (via `fafs.js/env()`). |
|
|
84
|
-
| `addGenericToolcall(name)` | string (e.g., `'read_file'`) | - | Copy from `genericToolset.js` pool. Post-setup only. |
|
|
85
|
-
| `start(servePort?, connectUrl?, cliIntro?, toolName?, toolDesc?)` | Mixed | `Promise<void>` | **Smart launcher**:<br>- `servePort` (num): WS **server** (**toolName** MUST match name regex or auto-gen).<br>- `connectUrl` (str, e.g. `'ws://127.0.0.1:8000/ws'`): WS **client** (toolName/desc for attachment).<br>- Neither: **CLI** mode.<br>- Both: Hybrid. |
|
|
86
|
-
|
|
87
|
-
## Workflow Diagram
|
|
88
|
-
```mermaid
|
|
89
|
-
graph TD
|
|
90
|
-
A[New AgentManager name, secret] --> B[setup prompt, api, options, toolsetMode]
|
|
91
|
-
B --> C{start args?}
|
|
92
|
-
C -->|servePort| D[enableServer port, name, desc<br/>+ optional attach client]
|
|
93
|
-
C -->|connectUrl| E[attach client url, name, desc]
|
|
94
|
-
C -->|none| F[startCli intro]
|
|
95
|
-
D --> G[Session Loop: Prompt → API/Tools → Response]
|
|
96
|
-
E --> G
|
|
97
|
-
F --> G
|
|
98
|
-
G --> H[directCall or persist]
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
**Per-Endpoint Options**:
|
|
102
|
-
- **CLI**: `start()` → `Cli` (interactive/piped). Options via `setup`.
|
|
103
|
-
- **WS Server**: `start(port)` → `AgentServer` (localhost only). Exposes agent as tool (name/desc). `secret` required for clients. `prompt.on('reset')` → `server.resetAll()`.
|
|
104
|
-
- **WS Client**: `start(undefined, url)` → `AgentClient`. Connects to remote server; agent callable as tool.
|
|
105
|
-
- **Direct**: `directCall()` bypasses networking/CLI.
|
|
106
|
-
|
|
107
|
-
## Examples
|
|
108
|
-
|
|
109
|
-
### 1. Interactive CLI Agent
|
|
110
|
-
```javascript
|
|
111
|
-
const agent = new AgentManager({ name: 'chatbot' });
|
|
112
|
-
agent.setup({
|
|
113
|
-
prompt: 'You are a friendly chatbot.',
|
|
114
|
-
api: 'xai',
|
|
115
|
-
toolsetMode: 'auto'
|
|
116
|
-
});
|
|
117
|
-
await agent.start('Chatbot ready!'); // Auto-generates intro
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### 2. WS Server (Expose as Tool)
|
|
121
|
-
```javascript
|
|
122
|
-
agent.setup({ ... });
|
|
123
|
-
await agent.start(8000, undefined, undefined, 'weathertool', 'Get real-time weather');
|
|
124
|
-
```
|
|
125
|
-
- Clients: `npx @j-o-r/hello-dave dave --connect ws://localhost:8000/ws --secret mysecret`
|
|
126
|
-
|
|
127
|
-
### 3. Hybrid + Direct Call
|
|
128
|
-
```javascript
|
|
129
|
-
await agent.start(8001, 'ws://other:8000/ws'); // Server on 8001 + client to other
|
|
130
|
-
const resp = await agent.directCall('Hybrid query'); // Uses attached tools too
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### 4. Custom Tools + Generics
|
|
134
|
-
```javascript
|
|
135
|
-
agent.setup({ toolsetMode: 'required' });
|
|
136
|
-
const ts = agent.getToolset();
|
|
137
|
-
ts.add('customMath', 'Add numbers', {
|
|
138
|
-
type: 'object', properties: {a: {type: 'number'}, b: {type: 'number'}},
|
|
139
|
-
required: ['a', 'b']
|
|
140
|
-
}, async ({a, b}) => a + b);
|
|
141
|
-
agent.addGenericToolcall('javascript_interpreter');
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## Advanced: Networking & Secrets
|
|
145
|
-
- **Server-Client Chain**: Server A attaches to Server B → A callable from B (and vice versa if mutual).
|
|
146
|
-
- **Cron/CLI Messaging**: Pipe to client: `echo 'query' | npx ... dave --connect ...`
|
|
147
|
-
- **Reset**: `Prompt` emits `'reset'` → propagates to attached servers/clients.
|
|
148
|
-
|
|
149
|
-
## Errors
|
|
150
|
-
- No `setup()`: Throws.
|
|
151
|
-
- **Invalid `name`/`toolName`: Regex `/^[a-z_0-9_]{2,}$/` fail → `Error`.**
|
|
152
|
-
- No `toolset` on server: Throws.
|
|
153
|
-
|
|
154
|
-
See source `lib/AgentManager.js` for full JSDoc/types. Cross-links:
|
|
155
|
-
- [Prompt](./prompt-class.md)
|
|
156
|
-
- [ToolSet](./toolset.md)
|
|
157
|
-
- [Generic Tools](../lib/genericToolset.js)
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
# CodeServer Pattern
|
|
2
|
-
|
|
3
|
-
[](https://pm2.keymetrics.io/) [](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Introduction & Motivation](#introduction--motivation)
|
|
8
|
-
- [Architecture](#architecture)
|
|
9
|
-
- [Prerequisites](#prerequisites)
|
|
10
|
-
- [Step-by-Step Setup](#step-by-step-setup)
|
|
11
|
-
- [Interaction via \`bin/dave.js\`](#interaction-via-bindavejs)
|
|
12
|
-
- [Monitoring & Stopping with PM2](#monitoring--stopping-with-pm2)
|
|
13
|
-
- [Customization](#customization)
|
|
14
|
-
- [Benefits](#benefits)
|
|
15
|
-
- [Troubleshooting](#troubleshooting)
|
|
16
|
-
- [Integration with AgentManager](#integration-with-agentmanager)
|
|
17
|
-
- [References](#references)
|
|
18
|
-
|
|
19
|
-
## Introduction & Motivation
|
|
20
|
-
|
|
21
|
-
The **CodeServer pattern** demonstrates a production-ready setup for running a **persistent, always-on agent server** managed by [PM2](https://pm2.keymetrics.io/). It launches:
|
|
22
|
-
|
|
23
|
-
- **Main Server**: \`code_agent.js\` as a WebSocket server (code-focused agent with JavaScript tools).
|
|
24
|
-
- **Sub-Agents (Clients)**: Specialized agents (\`todo_agent.js\`, \`readme_agent.js\`, \`npm_agent.js\`, \`docs_agent.js\`) that **attach as tools** to the main server via WebSocket.
|
|
25
|
-
|
|
26
|
-
**Motivation**:
|
|
27
|
-
- **Persistence**: Long-running sessions without restarts (state in \`.cache/hello-dave/[agent]/\`).
|
|
28
|
-
- **Delegation**: Main agent delegates to specialists (e.g., "update docs" → \`docsDave\` tool).
|
|
29
|
-
- **No Heartbeats**: PM2 handles restarts, monitoring—no custom pings.
|
|
30
|
-
- **Scalability**: Easy to add sub-agents, deploy across machines.
|
|
31
|
-
- **CLI-Friendly**: Interact via \`bin/dave.js --connect\`.
|
|
32
|
-
|
|
33
|
-
Ideal for dev workflows: code execution, docs mgmt, npm inspection, todos—all in one persistent hub.
|
|
34
|
-
|
|
35
|
-
See live example: [examples/CodeServer](../examples/CodeServer)
|
|
36
|
-
|
|
37
|
-
## Architecture
|
|
38
|
-
|
|
39
|
-
```mermaid
|
|
40
|
-
graph TB
|
|
41
|
-
PM2[PM2 Process Manager] --> Main[Main: code_agent.js<br/>--serve PORT --secret SECRET<br/>WS Server on /ws]
|
|
42
|
-
PM2 --> Todo[todo_agent.js<br/>--connect ws://localhost:PORT/ws<br/>tool: todo_agent]
|
|
43
|
-
PM2 --> Readme[readme_agent.js<br/>--connect ...<br/>tool: readme_agent]
|
|
44
|
-
PM2 --> NPM[npm_agent.js<br/>--connect ...<br/>tool: npm_module_inspector]
|
|
45
|
-
PM2 --> Docs[docs_agent.js<br/>--connect ...<br/>tool: agent_docs]
|
|
46
|
-
|
|
47
|
-
User[bin/dave.js --connect] -.-> Main
|
|
48
|
-
Main -->|Delegates via tools| Todo & Readme & NPM & Docs
|
|
49
|
-
Todo -.->|File ops| ProjectFiles[(TODO.md, etc.)]
|
|
50
|
-
Docs -.->|Docs mgmt| DocsFolder[./docs/*.md]
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**Key Flows**:
|
|
54
|
-
1. PM2 spawns all processes (named \`FOLDER_agent_PORT\`).
|
|
55
|
-
2. Clients connect to main server → auto-register as **tools** (e.g., \`todo_agent\`, \`readme_agent\`).
|
|
56
|
-
3. User queries main server → delegates (e.g., \`call todo_agent {add: "new task"}\`).
|
|
57
|
-
4. Sessions persist independently per agent.
|
|
58
|
-
|
|
59
|
-
## Prerequisites
|
|
60
|
-
|
|
61
|
-
| Requirement | Install Command | Notes |
|
|
62
|
-
|-------------|-----------------|-------|
|
|
63
|
-
| **Node.js** | `node --version` (≥18) | ESM support required. |
|
|
64
|
-
| **PM2** | `npm i -g pm2` | Process manager. Startup: `pm2 startup`. |
|
|
65
|
-
| **Project** | `git clone <repo> && cd hello-dave` | Examples in \`./examples/\`. |
|
|
66
|
-
|
|
67
|
-
Verify: `pm2 --version` & `node -e "import('@j-o-r/hello-dave')"`
|
|
68
|
-
|
|
69
|
-
## Step-by-Step Setup
|
|
70
|
-
|
|
71
|
-
1. **Navigate to project**:
|
|
72
|
-
```bash
|
|
73
|
-
cd /path/to/hello-dave
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
2. **Launch CodeServer** (pick PORT 1024-65535, SECRET ≥3 chars):
|
|
77
|
-
```bash
|
|
78
|
-
./examples/CodeServer 8080 mysecret123
|
|
79
|
-
```
|
|
80
|
-
Output:
|
|
81
|
-
```
|
|
82
|
-
Starting CodeServer on port 8080 in folder 'hello-dave' ... with SECRET 'mysecret123'
|
|
83
|
-
CodeServer processes spawned with prefix 'hello-dave_' and suffix _8080.
|
|
84
|
-
dave --connect ws://127.0.0.1:8080/ws --secret 'mysecret123'
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
3. **Verify PM2**:
|
|
88
|
-
```bash
|
|
89
|
-
pm2 list | grep 8080
|
|
90
|
-
```
|
|
91
|
-
| Name | Status | CPU | Memory |
|
|
92
|
-
|-----------------------|--------|-----|--------|
|
|
93
|
-
| hello-dave_code_agent_8080 | online | ... | ... |
|
|
94
|
-
| hello-dave_todo_agent_8080 | online | ... | ... |
|
|
95
|
-
| ... (4 total) | ... | ... | ... |
|
|
96
|
-
|
|
97
|
-
## Interaction via \`bin/dave.js\`
|
|
98
|
-
|
|
99
|
-
**Interactive**:
|
|
100
|
-
```bash
|
|
101
|
-
./bin/dave.js --connect 'ws://localhost:8080/ws' --secret 'mysecret123'
|
|
102
|
-
```
|
|
103
|
-
- Chat with **code_agent** (main agent).
|
|
104
|
-
- Delegates automatically: "Manage todos", "Inspect @j-o-r/cli", "Update docs/codeserver-pattern.md".
|
|
105
|
-
|
|
106
|
-
**Piped (one-shot)**:
|
|
107
|
-
```bash
|
|
108
|
-
echo "List pending todos" | ./bin/dave.js --connect 'ws://localhost:8080/ws' --secret 'mysecret123'
|
|
109
|
-
echo "user_reset" | ./bin/dave.js --connect ... # Reset session
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
**Delegation Examples**:
|
|
113
|
-
- \`code_agent\`: "Use todo_agent to add 'Review PRs'"
|
|
114
|
-
- \`code_agent\`: "Call agent_docs to create nodejs-guide.md"
|
|
115
|
-
|
|
116
|
-
## Monitoring & Stopping with PM2
|
|
117
|
-
|
|
118
|
-
**Monitor**:
|
|
119
|
-
- `pm2 list` / `pm2 monit` (dashboard)
|
|
120
|
-
- `pm2 logs hello-dave_code_agent_8080` (agent logs)
|
|
121
|
-
- `pm2 logs *8080 --lines 50`
|
|
122
|
-
|
|
123
|
-
**Stop**:
|
|
124
|
-
```bash
|
|
125
|
-
pm2 stop hello-dave_*_8080 # All related
|
|
126
|
-
# Or delete:
|
|
127
|
-
pm2 delete hello-dave_code_agent_8080 hello-dave_todo_agent_8080 ...
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**Startup** (auto-restart on boot): `pm2 save && pm2 startup`
|
|
131
|
-
|
|
132
|
-
## Customization
|
|
133
|
-
|
|
134
|
-
### Adding Sub-Agents
|
|
135
|
-
Edit [examples/CodeServer](../examples/CodeServer):
|
|
136
|
-
```bash
|
|
137
|
-
# Add new agent
|
|
138
|
-
pm2 start "${SCRIPT_DIR}/newAgent.js" --name "${FOLDER}_new_agent_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
|
|
139
|
-
```
|
|
140
|
-
- Create \`newAgent.js\` like [examples/todo_agent.js](../examples/todo_agent.js): Set \`tool_call_name\`, prompt.
|
|
141
|
-
|
|
142
|
-
### Changing Tools
|
|
143
|
-
- Main server: Edit \`code_agent.js\`: \`--tools javascript,bash,ssh\`
|
|
144
|
-
- Sub-agents: \`agent.addGenericToolcall('read_file')\` etc. See [toolset.md](../toolset.md).
|
|
145
|
-
|
|
146
|
-
### Prompts/Models
|
|
147
|
-
- Per-agent: Edit JS files (e.g., \`options.model = 'grok-4-1-fast-reasoning'\`).
|
|
148
|
-
|
|
149
|
-
## Benefits
|
|
150
|
-
|
|
151
|
-
| Feature | Advantage |
|
|
152
|
-
|---------|-----------|
|
|
153
|
-
| **Persistent Sessions** | State in \`.cache/hello-dave/[name]/sessions/\`—no re-explaining. |
|
|
154
|
-
| **Delegation** | Main agent uses sub-agents as tools (parallel, specialized). |
|
|
155
|
-
| **No Heartbeat** | PM2 restarts on crash; no custom logic. |
|
|
156
|
-
| **Resource Efficient** | Shared context; subs only active on call. |
|
|
157
|
-
| **Portable** | Script auto-prefixes PM2 names by folder/port. |
|
|
158
|
-
|
|
159
|
-
## Troubleshooting
|
|
160
|
-
|
|
161
|
-
| Issue | Solution |
|
|
162
|
-
|-------|----------|
|
|
163
|
-
| **Port in use** | Change PORT; `lsof -i :8080` & `kill`. |
|
|
164
|
-
| **Secret mismatch** | Ensure exact match (no extra spaces). |
|
|
165
|
-
| **PM2 not found** | `npm i -g pm2`. |
|
|
166
|
-
| **Connection refused** | Wait 5s for server startup; check `pm2 logs`. |
|
|
167
|
-
| **No delegation** | Verify client tool names in JS (e.g., \`todo_agent\`). |
|
|
168
|
-
| **High memory** | `pm2 del *` or tweak \`contextWindow\`. |
|
|
169
|
-
|
|
170
|
-
Logs: `.cache/hello-dave/[agent]/sessions/*.ndjson` (use \`bin/dave.js --inspect log.ndjson\`).
|
|
171
|
-
|
|
172
|
-
## Integration with AgentManager
|
|
173
|
-
|
|
174
|
-
Built on [AgentManager](../docs/agent-manager.md):
|
|
175
|
-
|
|
176
|
-
- **Server**: `agent.start(PORT)` → WS server exposing \`code_agent\`.
|
|
177
|
-
- **Clients**: `agent.start(undefined, 'ws://...', undefined, 'todo_agent', 'desc')` → Attaches as tool.
|
|
178
|
-
|
|
179
|
-
**Tools**: Generic from [toolset.md](../docs/toolset.md) (e.g., \`execute_bash_script\`, \`javascript_interpreter\`).
|
|
180
|
-
|
|
181
|
-
Cross-links:
|
|
182
|
-
- [Prompt Class](../docs/prompt-class.md)
|
|
183
|
-
- [Generic Tools](../lib/genericToolset.js)
|
|
184
|
-
|
|
185
|
-
## References
|
|
186
|
-
|
|
187
|
-
- [PM2 Docs](https://pm2.keymetrics.io/docs/usage/quick-start/)
|
|
188
|
-
- Examples: [CodeServer](../examples/CodeServer), [code_agent.js](../examples/code_agent.js), [todo_agent.js](../examples/todo_agent.js), etc.
|
|
189
|
-
- Sessions: \`bin/dave.js --list\`
|
|
190
|
-
|
|
191
|
-
**Updated**: March 24, 2026
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# Path Resolution Best Practices for Generic Tools
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
In `lib/genericToolset.js` and related tools (e.g., `syntax_check`, `write_file`), **path resolution** distinguishes between:
|
|
5
|
-
- **Module-relative paths** (utils/scripts): Use `__dirname` for portability.
|
|
6
|
-
- **User-provided file paths**: Resolve to `process.cwd()` (CWD sandbox) + strict validation.
|
|
7
|
-
|
|
8
|
-
This ensures **sandboxing** (no escapes), **portability** (works from any CWD/PM2), and **security**. All tools enforce: no `/`, `..`, `\\\\`; `resolvedPath.startsWith(process.cwd())`.
|
|
9
|
-
|
|
10
|
-
**ESM Setup** (genericToolset.js):
|
|
11
|
-
```javascript
|
|
12
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Polyfill for ESM
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## __dirname vs process.cwd(): When to Use What
|
|
16
|
-
|
|
17
|
-
| Context | Resolution | Example Code | Rationale |
|
|
18
|
-
|---------|------------|--------------|-----------|
|
|
19
|
-
| **Utils/Scripts** (e.g., syntax_check.sh, search_sessions.sh) | `__dirname` (module-rel) | `path.resolve(__dirname, '..', 'utils', 'syntax_check.sh')` | Portable: Locates utils/ from `lib/` regardless of CWD. Works in servers/clients. |
|
|
20
|
-
| **User Files** (read/write/syntax/memory) | `process.cwd()` | `path.resolve(process.cwd(), params.file)` | Sandbox: Pins to project CWD (`~/devpri/js/hello-dave`). Prevents jailbreaks. |
|
|
21
|
-
| **Cache/Memory** | `path.join(process.cwd(), '.cache/...')` | `.cache/hello-dave/memory.ndjson` | Per-project persistence. |
|
|
22
|
-
| **Shebangs/Chmod** | Absolute (resolved) | `SH`chmod +x ${[resolvedPath]}` | Post-write on validated path. |
|
|
23
|
-
|
|
24
|
-
**Universal Validation** (in read_file, write_file, syntax_check):
|
|
25
|
-
```javascript
|
|
26
|
-
const file = params.file?.trim();
|
|
27
|
-
if (file.startsWith('/') || file.includes('..') || file.includes('\\\\')) {
|
|
28
|
-
throw new Error('Path must be relative within CWD only (no `/`, `..`, or `\\\\`).');
|
|
29
|
-
}
|
|
30
|
-
const resolvedPath = path.resolve(process.cwd(), file);
|
|
31
|
-
if (!resolvedPath.startsWith(process.cwd())) {
|
|
32
|
-
throw new Error(`Path '${file}' escapes CWD scope.`);
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## syntax_check.sh Path Fix (User-Reported)
|
|
37
|
-
|
|
38
|
-
**Issue** (Early Versions):
|
|
39
|
-
- Relative paths passed to SH`` → Failed if CWD != lib/.
|
|
40
|
-
- E.g., `SH`syntax_check.sh "rel/file.js"`` → "No such file" in sub-processes (PM2/CodeServer).
|
|
41
|
-
|
|
42
|
-
**Fix** (Implemented):
|
|
43
|
-
1. **Absolute Script Path**: `path.resolve(__dirname, '..', 'utils', 'syntax_check.sh')`.
|
|
44
|
-
2. **Absolute File Arg**: `${syntaxChecker} "${resolvedPath}"` (resolvedPath = CWD-abs).
|
|
45
|
-
3. **Script Handles Absolutes**: `FILE="$1"`; `head -n1 "$FILE"` works anywhere.
|
|
46
|
-
|
|
47
|
-
**Test from Any CWD**:
|
|
48
|
-
```bash
|
|
49
|
-
cd /tmp
|
|
50
|
-
/full/path/to/hello-dave/utils/syntax_check.sh /full/path/to/hello-dave/test.js # ✅ JS OK
|
|
51
|
-
# Or via tool: agent.directCall("syntax_check('test.js')") # Resolves internally
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
**SH Best Practice**: Use array args `${[resolvedPath]}` → Auto-quotes/escapes paths with spaces.
|
|
55
|
-
|
|
56
|
-
## Best Practices & Pitfalls
|
|
57
|
-
|
|
58
|
-
### ✅ Do
|
|
59
|
-
1. **Utils**: Always `__dirname, '..', 'utils', 'script.sh'` → Portable across deployments.
|
|
60
|
-
2. **Files**: `process.cwd()` + validation → Sandboxed writes/reads.
|
|
61
|
-
3. **SH Calls**: `SH`${script} ${[path]}`.run()` → Safe quoting via @j-o-r/sh.
|
|
62
|
-
4. **Join vs Resolve**: `path.join(process.cwd(), '.cache')` for dirs; `resolve` for files.
|
|
63
|
-
5. **ESM __dirname**: Polyfill with `fileURLToPath(import.meta.url)`.
|
|
64
|
-
|
|
65
|
-
### ❌ Avoid
|
|
66
|
-
1. `path.resolve(file)` → Assumes CWD; skips validation.
|
|
67
|
-
2. `__dirname` for user files → Escapes to lib/ (security hole).
|
|
68
|
-
3. Relative SH args → Breaks in non-lib CWD (e.g., WS clients).
|
|
69
|
-
4. `process.chdir()` → Mutates global; use per-tool cwd.
|
|
70
|
-
|
|
71
|
-
### Real-World Examples (from genericToolset.js)
|
|
72
|
-
- **history_search**:
|
|
73
|
-
```js
|
|
74
|
-
const history_search = path.resolve(__dirname, '..', 'utils', 'search_sessions.sh');
|
|
75
|
-
SH`${history_search} "${escapedQuery}"`.run();
|
|
76
|
-
```
|
|
77
|
-
- **syntax_check**:
|
|
78
|
-
```js
|
|
79
|
-
const syntaxChecker = path.resolve(__dirname, '..', 'utils', 'syntax_check.sh');
|
|
80
|
-
return await SH`${syntaxChecker} "${resolvedPath}"`.run();
|
|
81
|
-
```
|
|
82
|
-
- **write_file** (AUTO-VALIDATE):
|
|
83
|
-
```js
|
|
84
|
-
const syntaxChecker = path.resolve(__dirname, '..', 'utils', 'syntax_check.sh');
|
|
85
|
-
await SH`${syntaxChecker} ${[resolvedPath]}`.run(); // Throws on fail
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Troubleshooting
|
|
89
|
-
| Issue | Cause | Fix |
|
|
90
|
-
|-------|-------|-----|
|
|
91
|
-
| "No such file: utils/script.sh" | Wrong CWD | Use `__dirname` for utils. |
|
|
92
|
-
| "Path escapes CWD" | `..` in input | Input validation blocks. |
|
|
93
|
-
| SH arg unescaped | Spaces/specials | Array `${[path]}` auto-handles. |
|
|
94
|
-
| ESM no __dirname | Node <20 | Polyfill shown above. |
|
|
95
|
-
|
|
96
|
-
**Pro Tip**: For custom tools, copy pattern: `__dirname` (utils), `process.cwd()` (files).
|
|
97
|
-
|
|
98
|
-
## Cross-Links
|
|
99
|
-
- [ToolSet](../toolset.md#generic-tools)
|
|
100
|
-
- [Syntax Validation](../tools-syntax-validation.md)
|
|
101
|
-
- [genericToolset.js](../lib/genericToolset.js) (grep "path.resolve")
|
|
102
|
-
- Utils: [syntax_check.sh](../utils/syntax_check.sh)
|
|
103
|
-
|
|
104
|
-
**Updated**: March 27, 2026 (syntax_check.sh path fix documented).
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# Hello-Dave Project Overview
|
|
2
|
-
|
|
3
|
-
## Root Directory
|
|
4
|
-
The root contains essential project configuration, documentation, and entry points:
|
|
5
|
-
- **README.md**: Main project documentation and setup instructions.
|
|
6
|
-
- **TODO.md**: Outstanding tasks and development notes.
|
|
7
|
-
- **package.json**: NPM package metadata, dependencies, and scripts.
|
|
8
|
-
- **LICENSE**: Project license (Apache 2.0).
|
|
9
|
-
- **jsconfig.json** / **tsc.json**: TypeScript/JavaScript configuration for editor and compiler support.
|
|
10
|
-
- **.gitignore** / **.npmignore**: Git and NPM ignore rules.
|
|
11
|
-
- **workspace.js**: Development or workspace management script.
|
|
12
|
-
- Directories: `bin/`, `docs/`, `examples/`, `lib/`, `scenarios/`, `types/`, `utils/`, `release/`, `node_modules/`, `.cache/` (for sessions).
|
|
13
|
-
|
|
14
|
-
## bin/
|
|
15
|
-
Executable CLI scripts (npm bin entries) for spawning and interacting with specialized \"Dave\" agents. These are user-facing tools for quick tasks:
|
|
16
|
-
- `spawn_agent.js`: Generates and runs custom agent scripts.
|
|
17
|
-
- `ask_agent.js`, `chat2Dave.js`: General interactive chat/query.
|
|
18
|
-
- `code_agent.js`: Code-related agent.
|
|
19
|
-
- `prompt_agent.js`, `docs_agent.js`: Prompt engineering and docs management.
|
|
20
|
-
- `readme_agent.js`, `todo_agent.js`: Project maintenance (README/TODO).
|
|
21
|
-
- `npm_agent.js`: NPM module inspection/publishing.
|
|
22
|
-
- Others: `formatDave.js`, `clearDave.js`, `CodeServer`.
|
|
23
|
-
|
|
24
|
-
## lib/
|
|
25
|
-
Core library code (ESM modules) **named exports only** from `lib/index.js` (NO default export):
|
|
26
|
-
- **index.js**: Main export barrel (`{ AgentManager, Prompt, ToolSet, ... }`).
|
|
27
|
-
- **AgentManager.js**: Central orchestrator for agents—handles setup, sessions, tools, networking (WS server/client), and `start()` for CLI/server modes.
|
|
28
|
-
- **Prompt.js**: Conversation manager (EventEmitter)—tracks messages, tools, truncation, token counting, provider adapters.
|
|
29
|
-
- **ToolSet.js**: Defines/extends tools (JSON Schema + handlers) like bash execution, web search, JS interpreter.
|
|
30
|
-
- **AgentServer.js**, **AgentClient.js**: WebSocket server/client for agent networking.
|
|
31
|
-
- **Session.js**: Persistent chat history/logs (NDJSON in `.cache/`).
|
|
32
|
-
- **Cli.js**: CLI input/output handling.
|
|
33
|
-
- **genericToolset.js**: Pre-configured toolset with common tools.
|
|
34
|
-
- **fafs.js**, **promptHelpers.js**: Utilities (env, file access, prompt ops).
|
|
35
|
-
- **API/**: Provider-specific wrappers (subdirs):
|
|
36
|
-
- `anthropic.com/`: Claude API.
|
|
37
|
-
- `brave.com/`: Search API.
|
|
38
|
-
- `openai.com/`: GPT API.
|
|
39
|
-
- `x.ai/`: Grok/xAI API (responses, files, collections).
|
|
40
|
-
|
|
41
|
-
## Agent Workflow
|
|
42
|
-
An **Agent** (via `AgentManager`) is configured with:
|
|
43
|
-
1. **System prompt** (via `Prompt.js`): Defines personality/task.
|
|
44
|
-
2. **API provider** (from `lib/API/`): xAI/Grok, OpenAI/GPT, Anthropic/Claude.
|
|
45
|
-
3. **ToolSet** (`ToolSet.js`): Custom/local functions (e.g., `execute_bash_script`, `web_search`); extensible.
|
|
46
|
-
4. **Session**: Conversation history.
|
|
47
|
-
|
|
48
|
-
Modes: Standalone CLI, one-shot query, WS **server** (expose as tool), **client** (attach to server), hybrid. `bin/spawn_agent.js` generates custom agents leveraging this.
|
|
49
|
-
|
|
50
|
-
## docs/
|
|
51
|
-
Project documentation (Markdown) ✅ **Complete** (reviewed Mar 24, 2026):
|
|
52
|
-
- `project-overview.md`: This file.
|
|
53
|
-
- `prompt-class.md`: Deep dive on `Prompt.js`.
|
|
54
|
-
- `toolset.md`: `ToolSet.js` details + 9 generics.
|
|
55
|
-
- `agent-manager.md`: **AgentManager** workflows, options, Mermaid diagrams.
|
|
56
|
-
- `xai-responses.md`: xAI Responses API integration/examples.
|
|
57
|
-
- `xai-collections.md`: xAI Collections (raw; Later priority).
|
|
58
|
-
|
|
59
|
-
## Other Directories
|
|
60
|
-
- **examples/**: Usage demos (e.g., `daisy_agent.js` music agent).
|
|
61
|
-
- **scenarios/**: Tests/demos (e.g., `grok_agent.js`, `wsAgent.js`).
|
|
62
|
-
- **types/**: TypeScript `.d.ts` files.
|
|
63
|
-
- **utils/**: Miscellaneous utilities.
|
|
64
|
-
- **release/**: NPM pack artifacts.
|
|
65
|
-
|
|
66
|
-
## Summary
|
|
67
|
-
`hello-dave` (@j-o-r/hello-dave NPM pkg) is a lightweight ESM Node.js framework for **tool-using AI agents** with unified LLM access (Grok/Claude/GPT), WS networking, and CLI tools. **Import via named exports: `import { AgentManager } from '@j-o-r/hello-dave';`**. Focus: Rapid prototyping of domain agents (code, docs, music) via `AgentManager` + `Prompt` + `ToolSet` + APIs. Sessions in `.cache/`. Node >=20.
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# Hello-Dave Project Overview
|
|
2
|
-
|
|
3
|
-
## Root Directory
|
|
4
|
-
The root contains essential project configuration, documentation, and entry points:
|
|
5
|
-
- **README.md**: Main project documentation and setup instructions.
|
|
6
|
-
- **TODO.md**: Outstanding tasks and development notes.
|
|
7
|
-
- **package.json**: NPM package metadata, dependencies, and scripts.
|
|
8
|
-
- **LICENSE**: Project license (Apache 2.0).
|
|
9
|
-
- **jsconfig.json** / **tsc.json**: TypeScript/JavaScript configuration for editor and compiler support.
|
|
10
|
-
- **.gitignore** / **.npmignore**: Git and NPM ignore rules.
|
|
11
|
-
- **workspace.js**: Development or workspace management script.
|
|
12
|
-
- Directories: `bin/`, `docs/`, `examples/`, `lib/`, `scenarios/`, `types/`, `utils/`, `release/`, `node_modules/`, `.cache/` (for sessions).
|
|
13
|
-
|
|
14
|
-
## bin/
|
|
15
|
-
Executable CLI scripts (npm bin entries) for spawning and interacting with specialized \"Dave\" agents. These are user-facing tools for quick tasks:
|
|
16
|
-
- `spawnDave.js`: Generates and runs custom agent scripts.
|
|
17
|
-
- `ask_agent.js`, `chat2Dave.js`: General interactive chat/query.
|
|
18
|
-
- `codeDave.js`: Code-related agent.
|
|
19
|
-
- `prompt_agent.js`, `docsDave.js`: Prompt engineering and docs management.
|
|
20
|
-
- `readmeDave.js`, `todoDave.js`: Project maintenance (README/TODO).
|
|
21
|
-
- `npmDave.js`: NPM module inspection/publishing.
|
|
22
|
-
- Others: `formatDave.js`, `clearDave.js`, `CodeServer`.
|
|
23
|
-
|
|
24
|
-
## lib/
|
|
25
|
-
Core library code (ESM modules) implementing the agent framework:
|
|
26
|
-
- **index.js**: Main export barrel (AgentManager, Prompt, ToolSet, API wrappers, etc.).
|
|
27
|
-
- **AgentManager.js**: Central orchestrator for agents—handles setup, sessions, tools, networking (WS server/client), and `start()` for CLI/server modes.
|
|
28
|
-
- **Prompt.js**: Conversation manager (EventEmitter)—tracks messages, tools, truncation, token counting, provider adapters.
|
|
29
|
-
- **ToolSet.js**: Defines/extends tools (JSON Schema + handlers) like bash execution, web search, JS interpreter.
|
|
30
|
-
- **AgentServer.js**, **AgentClient.js**: WebSocket server/client for agent networking.
|
|
31
|
-
- **Session.js**: Persistent chat history/logs (NDJSON in `.cache/`).
|
|
32
|
-
- **Cli.js**: CLI input/output handling.
|
|
33
|
-
- **genericToolset.js**: Pre-configured toolset with common tools.
|
|
34
|
-
- **fafs.js**, **promptHelpers.js**: Utilities (env, file access, prompt ops).
|
|
35
|
-
- **API/**: Provider-specific wrappers (subdirs):
|
|
36
|
-
- `anthropic.com/`: Claude API.
|
|
37
|
-
- `brave.com/`: Search API.
|
|
38
|
-
- `openai.com/`: GPT API.
|
|
39
|
-
- `x.ai/`: Grok/xAI API (responses, files, collections).
|
|
40
|
-
|
|
41
|
-
## Agent Workflow
|
|
42
|
-
An **Agent** (via `AgentManager`) is configured with:
|
|
43
|
-
1. **System prompt** (via `Prompt.js`): Defines personality/task.
|
|
44
|
-
2. **API provider** (from `lib/API/`): xAI/Grok, OpenAI/GPT, Anthropic/Claude.
|
|
45
|
-
3. **ToolSet** (`ToolSet.js`): Custom/local functions (e.g., `execute_bash_script`, `web_search`); extensible.
|
|
46
|
-
4. **Session**: Conversation history.
|
|
47
|
-
|
|
48
|
-
Modes: Standalone CLI, one-shot query, WS **server** (expose as tool), **client** (attach to server), hybrid. `bin/spawnDave.js` generates custom agents leveraging this.
|
|
49
|
-
|
|
50
|
-
## docs/
|
|
51
|
-
Project documentation (Markdown) ✅ **Complete** (reviewed Mar 24, 2026):
|
|
52
|
-
- `project-overview.md`: This file.
|
|
53
|
-
- `prompt-class.md`: Deep dive on `Prompt.js`.
|
|
54
|
-
- `toolset.md`: `ToolSet.js` details + 9 generics.
|
|
55
|
-
- `agent-manager.md`: **AgentManager** workflows, options, Mermaid diagrams.
|
|
56
|
-
- `xai-responses.md`: xAI Responses API integration/examples.
|
|
57
|
-
- `xai-collections.md`: xAI Collections (raw; Later priority).
|
|
58
|
-
|
|
59
|
-
## Other Directories
|
|
60
|
-
- **examples/**: Usage demos (e.g., `daisy_agent.js` music agent).
|
|
61
|
-
- **scenarios/**: Tests/demos (e.g., `grok_agent.js`, `wsAgent.js`).
|
|
62
|
-
- **types/**: TypeScript `.d.ts` files.
|
|
63
|
-
- **utils/**: Miscellaneous utilities.
|
|
64
|
-
- **release/**: NPM pack artifacts.
|
|
65
|
-
|
|
66
|
-
## Summary
|
|
67
|
-
`hello-dave` (@j-o-r/hello-dave NPM pkg) is a lightweight ESM Node.js framework for **tool-using AI agents** with unified LLM access (Grok/Claude/GPT), WS networking, and CLI tools. Focus: Rapid prototyping of domain agents (code, docs, music) via `AgentManager` + `Prompt` + `ToolSet` + APIs. Sessions in `.cache/`. Node >=20."
|