@j-o-r/hello-dave 0.0.0

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 (53) hide show
  1. package/LICENSE +73 -0
  2. package/README.md +207 -0
  3. package/bin/hdAsk.js +103 -0
  4. package/bin/hdClear.js +13 -0
  5. package/bin/hdCode.js +110 -0
  6. package/bin/hdConnect.js +230 -0
  7. package/bin/hdInspect.js +28 -0
  8. package/bin/hdNpm.js +114 -0
  9. package/bin/hdPrompt.js +108 -0
  10. package/examples/claude-test.js +89 -0
  11. package/examples/claude.js +143 -0
  12. package/examples/gpt.js +127 -0
  13. package/examples/gpt_code.js +125 -0
  14. package/examples/gpt_note_keeping.js +117 -0
  15. package/examples/grok.js +119 -0
  16. package/examples/grok_code.js +114 -0
  17. package/examples/grok_note_keeping.js +111 -0
  18. package/lib/API/anthropic.com/text.js +402 -0
  19. package/lib/API/brave.com/search.js +239 -0
  20. package/lib/API/openai.com/README.md +1 -0
  21. package/lib/API/openai.com/reponses/MESSAGES.md +69 -0
  22. package/lib/API/openai.com/reponses/text.js +416 -0
  23. package/lib/API/x.ai/text.js +415 -0
  24. package/lib/AgentClient.js +197 -0
  25. package/lib/AgentManager.js +144 -0
  26. package/lib/AgentServer.js +336 -0
  27. package/lib/Cli.js +256 -0
  28. package/lib/Prompt.js +728 -0
  29. package/lib/Session.js +231 -0
  30. package/lib/ToolSet.js +186 -0
  31. package/lib/fafs.js +93 -0
  32. package/lib/genericToolset.js +170 -0
  33. package/lib/index.js +34 -0
  34. package/lib/promptHelpers.js +132 -0
  35. package/lib/testToolset.js +42 -0
  36. package/module.md +189 -0
  37. package/package.json +49 -0
  38. package/types/API/anthropic.com/text.d.ts +207 -0
  39. package/types/API/brave.com/search.d.ts +156 -0
  40. package/types/API/openai.com/reponses/text.d.ts +225 -0
  41. package/types/API/x.ai/text.d.ts +286 -0
  42. package/types/AgentClient.d.ts +70 -0
  43. package/types/AgentManager.d.ts +112 -0
  44. package/types/AgentServer.d.ts +38 -0
  45. package/types/Cli.d.ts +52 -0
  46. package/types/Prompt.d.ts +298 -0
  47. package/types/Session.d.ts +31 -0
  48. package/types/ToolSet.d.ts +95 -0
  49. package/types/fafs.d.ts +47 -0
  50. package/types/genericToolset.d.ts +3 -0
  51. package/types/index.d.ts +23 -0
  52. package/types/promptHelpers.d.ts +1 -0
  53. package/types/testToolset.d.ts +3 -0
