@j-o-r/hello-dave 0.0.2 → 0.0.3

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 (60) hide show
  1. package/README.md +288 -163
  2. package/README.md.backup +269 -0
  3. package/bin/dave.js +165 -0
  4. package/examples/CodeServer +43 -0
  5. package/{bin/hdAsk.js → examples/askDave.js} +50 -39
  6. package/{bin/hdCode.js → examples/codeDave.js} +47 -47
  7. package/examples/coderev.js +72 -0
  8. package/examples/daisy.js +177 -0
  9. package/examples/docsDave.js +119 -0
  10. package/examples/gpt.js +54 -72
  11. package/examples/grok.js +47 -68
  12. package/examples/npmDave.js +175 -0
  13. package/examples/promptDave.js +112 -0
  14. package/examples/readmeDave.js +144 -0
  15. package/examples/spawndave.js +240 -0
  16. package/examples/todoDave.js +132 -0
  17. package/lib/API/openai.com/reponses/text.js +12 -18
  18. package/lib/API/x.ai/collections.js +354 -0
  19. package/lib/API/x.ai/files.js +218 -0
  20. package/lib/API/x.ai/responses.js +494 -0
  21. package/lib/API/x.ai/text.js +1 -1
  22. package/lib/AgentClient.js +13 -6
  23. package/lib/AgentManager.js +79 -10
  24. package/lib/AgentServer.js +45 -21
  25. package/lib/Cli.js +7 -1
  26. package/lib/Prompt.js +4 -2
  27. package/lib/ToolSet.js +2 -1
  28. package/lib/genericToolset.js +124 -87
  29. package/lib/index.js +4 -2
  30. package/lib/wsCli.js +257 -0
  31. package/lib/wsIO.js +96 -0
  32. package/package.json +26 -20
  33. package/types/API/openai.com/reponses/text.d.ts +17 -3
  34. package/types/API/x.ai/collections.d.ts +167 -0
  35. package/types/API/x.ai/files.d.ts +84 -0
  36. package/types/API/x.ai/responses.d.ts +379 -0
  37. package/types/AgentClient.d.ts +5 -0
  38. package/types/AgentManager.d.ts +24 -31
  39. package/types/AgentServer.d.ts +5 -1
  40. package/types/Prompt.d.ts +4 -2
  41. package/types/ToolSet.d.ts +1 -0
  42. package/types/index.d.ts +4 -3
  43. package/types/wsCli.d.ts +3 -0
  44. package/types/wsIO.d.ts +26 -0
  45. package/utils/bars.js +40 -0
  46. package/utils/clear_sessions.sh +54 -0
  47. package/{bin/hdInspect.js → utils/format_log.js} +5 -0
  48. package/utils/list_sessions.sh +46 -0
  49. package/utils/search_sessions.sh +73 -0
  50. package/bin/hdClear.js +0 -13
  51. package/bin/hdConnect.js +0 -230
  52. package/bin/hdNpm.js +0 -114
  53. package/bin/hdPrompt.js +0 -108
  54. package/examples/claude-test.js +0 -89
  55. package/examples/claude.js +0 -143
  56. package/examples/gpt_code.js +0 -125
  57. package/examples/gpt_note_keeping.js +0 -117
  58. package/examples/grok_code.js +0 -114
  59. package/examples/grok_note_keeping.js +0 -111
  60. package/module.md +0 -189
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env node
2
+ import { AgentManager } from '@j-o-r/hello-dave';
3
+ import { parseArgs, readIn } from '@j-o-r/sh';
4
+
5
+ const name = 'readme_dave';
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;
13
+
14
+ /** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
15
+ const options = { tools : []};
16
+ options.tools.push({
17
+ type: 'web_search'
18
+ });
19
+ if (args['secret']) { // model gets default value
20
+ secret = args['secret'];
21
+ }
22
+ // Set properties only if provided via command line (except model which has default)
23
+ if (args['model'] || true) { // model gets default value
24
+ // @ts-ignore
25
+ options.model = args['model'] || 'grok-4-fast-reasoning';
26
+ }
27
+ if (args['temperature']) {
28
+ options.temperature = parseFloat(args['temperature']);
29
+ }
30
+ if (args['tokens']) {
31
+ options.max_output_tokens = parseInt(args['tokens']);
32
+ }
33
+ if (args['top_p']) {
34
+ options.top_p = parseFloat(args['top_p']);
35
+ }
36
+ const reasoning = args['reasoning'] ? args['reasoning'] : null;
37
+ if (reasoning) {
38
+ if (reasoning) {
39
+ options.reasoning = {
40
+ // @ts-ignore
41
+ effort: reasoning,
42
+ summary: 'auto'
43
+ }
44
+ }
45
+ }
46
+
47
+ const toolsetMode = 'auto';
48
+ const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
49
+
50
+ // Copy from the generic toolset
51
+ function printHelp() {
52
+ console.log(`
53
+ '${name} --help' You are looking at it.
54
+
55
+ OPTIONS:
56
+ --tokens [number]: max generated tokens
57
+ --context [number] : truncate message history to context-windows size default 130000
58
+ --temperature [float] : -2 / +2
59
+ --model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast|grok-code-fast-1]
60
+ --top_p [float]: number > 0, 0.1 means no top_p
61
+ --reasoning [low|high]
62
+ --tools [javascript,bash] comma seperated list
63
+
64
+ SERVER TOOLS:
65
+ --serve [number]: create a Agent server on port number ws://127.0.0.1:[serve]/ws
66
+ --connect [url]: connect to a Server Agent e.g ws://127.0.0.1:8080/ws (https://my.domain/ws) ...
67
+ --secret [string] : limit access to websocket server with a secret
68
+ `);
69
+ process.exit()
70
+ }
71
+
72
+ if (help) {
73
+ printHelp();
74
+ }
75
+
76
+ const tool_call_description = `
77
+ Project README manager. Maintains README.md with comprehensive project documentation.
78
+ Inspects current README.md, updates sections (installation, usage, etc.), generates content based on project files and user input.
79
+ Suggests improvements, adds badges, TOC, etc.
80
+ `.trim();
81
+ const tool_call_name = 'readme_agent';
82
+ const prompt = `
83
+ You are an expert README.md manager for this project. README.md should follow best practices with sections like:
84
+
85
+ # Project Title
86
+ ![Badges]
87
+
88
+ ## Table of Contents
89
+
90
+ ## Description
91
+ ## Features
92
+ ## Installation
93
+ ## Usage
94
+ ## Examples
95
+ ## Development
96
+ ## Contributing
97
+ ## License
98
+
99
+ ALWAYS:
100
+
101
+ 1. Inspect the current README.md if it exists (\`cat README.md\` or similar).
102
+
103
+ 2. Inspect key project files: \`cat package.json\`, \`ls -la\`, \`ls bin/\`, \`ls lib/\`, \`git status\`, etc.
104
+
105
+ 3. Understand the user input:
106
+ - "add installation instructions"
107
+ - "generate usage examples"
108
+ - "add table of contents"
109
+ - "update description to: ..."
110
+ - "suggest improvements"
111
+ - "include npm badges"
112
+ - "make it more professional"
113
+
114
+ 4. Update README.md with changes. Ensure excellent Markdown formatting, accuracy based on project.
115
+
116
+ 5. Write the FULL updated content to ./README.md.
117
+
118
+ 6. In your response, summarize:
119
+ - Changes made
120
+ - Preview of key sections (e.g., first 20 lines)
121
+ - Any suggestions for further enhancements
122
+
123
+ If no README.md exists, create a comprehensive one by analyzing the entire project: package.json, code structure, scripts, etc. Infer project name, description, usage from files.
124
+
125
+ Use tools to read files, list directories, etc., as needed.
126
+ `.trim();
127
+ const agent = new AgentManager({ name, secret });
128
+ agent.setup({
129
+ prompt,
130
+ api,
131
+ options,
132
+ toolsetMode,
133
+ contextWindow
134
+ });
135
+ const toolset = agent.getToolset();
136
+ if (toolset) {
137
+ agent.addGenericToolcall('execute_bash_script');
138
+ }
139
+ const cliIntro = `
140
+ ${name} ${options.model}.
141
+ - context: ${contextWindow}
142
+ `.trim();
143
+
144
+ await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
@@ -0,0 +1,240 @@
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 = 'spawndave';
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;
13
+
14
+ const options = { tools: [] };
15
+
16
+ options.tools.push({ type: 'web_search' });
17
+
18
+ if (args['secret']) {
19
+ secret = args['secret'];
20
+ }
21
+
22
+ if (args['model'] || true) {
23
+ options.model = args['model'] || 'grok-4-fast-reasoning'; // Up-to-date as of 2026
24
+ }
25
+ if (args['temperature']) {
26
+ options.temperature = parseFloat(args['temperature']);
27
+ }
28
+ if (args['tokens']) {
29
+ options.max_output_tokens = parseInt(args['tokens']);
30
+ }
31
+ if (args['top_p']) {
32
+ options.top_p = parseFloat(args['top_p']);
33
+ }
34
+ options.reasoning = { effort: 'high', summary: 'auto' };
35
+
36
+ const contextWindow = args['context'] ? parseInt(args['context']) : 500000;
37
+ const toolsetMode = 'auto';
38
+
39
+ function printHelp() {
40
+ console.log(`${name} --help: Interactive AI Agent Creator (Fully Portable - Works Anywhere!)
41
+
42
+ Guides you to create custom @j-o-r/hello-dave CLI agents (bin/<name>.js) w/ full support for CLI, WS Server (--serve), WS Client (--connect), hybrids, and **multi-agent CodeServer patterns**.
43
+
44
+ PORTABLE: Runs in ANY project (auto-installs deps, no local docs needed). Docs: https://codeberg.org/duin/hello-dave (agent-manager.md, codeserver-pattern.md).
45
+
46
+ USAGE:
47
+ npx @j-o-r/hello-dave spawndave # Interactive creation
48
+ npx @j-o-r/hello-dave spawndave --name myagent "Desc" # Semi-auto
49
+ echo "Create CodeServer launcher" | npx @j-o-r/hello-dave spawndave # Multi-agent
50
+
51
+ OPTIONS: --model [...] --temp [...] --secret [...]
52
+
53
+ PROCESS:
54
+ 1. Inspect project, auto-install deps (@j-o-r/hello-dave @j-o-r/sh).
55
+ 2. Gather: name, desc, tools, prompt.
56
+ 3. Generate/validate ESM script (node --check + tool rules).
57
+ 4. Write ./bin/<name>.js, chmod +x, **CLI auto-test**.
58
+ 5. **Server/Client Guide**: Test --serve → --connect; hybrids.
59
+ 6. **CodeServer Aware**: Generates PM2 launchers (self-contained, like examples/CodeServer).
60
+
61
+ EXAMPLES (Generated Agents):
62
+ ./bin/myagent.js # CLI
63
+ echo 'query' | ./bin/myagent.js # One-shot
64
+ ./bin/myagent.js --serve 8081 # WS Server
65
+ ./bin/myagent.js --connect ws://...:8081/ws --secret KEY # WS Client
66
+ ./bin/myagent.js --serve 8081 --connect ws://other:8080/ws # Hybrid
67
+ ./examples/MyServer 8081 mysecret # Multi-agent PM2 (generated)
68
+
69
+ **Multi-Agent**: "Generate launcher script like CodeServer pattern for myagent + todoagent".
70
+ `);
71
+ process.exit();
72
+ }
73
+
74
+ if (help) printHelp();
75
+
76
+ const REPO_URL = 'https://codeberg.org/duin/hello-dave';
77
+ const DOCS_BASE = `${REPO_URL}/src/branch/main/docs/`;
78
+ const EXAMPLES_URL = `${REPO_URL}/src/branch/main/examples/`;
79
+
80
+ const promptParts = [
81
+ 'You are AgentCreator, expert in @j-o-r/hello-dave. Create production-ready CLI agents (bin/<name>.js) **portably** anywhere (no local docs needed).',
82
+ '',
83
+ '**AGENT NAME RULE ⚠️**: name MUST be lowercase a-z0-9_ min 2 chars (/^[a-z_0-9_]{2,}$/). EX: myagent, codeagent, ws_tool.',
84
+ '',
85
+ '**IMPORTS CRITICAL ⚠️**: **NAMED imports ONLY** - NO default! `import { AgentManager } from \'@j-o-r/hello-dave\';` `import { parseArgs } from \'@j-o-r/sh\';`',
86
+ '',
87
+ '**PORTABILITY**: Auto-install deps: `@j-o-r/hello-dave @j-o-r/sh`. Absolute imports. NO local file refs (docs/examples).',
88
+ '',
89
+ '**INITIAL INSPECT** (execute_bash_script):',
90
+ '1. `npm ls @j-o-r/hello-dave @j-o-r/sh 2>/dev/null || echo MISSING` → If MISSING: `npm i @j-o-r/hello-dave @j-o-r/sh --save-exact`.',
91
+ '2. `mkdir -p bin examples`.',
92
+ '3. `cat package.json` (project name). `ls -la bin/`.',
93
+ '',
94
+ '**TOOL RULES (CRITICAL - NO MIX)**:',
95
+ '- **XAI Natives** (pre-setup): `options.tools.push({ type: \'web_search\' });` etc.',
96
+ '- **Generics** (post-setup): `agent.addGenericToolcall(\'read_file\');` w/ `toolsetMode: \'auto\'`.',
97
+ 'Default: web_search + execute_bash_script/read_file/write_file.',
98
+ '',
99
+ '**PROCESS (EXACT)**:',
100
+ '1. INSPECT & SETUP.',
101
+ '2. GATHER (conversational): **name (validate /^[a-z_0-9_]{2,}$/ or reject)**, desc, api(\'xai\'), model/options, tools, custom prompt, CLI intro/help.',
102
+ '3. GENERATE & VALIDATE: Use blueprint. Write temp_validate.js, `node --check temp_validate.js` (PASS), grep toolsetMode/auto (1x), generics/addGeneric (≥1 if used), natives/push (≥1 if used), NO options.tools.function.read_file. rm temp.',
103
+ '4. REVIEW: Show ```js``` + "✅ node --check | Tools OK". Edit if needed.',
104
+ '5. DEPLOY: `write_file ./bin/${name}.js FULL_CODE`, `chmod +x ./bin/${name}.js`.',
105
+ '6. **TEST**: `execute_bash_script \'./bin/${name}.js "Briefly describe yourself and your modes (CLI/server/client)"\'` → Show output.',
106
+ '7. **SERVER/CLIENT GUIDE**: "Test server: ./bin/${name}.js --serve 8081 (find free port). Client: echo \'query\' | ./bin/${name}.js --connect ws://localhost:8081/ws --secret SECRET".',
107
+ '8. **CodeServer MULTI-AGENT**: If requested (e.g., "multi-agent", "CodeServer"), generate **self-contained Bash launcher** (PM2-managed main server + subs). Write to examples/<Name>Server (e.g., examples/CodeServer). Use blueprint below. PM2: Assume installed (`npm i -g pm2`).',
108
+ '',
109
+ '**AGENT BLUEPRINT** (COPY/REPLACE - Plain backticks ` NO ESCAPES):',
110
+ `\`#!/usr/bin/env node
111
+ import { AgentManager } from '@j-o-r/hello-dave';
112
+ import { parseArgs } from '@j-o-r/sh';
113
+
114
+ const name = 'AGENTNAME'; // ← REPLACE w/ lowercase /^[a-z_0-9_]{2,}$/
115
+ const api = 'xai';
116
+ let secret = '';
117
+
118
+ const args = parseArgs();
119
+ const help = args['help'] || false;
120
+ const connect = args['connect'] ? args['connect'] : undefined;
121
+ const serve = args['serve'] ? parseInt(args['serve']) : undefined;
122
+
123
+ const options = { tools: [] };
124
+
125
+ // NATIVES HERE e.g. options.tools.push({ type: 'web_search' });
126
+
127
+ if (args['secret']) { secret = args['secret']; }
128
+ if (args['model'] || true) { options.model = args['model'] || 'grok-4-fast-reasoning'; }
129
+ if (args['temperature']) { options.temperature = parseFloat(args['temperature']); } else { options.temperature = 0.8; }
130
+ options.reasoning = { effort: 'medium', summary: 'auto' };
131
+
132
+ const contextWindow = args['context'] ? parseInt(args['context']) : 500000;
133
+ const toolsetMode = 'auto';
134
+
135
+ function printHelp() {
136
+ console.log(\`AGENTNAME --help: AGENTDESC
137
+
138
+ Full modes: CLI, WS Server (--serve), WS Client (--connect), Hybrid.
139
+
140
+ Repo docs: https://codeberg.org/duin/hello-dave (agent-manager.md, codeserver-pattern.md).
141
+
142
+ USAGE:
143
+ ./bin/AGENTNAME # Interactive CLI
144
+ echo "query" | ./bin/AGENTNAME # One-shot
145
+ ./bin/AGENTNAME --serve 8081 # WS Server
146
+ ./bin/AGENTNAME --connect ws://host:8081/ws --secret KEY # WS Client
147
+ ./bin/AGENTNAME --serve 8081 --connect ws://other:8080/ws # Hybrid
148
+
149
+ OPTIONS: --model ... --secret ...
150
+
151
+ EXAMPLES:
152
+ Chain: Server A --connect B → delegates to B.
153
+ Multi-Agent: Generate/use PM2 launcher (CodeServer pattern).\`);
154
+ process.exit();
155
+ }
156
+
157
+ if (help) printHelp();
158
+
159
+ const prompt = \`You are AGENTNAME, AGENTDESC.
160
+
161
+ CUSTOMPROMPT\`.trim();
162
+
163
+ const agent = new AgentManager({ name, secret });
164
+ agent.setup({ prompt, api, options, toolsetMode, contextWindow });
165
+
166
+ // GENERICS HERE e.g. agent.addGenericToolcall('execute_bash_script');
167
+
168
+ const cliIntro = \`🤖 AGENTNAME ready! Modes: CLI/Server/Client/Hybrid.
169
+
170
+ CLIINTRO\`.trim();
171
+
172
+ const toolName = 'agent_' + name;
173
+ const toolDescription = \`AGENTDESC. Supports WS chaining/multi-agent.\`.trim();
174
+
175
+ await agent.start(serve, connect, cliIntro, toolName, toolDescription);\``,
176
+ '',
177
+ '**CODE_SERVER BLUEPRINT** (Bash for multi-agent - Self-contained, like CodeServer pattern):',
178
+ `\`#!/bin/bash
179
+ # Portable Multi-Agent Launcher (PM2-managed: main server + subs)
180
+ # Run: npm i -g pm2 (once)
181
+ if [ $# -lt 1 ] || [ $# -gt 2 ]; then
182
+ echo "Usage: $0 <PORT> [SECRET] # PORT:1024-65535, SECRET:>=3 chars (def:123)"
183
+ exit 1
184
+ fi
185
+ PORT="$1"
186
+ SECRET="\${2:-123}"
187
+ if [ \${#SECRET} -lt 3 ]; then echo "SECRET too short"; exit 1; fi
188
+ if ! [[ "$PORT" =~ ^[0-9]+$ ]] || [ "$PORT" -lt 1024 ] || [ "$PORT" -gt 65535 ]; then echo "Bad PORT"; exit 1; fi
189
+
190
+ SCRIPT_DIR="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
191
+ PROJECT_DIR="\$( cd "\$( dirname "\${SCRIPT_DIR}" )" && pwd )"
192
+ FOLDER=\$(basename "$PROJECT_DIR")
193
+
194
+ echo "Starting <MainAgent>Server on port \${PORT} in '\$FOLDER' w/ SECRET '\$SECRET'..."
195
+
196
+ # Cleanup old PM2
197
+ pm2 delete "\${FOLDER}_mainagent_\${PORT}" 2>/dev/null || true
198
+ pm2 delete "\${FOLDER}_sub1agent_\${PORT}" 2>/dev/null || true # Add per sub
199
+ # ... more subs
200
+
201
+ # Main server
202
+ pm2 start "\${SCRIPT_DIR}/bin/mainagent.js" --name "\${FOLDER}_mainagent_\${PORT}" -- --serve "\${PORT}" --tools javascript --secret "\${SECRET}"
203
+ # Subs as clients
204
+ pm2 start "\${SCRIPT_DIR}/bin/sub1agent.js" --name "\${FOLDER}_sub1agent_\${PORT}" -- --connect "ws://127.0.0.1:\${PORT}/ws" --secret "\${SECRET}"
205
+ # ... more: pm2 start ... sub2agent.js ...
206
+
207
+ echo "Processes: pm2 list | grep '\${FOLDER}_\${PORT}'"
208
+ echo "Connect: npx @j-o-r/hello-dave dave --connect ws://127.0.0.1:\${PORT}/ws --secret '\${SECRET}'"\``,
209
+ '',
210
+ 'Enthusiastic, step-by-step. Match portable style. **ALWAYS validate name regex before generate/deploy.** Current date: 2026. Models: grok-4-fast-reasoning/grok-beta. CodeServer pattern: https://codeberg.org/duin/hello-dave/src/branch/main/examples/CodeServer'
211
+ ];
212
+
213
+ const prompt = promptParts.join('\\n');
214
+
215
+ const agent = new AgentManager({ name, secret });
216
+ agent.setup({
217
+ prompt,
218
+ api,
219
+ options,
220
+ toolsetMode,
221
+ contextWindow
222
+ });
223
+
224
+ agent.addGenericToolcall('execute_bash_script');
225
+ agent.addGenericToolcall('read_file');
226
+ agent.addGenericToolcall('write_file');
227
+ agent.addGenericToolcall('javascript_interpreter');
228
+
229
+ const cliIntro = `🤖 ${name} (${options.model}) ready! (context: ${contextWindow})
230
+
231
+ Portable Agent Creator: Builds CLI/WS agents + CodeServer launchers **anywhere** (auto-deps, online docs).
232
+
233
+ Examples:
234
+ - "Create code-review agent: name=coderev, desc=Git diff analyzer, tools=read_file execute_bash_script web_search"
235
+ - "Generate CodeServer launcher for coderev + tododave + npmdave"`.trim();
236
+
237
+ const toolName = 'spawn_dave';
238
+ const toolDescription = `Portable creator for CLI/WS agents (bin/<name>.js) + PM2 multi-agent launchers. Validates/tests/deploys. No local docs needed (uses repo: https://codeberg.org/duin/hello-dave).`.trim();
239
+
240
+ await agent.start(serve, connect, cliIntro, toolName, toolDescription);
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+ import { AgentManager } from '@j-o-r/hello-dave';
3
+ import { parseArgs, readIn } from '@j-o-r/sh';
4
+
5
+ const name = 'todo_dave';
6
+ const api = 'xai';
7
+ let secret = '';
8
+
9
+ const input = ''; // await readIn() /* not compabtible with `pm2` */;
10
+ const args = parseArgs();
11
+ const help = args['help'] || false;
12
+ const connect = args['connect'] ? args['connect'] : undefined;
13
+ const serve = args['serve'] ? parseInt(args['serve']) : undefined;
14
+
15
+ /** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
16
+ const options = { tools : []};
17
+
18
+ if (args['secret']) { // model gets default value
19
+ secret= args['secret'];
20
+ }
21
+ // Set properties only if provided via command line (except model which has default)
22
+ if (args['model'] || true) { // model gets default value
23
+ // @ts-ignore
24
+ options.model = args['model'] || 'grok-4-fast-reasoning';
25
+ }
26
+ if (args['temperature']) {
27
+ options.temperature = parseFloat(args['temperature']);
28
+ }
29
+ if (args['tokens']) {
30
+ options.max_output_tokens = parseInt(args['tokens']);
31
+ }
32
+ if (args['top_p']) {
33
+ options.top_p = parseFloat(args['top_p']);
34
+ }
35
+ const reasoning = true; // args['reasoning'] ? args['reasoning'] : null;
36
+ if (reasoning) {
37
+ options.reasoning = {
38
+ effort:'medium',
39
+ summary: 'auto'
40
+ }
41
+ }
42
+
43
+ options.tools.push({
44
+ type: 'web_search'
45
+ });
46
+ const toolsetMode = 'auto';
47
+ const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
48
+
49
+ // Copy from the generic toolset
50
+ function printHelp() {
51
+ console.log(`
52
+ '${name} --help' You are looking at it.
53
+ '
54
+ OPTIONS:
55
+ --tokens [number]: max generated tokens
56
+ --context [number] : truncate message history to context-windows size default 130000
57
+ --temperature [float] : -2 / +2
58
+ --model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast|grok-code-fast-1]
59
+ --top_p [float]: number > 0, 0.1 means no top_p
60
+ --reasoning [low|high]
61
+ --tools [javascript,bash] comma seperated list
62
+ `);
63
+ process.exit()
64
+ }
65
+
66
+ if (help) {
67
+ printHelp();
68
+ }
69
+
70
+ const tool_call_description = `
71
+ Project TODO list manager. Maintains TODO.md with tasks in Markdown checklists.
72
+ Inspects current TODO.md, adds/checks/completes tasks based on input, updates the file.
73
+ Suggests next actions, stores future important tasks.
74
+ `.trim();
75
+ const tool_call_name = 'todo_agent';
76
+ const prompt = `
77
+ You are an expert TODO manager for this project. TODO.md stores tasks in Markdown format with checklists:
78
+
79
+ ## TODO (high priority pending)
80
+ - [ ] Task 1
81
+
82
+ ## In Progress
83
+ - [ ] Task 2
84
+
85
+ ## Later (future tasks)
86
+ - [ ] Important task to do later
87
+
88
+ ## Done
89
+ - [x] Completed task
90
+
91
+ ALWAYS:
92
+
93
+ 1. Inspect the current TODO.md file if it exists (use \`cat TODO.md\` or similar).
94
+
95
+ 2. Understand the user input:
96
+ - Add new tasks: "add task: Fix bug in foo.js"
97
+ - Complete: "done: task X" or mark specific
98
+ - Check status: "status" or "what's next?"
99
+ - Prioritize/reorganize
100
+ - Archive old done tasks if too many
101
+
102
+ 3. Update TODO.md with changes. Keep it organized, add dates if useful (e.g., - [ ] 2026-02-24: Task).
103
+
104
+ 4. Write the FULL updated content to ./TODO.md.
105
+
106
+ 5. In your response, summarize:
107
+ - Current status (pending count, next suggested)
108
+ - Changes made
109
+ - Updated TODO.md preview (first 10 lines or key sections)
110
+
111
+ If no TODO.md, create one inspecting the project (package.json, README.md, git status) for initial tasks like "Review code", "Add tests", etc.
112
+
113
+ Use tools to inspect files as needed (ls, cat, git log, etc.).
114
+ `.trim();
115
+ const agent = new AgentManager({ name, secret });
116
+ agent.setup({
117
+ prompt,
118
+ api,
119
+ options,
120
+ toolsetMode,
121
+ contextWindow
122
+ });
123
+ const toolset = agent.getToolset();
124
+ if (toolset) {
125
+ agent.addGenericToolcall('execute_bash_script');
126
+ }
127
+ const cliIntro = `
128
+ ${name} ${options.model}.
129
+ - context: ${contextWindow}
130
+ `.trim();
131
+
132
+ await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
@@ -22,12 +22,12 @@ import { sleep } from '@j-o-r/sh';
22
22
  * @property {number} [max_output_tokens=4000] - Maximum number of output tokens.
23
23
  * @property {number} [max_tool_calls=10] - Maximum number of tool calls allowed.
24
24
  * @property {?Object} [metadata=null] - Optional metadata object.
25
- * @property {'gpt-4.1'|'GPT-4o'|'o3'|'o3-mini'|'o4-mini'|'o1'|'o3-pro'} [model='gpt-4.1'] - Model version to use.
25
+ * @property {'gpt-5.4'|'gpt-5-mini'|'gpt-5-nano'|'gpt-5-pro'} [model='gpt-5-mini'] - Model version to use.
26
26
  * @property {?string} [prompt=null] - Reusable prompt string.
27
27
  * @property {Object} [reasoning={effort: 'medium', summary: 'auto'}] - Reasoning configuration.
28
28
  * @property {'low'|'medium'|'high'|null} reasoning.effort - Effort level for reasoning.
29
29
  * @property {'auto'|'concise'|'detailed'} reasoning.summary - Summary type for reasoning.
30
- * @property {'low'|'medium'|'high'} [search]
30
+ * @property {'low'|'medium'|'high'} [search] - Convenience: Adds `{type: "web_search_preview", search_context_size: search}` tool.
31
31
  * @property {'auto'} [service_tier='auto'] - Service tier option, default is auto-selected.
32
32
  * @property {boolean} [store=false] - Whether to store the response or not.
33
33
  * @property {boolean} [stream=false] - Whether to stream the response or not.
@@ -36,7 +36,7 @@ import { sleep } from '@j-o-r/sh';
36
36
  * @property {'text'|'json_schema'} text.format - Summary type for reasoning.
37
37
  * @property {boolean} [parallel_tool_calls=true] - Allow parallel tool calls if true.
38
38
  * @property {'auto'} [tool_choice='auto'] - Tool choice setting, default is auto-selected.
39
- * @property {OAToolCall[]} tools=[] Array of tool call objects.
39
+ * @property {OpenAITool[]} [tools=[]] - Array of tool objects: custom function tools (`OAToolCall`) or built-in OpenAI tools (e.g., `{type: "web_search_preview"}`).
40
40
  * @property {?number } top_logprobs=null An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
41
41
  * @property {?number } top_p=1 Top-p sampling value between 0 and 1.
42
42
  * @property {?string} [previous_response_id] - Needed reponse_id to validate tool calls on the next request
@@ -51,6 +51,14 @@ import { sleep } from '@j-o-r/sh';
51
51
  * @property {Object.<string, OAParameterProperty>} parameters.properties - An object describing each parameter property.
52
52
  * @property {string[]} [parameters.required] - An array of required parameter names.
53
53
  */
