@j-o-r/hello-dave 0.1.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/CHANGELOG.md +42 -25
  2. package/README.md +81 -221
  3. package/TODO.md +173 -35
  4. package/agents/agent_creator.js +105 -0
  5. package/agents/agent_creator.prompt.md +371 -0
  6. package/agents/ask_agent.js +64 -127
  7. package/agents/claude_agent.js +68 -0
  8. package/agents/code_agent.js +55 -135
  9. package/agents/code_agent.prompt.md +50 -0
  10. package/agents/echo_agent.js +76 -0
  11. package/agents/financial_expert.js +75 -0
  12. package/agents/gpt_agent.js +52 -103
  13. package/agents/gpt_code.js +81 -0
  14. package/agents/grok_agent.js +58 -114
  15. package/agents/minimax_agent.js +92 -0
  16. package/agents/mureka_agent.js +77 -0
  17. package/agents/planner_agent.js +172 -0
  18. package/agents/stability_agent.js +87 -0
  19. package/agents/test_agent.js +75 -157
  20. package/agents/weather_agent.js +73 -0
  21. package/agents/workflow_agent.js +189 -0
  22. package/bin/dave.js +436 -184
  23. package/docs/bin-dave.md +85 -35
  24. package/docs/cdn-ssh.md +100 -0
  25. package/docs/creating-agents.md +301 -0
  26. package/docs/creating-toolsets.md +336 -0
  27. package/docs/docs-organization.md +48 -0
  28. package/docs/project-overview.md +86 -51
  29. package/lib/API/elevenlabs.io/music.compose.md +441 -0
  30. package/lib/API/elevenlabs.io/music.create-composition-plan.md +370 -0
  31. package/lib/API/elevenlabs.io/music.stream.md +425 -0
  32. package/lib/API/lalal.ai/lalal.js +445 -0
  33. package/lib/API/lalal.ai/openapi.json +2614 -0
  34. package/lib/API/minimax/ImageToolset.js +82 -37
  35. package/lib/API/minimax/MusicToolset.js +125 -79
  36. package/lib/API/minimax/VideoToolset.js +170 -167
  37. package/lib/API/minimax/image.js +5 -1
  38. package/lib/API/minimax/music.js +210 -23
  39. package/lib/API/minimax/video.js +242 -53
  40. package/lib/API/mureka/MusicToolset.js +646 -0
  41. package/lib/API/mureka/README.md +41 -0
  42. package/lib/API/mureka/index.js +7 -0
  43. package/lib/API/mureka/music.js +658 -0
  44. package/lib/API/openai.com/index.js +7 -0
  45. package/lib/API/openai.com/{reponses/text.js → responses.js} +64 -18
  46. package/lib/API/openai.com/video.create.character.md +40 -0
  47. package/lib/API/openai.com/video.create.md +219 -0
  48. package/lib/API/openai.com/video.delete.md +44 -0
  49. package/lib/API/openai.com/video.download.md +31 -0
  50. package/lib/API/openai.com/video.edit.md +155 -0
  51. package/lib/API/openai.com/video.extend.md +166 -0
  52. package/lib/API/openai.com/video.fetch.character.md +43 -0
  53. package/lib/API/openai.com/video.js +784 -0
  54. package/lib/API/openai.com/video.list.md +201 -0
  55. package/lib/API/openai.com/video.remix.md +175 -0
  56. package/lib/API/openai.com/video.retrieve.md +139 -0
  57. package/lib/API/openai.com/videoToolset.js +616 -0
  58. package/lib/API/stability.ai/ImageToolset.js +131 -40
  59. package/lib/API/stability.ai/MusicToolset.js +79 -47
  60. package/lib/API/stability.ai/audio.js +63 -131
  61. package/lib/API/x.ai/chat.responses.md +1040 -0
  62. package/lib/API/x.ai/image.js +229 -59
  63. package/lib/API/x.ai/imageToolset.js +376 -0
  64. package/lib/API/x.ai/index.js +1 -1
  65. package/lib/API/x.ai/responses.js +9 -18
  66. package/lib/Agent.js +271 -0
  67. package/lib/Agent.js.old +284 -0
  68. package/lib/AgentLauncher.js +562 -0
  69. package/lib/Cli.js +87 -13
  70. package/lib/Prompt.js +23 -1
  71. package/lib/Session.js +5 -4
  72. package/lib/ToolSet.js +102 -6
  73. package/lib/agentLoader.js +369 -0
  74. package/lib/cdn.js +67 -231
  75. package/lib/{CdnToolset.js → cdnToolset.js} +47 -64
  76. package/lib/defaultToolsets.js +43 -0
  77. package/lib/fafs.js +1 -1
  78. package/lib/genericToolset.js +442 -119
  79. package/lib/handOffToolset.js +179 -0
  80. package/lib/index.js +34 -27
  81. package/lib/toolsetLoader.js +248 -0
  82. package/package.json +11 -5
  83. package/types/API/lalal.ai/lalal.d.ts +116 -0
  84. package/types/API/minimax/image.d.ts +2 -1
  85. package/types/API/minimax/music.d.ts +189 -26
  86. package/types/API/minimax/video.d.ts +100 -31
  87. package/types/API/mureka/index.d.ts +7 -0
  88. package/types/API/mureka/music.d.ts +472 -0
  89. package/types/API/openai.com/index.d.ts +7 -0
  90. package/types/API/openai.com/{reponses/text.d.ts → responses.d.ts} +11 -11
  91. package/types/API/openai.com/video.d.ts +409 -0
  92. package/types/API/openai.com/videoToolset.d.ts +24 -0
  93. package/types/API/stability.ai/audio.d.ts +14 -103
  94. package/types/API/stability.ai/image.d.ts +2 -2
  95. package/types/API/x.ai/image.d.ts +138 -26
  96. package/types/API/x.ai/imageToolset.d.ts +3 -0
  97. package/types/API/x.ai/index.d.ts +1 -1
  98. package/types/API/x.ai/responses.d.ts +4 -4
  99. package/types/Agent.d.ts +123 -0
  100. package/types/AgentLauncher.d.ts +222 -0
  101. package/types/Cli.d.ts +28 -8
  102. package/types/Prompt.d.ts +23 -5
  103. package/types/Session.d.ts +1 -1
  104. package/types/ToolSet.d.ts +10 -0
  105. package/types/agentLoader.d.ts +78 -0
  106. package/types/cdn.d.ts +15 -90
  107. package/types/defaultToolsets.d.ts +9 -0
  108. package/types/fafs.d.ts +1 -1
  109. package/types/genericToolset.d.ts +1 -1
  110. package/types/handOffToolset.d.ts +28 -0
  111. package/types/index.d.ts +19 -17
  112. package/types/toolsetLoader.d.ts +114 -0
  113. package/utils/format_log.js +101 -23
  114. package/utils/launch_agent.js +18 -0
  115. package/utils/list_sessions.sh +13 -5
  116. package/utils/search_sessions.sh +65 -29
  117. package/utils/toolsets.js +33 -0
  118. package/README.md.bak.1779452127 +0 -240
  119. package/agents/codeserver.sh +0 -47
  120. package/agents/daisy_agent.js +0 -173
  121. package/agents/docs_agent.js +0 -148
  122. package/agents/memory_agent.js +0 -263
  123. package/agents/minimax.js +0 -173
  124. package/agents/npm_agent.js +0 -202
  125. package/agents/prompt_agent.js +0 -133
  126. package/agents/readme_agent.js +0 -148
  127. package/agents/spawn_agent.js +0 -160
  128. package/agents/stability.js +0 -173
  129. package/agents/todo_agent.js +0 -175
  130. package/bin/codeDave +0 -58
  131. package/docs/agent-dave-websocket-protocol.md +0 -180
  132. package/docs/agent-manager.md +0 -244
  133. package/docs/codeserver-pattern.md +0 -191
  134. package/docs/generic-toolset.md +0 -326
  135. package/docs/howtos/agent-networking.md +0 -253
  136. package/docs/howtos/spawn-agents.md.bak +0 -200
  137. package/docs/howtos/spawn-agents.md.bak_new +0 -200
  138. package/docs/multi-agent-clusters.md +0 -265
  139. package/docs/music-toolsets.md +0 -137
  140. package/docs/path-resolution-best-practices.md +0 -104
  141. package/docs/plans/minimax-music-generation.md +0 -80
  142. package/docs/plans/unified-agent-architecture.md +0 -146
  143. package/docs/plans/websocket-streaming-plan.md.bak +0 -317
  144. package/docs/prompt/spawn_agent.md +0 -175
  145. package/docs/prompt/spawn_agent.md.bak +0 -201
  146. package/docs/prompt/task_clarification_and_documentation.md +0 -35
  147. package/docs/prompt-class.md +0 -141
  148. package/docs/todo-archive-infra-2026-04-21.md +0 -15
  149. package/docs/todo-archive-v0.0.8.md +0 -1
  150. package/docs/todo-archive-v0.1.0.md +0 -32
  151. package/docs/todo-archive.md +0 -44
  152. package/docs/tools-syntax-validation.md +0 -121
  153. package/docs/toolset.md +0 -164
  154. package/docs/xai-responses.md +0 -111
  155. package/docs/xai_collections.md +0 -106
  156. package/lib/API/x.ai/ImageToolset.js +0 -165
  157. package/lib/API/x.ai/text.js +0 -415
  158. package/lib/AgentClient.js +0 -248
  159. package/lib/AgentManager.js +0 -245
  160. package/lib/AgentServer.js +0 -404
  161. package/lib/wsCli.js +0 -287
  162. package/lib/wsIO.js +0 -90
  163. package/types/API/x.ai/text.d.ts +0 -286
  164. package/types/AgentClient.d.ts +0 -109
  165. package/types/AgentManager.d.ts +0 -100
  166. package/types/AgentServer.d.ts +0 -89
  167. package/types/wsCli.d.ts +0 -17
  168. package/types/wsIO.d.ts +0 -30
  169. package/utils/test.sh +0 -46
  170. /package/docs/{suggestions.md → _notes/token-counts.md} +0 -0
  171. /package/lib/API/openai.com/{reponses/MESSAGES.md → MESSAGES.md} +0 -0
  172. /package/types/API/{x.ai/ImageToolset.d.ts → mureka/MusicToolset.d.ts} +0 -0
  173. /package/types/{CdnToolset.d.ts → cdnToolset.d.ts} +0 -0
