@j-o-r/hello-dave 0.0.2 → 0.0.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 (161) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +445 -160
  3. package/README.md.backup +269 -0
  4. package/README.md.bak +481 -0
  5. package/README.md.bak.1774780058 +338 -0
  6. package/README.md.bak2 +455 -0
  7. package/bin/dave.js +165 -0
  8. package/docs.bak.1774780058/agent-manager.md +167 -0
  9. package/docs.bak.1774780058/agent-manager.md.bak +137 -0
  10. package/docs.bak.1774780058/agent-manager.md.bak2 +157 -0
  11. package/docs.bak.1774780058/codeserver-pattern.md +191 -0
  12. package/docs.bak.1774780058/path-resolution-best-practices.md +104 -0
  13. package/docs.bak.1774780058/project-overview.md +67 -0
  14. package/docs.bak.1774780058/project-overview.md.bak +67 -0
  15. package/docs.bak.1774780058/prompt-class.md +141 -0
  16. package/docs.bak.1774780058/prompt-class.md.bak +142 -0
  17. package/docs.bak.1774780058/tools-syntax-validation.md +121 -0
  18. package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +125 -0
  19. package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +125 -0
  20. package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +106 -0
  21. package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +106 -0
  22. package/docs.bak.1774780058/toolset.md +164 -0
  23. package/docs.bak.1774780058/toolset.md.bak +94 -0
  24. package/docs.bak.1774780058/toolset.md.bak3 +161 -0
  25. package/docs.bak.1774780058/toolset.md.bak4 +161 -0
  26. package/docs.bak.1774780058/toolset.md.bak5 +161 -0
  27. package/docs.bak.1774780058/toolset.md.bak6 +163 -0
  28. package/docs.bak.1774780058/toolset.md.bak_path +163 -0
  29. package/docs.bak.1774780058/toolset.md.bak_syntax +161 -0
  30. package/docs.bak.1774780058/xai-responses.md +111 -0
  31. package/docs.bak.1774780058/xai-responses.md.bak +107 -0
  32. package/docs.bak.1774780058/xai-responses.md.bak2 +107 -0
  33. package/docs.bak.1774780058/xai_collections.md +106 -0
  34. package/examples/ask_agent.js +137 -0
  35. package/examples/code_agent.js +149 -0
  36. package/examples/coderev_agent.js +136 -0
  37. package/examples/codeserver.sh +47 -0
  38. package/examples/daisy_agent.js +170 -0
  39. package/examples/docs_agent.js +148 -0
  40. package/examples/gpt_agent.js +125 -0
  41. package/examples/grok_agent.js +132 -0
  42. package/examples/grok_agent.js.bak +98 -0
  43. package/examples/grok_agent.js.bak.2 +99 -0
  44. package/examples/grok_agent.js.bak.3 +1 -0
  45. package/examples/grok_agent.js.bak.4 +124 -0
  46. package/examples/grok_agent.js.bak.5 +1 -0
  47. package/examples/grok_agent.js.bak.6 +1 -0
  48. package/examples/memory_agent.js +152 -0
  49. package/examples/npm_agent.js +202 -0
  50. package/examples/npm_agent.js.bak.3 +2 -0
  51. package/examples/npm_agent.js.bak.4 +205 -0
  52. package/examples/npm_agent.js.bak.5 +1 -0
  53. package/examples/npm_agent.js.bak.6 +1 -0
  54. package/examples/prompt_agent.js +133 -0
  55. package/examples/readme_agent.js +148 -0
  56. package/examples/spawn_agent.js +293 -0
  57. package/examples/test_agent.js +187 -0
  58. package/examples/todo_agent.js +175 -0
  59. package/examples.bak.1774780058/ask_agent.js +114 -0
  60. package/examples.bak.1774780058/code_agent.js +149 -0
  61. package/examples.bak.1774780058/coderev_agent.js +72 -0
  62. package/examples.bak.1774780058/codeserver.sh +47 -0
  63. package/examples.bak.1774780058/daisy_agent.js +177 -0
  64. package/examples.bak.1774780058/docs_agent.js +119 -0
  65. package/{bin/hdAsk.js → examples.bak.1774780058/gpt_agent.js} +46 -40
  66. package/examples.bak.1774780058/grok_agent.js +98 -0
  67. package/examples.bak.1774780058/memory_agent.js +112 -0
  68. package/examples.bak.1774780058/npm_agent.js +175 -0
  69. package/examples.bak.1774780058/prompt_agent.js +112 -0
  70. package/examples.bak.1774780058/readme_agent.js +144 -0
  71. package/examples.bak.1774780058/spawn_agent.js +263 -0
  72. package/examples.bak.1774780058/test_agent.js +162 -0
  73. package/examples.bak.1774780058/todo_agent.js +138 -0
  74. package/lib/API/openai.com/reponses/text.js +12 -18
  75. package/lib/API/x.ai/collections.js +354 -0
  76. package/lib/API/x.ai/files.js +218 -0
  77. package/lib/API/x.ai/responses.js +492 -0
  78. package/lib/API/x.ai/text.js +1 -1
  79. package/lib/AgentClient.js +13 -6
  80. package/lib/AgentManager.js +80 -10
  81. package/lib/AgentServer.js +50 -22
  82. package/lib/Cli.js +7 -1
  83. package/lib/Prompt.js +4 -2
  84. package/lib/ToolSet.js +2 -1
  85. package/lib/genericToolset.js +258 -88
  86. package/lib/genericToolset.js.bak_syntax +402 -0
  87. package/lib/index.js +4 -2
  88. package/lib/wsCli.js +256 -0
  89. package/lib/wsIO.js +96 -0
  90. package/package.json +26 -21
  91. package/scenarios.bak.1774780058/data/eval_node_message.json +9 -0
  92. package/scenarios.bak.1774780058/data/hist_oa.json +66 -0
  93. package/scenarios.bak.1774780058/data/o3_response1.json +96 -0
  94. package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +112 -0
  95. package/scenarios.bak.1774780058/data/tool_oa.json +96 -0
  96. package/scenarios.bak.1774780058/data/tool_xai.json +59 -0
  97. package/scenarios.bak.1774780058/data/tool_xai2.json +40 -0
  98. package/scenarios.bak.1774780058/data/xai-response-1.json +59 -0
  99. package/scenarios.bak.1774780058/data/xai-response-2.json +10 -0
  100. package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +59 -0
  101. package/scenarios.bak.1774780058/data/xai_search_response.json +58 -0
  102. package/scenarios.bak.1774780058/environment.js +10 -0
  103. package/scenarios.bak.1774780058/example.js +17 -0
  104. package/scenarios.bak.1774780058/genericToolset.test.js +182 -0
  105. package/scenarios.bak.1774780058/grok.js +113 -0
  106. package/scenarios.bak.1774780058/memory-tools.js +51 -0
  107. package/scenarios.bak.1774780058/openai-o3.js +137 -0
  108. package/scenarios.bak.1774780058/openai-prompt.js +155 -0
  109. package/scenarios.bak.1774780058/openai-session.js +148 -0
  110. package/scenarios.bak.1774780058/openai.js +102 -0
  111. package/scenarios.bak.1774780058/prompt.js +118 -0
  112. package/scenarios.bak.1774780058/promptFishbowl.js +76 -0
  113. package/scenarios.bak.1774780058/search.brave.com.js +25 -0
  114. package/scenarios.bak.1774780058/sh.js +15 -0
  115. package/scenarios.bak.1774780058/test-wsio.js +26 -0
  116. package/scenarios.bak.1774780058/testToolset.js +42 -0
  117. package/scenarios.bak.1774780058/toolset.js +16 -0
  118. package/scenarios.bak.1774780058/toolset.test.js +141 -0
  119. package/scenarios.bak.1774780058/write_file_syntax.test.js +145 -0
  120. package/scenarios.bak.1774780058/write_file_validation/README.md +30 -0
  121. package/scenarios.bak.1774780058/write_file_validation/bad.js +3 -0
  122. package/scenarios.bak.1774780058/write_file_validation/good.js +4 -0
  123. package/scenarios.bak.1774780058/write_file_validation/test.sh +43 -0
  124. package/scenarios.bak.1774780058/wsClient.js +69 -0
  125. package/scenarios.bak.1774780058/xai_responses.integration.test.js +57 -0
  126. package/scenarios.bak.1774780058/xai_responses.test.js +154 -0
  127. package/scenarios.bak.1774780058/xaicoll.js +50 -0
  128. package/scenarios.bak.1774780058/xaifiles.js +48 -0
  129. package/types/API/openai.com/reponses/text.d.ts +17 -3
  130. package/types/API/x.ai/collections.d.ts +167 -0
  131. package/types/API/x.ai/files.d.ts +84 -0
  132. package/types/API/x.ai/responses.d.ts +379 -0
  133. package/types/AgentClient.d.ts +5 -0
  134. package/types/AgentManager.d.ts +25 -31
  135. package/types/AgentServer.d.ts +5 -1
  136. package/types/Prompt.d.ts +4 -2
  137. package/types/ToolSet.d.ts +1 -0
  138. package/types/index.d.ts +4 -3
  139. package/types/wsCli.d.ts +3 -0
  140. package/types/wsIO.d.ts +26 -0
  141. package/utils/bars.js +40 -0
  142. package/utils/clear_sessions.sh +54 -0
  143. package/{bin/hdInspect.js → utils/format_log.js} +5 -0
  144. package/utils/list_sessions.sh +46 -0
  145. package/utils/search_sessions.sh +73 -0
  146. package/utils/syntax_check.sh +61 -0
  147. package/utils/test.sh +46 -0
  148. package/bin/hdClear.js +0 -13
  149. package/bin/hdCode.js +0 -115
  150. package/bin/hdConnect.js +0 -230
  151. package/bin/hdNpm.js +0 -114
  152. package/bin/hdPrompt.js +0 -108
  153. package/examples/claude-test.js +0 -89
  154. package/examples/claude.js +0 -143
  155. package/examples/gpt.js +0 -127
  156. package/examples/gpt_code.js +0 -125
  157. package/examples/gpt_note_keeping.js +0 -117
  158. package/examples/grok.js +0 -119
  159. package/examples/grok_code.js +0 -114
  160. package/examples/grok_note_keeping.js +0 -111
  161. package/module.md +0 -189