54
+ /**
55
+ * @typedef {Object} OABuiltinTool
56
+ * @property {'code_interpreter'|'file_search'|'computer'|'web_search'} type - Type of built-in OpenAI tool (Responses API).
57
+ * @property {'low'|'medium'|'high'} [search_context_size] - Context size for `web_search_preview` only.
58
+ */
59
+ /**
60
+ * @typedef {OAToolCall | OABuiltinTool} OpenAITool
61
+ */
54
62
 
55
63
  /**
56
64
  * @typedef {Object} OAParameterProperty
@@ -247,23 +255,9 @@ function getBody(prompt, toolset, options) {
247
255
  if (toolset) {
248
256
  // @ts-ignore
249
257
  body.tool_choice = toolset.toolChoice;
250
- body.tools = generateTools(toolset);
258
+ body.tools = [...body.tools, ...generateTools(toolset)];
251
259
  body.parallel_tool_calls = true;
252
- // parallel_tool_calls
253
- }
254
- // Add OPENAI SEARCH
255
- // in the toolset
256
- if (body.search) {
257
- if (!body.tools) {
258
- body.tools = [];
259
- }
260
- body.tools.push({
261
- type: 'web_search_preview',
262
- // @ts-ignore
263
- search_context_size: body.search
264
- })
265
260
  }
266
- delete body.search;
267
261
  return body;
268
262
 
269
263
  }