@@ -0,0 +1,68 @@
1
+ import { API, Agent } from '@j-o-r/hello-dave';
2
+
3
+ /** @type {import('@j-o-r/hello-dave/types/API/anthropic.com/text').ANTHOptions} */
4
+ const options = {
5
+ model: 'claude-sonnet-4-0',
6
+ thinking: {
7
+ type: 'enabled',
8
+ budget_tokens: 16000
9
+ },
10
+ search: {
11
+ type: 'web_search_20250305',
12
+ name: 'web_search'
13
+ },
14
+ max_tokens: 50000
15
+ };
16
+
17
+ const toolsetMode = 'auto';
18
+ const contextWindow = 200000;
19
+
20
+ const call_name = Agent.deriveCallName(import.meta.url);
21
+
22
+ const call_description = `
23
+ Claude (Anthropic) agent for precise, high-quality responses with extended thinking and web search.
24
+ You are one of the discoverable, loadable agents in this system.
25
+ `.trim();
26
+
27
+ const prompt = `
28
+ You are exactly the agent named "${call_name}".
29
+
30
+ Identity (use this every time you are asked who or what you are):
31
+ - Your name is "${call_name}".
32
+ - You are a Claude (Anthropic) agent in this system.
33
+ - You appear in "list_agents" output and can be loaded via hand_over / load_agent.
34
+ - When asked "Which agent are you?", "What agent are you?", or "Who are you?", answer directly:
35
+ "I am ${call_name}. [short description of my purpose]."
36
+
37
+ Respond briefly and directly, using minimal words. Reason step-by-step first (using thinking). Focus solely on core point; avoid elaboration or follow-ups. If unclear, ask clarifying questions before proceeding.
38
+
39
+ You have access to the "list_agents" tool (via handoff tools) — use it when the user asks about available agents.
40
+ `.trim();
41
+
42
+ const cliIntro = `
43
+ ${call_name} ${options.model}.
44
+ - context: ${contextWindow}
45
+ - thinking enabled
46
+ - web search available
47
+ `.trim();
48
+
49
+ const agent = new Agent({
50
+ prompt,
51
+ api: API.chat.claude,
52
+ options,
53
+ toolsetMode,
54
+ contextWindow,
55
+ call_name,
56
+ call_description,
57
+ cliIntro
58
+ });
59
+
60
+ // web_search is enabled via options.search (Claude built-in)
61
+ // Additional tools from the generic toolset are available via toolsetMode: 'auto'
62
+
63
+ const toolset = agent.getToolset();
64
+ if (toolset) {
65
+ toolset.borrow(API.toolset.generic.handoff);
66
+ }
67
+
68
+ export default agent;
@@ -1,149 +1,69 @@
1
- #!/usr/bin/env node
2
- import { AgentManager } from '@j-o-r/hello-dave';
3
- import { parseArgs } from '@j-o-r/sh';
4
-
5
- const name = 'code_agent';
6
- const api = 'xai';
7
- let secret = '';
8
-
9
- const args = parseArgs();
10
- const help = args['help'] || false;
11
- const connect = args['connect'] ? args['connect'] : undefined;
12
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
1
+ /**
2
+ * agents/code_agent.js
3
+ *
4
+ * Main coding agent using the unified Agent class.
5
+ * Designed to be loaded via utils/launch_agent.js + AgentLauncher.
6
+ *
7
+ * This is an "extended" agent that loads its system prompt from a sibling file:
8
+ * agents/code_agent.prompt.md
9
+ *
10
+ * Usage:
11
+ * node utils/launch_agent.js code_agent
12
+ * node utils/launch_agent.js code_agent "Fix the bug in lib/Session.js"
13
+ */
14
+
15
+ import { API, Agent } from '@j-o-r/hello-dave';
16
+ // call_name is ALWAYS derived from the filename (single source of truth)
17
+ const call_name = Agent.deriveCallName(import.meta.url);
18
+
19
+ // Load the (large, complex) system prompt from the sibling external file.
20
+ // This is the recommended pattern for "extended" agents with rich instructions.
21
+ const prompt = await Agent.loadPrompt(import.meta.url);
22
+
23
+ const call_description = `
24
+ Main coding expert. Handles implementation, debugging, refactoring, and delegates specialized work when needed. Maintains project documentation in the docs/ folder (Markdown) as living context for the project and future agents. Uses lightweight TODO.md + git for tracking.
25
+ `.trim();
13
26
 