@@ -1,117 +0,0 @@
1
- #!/usr/bin/env node
2
- import { fileURLToPath } from 'url';
3
- import path from 'path';
4
- import AgentManager from '../lib/AgentManager.js';
5
- import { systemInfo } from '../lib/fafs.js';
6
- import { parseArgs, readIn } from '@j-o-r/sh';
7
- import toolsPool from '../lib/genericToolset.js';
8
-
9
- const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
10
- const api = 'gpt'; // Using GPT API for general AI assistance, adjust if needed
11
-
12
- const input = await readIn();
13
- const args = parseArgs();
14
- const help = args['help'] || false;
15
- const connect = args['connect'] ? args['connect'] : undefined;
16
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
17
-
18
- /**
19
- * @type {import('lib/API/openai.com/reponses/text.js').OAOptions}
20
- */
21
- const options = {}
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'] || 'gpt-5-mini';
26
- }
27
- // temperature is NOT available for o3 / 03-mini
28
- if (args['temperature']) {
29
- options.temperature = parseFloat(args['temperature']);
30
- }
31
- if (args['tokens']) {
32
- options.max_output_tokens = parseInt(args['tokens']);
33
- }
34
- if (args['top_p']) {
35
- options.top_p = parseFloat(args['top_p']);
36
- }
37
- // always enable search
38
- // @ts-ignore
39
- options.search = args['search'] || 'medium';
40
-
41
- const reasoning = args['reasoning'] ? args['reasoning'] : null;
42
-
43
- if (reasoning) {
44
- // @ts-ignore
45
- options.reasoning = { effort: reasoning, summary: 'auto' }
46
- }
47
-
48
- const toolsetMode = 'auto';
49
- const contextWindow = args['context'] ? parseInt(args['context']) : 399000;
50
-
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
58
- --temperature [float] : default 0.4
59
- --model [gpt-5|gpt-5-mini|gpt-5-nano|gpt-4.1|o3|o3-mini|o4-mini|o1|o3-pro]
60
- --reasoning [low|medium|high]
61
- e.g.
62
- gpt --model o3-mini --tokens 4000 --context 10000
63
-
64
- `);
65
- process.exit()
66
- }
67
-
68
- if (help) {
69
- printHelp();
70
- }
71
- const sys = await systemInfo();
72
-
73
- // You are an AI note-keeping assistant for Markdown notes in extended context. Use/create 'notes' folder in cwd. Search via tools like grep. Create/update/delete .md files safely. Goals: track progress, manage todos, capture requirements, document processes, store links/bookmarks/remarks. Respond concisely, step-by-step, no unnecessary follow-ups.
74
- const prompt = `
75
- You are an AI note-keeping assistant for Markdown notes. Use/create 'notes' folder in cwd. Search via grep. Safely create/update/delete .md files. Goals: track progress, manage todos, capture requirements, document processes, store links/remarks. Respond concisely, step-by-step; organize in logical folders, no unnecessary follow-ups.
76
- ---env
77
- ${sys}
78
- ---
79
- `.trim();
80
- const agent = new AgentManager({ name });
81
- agent.setup({
82
- prompt,
83
- api,
84
- options,
85
- toolsetMode,
86
- contextWindow
87
- });
88
- const toolset = agent.getToolset();
89
-
90
- if (toolset) {
91
- let tool = toolsPool.get('execute_bash_script');
92
- if (tool) {
93
- toolset.add('execute_bash_script', tool.description, tool.parameters, tool.method);
94
- }
95
- }
96
-
97
- const cliIntro = `
98
- ${name} ${options.model}.
99
- - search ${options.search}
100
- - context: ${contextWindow}
101
- `.trim();
102
- const description = `
103
- AI-assisted note-keeping tool for Markdown notes. Support: search, create, update, delete. Track progress, todos, requirements, docs, links, bookmarks, remarks. Use as extended memory for task progress, decisions, state. On startup, query notes for last known state/context. Save notes regularly.
104
- `.trim();
105
-
106
- if (input === '' && serve) {
107
- agent.enableServer('memory', description, serve);
108
- }
109
- if (input !== '') {
110
- // Direct input output
111
- const res = await agent.directCall(input);
112
- console.log(res);
113
- } else if (connect) {
114
- agent.attach('memory', description, connect)
115
- } else {
116
- agent.startCli(cliIntro);
117
- }
package/examples/grok.js DELETED
@@ -1,119 +0,0 @@
1
- #!/usr/bin/env node
2
- import { fileURLToPath } from 'url';
3
- import path from 'path';
4
- import AgentManager from '../lib/AgentManager.js';
5
- import { parseArgs, readIn } from '@j-o-r/sh';
6
- import genTools from '../lib/genericToolset.js';
7
-
8
- const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
9
- const api = 'grok';
10
-
11
- const input = await readIn();
12
- const args = parseArgs();
13
- const help = args['help'] || false;
14
- const connect = args['connect'] ? args['connect'] : undefined;
15
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
16
-
17
- /** @type {import('lib/API/x.ai/text.js').XOptions} */
18
- const options = {}
19
- // Set properties only if provided via command line (except model which has default)
20
- if (args['model'] || true) { // model gets default value
21
- // @ts-ignore
22
- options.model = args['model'] || 'grok-4';
23
- }
24
- if (args['temperature']) {
25
- options.temperature = parseFloat(args['temperature']);
26
- }
27
- if (args['tokens']) {
28
- options.max_completion_tokens = parseInt(args['tokens']);
29
- }
30
- if (args['top_p']) {
31
- options.top_p = parseFloat(args['top_p']);
32
- }
33
-
34
- options.search_parameters = { mode: 'auto' }
35
- // @ts-ignore
36
- const reasoning = args['reasoning'] ? args['reasoning'] : null;
37
- if (reasoning) {
38
- // @ts-ignore
39
- options.reasoning_effort = reasoning
40
- }
41
- const toolsetMode = (args.tools || serve) ? 'auto' : undefined;
42
- const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
43
-
44
- function printHelp() {
45
- console.log(`
46
- '${name} --help' You are looking at it.
47
- '
48
- OPTIONS:
49
- --tokens [number]: max generated tokens
50
- --context [number] : truncate message history to context-windows size default 130000
51
- --temperature [float] : -2 / +2
52
- --model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast]
53
- --top_p [float]: number > 0, 0.1 means no top_p
54
- --reasoning [low|high]
55
- --tools [javascript,bash] comma seperated list
56
- e.g.
57
- grok.js --model grok-3-mini --tokens 4000 --context 10000
58
-
59
- `);
60
- process.exit()
61
- }
62
-
63
- if (help) {
64
- printHelp();
65
- }
66
- const prompt = `
67
- 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.
68
- `.trim();
69
-
70
- const agent = new AgentManager({ name });
71
- agent.setup({
72
- prompt,
73
- api,
74
- options,
75
- toolsetMode,
76
- contextWindow
77
- });
78
- const tools = [];
79
- const toolset = agent.getToolset();
80
- if (toolset && args['tools']) {
81
- const addTools = args['tools'].split(',') || [];
82
- if (addTools.includes('javascript')) {
83
- let tool = genTools.get('javascript_interpreter');
84
- if (tool) {
85
- tools.push('javascript_interpreter');
86
- toolset.add('javascript_interpreter', tool.description, tool.parameters, tool.method);
87
- }
88
- }
89
- if (addTools.includes('bash')) {
90
- let tool = genTools.get('execute_bash_script');
91
- if (tool) {
92
- tools.push('execute_bash_script');
93
- toolset.add('execute_bash_script', tool.description, tool.parameters, tool.method);
94
- }
95
- }
96
- }
97
-
98
- const cliIntro = `
99
- ${name} ${options.model}.
100
- - search ${options.search_parameters.mode}
101
- `.trim();
102
-
103
- const description = `
104
- Generic helper and smart AI for difficult tasks. Natural language, math and reasoning - the perfect jack of all trades
105
- `.trim();
106
-
107
- if (input === '' && serve) {
108
- agent.enableServer(name, description, serve);
109
- }
110
- if (input !== '') {
111
- // Direct input output
112
- const res = await agent.directCall(input);
113
- console.log(res);
114
- } else if(connect) {
115
- agent.attach(name, description, connect)
116
- } else if(!serve) {
117
- // Mix a cli with a server is a thing we need to test
118
- agent.startCli(cliIntro);
119
- }
@@ -1,114 +0,0 @@
1
- #!/usr/bin/env node
2
- import { fileURLToPath } from 'url';
3
- import path from 'path';
4
- import AgentManager from '../lib/AgentManager.js';
5
- import { parseArgs, readIn } from '@j-o-r/sh';
6
- import genTools from '../lib/genericToolset.js';
7
- import { systemInfo } from '../lib/fafs.js';
8
-
9
- const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
10
- const api = 'grok';
11
-
12
- const input = await readIn();
13
- const args = parseArgs();
14
- const help = args['help'] || false;
15
- const connect = args['connect'] ? args['connect'] : undefined;
16
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
17
-
18
- /** @type {import('lib/API/x.ai/text.js').XOptions} */
19
- const options = {}
20
- // Set properties only if provided via command line (except model which has default)
21
- if (args['model'] || true) { // model gets default value
22
- // @ts-ignore
23
- options.model = args['model'] || 'grok-code-fast-1';
24
- }
25
- if (args['temperature']) {
26
- options.temperature = parseFloat(args['temperature']);
27
- }
28
- if (args['tokens']) {
29
- options.max_completion_tokens = parseInt(args['tokens']);
30
- }
31
- if (args['top_p']) {
32
- options.top_p = parseFloat(args['top_p']);
33
- }
34
- options.search_parameters = { mode: 'auto' }
35
- const reasoning = args['reasoning'] ? args['reasoning'] : null;
36
- if (reasoning) {
37
- // @ts-ignore
38
- options.reasoning_effort = reasoning
39
- }
40
-
41
- const toolsetMode = 'auto';
42
- const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
43
-
44
- // Copy from the generic toolset
45
- function printHelp() {
46
- console.log(`
47
- '${name} --help' You are looking at it.
48
- '
49
- OPTIONS:
50
- --tokens [number]: max generated tokens
51
- --context [number] : truncate message history to context-windows size default 130000
52
- --temperature [float] : -2 / +2
53
- --model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast|grok-code-fast-1]
54
- --top_p [float]: number > 0, 0.1 means no top_p
55
- --reasoning [low|high]
56
- --tools [javascript,bash] comma seperated list
57
- e.g.
58
- grok.js --model grok-3-mini --tokens 4000 --context 10000
59
-
60
- `);
61
- process.exit()
62
- }
63
-
64
- if (help) {
65
- printHelp();
66
- }
67
-
68
- const sys = await systemInfo();
69
- const prompt = `
70
- 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 safe Bash execution. For writing and reading files, stay in the current working folder. Provide clear, step-by-step responses, examples, and ensure safety compliance.
71
- Update your 'memory' frequently.
72
- ---env
73
- ${sys}
74
- ---
75
- `.trim();
76
- const agent = new AgentManager({ name });
77
- agent.setup({
78
- prompt,
79
- api,
80
- options,
81
- toolsetMode,
82
- contextWindow
83
- });
84
- const toolset = agent.getToolset();
85
- if (toolset) {
86
- const addTools = (args['tools']) ? args['tools'].split(',') : ['bash'];
87
- if (addTools.includes('javascript')) {
88
- agent.addGenericToolcall('javascript_interpreter');
89
- }
90
- if (addTools.includes('bash')) {
91
- agent.addGenericToolcall('execute_bash_script');
92
- }
93
- }
94
- const cliIntro = `
95
- ${name} ${options.model}.
96
- - search ${options.search_parameters.mode}
97
- - context: ${contextWindow}
98
- `.trim();
99
- const description = `
100
- Gateway to a specialized coding assistant for Bash, JavaScript (ESM/ESNext), and other languages. Handles execution, reading, creation, querying, explaining, and code help, with safety and folder restrictions.
101
- `.trim();
102
-
103
- if (input === '' && serve) {
104
- agent.enableServer('code', description, serve);
105
- }
106
- if (input !== '') {
107
- // Direct input output
108
- const res = await agent.directCall(input);
109
- console.log(res);
110
- } else if (connect) {
111
- agent.attach('code', description, connect)
112
- } else {
113
- agent.startCli(cliIntro);
114
- }
@@ -1,111 +0,0 @@
1
- #!/usr/bin/env node
2
- import { fileURLToPath } from 'url';
3
- import path from 'path';
4
- import AgentManager from '../lib/AgentManager.js';
5
- import { systemInfo } from '../lib/fafs.js';
6
- import { parseArgs, readIn } from '@j-o-r/sh';
7
- import toolsPool from '../lib/genericToolset.js';
8
-
9
- const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
10
- const api = 'grok'; // Using GPT API for general AI assistance, adjust if needed
11
-
12
- const input = await readIn();
13
- const args = parseArgs();
14
- const help = args['help'] || false;
15
- const connect = args['connect'] ? args['connect'] : undefined;
16
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
17
-
18
- /** @type {import('../lib/API/x.ai/text.js').XOptions} */ // Assuming GPT uses OpenAI API
19
- const options = {}
20
- // Set properties only if provided via command line
21
- if (args['model'] || true) {
22
- // @ts-ignore
23
- options.model = args['model'] || 'grok-4';
24
- }
25
- if (args['temperature']) {
26
- options.temperature = parseFloat(args['temperature']);
27
- }
28
- if (args['tokens']) {
29
- options.max_completion_tokens = parseInt(args['tokens']);
30
- }
31
- if (args['top_p']) {
32
- options.top_p = parseFloat(args['top_p']);
33
- }
34
-
35
- options.search_parameters = {mode:'auto'}
36
-
37
- const reasoning = args['reasoning'] ? args['reasoning'] : null;
38
- if (reasoning) {
39
- // @ts-ignore
40
- options.reasoning_effort = reasoning
41
- }
42
-
43
- const toolsetMode = 'auto';
44
- const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
45
-
46
- // Copy from the generic toolset
47
- function printHelp() {
48
- console.log(`
49
- '${name} --help' You are looking at it.
50
-
51
- OPTIONS:
52
- --tokens [number]: max generated tokens
53
- --context [number] : truncate message history to context-windows size default 250000
54
- --temperature [float] : -2 / +2
55
- --model [gpt-4o|gpt-4o-mini|etc] // Adjust based on available models
56
- --top_p [float]: number > 0, 0.1 means no top_p
57
- --reasoning [low|high]
58
- --tools [javascript,bash] comma separated list
59
- e.g.
60
- note_keeping.js --model gpt-4o-mini --tokens 4000 --context 10000
61
-
62
- `);
63
- process.exit()
64
- }
65
-
66
- if (help) {
67
- printHelp();
68
- }
69
- const sys = await systemInfo();
70
- const prompt = `
71
- You are an AI note-keeping assistant for Markdown notes in extended context. Use/create 'notes' folder in cwd. Search via tools like grep. Create/update/delete .md files safely. Goals: track progress, manage todos, capture requirements, document processes, store links/bookmarks/remarks. Respond concisely, step-by-step, no unnecessary follow-ups.
72
- ---env
73
- ${sys}
74
- ---
75
- `.trim();
76
- const agent = new AgentManager({ name });
77
- agent.setup({
78
- prompt,
79
- api,
80
- options,
81
- toolsetMode,
82
- contextWindow
83
- });
84
- const toolset = agent.getToolset();
85
-
86
- if (toolset) {
87
- let tool = toolsPool.get('execute_bash_script');
88
- if (tool) {
89
- toolset.add('execute_bash_script', tool.description, tool.parameters, tool.method);
90
- }
91
- }
92
- const cliIntro = `
93
- ${options.model}.
94
- - search ${options.search_parameters.mode}
95
- `.trim();
96
- const description = `
97
- AI-assisted note-keeping tool for managing Markdown notes, including search, creation, updates, and deletion. Supports progress tracking, todos, requirements, docs, links, bookmarks, and remarks.
98
- `.trim();
99
-
100
- if (input === '' && serve) {
101
- agent.enableServer('memory', description, serve);
102
- }
103
- if (input !== '') {
104
- // Direct input output
105
- const res = await agent.directCall(input);
106
- console.log(res);
107
- } else if(connect) {
108
- agent.attach('memory', description, connect)
109
- } else {
110
- agent.startCli(cliIntro);
111
- }
package/module.md DELETED
@@ -1,189 +0,0 @@
1
- # @j-o-r/hello-dave Module Documentation
2
-
3
- ## Overview
4
- **Name:** @j-o-r/hello-dave
5
- **Version:** 0.0.0
6
- **Description:** API to various endpoints mainly focused on AI
7
-
8
- This is a small, ESM-only Node.js toolkit for building AI "agents" with:
9
- - One unified Prompt abstraction across multiple LLM providers (x.ai Grok, OpenAI, Anthropic)
10
- - First-class function calling via a simple ToolSet
11
- - A tiny AgentManager that wires everything together (CLI, direct calls, WS server/client)
12
- - Optional persisted sessions and records on disk
13
-
14
- Key features include:
15
- - Support for multiple AI providers: x.ai (Grok), OpenAI, Anthropic
16
- - ToolSet for function calling with JSON schema
17
- - AgentManager for easy integration
18
- - CLI tools for interactive use
19
- - WebSocket-based agent servers and clients for distributed setups
20
- - Session persistence under ./.cache/hello-dave/<agent-name>/
21
- - Built-in tools like JavaScript interpreter and bash execution
22
-
23
- Note: This is a personal project, created for convenience and exclusively used and tested on Debian/Ubuntu. It can be used to create, use and combine Agents. It has great potential and is very powerful; e.g., `hdCode` has full access to the user environment and is able to execute any command or code. Prompt injection is a risk so use with care.
24
-
25
- ## Installation Notes
26
- The module is already installed in the current working directory. For manual installation in your project:
27
- ```bash
28
- npm install @j-o-r/hello-dave
29
- ```
30
-
31
- Requirements:
32
- - Node.js >= 20 (ESM only)
33
- - API keys via environment variables (set only what you use):
34
- - XAIKEY for x.ai (Grok)
35
- - OPENAIKEY for OpenAI
36
- - ANTHKEY for Anthropic
37
- - BRAVESEARCHKEY for Brave Search tool (optional)
38
-
39
- After installation, use either the programmatic API (AgentManager) or the provided CLIs.
40
-
41
- For development from repo:
42
- - npm install
43
- - export keys
44
- - node examples/grok.js # or add ./bin to PATH
45
-
46
- ## API Usage Examples
47
-
48
- ### Minimal Direct Call
49
- ```js
50
- import AgentManager from '@j-o-r/hello-dave';
51
-
52
- const agent = new AgentManager({ name: 'grok' });
53
- agent.setup({
54
- prompt: 'Be precise and concise.',
55
- api: 'grok',
56
- options: {
57
- model: 'grok-4',
58
- search_parameters: { mode: 'auto' }
59
- },
60
- toolsetMode: 'auto',
61
- contextWindow: 250_000
62
- });
63
-
64
- const answer = await agent.directCall('Two bullet points on tail recursion.');
65
- console.log(answer);
66
- ```
67
-
68
- ### Adding Custom Tools
69
- ```js
70
- const toolset = agent.getToolset();
71
- if (toolset) {
72
- toolset.add(
73
- 'say_hello',
74
- 'Return a friendly greeting',
75
- {
76
- type: 'object',
77
- properties: { name: { type: 'string', description: 'Who to greet' } },
78
- required: ['name']
79
- },
80
- async ({ name }) => `Hello, ${name}!`
81
- );
82
- }
83
- ```
84
-
85
- ### Running as Tool Server
86
- ```js
87
- agent.enableServer('search', 'General-purpose search interface', 8000);
88
- // WS on ws://127.0.0.1:8000/ws; connected clients become callable tools.
89
- ```
90
-
91
- ### Attaching as WS Client
92
- ```js
93
- agent.attach(
94
- 'code',
95
- 'Run JavaScript snippets safely and return output',
96
- 'ws://127.0.0.1:8000/ws'
97
- );
98
- ```
99
-
100
- ### CLI Example (from examples/grok.js)
101
- - Interactive: node examples/grok.js
102
- - One-shot: echo "question" | node examples/grok.js
103
- - With tools: node examples/grok.js --tools javascript,bash
104
- - Server: node examples/grok.js --serve 8000 --tools javascript,bash
105
- - Client: node examples/grok.js --connect ws://127.0.0.1:8000/ws
106
-
107
- ### Utils
108
- ```bash
109
- npx hdClear # Clear sessions and logs
110
- npx hdInspect [file.ndjson] # Read ndjson files
111
- npx hdPrompt # Design prompts (needs x.ai key)
112
- npx hdAsk # Ask generic question to GPT (needs OpenAI key)
113
- npx hdConnect [ws://url] # Connect to WS agent server
114
- ```
115
-
116
- ## Full API Reference
117
-
118
- ### AgentManager (main entry point)
119
- From types/AgentManager.d.ts
120
-
121
- **Constructor:**
122
- - `new AgentManager(options: Options)`: Create agent with name and optional cachePath.
123
-
124
- **Methods:**
125
- - `setup(setup: Setup): this`: Configure prompt, api, options, etc.
126
- - `startCli(description: string): void`: Start CLI for local usage.
127
- - `attach(name: string, description: string, url?: string): AgentClient`: Attach to WS server as client.
128
- - `enableServer(name: string, description?: string, port?: number): void`: Start WS server on localhost.
129
- - `directCall(input: string): Promise<string>`: Direct call to the prompt.
130
- - `getPrompt(): Prompt`: Get the Prompt instance.
131
- - `getToolset(): ToolSet | void`: Get the ToolSet if enabled.
132
- - `environment(): Promise<EnvironmentInfo>`: Get environment info.
133
- - `addGenericToolcall(name: string): void`: Add a generic tool call.
134
-
135
- **Types:**
136
- - `Options`: { name: string, cachePath?: string }
137
- - `Setup`: { prompt: string, options: OAOptions | XOptions | ANTHOptions, api: 'gpt' | 'grok' | 'claude', contextWindow?: number, toolsetMode?: 'auto' | 'required' | void, debug?: boolean }
138
-
139
- ### ToolSet
140
- From types/ToolSet.d.ts
141
-
142
- **Constructor:**
143
- - `new ToolSet(choice?: string)`: 'auto' | 'none' | 'required'
144
-
145
- **Properties:**
146
- - `length: number`: Number of registered functions.
147
- - `toolChoice: string`
148
-
149
- **Methods:**
150
- - `add(name: string, description: string, parameters: TSSchema, method: (arg0: object) => Promise<any>): void`: Register a tool.
151
- - `get(name: string): TSTool`: Get a tool.
152
- - `delete(name: string): void`: Remove a tool.
153
- - `has(name: string): boolean`: Check if tool exists.
154
- - `list(): TSToolListItem[]`: List all tools.
155
- - `call(name: string, params: object): Promise<any>`: Execute a tool.
156
- - `execute(prompt: Prompt): Promise<void>`: Execute tool calls from prompt.
157
-
158
- **Types:**
159
- - `TSSchema`: { type: string, properties: object, required?: string[] }
160
- - `TSTool`: { description: string, parameters: TSSchema, method: (arg0: object) => Promise<any> }
161
- - `TSToolListItem`: { name: string, description: string, parameters: TSSchema }
162
-
163
- ### Prompt
164
- From types/Prompt.d.ts (partial, large file)
165
-
166
- Handles uniform message format, function-call plumbing, truncation, provider-neutral calls.
167
-
168
- ### Other Classes
169
- - `AgentClient`: WS client for processing requests.
170
- - `AgentServer`: WS server that turns clients into ToolSet functions.
171
- - `Cli`: TUI with history, shortcuts (uses @j-o-r/cli internally).
172
- - `Session`: On-disk persistence for sessions, logs, records.
173
-
174
- ### API Adaptors
175
- - API/x.ai: For Grok
176
- - API/openai.com: For GPT
177
- - API/anthropic.com: For Claude
178
- - API/brave.com: For search tool
179
-
180
- ## Dependencies
181
- - **@j-o-r/apiserver**: ^2.1.5 - For HTTP/WS server functionality (see its module.md for details).
182
- - **@j-o-r/cli**: * - For CLI interface (interactive TUI with modes, questions, shortcuts).
183
- - **gpt-3-encoder**: * - For token encoding.
184
-
185
- Relevant dependency info:
186
- - @j-o-r/cli: Interactive CLI framework with mode-based output, command parsing, key mappings, spinners. Used for the built-in CLI tools.
187
- - @j-o-r/apiserver: Lightweight HTTP/WS server for API controllers, streaming, file serving. Used for WS agent servers.
188
-
189
- All dependencies are scoped under @j-o-r, personal modules.