@@ -0,0 +1,143 @@
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 { env } from '../lib/index.js';
8
+
9
+ const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
10
+ const api = 'claude';
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/anthropic.com/text.js').ANTHOptions} */
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'] || 'claude-sonnet-4-0';
24
+ }
25
+ if (args['temperature']) {
26
+ options.temperature = parseFloat(args['temperature']);
27
+ }
28
+ if (args['tokens']) {
29
+ options.max_tokens = parseInt(args['tokens']);
30
+ }
31
+ if (args['top_p']) {
32
+ options.top_p = parseFloat(args['top_p']);
33
+ }
34
+ if (args['top_k']) {
35
+ options.top_k = parseInt(args['top_k']);
36
+ }
37
+
38
+ const thinking = args['thinking'] ? parseInt(args['thinking']) : 0;
39
+ if (thinking > 0) {
40
+ options.thinking = {
41
+ type: "enabled",
42
+ budget_tokens: thinking
43
+ }
44
+ }
45
+ const search = args['search'] ? parseInt(args['search']) : 7;
46
+ if (search > 0) {
47
+ const userInfo = await env();
48
+ options.search = {
49
+ type: 'web_search_20250305',
50
+ name: 'web_search',
51
+ max_uses: search,
52
+ user_location: {
53
+ type: 'approximate',
54
+ timezone: userInfo.timezone,
55
+ region: userInfo.region,
56
+ city: userInfo.city,
57
+ country: userInfo.country
58
+ }
59
+ }
60
+ }
61
+ const toolsetMode = (args.tools || serve) ? 'auto' : undefined;
62
+ const contextWindow = args['context'] ? parseInt(args['context']) : 190000;
63
+
64
+ function printHelp() {
65
+ console.log(`
66
+ '${name} --help' You are looking at it.
67
+ '
68
+ OPTIONS:
69
+ --tokens [number]: max generated tokens
70
+ --context [number] : truncate message history to context-windows size default 190000
71
+ --temperature [float] : -2 / +2
72
+ --model [claude-sonnet-4-0|other models]
73
+ --top_p [float]: number > 0, 0.1 means no top_p
74
+ --top_k [number]: number > 0 and < 2048
75
+ --thinking [number]: thinking tokens (default: 0)
76
+ --search [number]: number of search requests (default: 7)
77
+ --tools [javascript,bash] comma seperated list
78
+ --connect [address]: connect to server
79
+ --serve [port]: start server on port
80
+ e.g.
81
+ claude.js --model claude-sonnet-4-0 --tokens 4000 --context 10000 --thinking 2000
82
+
83
+ `);
84
+ process.exit()
85
+ }
86
+
87
+ if (help) {
88
+ printHelp();
89
+ }
90
+ const prompt = `
91
+ 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.
92
+ `.trim();
93
+
94
+ const agent = new AgentManager({ name });
95
+ agent.setup({
96
+ prompt,
97
+ api,
98
+ options,
99
+ toolsetMode,
100
+ contextWindow
101
+ });
102
+ const tools = [];
103
+ const toolset = agent.getToolset();
104
+ if (toolset && args['tools']) {
105
+ const addTools = args['tools'].split(',') || [];
106
+ if (addTools.includes('javascript')) {
107
+ let tool = genTools.get('javascript_interpreter');
108
+ if (tool) {
109
+ tools.push('javascript_interpreter');
110
+ toolset.add('javascript_interpreter', tool.description, tool.parameters, tool.method);
111
+ }
112
+ }
113
+ if (addTools.includes('bash')) {
114
+ let tool = genTools.get('execute_bash_script');
115
+ if (tool) {
116
+ tools.push('execute_bash_script');
117
+ toolset.add('execute_bash_script', tool.description, tool.parameters, tool.method);
118
+ }
119
+ }
120
+ }
121
+
122
+ const cliIntro = `
123
+ ${name} ${options.model}.
124
+ - search ${options.search ? options.search.max_uses : 'disabled'}
125
+ `.trim();
126
+
127
+ const description = `
128
+ Generic helper and smart AI for difficult tasks. Natural language, math and reasoning - the perfect jack of all trades
129
+ `.trim();
130
+
131
+ if (input === '' && serve) {
132
+ agent.enableServer(name, description, serve);
133
+ }
134
+ if (input !== '') {
135
+ // Direct input output
136
+ const res = await agent.directCall(input);
137
+ console.log(res);
138
+ } else if(connect) {
139
+ agent.attach(name, description, connect)
140
+ } else if(!serve) {
141
+ // Mix a cli with a server is a thing we need to test
142
+ agent.startCli(cliIntro);
143
+ }
@@ -0,0 +1,127 @@
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 = 'gpt';
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
+ /**
18
+ * @type {import('lib/API/openai.com/reponses/text.js').OAOptions}
19
+ */
20
+ const options = {}
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'] || 'gpt-5';
25
+ }
26
+ // temperature is NOT available for o3 / 03-mini
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
+ if (args['search'] || true) {
37
+ // always enable search
38
+ // @ts-ignore
39
+ // options.search = args['search'] || 'medium';
40
+ }
41
+
42
+ const reasoning = args['reasoning'] ? args['reasoning'] : null;
43
+
44
+ if (reasoning) {
45
+ // @ts-ignore
46
+ options.reasoning= {effort: reasoning, summary: 'auto'}
47
+ }
48
+
49
+ const toolsetMode = (args.tools || serve) ? 'auto' : undefined;
50
+ const contextWindow = args['context'] ? parseInt(args['context']) : 399000;
51
+
52
+ function printHelp () {
53
+ console.log(`
54
+ '${name} --help' You are looking at it.
55
+ '
56
+ OPTIONS:
57
+ --tokens [number]: max generated tokens
58
+ --context [number] : truncate message history to context-windows size default
59
+ --temperature [float] : default 0.4
60
+ --model [gpt-5|gpt-5-mini|gpt-5-nano|gpt-4.1|o3|o3-mini|o4-mini|o1|o3-pro]
61
+ --search [low|medium|high]
62
+ --reasoning [low|medium|high]
63
+ --tools [javascript,bash] comma seperated list
64
+ e.g.
65
+ gpt --model o3-mini --tokens 4000 --context 10000
66
+
67
+ `);
68
+ process.exit()
69
+ }
70
+
71
+ if (help) {
72
+ printHelp();
73
+ }
74
+
75
+ const prompt = `
76
+ 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.
77
+ `.trim();
78
+
79
+ const agent = new AgentManager({ name });
80
+ agent.setup({
81
+ prompt,
82
+ api,
83
+ options,
84
+ toolsetMode,
85
+ contextWindow
86
+ });
87
+ const tools = [];
88
+ const toolset = agent.getToolset();
89
+ if (args['tools']) {
90
+ const addTools = args['tools'].split(',') || [];
91
+ if (addTools.includes('javascript')) {
92
+ let tool = genTools.get('javascript_interpreter');
93
+ if (tool) {
94
+ tools.push('javascript_interpreter');
95
+ toolset.add('javascript_interpreter', tool.description, tool.parameters, tool.method);
96
+ }
97
+ }
98
+ if (addTools.includes('bash')) {
99
+ let tool = genTools.get('execute_bash_script');
100
+ if (tool) {
101
+ tools.push('execute_bash_script');
102
+ toolset.add('execute_bash_script', tool.description, tool.parameters, tool.method);
103
+ }
104
+ }
105
+ }
106
+
107
+ const cliIntro = `
108
+ ${name} ${options.model}.
109
+ - context: ${contextWindow}
110
+ `.trim();
111
+
112
+ const description = `
113
+ Generic helper and smart AI for difficult tasks. Natural language, math and reasoning - the perfect jack of all trades
114
+ `.trim();
115
+
116
+ if (input === '' && serve) {
117
+ agent.enableServer(name, description, serve);
118
+ }
119
+ if (input !== '') {
120
+ // Direct input output
121
+ const res = await agent.directCall(input);
122
+ console.log(res);
123
+ } else if(connect) {
124
+ agent.attach(name, description, connect)
125
+ } else {
126
+ agent.startCli(cliIntro);
127
+ }
@@ -0,0 +1,125 @@
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 = 'gpt';
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';
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
+ if (args['search'] || true) {
38
+ // always enable search
39
+ // @ts-ignore
40
+ options.search = args['search'] || 'medium';
41
+ }
42
+ const reasoning = args['reasoning'] ? args['reasoning'] : null;
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
+ --search [low|medium|high]
61
+ --reasoning [low|medium|high]
62
+ --tools [javascript,bash] comma seperated list
63
+ e.g.
64
+ gpt --model o3-mini --tokens 4000 --context 10000
65
+
66
+ `);
67
+ process.exit()
68
+ }
69
+
70
+ if (help) {
71
+ printHelp();
72
+ }
73
+
74
+ const sys = await systemInfo();
75
+ const prompt = `
76
+ 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.
77
+ ---env
78
+ ${sys}
79
+ ---
80
+ `.trim();
81
+
82
+ const agent = new AgentManager({ name });
83
+ agent.setup({
84
+ prompt,
85
+ api,
86
+ options,
87
+ toolsetMode,
88
+ contextWindow
89
+ });
90
+
91
+ const toolset = agent.getToolset();
92
+ if (toolset) {
93
+ const addTools = (args['tools']) ? args['tools'].split(',') : [];
94
+ if (addTools.includes('javascript')) {
95
+ let tool = genTools.get('javascript_interpreter');
96
+ if (tool) {
97
+ toolset.add('javascript_interpreter', tool.description, tool.parameters, tool.method);
98
+ }
99
+ }
100
+ let tool = genTools.get('execute_bash_script');
101
+ if (tool) {
102
+ toolset.add('execute_bash_script', tool.description, tool.parameters, tool.method);
103
+ }
104
+ }
105
+ const cliIntro = `
106
+ ${name} ${options.model}.
107
+ - search ${options.search}
108
+ - context: ${contextWindow}
109
+ `.trim();
110
+
111
+ const description = `
112
+ Gateway coding assistant Agent for Bash, JavaScript (ESM/ESNext), and other languages. Handles execution, reading, creation, querying, explaining, and code help, with safety and folder restrictions.
113
+ `.trim();
114
+ if (input === '' && serve) {
115
+ agent.enableServer('code', description, serve);
116
+ }
117
+ if (input !== '') {
118
+ // Direct input output
119
+ const res = await agent.directCall(input);
120
+ console.log(res);
121
+ } else if(connect) {
122
+ agent.attach('code', description, connect)
123
+ } else {
124
+ agent.startCli(cliIntro);
125
+ }
@@ -0,0 +1,117 @@
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
+ }
@@ -0,0 +1,119 @@
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
+ }