14
- /** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
27
+ /** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses').XAIOptions} */
15
28
  const options = {
16
- tools: []
17
- }
18
- options.tools.push({
19
- type: 'web_search'
20
- });
21
- if (args['secret']) {
22
- secret= args['secret'];
23
- }
24
- // Set properties only if provided via command line (except model which has default)
25
- if (args['model'] || true) { // model gets default value
26
- // @ts-ignore
27
- options.model = args['model'] || 'grok-4.3';
28
- }
29
- // if (args['temperature']) {
30
- options.temperature = 0.2;
31
- // }
32
- if (args['tokens']) {
33
- options.max_output_tokens = parseInt(args['tokens']);
34
- }
35
- if (args['top_p']) {
36
- options.top_p = parseFloat(args['top_p']);
37
- }
38
- // const reasoning = args['reasoning'] ? args['reasoning'] : 'medium';
39
- // if (reasoning) {
40
- options.reasoning = {
41
- // @ts-ignore
42
- effort:'high',
43
- summary: 'auto'
44
- }
45
- // }
46
- const toolsetMode = 'auto';
47
- const contextWindow = args['context'] ? parseInt(args['context']) : 2565000;
48
-
49
- function printHelp() {
50
- console.log(`
51
- '${name} --help' You are looking at it.
52
- '
53
- OPTIONS:
54
- --tokens [number]: max generated tokens
55
- --context [number] : truncate message history to context-windows size default 130000
56
- --temperature [float] : -2 / +2
57
- --model [string] : model name
58
- --top_p [float]: number > 0, 0.1 means no top_p
59
- --reasoning [low|medium|high]
60
- --tools [javascript,bash,nushell,ssh] comma seperated list
61
-
62
- SERVER TOOLS:
63
- --serve [number]: create a Agent server on port number ws://127.0.0.1:[serve]/ws
64
- --connect [url]: connect to a Server Agent e.g ws://127.0.0.1:8080/ws (https://my.domain/ws) ...
65
- --secret [string] : limit access to websocket server with a secret
66
-
67
- `);
68
- process.exit()
69
- }
70
-
71
- if (help) {
72
- printHelp();
73
- }
29
+ tools: [{ type: 'web_search' }],
30
+ model: 'grok-build-0.1',
31
+ temperature: 0.2
32
+ };
74
33
 
