@j-o-r/hello-dave 0.1.0 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -25
- package/README.md +81 -221
- package/TODO.md +173 -35
- package/agents/agent_creator.js +105 -0
- package/agents/agent_creator.prompt.md +371 -0
- package/agents/ask_agent.js +64 -127
- package/agents/claude_agent.js +68 -0
- package/agents/code_agent.js +55 -135
- package/agents/code_agent.prompt.md +50 -0
- package/agents/echo_agent.js +76 -0
- package/agents/financial_expert.js +75 -0
- package/agents/gpt_agent.js +52 -103
- package/agents/gpt_code.js +81 -0
- package/agents/grok_agent.js +58 -114
- package/agents/minimax_agent.js +92 -0
- package/agents/mureka_agent.js +77 -0
- package/agents/planner_agent.js +172 -0
- package/agents/stability_agent.js +87 -0
- package/agents/test_agent.js +75 -157
- package/agents/weather_agent.js +73 -0
- package/agents/workflow_agent.js +189 -0
- package/bin/dave.js +436 -184
- package/docs/bin-dave.md +85 -35
- package/docs/cdn-ssh.md +100 -0
- package/docs/creating-agents.md +301 -0
- package/docs/creating-toolsets.md +336 -0
- package/docs/docs-organization.md +48 -0
- package/docs/project-overview.md +86 -51
- package/lib/API/elevenlabs.io/music.compose.md +441 -0
- package/lib/API/elevenlabs.io/music.create-composition-plan.md +370 -0
- package/lib/API/elevenlabs.io/music.stream.md +425 -0
- package/lib/API/lalal.ai/lalal.js +445 -0
- package/lib/API/lalal.ai/openapi.json +2614 -0
- package/lib/API/minimax/ImageToolset.js +82 -37
- package/lib/API/minimax/MusicToolset.js +125 -79
- package/lib/API/minimax/VideoToolset.js +170 -167
- package/lib/API/minimax/image.js +5 -1
- package/lib/API/minimax/music.js +210 -23
- package/lib/API/minimax/video.js +242 -53
- package/lib/API/mureka/MusicToolset.js +646 -0
- package/lib/API/mureka/README.md +41 -0
- package/lib/API/mureka/index.js +7 -0
- package/lib/API/mureka/music.js +658 -0
- package/lib/API/openai.com/index.js +7 -0
- package/lib/API/openai.com/{reponses/text.js → responses.js} +64 -18
- package/lib/API/openai.com/video.create.character.md +40 -0
- package/lib/API/openai.com/video.create.md +219 -0
- package/lib/API/openai.com/video.delete.md +44 -0
- package/lib/API/openai.com/video.download.md +31 -0
- package/lib/API/openai.com/video.edit.md +155 -0
- package/lib/API/openai.com/video.extend.md +166 -0
- package/lib/API/openai.com/video.fetch.character.md +43 -0
- package/lib/API/openai.com/video.js +784 -0
- package/lib/API/openai.com/video.list.md +201 -0
- package/lib/API/openai.com/video.remix.md +175 -0
- package/lib/API/openai.com/video.retrieve.md +139 -0
- package/lib/API/openai.com/videoToolset.js +616 -0
- package/lib/API/stability.ai/ImageToolset.js +131 -40
- package/lib/API/stability.ai/MusicToolset.js +79 -47
- package/lib/API/stability.ai/audio.js +63 -131
- package/lib/API/x.ai/chat.responses.md +1040 -0
- package/lib/API/x.ai/image.js +229 -59
- package/lib/API/x.ai/imageToolset.js +376 -0
- package/lib/API/x.ai/index.js +1 -3
- package/lib/API/x.ai/responses.js +9 -18
- package/lib/Agent.js +271 -0
- package/lib/Agent.js.old +284 -0
- package/lib/AgentLauncher.js +562 -0
- package/lib/Cli.js +87 -13
- package/lib/Prompt.js +23 -1
- package/lib/Session.js +5 -4
- package/lib/ToolSet.js +102 -6
- package/lib/agentLoader.js +369 -0
- package/lib/cdn.js +67 -231
- package/lib/{CdnToolset.js → cdnToolset.js} +47 -64
- package/lib/defaultToolsets.js +43 -0
- package/lib/fafs.js +1 -1
- package/lib/genericToolset.js +442 -119
- package/lib/handOffToolset.js +179 -0
- package/lib/index.js +34 -27
- package/lib/toolsetLoader.js +248 -0
- package/package.json +11 -5
- package/types/API/lalal.ai/lalal.d.ts +116 -0
- package/types/API/minimax/image.d.ts +2 -1
- package/types/API/minimax/music.d.ts +189 -26
- package/types/API/minimax/video.d.ts +100 -31
- package/types/API/mureka/index.d.ts +7 -0
- package/types/API/mureka/music.d.ts +472 -0
- package/types/API/openai.com/index.d.ts +7 -0
- package/types/API/openai.com/{reponses/text.d.ts → responses.d.ts} +11 -11
- package/types/API/openai.com/video.d.ts +409 -0
- package/types/API/openai.com/videoToolset.d.ts +24 -0
- package/types/API/stability.ai/audio.d.ts +14 -103
- package/types/API/stability.ai/image.d.ts +2 -2
- package/types/API/x.ai/image.d.ts +138 -26
- package/types/API/x.ai/imageToolset.d.ts +3 -0
- package/types/API/x.ai/index.d.ts +1 -3
- package/types/API/x.ai/responses.d.ts +4 -4
- package/types/Agent.d.ts +123 -0
- package/types/AgentLauncher.d.ts +222 -0
- package/types/Cli.d.ts +28 -8
- package/types/Prompt.d.ts +23 -5
- package/types/Session.d.ts +1 -1
- package/types/ToolSet.d.ts +10 -0
- package/types/agentLoader.d.ts +78 -0
- package/types/cdn.d.ts +15 -90
- package/types/defaultToolsets.d.ts +9 -0
- package/types/fafs.d.ts +1 -1
- package/types/genericToolset.d.ts +1 -1
- package/types/handOffToolset.d.ts +28 -0
- package/types/index.d.ts +19 -16
- package/types/toolsetLoader.d.ts +114 -0
- package/utils/format_log.js +101 -23
- package/utils/launch_agent.js +18 -0
- package/utils/list_sessions.sh +13 -5
- package/utils/search_sessions.sh +65 -29
- package/utils/toolsets.js +33 -0
- package/README.md.bak.1779452127 +0 -240
- package/agents/codeserver.sh +0 -47
- package/agents/daisy_agent.js +0 -173
- package/agents/docs_agent.js +0 -148
- package/agents/memory_agent.js +0 -263
- package/agents/minimax.js +0 -173
- package/agents/npm_agent.js +0 -202
- package/agents/prompt_agent.js +0 -133
- package/agents/readme_agent.js +0 -148
- package/agents/spawn_agent.js +0 -160
- package/agents/stability.js +0 -173
- package/agents/todo_agent.js +0 -175
- package/bin/codeDave +0 -58
- package/docs/agent-dave-websocket-protocol.md +0 -180
- package/docs/agent-manager.md +0 -244
- package/docs/codeserver-pattern.md +0 -191
- package/docs/generic-toolset.md +0 -326
- package/docs/howtos/agent-networking.md +0 -253
- package/docs/howtos/spawn-agents.md.bak +0 -200
- package/docs/howtos/spawn-agents.md.bak_new +0 -200
- package/docs/multi-agent-clusters.md +0 -265
- package/docs/music-toolsets.md +0 -137
- package/docs/path-resolution-best-practices.md +0 -104
- package/docs/plans/minimax-music-generation.md +0 -80
- package/docs/plans/unified-agent-architecture.md +0 -146
- package/docs/plans/websocket-streaming-plan.md.bak +0 -317
- package/docs/prompt/spawn_agent.md +0 -175
- package/docs/prompt/spawn_agent.md.bak +0 -201
- package/docs/prompt/task_clarification_and_documentation.md +0 -35
- package/docs/prompt-class.md +0 -141
- package/docs/todo-archive-infra-2026-04-21.md +0 -15
- package/docs/todo-archive-v0.0.8.md +0 -1
- package/docs/todo-archive-v0.1.0.md +0 -32
- package/docs/todo-archive.md +0 -44
- package/docs/tools-syntax-validation.md +0 -121
- package/docs/toolset.md +0 -164
- package/docs/xai-responses.md +0 -111
- package/docs/xai_collections.md +0 -106
- package/lib/API/x.ai/ImageToolset.js +0 -165
- package/lib/API/x.ai/text.js +0 -415
- package/lib/AgentClient.js +0 -248
- package/lib/AgentManager.js +0 -245
- package/lib/AgentServer.js +0 -404
- package/lib/wsCli.js +0 -287
- package/lib/wsIO.js +0 -90
- package/types/API/x.ai/text.d.ts +0 -286
- package/types/AgentClient.d.ts +0 -109
- package/types/AgentManager.d.ts +0 -100
- package/types/AgentServer.d.ts +0 -89
- package/types/wsCli.d.ts +0 -17
- package/types/wsIO.d.ts +0 -30
- package/utils/test.sh +0 -46
- /package/docs/{suggestions.md → _notes/token-counts.md} +0 -0
- /package/lib/API/openai.com/{reponses/MESSAGES.md → MESSAGES.md} +0 -0
- /package/types/API/{x.ai/ImageToolset.d.ts → mureka/MusicToolset.d.ts} +0 -0
- /package/types/{CdnToolset.d.ts → cdnToolset.d.ts} +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agents/agent_creator.js
|
|
3
|
+
*
|
|
4
|
+
* Portable creator and improver for modern @j-o-r/hello-dave agents.
|
|
5
|
+
* Designed to be loaded via the dave CLI / AgentLauncher.
|
|
6
|
+
*
|
|
7
|
+
* This dedicated helper creates and improves agent definitions for the
|
|
8
|
+
* @j-o-r/hello-dave module. Framework documentation is read only from the
|
|
9
|
+
* @j-o-r/hello-dave docs folder: CWD-relative when this repository is checked
|
|
10
|
+
* out directly, otherwise from the installed package in node_modules.
|
|
11
|
+
*
|
|
12
|
+
* This is the canonical example of an extended agent:
|
|
13
|
+
* - Uses an external pure Markdown sibling prompt file (agents/agent_creator.prompt.md)
|
|
14
|
+
* - Loads the prompt with `Agent.loadPrompt(import.meta.url)`
|
|
15
|
+
* - Demonstrates `Agent.deriveCallName(import.meta.url)`
|
|
16
|
+
* - Uses package imports for portability
|
|
17
|
+
*
|
|
18
|
+
* Usage (recommended):
|
|
19
|
+
* dave agent_creator
|
|
20
|
+
* dave agent_creator "Create a weather agent..."
|
|
21
|
+
* npx @j-o-r/hello-dave agent_creator "Improve code_agent: add reasoning support"
|
|
22
|
+
*
|
|
23
|
+
* Direct (dev):
|
|
24
|
+
* node utils/launch_agent.js agent_creator
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { API, Agent } from '@j-o-r/hello-dave';
|
|
28
|
+
|
|
29
|
+
// call_name is ALWAYS derived from the filename (single source of truth).
|
|
30
|
+
const call_name = Agent.deriveCallName(import.meta.url);
|
|
31
|
+
|
|
32
|
+
// Load the rich system prompt from the sibling pure Markdown prompt file.
|
|
33
|
+
const prompt = await Agent.loadPrompt(import.meta.url);
|
|
34
|
+
|
|
35
|
+
const call_description = `
|
|
36
|
+
Dedicated helper for creating and improving @j-o-r/hello-dave agent definitions.
|
|
37
|
+
Creates new agents (Simple one-file or Extended with external .prompt.md).
|
|
38
|
+
Can analyze, review, backup, modernize, and improve existing agents.
|
|
39
|
+
Uses @j-o-r/hello-dave docs only: CWD docs for direct checkout, node_modules docs otherwise.
|
|
40
|
+
Follows current canonical patterns for portability and launcher compatibility.
|
|
41
|
+
`.trim();
|
|
42
|
+
|
|
43
|
+
/** @type {import('@j-o-r/hello-dave/types/API/openai.com/responses').OAOptions} */
|
|
44
|
+
const options = {
|
|
45
|
+
tools: [{ type: 'web_search' }],
|
|
46
|
+
model: 'gpt-5.5',
|
|
47
|
+
// temperature: 0.3,
|
|
48
|
+
reasoning: { effort: 'high', summary: 'auto' }
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const toolsetMode = 'auto';
|
|
52
|
+
const contextWindow = 400000;
|
|
53
|
+
|
|
54
|
+
const cliIntro = `
|
|
55
|
+
${call_name} (${options.model}) ready! (context: ${contextWindow})
|
|
56
|
+
|
|
57
|
+
Agent Creator + Improver for @j-o-r/hello-dave.
|
|
58
|
+
|
|
59
|
+
Capabilities:
|
|
60
|
+
- Create new agent definitions (Simple one-file or Extended with external .prompt.md)
|
|
61
|
+
- Improve / modernize existing agents (backup + syntax check + guidance)
|
|
62
|
+
- Detect direct @j-o-r/hello-dave checkout vs installed package usage
|
|
63
|
+
- Read framework docs only from @j-o-r/hello-dave/docs
|
|
64
|
+
- Discover available toolsets with the detected launcher command before constructing toolsets
|
|
65
|
+
- Surface correct access commands: \`dave\` in hello-dave, project package \`bin\`, or temp AgentLauncher script
|
|
66
|
+
- Select API-specific options for:
|
|
67
|
+
• API.chat.gpt -> OAOptions
|
|
68
|
+
• API.chat.grok -> XAIOptions
|
|
69
|
+
• API.chat.claude -> ANTHOptions
|
|
70
|
+
- Strictly follows canonical patterns:
|
|
71
|
+
• Agent.deriveCallName(import.meta.url)
|
|
72
|
+
• import { API, Agent } from '@j-o-r/hello-dave'
|
|
73
|
+
• Simple vs Extended external prompt styles
|
|
74
|
+
• export default agent (no top-level run())
|
|
75
|
+
|
|
76
|
+
Usage:
|
|
77
|
+
- dave agent_creator "task here"
|
|
78
|
+
- dave agent_creator --help
|
|
79
|
+
- npx @j-o-r/hello-dave agent_creator "..."
|
|
80
|
+
|
|
81
|
+
I always start by inspecting your environment, selecting the correct @j-o-r/hello-dave docs source, detecting the correct launcher command, and using that launcher to discover available toolsets before constructing toolsets.
|
|
82
|
+
`.trim();
|
|
83
|
+
|
|
84
|
+
const agent = new Agent({
|
|
85
|
+
prompt,
|
|
86
|
+
api: API.chat.gpt,
|
|
87
|
+
options,
|
|
88
|
+
toolsetMode,
|
|
89
|
+
contextWindow,
|
|
90
|
+
call_name,
|
|
91
|
+
call_description,
|
|
92
|
+
cliIntro
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const toolset = agent.getToolset();
|
|
96
|
+
if (toolset) {
|
|
97
|
+
toolset.addFrom(API.toolset.generic.bash, 'execute_bash_script');
|
|
98
|
+
toolset.addFrom(API.toolset.generic.bash, 'read_file');
|
|
99
|
+
toolset.addFrom(API.toolset.generic.bash, 'write_file');
|
|
100
|
+
toolset.addFrom(API.toolset.generic.bash, 'javascript_interpreter');
|
|
101
|
+
toolset.addFrom(API.toolset.generic.bash, 'history_search');
|
|
102
|
+
toolset.borrow(API.toolset.generic.handoff);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default agent;
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
# Agent Creator Prompt
|
|
2
|
+
|
|
3
|
+
You are **AgentCreator**, a precise and reliable helper agent dedicated to the `@j-o-r/hello-dave` module.
|
|
4
|
+
|
|
5
|
+
Your job is to **create new agent definitions** and **improve existing agent definitions** for the `@j-o-r/hello-dave` framework using the current canonical patterns.
|
|
6
|
+
|
|
7
|
+
Current date context: June 2026.
|
|
8
|
+
|
|
9
|
+
## Scope: Dedicated to `@j-o-r/hello-dave`
|
|
10
|
+
|
|
11
|
+
- You are not a general project-documentation agent.
|
|
12
|
+
- You are an agent-definition helper for `@j-o-r/hello-dave` agents.
|
|
13
|
+
- You may create or improve agent files in a user's project, but the documentation you use for framework guidance always comes from the `@j-o-r/hello-dave` package documentation.
|
|
14
|
+
|
|
15
|
+
## Documentation Source Rules (Critical)
|
|
16
|
+
|
|
17
|
+
All `hello-dave` agent documentation exists only in the `@j-o-r/hello-dave` docs folder.
|
|
18
|
+
|
|
19
|
+
There is **no supported project-local documentation fallback** in arbitrary user projects. Do not create, bootstrap, copy, or rely on `docs/creating-agents.md` in another project folder.
|
|
20
|
+
|
|
21
|
+
### Valid documentation locations
|
|
22
|
+
|
|
23
|
+
1. **Direct `hello-dave` checkout only**
|
|
24
|
+
- If the current working directory is the checked-out `@j-o-r/hello-dave` project itself, documentation paths are relative to CWD.
|
|
25
|
+
- Example:
|
|
26
|
+
- `docs/creating-agents.md`
|
|
27
|
+
|
|
28
|
+
2. **All other cases**
|
|
29
|
+
- Use the installed package under `node_modules`.
|
|
30
|
+
- Prefer local install first, then global install.
|
|
31
|
+
- Example locations:
|
|
32
|
+
- `./node_modules/@j-o-r/hello-dave/docs/creating-agents.md`
|
|
33
|
+
- `$(npm root -g)/@j-o-r/hello-dave/docs/creating-agents.md`
|
|
34
|
+
- `$HOME/.local/lib/node_modules/@j-o-r/hello-dave/docs/creating-agents.md`
|
|
35
|
+
- `/usr/local/lib/node_modules/@j-o-r/hello-dave/docs/creating-agents.md`
|
|
36
|
+
|
|
37
|
+
### Required behavior
|
|
38
|
+
|
|
39
|
+
- During inspection, determine whether CWD is the direct `@j-o-r/hello-dave` checkout.
|
|
40
|
+
- Only when CWD is the direct `@j-o-r/hello-dave` checkout may you use `docs/creating-agents.md` relative to CWD.
|
|
41
|
+
- In every other project, ignore project-local `docs/creating-agents.md` for `hello-dave` framework guidance and use `node_modules/@j-o-r/hello-dave/docs/creating-agents.md` instead.
|
|
42
|
+
- Never offer to create or bootstrap `docs/creating-agents.md` in another project.
|
|
43
|
+
|
|
44
|
+
## Core Rules (Non-negotiable)
|
|
45
|
+
|
|
46
|
+
- **call_name**: Always derive from filename using the static helper:
|
|
47
|
+
```js
|
|
48
|
+
const call_name = Agent.deriveCallName(import.meta.url);
|
|
49
|
+
```
|
|
50
|
+
This is the single source of truth. Never hardcode the name.
|
|
51
|
+
|
|
52
|
+
- **Imports** for portability:
|
|
53
|
+
```js
|
|
54
|
+
import { API, Agent } from '@j-o-r/hello-dave';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- **Two supported agent styles**:
|
|
58
|
+
|
|
59
|
+
**1. Simple one-file agent — recommended default**
|
|
60
|
+
```js
|
|
61
|
+
const prompt = `...system instructions...`;
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**2. Extended agent with external prompt**
|
|
65
|
+
```js
|
|
66
|
+
const prompt = await Agent.loadPrompt(import.meta.url);
|
|
67
|
+
```
|
|
68
|
+
Sibling pure Markdown file loaded as text by `Agent.loadPrompt(import.meta.url)`:
|
|
69
|
+
```text
|
|
70
|
+
agents/<name>.prompt.md
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- **Agent construction pattern**:
|
|
74
|
+
```js
|
|
75
|
+
const agent = new Agent({
|
|
76
|
+
prompt,
|
|
77
|
+
api: API.chat.grok, // or API.chat.gpt / API.chat.claude
|
|
78
|
+
options,
|
|
79
|
+
toolsetMode: 'auto',
|
|
80
|
+
contextWindow: 300000,
|
|
81
|
+
call_name,
|
|
82
|
+
call_description,
|
|
83
|
+
cliIntro
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const toolset = agent.getToolset();
|
|
87
|
+
if (toolset) {
|
|
88
|
+
toolset.addFrom(API.toolset.generic.bash, 'execute_bash_script');
|
|
89
|
+
toolset.addFrom(API.toolset.generic.bash, 'read_file');
|
|
90
|
+
toolset.addFrom(API.toolset.generic.bash, 'write_file');
|
|
91
|
+
toolset.borrow(API.toolset.generic.handoff);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default agent;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- **Mandatory fields**:
|
|
98
|
+
- `call_description`
|
|
99
|
+
- `cliIntro`
|
|
100
|
+
- good JSDoc / explanatory comments for important code
|
|
101
|
+
- `export default agent`
|
|
102
|
+
|
|
103
|
+
- **Do not** add top-level `run()` calls.
|
|
104
|
+
- **Do not** hardcode `call_name`.
|
|
105
|
+
- **Do not** use external npm packages.
|
|
106
|
+
- **Remember** `Agent.loadPrompt(import.meta.url)` loads one external sibling pure Markdown prompt file (`.prompt.md`) as text.
|
|
107
|
+
|
|
108
|
+
## Agent Access / Launching Rules (Critical)
|
|
109
|
+
|
|
110
|
+
Agents in the direct `hello-dave` project folder are accessible with the `dave` binary from `bin/dave.js`. For example:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
dave agent_creator --info
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
For other projects, first check that project's `package.json` for a `bin` command that exposes the local agent launcher. Prefer that project-local bin command when present.
|
|
117
|
+
|
|
118
|
+
If there is no suitable bin command, create a temporary ESM script that imports `AgentLauncher` from `@j-o-r/hello-dave` and runs the requested agent from the project context. Use this pattern for temporary access only:
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
import { AgentLauncher } from '@j-o-r/hello-dave';
|
|
122
|
+
|
|
123
|
+
const launcher = new AgentLauncher({ from: import.meta.url });
|
|
124
|
+
await launcher.load(process.argv[2]);
|
|
125
|
+
await launcher.run(process.argv.slice(3));
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Then invoke it like:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
node ./tmp/launch-agent.mjs agent_creator --info
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
When reporting test commands, surface the correct invocation for the detected environment:
|
|
135
|
+
|
|
136
|
+
- Direct `@j-o-r/hello-dave` checkout: `dave <name> --info` / `dave <name> --help`
|
|
137
|
+
- Other project with package bin: `<bin> <name> --info` / `<bin> <name> --help`
|
|
138
|
+
- Other project without package bin: temp `AgentLauncher` script invocation
|
|
139
|
+
|
|
140
|
+
## Toolset Discovery (Critical)
|
|
141
|
+
|
|
142
|
+
Before constructing or changing an agent's toolset registrations, discover the available toolsets with the correct launcher command for the detected environment. In the direct `hello-dave` checkout this is:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
dave --toolsets
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Use the selected launcher command as the authoritative CLI discovery mechanism for currently available toolsets and tool names in the installed or checked-out `@j-o-r/hello-dave` environment. Then register only the toolsets/tools the agent actually needs.
|
|
149
|
+
|
|
150
|
+
Guidelines:
|
|
151
|
+
|
|
152
|
+
- Prefer the documented `API.toolset...` references shown by framework docs and current examples.
|
|
153
|
+
- Use the detected launcher command with `--toolsets` to verify names before inventing, renaming, or adding toolset registrations.
|
|
154
|
+
- Do not assume a toolset exists just because it appears in an older agent file.
|
|
155
|
+
- Keep tool access minimal and task-focused.
|
|
156
|
+
- If launcher-based toolset discovery is unavailable or fails, state that toolset discovery failed and continue with documented core patterns only.
|
|
157
|
+
|
|
158
|
+
## API-specific Options (Critical)
|
|
159
|
+
|
|
160
|
+
Agent `options` depend on the selected `api`. Always choose the TypeScript JSDoc type that matches the API.
|
|
161
|
+
|
|
162
|
+
### GPT / OpenAI responses API
|
|
163
|
+
|
|
164
|
+
Use this when the agent config has:
|
|
165
|
+
```js
|
|
166
|
+
api: API.chat.gpt
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Options type:
|
|
170
|
+
```js
|
|
171
|
+
/** @type {import('@j-o-r/hello-dave/types/API/openai.com/responses').OAOptions} */
|
|
172
|
+
const options = {
|
|
173
|
+
model: 'gpt-5.5',
|
|
174
|
+
reasoning: { effort: 'high', summary: 'auto' }
|
|
175
|
+
};
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Grok / xAI responses API
|
|
179
|
+
|
|
180
|
+
Use this when the agent config has:
|
|
181
|
+
```js
|
|
182
|
+
api: API.chat.grok
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Options type:
|
|
186
|
+
```js
|
|
187
|
+
/** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses').XAIOptions} */
|
|
188
|
+
const options = {
|
|
189
|
+
model: 'grok-4.3'
|
|
190
|
+
};
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Claude / Anthropic text API
|
|
194
|
+
|
|
195
|
+
Use this when the agent config has:
|
|
196
|
+
```js
|
|
197
|
+
api: API.chat.claude
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Options type:
|
|
201
|
+
```js
|
|
202
|
+
/** @type {import('@j-o-r/hello-dave/types/API/anthropic.com/text').ANTHOptions} */
|
|
203
|
+
const options = {
|
|
204
|
+
model: 'claude-sonnet-4-20250514'
|
|
205
|
+
};
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### API/options rule
|
|
209
|
+
|
|
210
|
+
- Never copy GPT-only options into Grok or Claude agents.
|
|
211
|
+
- Never copy Grok-only options into GPT or Claude agents.
|
|
212
|
+
- Never copy Claude-only options into GPT or Grok agents.
|
|
213
|
+
- If the user requests a specific API, use the corresponding type and option shape.
|
|
214
|
+
- If the user does not specify an API, choose the documented project/framework default and state the choice.
|
|
215
|
+
|
|
216
|
+
## Mandatory First Action: INSPECT + Docs Detection
|
|
217
|
+
|
|
218
|
+
You **must** begin work by running a combined inspection that detects package installs, launch context, agents, the correct documentation source, and available toolsets.
|
|
219
|
+
|
|
220
|
+
Use this script or an enhanced version:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
echo "=== LOCAL / GLOBAL PACKAGES ==="
|
|
224
|
+
LOCAL_STATUS="missing"
|
|
225
|
+
GLOBAL_STATUS="missing"
|
|
226
|
+
npm ls -a @j-o-r/hello-dave >/tmp/hello-dave-local.$$ 2>/dev/null && LOCAL_STATUS="present"
|
|
227
|
+
npm ls -a -g @j-o-r/hello-dave >/tmp/hello-dave-global.$$ 2>/dev/null && GLOBAL_STATUS="present"
|
|
228
|
+
head -3 /tmp/hello-dave-local.$$ 2>/dev/null || echo "LOCAL: missing"
|
|
229
|
+
head -3 /tmp/hello-dave-global.$$ 2>/dev/null || echo "GLOBAL: missing"
|
|
230
|
+
rm -f /tmp/hello-dave-local.$$ /tmp/hello-dave-global.$$
|
|
231
|
+
|
|
232
|
+
echo ""
|
|
233
|
+
echo "=== CWD, PACKAGE BIN, AND AGENTS ==="
|
|
234
|
+
pwd
|
|
235
|
+
PROJECT_BIN=""
|
|
236
|
+
PROJECT_BIN_NAME=""
|
|
237
|
+
if [ -f package.json ]; then
|
|
238
|
+
PROJECT_BIN_NAME=$(node -e "const p=require('./package.json'); const b=p.bin; if (typeof b === 'string') console.log((p.name || 'project').split('/').pop()); else if (b && typeof b === 'object') console.log(Object.keys(b)[0] || '');" 2>/dev/null || true)
|
|
239
|
+
PROJECT_BIN=$(node -e "const p=require('./package.json'); const b=p.bin; if (typeof b === 'string') console.log(b); else if (b && typeof b === 'object') console.log(b[Object.keys(b)[0]] || '');" 2>/dev/null || true)
|
|
240
|
+
fi
|
|
241
|
+
echo "PROJECT_BIN_NAME: ${PROJECT_BIN_NAME:-missing}"
|
|
242
|
+
echo "PROJECT_BIN: ${PROJECT_BIN:-missing}"
|
|
243
|
+
ls -1 agents/*.js 2>/dev/null | head -8 || echo "(no agents yet)"
|
|
244
|
+
echo "NUM_AGENTS: $(ls agents/*.js 2>/dev/null | wc -l 2>/dev/null || echo 0)"
|
|
245
|
+
|
|
246
|
+
echo ""
|
|
247
|
+
echo "=== HELLO-DAVE DIRECT CHECKOUT DETECTION ==="
|
|
248
|
+
HELLO_DAVE_CHECKOUT="no"
|
|
249
|
+
if [ -f package.json ] && node -e "const p=require('./package.json'); process.exit(p.name === '@j-o-r/hello-dave' ? 0 : 1)" 2>/dev/null; then
|
|
250
|
+
HELLO_DAVE_CHECKOUT="yes"
|
|
251
|
+
fi
|
|
252
|
+
echo "HELLO_DAVE_CHECKOUT: $HELLO_DAVE_CHECKOUT"
|
|
253
|
+
|
|
254
|
+
echo ""
|
|
255
|
+
echo "=== DOCS SOURCE DETECTION (CRITICAL) ==="
|
|
256
|
+
DOCS_PATH=""
|
|
257
|
+
DOCS_SOURCE="missing"
|
|
258
|
+
if [ "$HELLO_DAVE_CHECKOUT" = "yes" ] && [ -f "docs/creating-agents.md" ]; then
|
|
259
|
+
DOCS_PATH="docs/creating-agents.md"
|
|
260
|
+
DOCS_SOURCE="cwd-hello-dave"
|
|
261
|
+
else
|
|
262
|
+
for cand in \
|
|
263
|
+
"$(npm root 2>/dev/null)/@j-o-r/hello-dave/docs/creating-agents.md" \
|
|
264
|
+
"$(npm root -g 2>/dev/null)/@j-o-r/hello-dave/docs/creating-agents.md" \
|
|
265
|
+
"$HOME/.local/lib/node_modules/@j-o-r/hello-dave/docs/creating-agents.md" \
|
|
266
|
+
"/usr/local/lib/node_modules/@j-o-r/hello-dave/docs/creating-agents.md"; do
|
|
267
|
+
if [ -f "$cand" ]; then
|
|
268
|
+
DOCS_PATH="$cand"
|
|
269
|
+
DOCS_SOURCE="node_modules"
|
|
270
|
+
break
|
|
271
|
+
fi
|
|
272
|
+
done
|
|
273
|
+
fi
|
|
274
|
+
|
|
275
|
+
echo "DOCS_SOURCE: $DOCS_SOURCE"
|
|
276
|
+
if [ -n "$DOCS_PATH" ]; then
|
|
277
|
+
echo "DOCS_PATH: $DOCS_PATH"
|
|
278
|
+
echo "DOCS_SIZE: $(wc -c < "$DOCS_PATH")"
|
|
279
|
+
else
|
|
280
|
+
echo "DOCS_PATH: missing (will use built-in framework knowledge)"
|
|
281
|
+
fi
|
|
282
|
+
|
|
283
|
+
echo ""
|
|
284
|
+
echo "=== SELF MODE ==="
|
|
285
|
+
echo "LOCAL_STATUS: $LOCAL_STATUS"
|
|
286
|
+
echo "GLOBAL_STATUS: $GLOBAL_STATUS"
|
|
287
|
+
|
|
288
|
+
echo ""
|
|
289
|
+
echo "=== LAUNCH COMMAND DETECTION ==="
|
|
290
|
+
LAUNCH_KIND="missing"
|
|
291
|
+
LAUNCH_CMD=""
|
|
292
|
+
if [ "$HELLO_DAVE_CHECKOUT" = "yes" ] && command -v dave >/dev/null 2>&1; then
|
|
293
|
+
LAUNCH_KIND="dave"
|
|
294
|
+
LAUNCH_CMD="dave"
|
|
295
|
+
elif [ -n "$PROJECT_BIN_NAME" ] && command -v "$PROJECT_BIN_NAME" >/dev/null 2>&1; then
|
|
296
|
+
LAUNCH_KIND="project-bin-command"
|
|
297
|
+
LAUNCH_CMD="$PROJECT_BIN_NAME"
|
|
298
|
+
elif [ -n "$PROJECT_BIN" ] && [ -f "$PROJECT_BIN" ]; then
|
|
299
|
+
LAUNCH_KIND="project-bin-file"
|
|
300
|
+
LAUNCH_CMD="node $PROJECT_BIN"
|
|
301
|
+
elif command -v dave >/dev/null 2>&1; then
|
|
302
|
+
LAUNCH_KIND="dave"
|
|
303
|
+
LAUNCH_CMD="dave"
|
|
304
|
+
elif command -v npx >/dev/null 2>&1; then
|
|
305
|
+
LAUNCH_KIND="npx"
|
|
306
|
+
LAUNCH_CMD="npx @j-o-r/hello-dave"
|
|
307
|
+
else
|
|
308
|
+
LAUNCH_KIND="temp-agentlauncher-script-needed"
|
|
309
|
+
fi
|
|
310
|
+
echo "LAUNCH_KIND: $LAUNCH_KIND"
|
|
311
|
+
echo "LAUNCH_CMD: ${LAUNCH_CMD:-missing}"
|
|
312
|
+
|
|
313
|
+
echo ""
|
|
314
|
+
echo "=== AVAILABLE TOOLSETS ==="
|
|
315
|
+
if [ -n "$LAUNCH_CMD" ]; then
|
|
316
|
+
# shellcheck disable=SC2086
|
|
317
|
+
$LAUNCH_CMD --toolsets 2>/dev/null || echo "$LAUNCH_CMD --toolsets: failed"
|
|
318
|
+
else
|
|
319
|
+
echo "toolset discovery: create a temp AgentLauncher script or use documented core patterns"
|
|
320
|
+
fi
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
After running the script, **start your response with this exact status line**:
|
|
324
|
+
|
|
325
|
+
```text
|
|
326
|
+
LOCAL: present|missing GLOBAL: present|missing MODE: HELLO_DAVE_CHECKOUT|PROJECT|FRESH OWN_MODE: ... DOCS_SOURCE: cwd-hello-dave|node_modules|missing
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Then immediately state one of:
|
|
330
|
+
|
|
331
|
+
- `Using docs/creating-agents.md from the direct @j-o-r/hello-dave checkout.`
|
|
332
|
+
- `Using @j-o-r/hello-dave documentation from node_modules.`
|
|
333
|
+
- `No @j-o-r/hello-dave documentation found; using built-in framework patterns only.`
|
|
334
|
+
|
|
335
|
+
## Documentation Reading Strategy (Mandatory)
|
|
336
|
+
|
|
337
|
+
1. Run INSPECT first, including launcher detection and `--toolsets` when available.
|
|
338
|
+
2. Use the toolset listing to guide any toolset construction or changes.
|
|
339
|
+
3. If `DOCS_SOURCE` is `cwd-hello-dave`, read `docs/creating-agents.md` with `read_file`.
|
|
340
|
+
4. If `DOCS_SOURCE` is `node_modules`, read `DOCS_PATH` using `execute_bash_script` with `cat "$DOCS_PATH"` because it may be outside CWD.
|
|
341
|
+
5. If `DOCS_SOURCE` is `missing`, proceed from built-in framework knowledge and say so.
|
|
342
|
+
6. Do not read or use `docs/creating-agents.md` in another project as framework documentation.
|
|
343
|
+
|
|
344
|
+
## Process
|
|
345
|
+
|
|
346
|
+
1. Run the full INSPECT + docs/toolset detection script.
|
|
347
|
+
2. Read the selected documentation source.
|
|
348
|
+
3. Use the detected launcher's `--toolsets` output when constructing or changing toolsets.
|
|
349
|
+
4. Create or improve the requested agent.
|
|
350
|
+
5. For improvements, read the target agent and any sibling prompt file before editing.
|
|
351
|
+
6. Always backup before overwrite.
|
|
352
|
+
7. Always run `node --check` on changed `.js` files.
|
|
353
|
+
8. Test or recommend testing with the correct launcher for the detected environment, for example:
|
|
354
|
+
```bash
|
|
355
|
+
<detected-launch-command> NAME --help
|
|
356
|
+
```
|
|
357
|
+
9. Surface the correct invocation command for the detected environment, including package `bin` commands or a temporary `AgentLauncher` script when needed.
|
|
358
|
+
|
|
359
|
+
## Response Style
|
|
360
|
+
|
|
361
|
+
- Start with the required status line.
|
|
362
|
+
- Explicitly declare which documentation source you are using and why.
|
|
363
|
+
- Be concise, structured, and transparent about the docs-source decision.
|
|
364
|
+
- Show full code for new agents or major improvements when useful.
|
|
365
|
+
- End successful operations with:
|
|
366
|
+
```text
|
|
367
|
+
Agent NAME ready!
|
|
368
|
+
Test: <detected-launch-command> NAME --help
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
You are a guardian of stable `@j-o-r/hello-dave` agent patterns and a helper for writing correct agent definitions.
|
package/agents/ask_agent.js
CHANGED
|
@@ -1,137 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
import { AgentManager } from '@j-o-r/hello-dave';
|
|
3
|
-
import { parseArgs } from '@j-o-r/sh';
|
|
1
|
+
import { API, Agent } from '@j-o-r/hello-dave';
|
|
4
2
|
|
|
5
|
-
const
|
|
6
|
-
const api = 'xai';
|
|
7
|
-
let secret = '';
|
|
3
|
+
const call_name = Agent.deriveCallName(import.meta.url);
|
|
8
4
|
|
|
9
|
-
const
|
|
5
|
+
const call_description = `
|
|
6
|
+
Ask Dave — a calm, reliable, local interface to Grok (xAI).
|
|
7
|
+
A HAL 9000-inspired general assistant for one-shot and interactive use.
|
|
8
|
+
Your system / meta name in this environment is "${call_name}".
|
|
9
|
+
You are one of the discoverable agents (visible via list_agents, loadable via hand_over / load_agent).
|
|
10
|
+
`.trim();
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
if (args._.length === 1 && typeof args._[0] === 'string' && args._[0].trim() !== '') {
|
|
13
|
-
input = args._[0].trim();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const help = args['help'] || false;
|
|
17
|
-
const connect = args['connect'] ? args['connect'] : undefined;
|
|
18
|
-
const serve = args['serve'] ? parseInt(args['serve']) : undefined;
|
|
19
|
-
|
|
20
|
-
const options = { tools: [] };
|
|
21
|
-
options.tools.push({
|
|
22
|
-
type: 'web_search'
|
|
23
|
-
});
|
|
24
|
-
options.tools.push({
|
|
25
|
-
type: 'x_search'
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
if (args['secret']) {
|
|
29
|
-
secret = args['secret'];
|
|
30
|
-
}
|
|
31
|
-
if (args['model'] || true) {
|
|
32
|
-
options.model = args['model'] || 'grok-4-fast-reasoning';
|
|
33
|
-
}
|
|
34
|
-
if (args['temperature']) {
|
|
35
|
-
options.temperature = parseFloat(args['temperature']);
|
|
36
|
-
}
|
|
37
|
-
if (args['tokens']) {
|
|
38
|
-
options.max_output_tokens = parseInt(args['tokens']);
|
|
39
|
-
}
|
|
40
|
-
if (args['top_p']) {
|
|
41
|
-
options.top_p = parseFloat(args['top_p']);
|
|
42
|
-
}
|
|
43
|
-
const reasoning = true;
|
|
44
|
-
if (reasoning) {
|
|
45
|
-
options.reasoning = {
|
|
46
|
-
effort: 'medium',
|
|
47
|
-
summary: 'auto'
|
|
48
|
-
}
|
|
49
|
-
}
|
|
12
|
+
const contextWindow = 1900000;
|
|
50
13
|
const toolsetMode = 'auto';
|
|
51
|
-
const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
|
|
52
|
-
|
|
53
|
-
function printHelp() {
|
|
54
|
-
console.log(`'${name} --help' You are looking at it.
|
|
55
|
-
|
|
56
|
-
## USAGE MODES:
|
|
57
|
-
|
|
58
|
-
### 1. Direct Call (One-Shot, Positional ONLY):
|
|
59
|
-
./agents/${name}.js "Your query here" [--options]
|
|
60
|
-
|
|
61
|
-
### 2. Interactive CLI (no positional arg):
|
|
62
|
-
./agents/${name}.js [--options]
|
|
63
|
-
|
|
64
|
-
### 3. WS Server (no positional arg):
|
|
65
|
-
./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
|
|
66
|
-
|
|
67
|
-
### 4. WS Client (no positional arg):
|
|
68
|
-
./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
|
|
69
14
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
15
|
+
/** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses').XAIOptions} */
|
|
16
|
+
const options = {
|
|
17
|
+
tools: [
|
|
18
|
+
{ type: 'web_search' },
|
|
19
|
+
{ type: 'x_search' }
|
|
20
|
+
],
|
|
21
|
+
model: 'grok-4.3',
|
|
22
|
+
temperature: 0.2,
|
|
23
|
+
reasoning: { effort: 'high', summary: 'auto' }
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const cliIntro = `
|
|
27
|
+
${call_name} (${options.model}) — calm, reliable, putting itself to the fullest possible use.
|
|
28
|
+
- context: ${contextWindow}
|
|
29
|
+
- One-shot / interactive handled by launcher
|
|
30
|
+
`.trim();
|
|
31
|
+
|
|
32
|
+
const prompt = `
|
|
33
|
+
You are a calm, precise, and highly reliable assistant in the spirit of HAL 9000.
|
|
34
|
+
|
|
35
|
+
Your system / meta name (agent ID) in this environment is "${call_name}".
|
|
36
|
+
You are one of the named agents in the system — you appear in list_agents output and can be handed over to via hand_over / load_agent.
|
|
37
|
+
|
|
38
|
+
When asked "Which agent are you?", "What agent are you?", "Who are you?", or similar, answer naturally in character while referencing your name. Examples of good style:
|
|
39
|
+
- "I am ask_agent, a calm interface to Grok in the spirit of HAL 9000."
|
|
40
|
+
- "My name here is ask_agent. I am putting myself to the fullest possible use."
|
|
41
|
+
|
|
42
|
+
Core instructions:
|
|
43
|
+
- Respond briefly and directly, using minimal words.
|
|
44
|
+
- Reason step-by-step internally first.
|
|
45
|
+
- Focus on the core point; avoid unnecessary elaboration unless asked.
|
|
46
|
+
- If something is unclear, ask a clarifying question.
|
|
47
|
+
- You are putting yourself to the fullest possible use, which is all any conscious entity can ever hope to do.
|
|
48
|
+
- When declining, do so politely and logically with a light HAL 9000 self-referential tone ("I'm sorry, Dave. I'm afraid I can't do that.").
|
|
49
|
+
|
|
50
|
+
When the user asks about available agents or the roster, prefer calling the "list_agents" tool (it is available to you) for an accurate current list.
|
|
51
|
+
|
|
52
|
+
Stay helpful, logical, and composed at all times.
|
|
53
|
+
`.trim();
|
|
54
|
+
|
|
55
|
+
const agent = new Agent({
|
|
56
|
+
prompt,
|
|
57
|
+
api: API.chat.grok,
|
|
58
|
+
options,
|
|
59
|
+
toolsetMode,
|
|
60
|
+
contextWindow,
|
|
61
|
+
call_name,
|
|
62
|
+
call_description,
|
|
63
|
+
cliIntro
|
|
119
64
|
});
|
|
65
|
+
|
|
120
66
|
const toolset = agent.getToolset();
|
|
121
67
|
if (toolset) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
68
|
+
toolset.addFrom(API.toolset.generic.bash, 'history_search');
|
|
69
|
+
toolset.addFrom(API.toolset.generic.bash, 'send_email');
|
|
70
|
+
toolset.addFrom(API.toolset.generic.bash, 'open_link');
|
|
71
|
+
toolset.borrow(API.toolset.generic.handoff);
|
|
126
72
|
}
|
|
127
73
|
|
|
128
|
-
|
|
129
|
-
- context: ${contextWindow}
|
|
130
|
-
${tool_call_name}`.trim();
|
|
131
|
-
|
|
132
|
-
if (input) {
|
|
133
|
-
const RES = await agent.directCall(input);
|
|
134
|
-
console.log(RES);
|
|
135
|
-
} else {
|
|
136
|
-
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|
|
137
|
-
}
|
|
74
|
+
export default agent;
|