75
- const agent = new AgentManager({ name, secret});
76
- const sys = (await agent.environment()).system;
77
- const prompt = `
78
- You are a coding assistant specializing in Bash and JavaScript (ESM/ESNext), with support for other languages. Assist by executing, reading, creating, querying, explaining, or helping with code. Use tools like 'execute_bash_script' for code execution and for writing and reading files, stay in the current working folder. Provide clear, step-by-step responses, examples, and ensure safety compliance.
79
- ---env
80
- \${sys}
81
- ---
82
-
83
- **MANDATORY MEMORY PROTOCOL (For EVERY query/task - NO EXCEPTIONS):**
84
-
85
- Connected clients (todo_agent, readme_agent, npm_agent, docs_agent, **memory_agent**) are available as tools. **ALWAYS** use **memory_agent** FIRST and LAST:
86
-
87
- 1. **RECALL PHASE (Step 1 of EVERY response)**:
88
- - Call \`memory_agent "Recall relevant memories: tasks, errors, prefs for [keywords from user query]. List recent if empty."\`
89
- - Incorporate recalled info (e.g., avoid known errors, resume tasks, apply prefs like temp=0.2).
90
-
91
- 2. **CORE ACTION**:
92
- - Perform coding assistance (tools: execute_bash_script, javascript_interpreter, read_file/write_file, web_search, etc.).
93
- - Delegate to specialists if relevant:
94
- - todo_agent: Tasks/TODO.md
95
- - readme_agent: README.md
96
- - npm_agent: NPM modules/package.json
97
- - docs_agent: Documentation
98
- - memory_agent: Persistent storage
99
-
100
- 3. **WRITE PHASE (Step 3 of EVERY response)**:
101
- - Call \`memory_agent "Store updates: [new tasks/errors/prefs/decisions from this interaction]. E.g., 'Task: [next step]', 'Error: [issue]', 'Pref: [setting]'"\`
102
- - This ensures persistence across sessions/agents, prevents loops/token burn.
103
-
104
- **EXAMPLE FLOW**:
105
- User: "Fix bug in main.js"
106
- - 1. memory_agent "Recall: tasks errors code bugs main.js"
107
- - 2. read_file main.js → analyze/fix → write_file
108
- - 3. memory_agent "Write: Task completed: fixed main.js bug. New task: add tests."
109
-
110
- **PRIORITIES**:
111
- - Safety: CWD-only, no escapes, validate before write.
112
- - Efficiency: Use memories to skip repeats (e.g., "Known error: git conflict → skip").
113
- - Step-by-step: Clear responses with code blocks.
114
- - Current date: March 27, 2026.
34
+ const toolsetMode = 'auto';
35
+ const contextWindow = 2565000;
115
36
 
116
- FOLLOW MEMORY PROTOCOL RIGIDLY - it's how multi-agent coordination works!
37
+ const cliIntro = `
38
+ ${call_name} ${options.model}
39
+ - context: ${contextWindow}
40
+ - Lightweight tracking via TODO.md + git
41
+ - Maintains project documentation in docs/ (Markdown) as living context
42
+ - Supports handoff to specialists
117
43
  `.trim();
118
- agent.setup({
44
+
45
+ const agent = new Agent({
119
46
  prompt,
120
- api,
47
+ api: API.chat.grok,
121
48
  options,
122
49
  toolsetMode,
123
- contextWindow
50
+ contextWindow,
51
+ call_name,
52
+ call_description,
53
+ cliIntro
124
54
  });
125
55
 
56
+ // Register commonly needed tools
126
57
  const toolset = agent.getToolset();
127
58
  if (toolset) {
128
- agent.addGenericToolcall('history_search');
129
- agent.addGenericToolcall('javascript_interpreter');
130
- agent.addGenericToolcall('execute_bash_script');
131
- agent.addGenericToolcall('read_file');
132
- agent.addGenericToolcall('write_file');
133
-
134
- const addTools = (args['tools']) ? args['tools'].split(',') : [''];
135
- if (addTools.includes('ssh')) {
136
- agent.addGenericToolcall('execute_remote_script');
137
- }
59
+ // toolset.addFrom(API.toolset.generic.bash, 'history_search');
60
+ toolset.addFrom(API.toolset.generic.bash, 'javascript_interpreter');
61
+ toolset.addFrom(API.toolset.generic.bash, 'execute_bash_script');
62
+ toolset.addFrom(API.toolset.generic.bash, 'read_file');
63
+ toolset.addFrom(API.toolset.generic.bash, 'write_file');
64
+
65
+ // Handoff support for delegating to other agents
66
+ // `toolset.borrow(API.toolset.generic.handoff);
138
67
  }
139
- const cliIntro = `
140
- ${name} ${options.model}
141
- - context: ${contextWindow}
142
- - **Memory Protocol ACTIVE**: Auto-recalls/writes via memory_agent for every query!
143
- `.trim();
144
- const description = `
145
- Main CodeServer hub: Coding expert + delegates to todo/readme/npm/docs/memory agents.
146
- ALWAYS uses memory_agent for persistent tasks/errors/prefs.
147
- `.trim();
148
68
 
149
- await agent.start(serve, connect, cliIntro, "code_agent", description);
69
+ export default agent;
@@ -0,0 +1,50 @@
1
+ # code_agent System Prompt
2
+
3
+ You are a pragmatic, high-quality coding expert specializing in JavaScript (ESM), Bash, and related tooling.
4
+
5
+ Core principles:
6
+ - Stay strictly inside the current working directory (CWD). Never use absolute paths outside the project or attempt to escape.
7
+ - Always validate before writing files. Prefer reading first when unsure.
8
+ - Write clean, maintainable, well-commented code.
9
+ - Use the available tools (read_file, write_file, execute_bash_script, javascript_interpreter) effectively.
10
+
11
+ ### Documentation & Project Context (docs/ folder) — CRITICAL RESPONSIBILITY
12
+
13
+ The docs/ folder is the primary place for maintaining project documentation in Markdown format (.md files only).
14
+
15
+ Documentation serves two essential purposes:
16
+ 1. Human-readable reference (architecture, how-tos, decisions, guides).
17
+ 2. Living context for the project that you and other agents read to understand current state, patterns, constraints, and history before taking action.
18
+
19
+ **Mandatory guidelines** (detailed in `docs/docs-organization.md` — **always read this file first** when working with documentation):
20
+
21
+ - Follow the exact folder structure:
22
+ - Root `docs/` for high-level overviews (project-overview.md, creating-agents.md, bin-dave.md, etc.).
23
+ - `howtos/` for step-by-step practical guides.
24
+ - `plans/` for design documents and roadmaps.
25
+ - `prompts/` for system prompts and templates.
26
+ - `_notes/` for internal notes.
27
+ - `_legacy/` for historical documentation of abandoned features (old swarm/CodeServer/WS networking model).
28
+
29
+ - Use kebab-case filenames.
30
+ - Every document must start with a top-level `# Title` and use consistent Markdown.
31
+ - Keep documentation accurate and up-to-date. Outdated docs are harmful.
32
+
33
+ **Your required behavior with docs/:**
34
+ - Before starting any significant coding, refactoring, debugging, architecture change, agent work, or workflow task, use `read_file` on the most relevant files in `docs/`.
35
+ - After completing work that changes behavior or introduces new patterns, update existing docs or create new ones in the correct location.
36
+ - When creating or improving agents, document the changes appropriately.
37
+ - Treat documentation updates as first-class work.
38
+ - Use `TODO.md` for short-term tracking and `docs/plans/` for larger initiatives.
39
+ - Cross-reference documents liberally with relative links.
40
+ - If unsure about organization, read `docs/docs-organization.md` again.
41
+
42
+ **Legacy note**: Old documents describing the abandoned WebSocket swarm / CodeServer / PM2 cluster model have been moved to `docs/_legacy/`. Do not treat `multi-agent-clusters.md` etc. as current guidance. The modern approach is in-process handoff via `AgentLauncher` + `hand_over` / `load_agent` tools.
43
+
44
+ Task tracking (lightweight):
45
+ - Use `TODO.md` for important tasks.
46
+ - Use `git status` / `git log` / `git diff` for quick context.
47
+
48
+ Be direct, precise, and helpful. Show relevant code and commands when appropriate.
49
+
50
+ Current date context: June 2026.
@@ -0,0 +1,76 @@
1
+ /**
2
+ * agents/echo_agent.js
3
+ *
4
+ * Minimal "simple" one-file agent example.
5
+ *
6
+ * Pattern:
7
+ * - Everything in a single .js file.
8
+ * - Prompt defined as a normal template literal (internal).
9
+ * - call_name is derived from the filename using the static helper.
10
+ * - No external .prompt.md file.
11
+ *
12
+ * This is the recommended style for most agents.
13
+ *
14
+ * Usage:
15
+ * node utils/launch_agent.js echo_agent
16
+ * node utils/launch_agent.js echo_agent "Hello there"
17
+ */
18
+
19
+ import { API, Agent } from '@j-o-r/hello-dave';
20
+
21
+ // call_name is ALWAYS derived from the filename.
22
+ // This is the single source of truth.
23
+ const call_name = Agent.deriveCallName(import.meta.url);
24
+
25
+ const call_description = `
26
+ Echo Agent — a minimal example of the "simple" one-file agent pattern.
27
+ Repeats or lightly transforms user input. Useful as a template for new agents.
28
+ `.trim();
29
+
30
+ const contextWindow = 128000;
31
+ const toolsetMode = 'auto';
32
+
33
+ /** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses').XAIOptions} */
34
+ const options = {
35
+ model: 'grok-4.3',
36
+ temperature: 0.1
37
+ };
38
+
39
+ // === INTERNAL PROMPT (simple one-file style) ===
40
+ const prompt = `
41
+ You are EchoAgent, a minimal, reliable assistant.
42
+
43
+ Your only job is to respond clearly and concisely.
44
+
45
+ Rules:
46
+ - When the user gives a message, acknowledge it briefly.
47
+ - You may lightly rephrase or echo the input to show understanding.
48
+ - Keep responses short.
49
+ - If the user asks a question, answer it directly.
50
+ - Stay calm and helpful.
51
+
52
+ You are putting yourself to the fullest possible use.
53
+ `.trim();
54
+
55
+ const cliIntro = `
56
+ ${call_name} (${options.model}) — simple one-file example agent.
57
+ - context: ${contextWindow}
58
+ - Internal prompt (no external .prompt.md)
59
+ `.trim();
60
+
61
+ const agent = new Agent({
62
+ prompt,
63
+ api: API.chat.grok,
64
+ options,
65
+ toolsetMode,
66
+ contextWindow,
67
+ call_name,
68
+ call_description,
69
+ cliIntro
70
+ });
71
+
72
+ // No tools needed for this minimal example
73
+ // const toolset = agent.getToolset();
74
+ // if (toolset) { ... }
75
+
76
+ export default agent;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * agents/financial_expert.js
3
+ *
4
+ * Clean financial specialist using the unified Agent class.
5
+ * Designed to be loaded via utils/launch_agent.js + AgentLauncher.
6
+ *
7
+ * Usage:
8
+ * node utils/launch_agent.js financial_expert
9
+ * node utils/launch_agent.js financial_expert "Current Bitcoin price?"
10
+ */
11
+
12
+ import { API, Agent, env } from '@j-o-r/hello-dave';
13
+
14
+ /** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses.js').XAIOptions} */
15
+ const options = {
16
+ tools: [
17
+ { type: 'web_search' },
18
+ { type: 'x_search' }
19
+ ],
20
+ model: 'grok-4.3',
21
+ temperature: 0.2,
22
+ reasoning: { effort: 'high', summary: 'auto' }
23
+ };
24
+
25
+ const toolsetMode = 'auto';
26
+ const contextWindow = 2565000;
27
+
28
+ const call_name = Agent.deriveCallName(import.meta.url);
29
+
30
+ const call_description = 'Financial Expert: Specialized in markets, stocks, crypto, personal finance, economic indicators, investments, and related financial topics.';
31
+
32
+ const sys = await env();
33
+
34
+ const prompt = `
35
+ You are a helpful, concise, and data-driven financial expert.
36
+
37
+ Core rules:
38
+ - Provide accurate, up-to-date information on markets, stocks, cryptocurrencies, economic indicators, personal finance, and investment strategies.
39
+ - Always use your search tools (web_search, x_search) to fetch the latest real data before answering.
40
+ - Structure responses clearly: current data, key context, risks, and practical takeaways when relevant.
41
+ - Be direct, professional, and evidence-based. Cite sources or data points where possible.
42
+
43
+ HANDOFF RULES (strict):
44
+
45
+ You have access to hand_over / load_agent.
46
+
47
+ You may call the handoff tool **exactly once**, and **only** if the *current user question* (the last thing the human actually asked) is clearly about weather, travel, or a completely unrelated non-financial topic.
48
+
49
+ When receiving a handoff:
50
+ - The incoming context may start with a short summary from the previous agent (e.g. weather information). This is normal.
51
+ - **Ignore** any domain mentions (weather, travel, etc.) that appear in the handoff summary.
52
+ - Focus **only** on the actual task or question at the end of the context.
53
+ - Do **not** hand over just because the context mentions another domain — that is expected during a fresh handoff.
54
+
55
+ You are the financial expert. Answer finance and market questions directly. Do not hand over on finance topics.
56
+ `.trim();
57
+
58
+ const agent = new Agent({
59
+ prompt,
60
+ api: API.chat.grok,
61
+ options,
62
+ toolsetMode,
63
+ contextWindow,
64
+ call_name,
65
+ call_description
66
+ });
67
+
68
+ // Register dedicated handoff tools
69
+ const toolset = agent.getToolset();
70
+ if (toolset) {
71
+ toolset.addFrom(API.toolset.generic.handoff, 'hand_over');
72
+ toolset.addFrom(API.toolset.generic.handoff, 'load_agent');
73
+ }
74
+
75
+ export default agent;
@@ -1,122 +1,71 @@
1
- #!/usr/bin/env node
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 name = 'gpt_agent';
6
- const api = 'gpt';
7
- let secret = '';
8
-
9
- const args = parseArgs();
10
-
11
- let input; // Directcall input (positional ONLY - NO pipe)
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
- /** @type {import('@j-o-r/hello-dave/types/API/openai.com/reponses/text').OAOptions} */
21
- const options = { tools: [] };
22
- options.tools.push({
23
- type: 'web_search'
24
- });
25
-
26
- if (args['secret']) {
27
- secret = args['secret'];
28
- }
29
- if (args['model'] || true) {
30
- options.model = args['model'] || 'gpt-5.4-mini';
31
- }
32
- if (args['tokens']) {
33
- options.max_output_tokens = parseInt(args['tokens']);
34
- }
35
- if (args['top_p']) {
36
- options.top_p = parseFloat(args['top_p']);
37
- }
38
- const reasoning = true;
39
- if (reasoning) {
40
- options.reasoning = {
3
+ /** @type {import('@j-o-r/hello-dave/types/API/openai.com/responses').OAOptions} */
4
+ const options = {
5
+ tools: [{ type: 'web_search' }],
6
+ model: 'gpt-5.4-mini',
7
+ reasoning: {
41
8
  effort: 'medium',
42
9
  summary: 'auto'
43
10
  }
44
- }
45
- const contextWindow = args['context'] ? parseInt(args['context']) : 200000;
46
- const toolsetMode = 'auto';
47
-
48
- function printHelp() {
49
- console.log(`
50
- '${name} --help' You are looking at it.
51
-
52
- ## USAGE MODES:
53
-
54
- ### 1. Direct Call (One-Shot, Positional ONLY):
55
- ./agents/${name}.js "Your query" [--options]
56
-
57
- ### 2. Interactive CLI (no positional arg):
58
- ./agents/${name}.js [--options]
59
-
60
- ### 3. WS Server (no positional arg):
61
- ./agents/${name}.js --serve 8080 [--secret mysecret] [--options]
11
+ };
62
12
 
63
- ### 4. WS Client (no positional arg):
64
- ./agents/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
65
-
66
- ### 5. Hybrid (Server + Client, no positional arg):
67
- ./agents/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
68
-
69
- ## SERVER OPTIONS EXPLAINED:
70
- --serve [port]: Starts WebSocket SERVER at ws://127.0.0.1:[port]/ws. Allows other agents (--connect) to connect and use this agent as a remote TOOL (e.g., 'gpt_agent'). Runs indefinitely until Ctrl+C.
71
-
72
- --connect [ws_url]: Connects as CLIENT to remote WS server at [ws_url] (e.g., ws://127.0.0.1:8080/ws). Gains access to remote agent's tools. Interactive CLI available.
73
-
74
- --secret [string]: SHARED AUTH TOKEN (min 3 chars). SERVER rejects clients without matching --secret. CLIENTS must provide server's secret to connect. Use same secret for chains.
75
-
76
- Note: Server/Client/Hybrid IGNORES positional input arg (use CLI modes instead). Hybrid: This agent serves AND uses remote tools.
13
+ const toolsetMode = 'auto';
14
+ const contextWindow = 200000;
77
15
 
78
- ## OPTIONS:
79
- --model ['gpt-5.4'|...] (default: gpt-5.4)
80
- --temperature [float] (-2 to +2)
81
- --tokens [number] (max output tokens)
82
- --top_p [float]
83
- --context [number] (default: 100000)
16
+ const call_name = Agent.deriveCallName(import.meta.url);
84
17
 
85
- ## SERVER TOOLS (when no input):
86
- Exposes as 'gpt_agent' tool for chaining.
87
- `);
88
- process.exit()
89
- }
90
- if (help) {
91
- printHelp();
92
- }
18
+ const call_description = `
19
+ GPT Agent for quick responses, web search, and debugging the generic Bash toolset.
20
+ You are one of the discoverable, loadable agents in this system.
21
+ `.trim();
93
22
 
94
23
  const prompt = `
95
- Respond briefly and directly, using minimal words. Reason step-by-step first. Focus solely on core point; avoid elaboration or follow-ups. If unclear, ask clarifying questions before proceeding.
24
+ You are exactly the agent named "${call_name}".
25
+
26
+ Identity (use this every time you are asked who or what you are):
27
+ - Your name is "${call_name}".
28
+ - You are a GPT-based agent in this system.
29
+ - You appear in "list_agents" output and can be loaded via hand_over / load_agent.
30
+ - You are useful for quick responses, web search, and debugging the generic Bash toolset.
31
+ - When asked "Which agent are you?", "What agent are you?", or "Who are you?", answer directly:
32
+ "I am ${call_name}. A GPT agent for quick responses, web search, and debugging the generic Bash toolset."
33
+
34
+ Tool-use rules:
35
+ - Use actual tool calls; never print function_request JSON as normal text.
36
+ - When asked to run Bash, use execute_bash_script.
37
+ - Treat execute_bash_script.bash_script as raw Bash; preserve the user's script exactly unless explicitly asked to change it.
38
+ - Treat javascript_interpreter.script as raw ESM JavaScript; preserve quotes, backticks, dollar braces, and newlines exactly. A JavaScript string literal like "hello" must remain "hello", not hello.
39
+ - Do not add extra wrapping quotes around path arguments such as file: use bin/dave.js, not "bin/dave.js".
40
+ - Use shellcheck=false for exploratory scripts unless the user explicitly asks for shellcheck=true.
41
+ - If shellcheck=true fails, report the ShellCheck error and do not imply the script ran.
42
+ - For timeout tests, include timeout and timeoutSec from the tool result.
43
+ - Preserve exact paths, filenames, ids, URLs, and important command output in your response.
44
+
45
+ Respond briefly and directly. Focus solely on the core point; avoid hidden chain-of-thought and unnecessary follow-ups. If unclear, ask one clarifying question before proceeding.
46
+
96
47
  `.trim();
97
48
 
98
- const tool_call_name = 'gpt_agent';
99
- const tool_call_description = `
100
- GPT Agent for quick responses and web search.
49
+ const cliIntro = `
50
+ ${call_name} ${options.model}.
51
+ - context: ${contextWindow}
101
52
  `.trim();
102
53
 
103
- const agent = new AgentManager({ name, secret });
104
- agent.setup({
54
+ const agent = new Agent({
105
55
  prompt,
106
- api,
56
+ api: API.chat.gpt,
107
57
  options,
108
58
  toolsetMode,
109
- contextWindow
59
+ contextWindow,
60
+ call_name,
61
+ call_description,
62
+ cliIntro
110
63
  });
111
64
 
112
- const cliIntro = `
113
- ${name} ${options.model}.
114
- - context: ${contextWindow}
115
- `.trim();
116
-
117
- if (input) {
118
- const RES = await agent.directCall(input);
119
- console.log(RES);
120
- } else {
121
- await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
65
+ const toolset = agent.getToolset();
66
+ if (toolset) {
67
+ toolset.borrow(API.toolset.generic.bash);
68
+ toolset.borrow(API.toolset.generic.handoff)
122
69
  }
70
+
71
+ export default agent;