@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.
- package/CHANGELOG.md +21 -0
- package/README.md +445 -160
- package/README.md.backup +269 -0
- package/README.md.bak +481 -0
- package/README.md.bak.1774780058 +338 -0
- package/README.md.bak2 +455 -0
- package/bin/dave.js +165 -0
- package/docs.bak.1774780058/agent-manager.md +167 -0
- package/docs.bak.1774780058/agent-manager.md.bak +137 -0
- package/docs.bak.1774780058/agent-manager.md.bak2 +157 -0
- package/docs.bak.1774780058/codeserver-pattern.md +191 -0
- package/docs.bak.1774780058/path-resolution-best-practices.md +104 -0
- package/docs.bak.1774780058/project-overview.md +67 -0
- package/docs.bak.1774780058/project-overview.md.bak +67 -0
- package/docs.bak.1774780058/prompt-class.md +141 -0
- package/docs.bak.1774780058/prompt-class.md.bak +142 -0
- package/docs.bak.1774780058/tools-syntax-validation.md +121 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +125 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +125 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +106 -0
- package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +106 -0
- package/docs.bak.1774780058/toolset.md +164 -0
- package/docs.bak.1774780058/toolset.md.bak +94 -0
- package/docs.bak.1774780058/toolset.md.bak3 +161 -0
- package/docs.bak.1774780058/toolset.md.bak4 +161 -0
- package/docs.bak.1774780058/toolset.md.bak5 +161 -0
- package/docs.bak.1774780058/toolset.md.bak6 +163 -0
- package/docs.bak.1774780058/toolset.md.bak_path +163 -0
- package/docs.bak.1774780058/toolset.md.bak_syntax +161 -0
- package/docs.bak.1774780058/xai-responses.md +111 -0
- package/docs.bak.1774780058/xai-responses.md.bak +107 -0
- package/docs.bak.1774780058/xai-responses.md.bak2 +107 -0
- package/docs.bak.1774780058/xai_collections.md +106 -0
- package/examples/ask_agent.js +137 -0
- package/examples/code_agent.js +149 -0
- package/examples/coderev_agent.js +136 -0
- package/examples/codeserver.sh +47 -0
- package/examples/daisy_agent.js +170 -0
- package/examples/docs_agent.js +148 -0
- package/examples/gpt_agent.js +125 -0
- package/examples/grok_agent.js +132 -0
- package/examples/grok_agent.js.bak +98 -0
- package/examples/grok_agent.js.bak.2 +99 -0
- package/examples/grok_agent.js.bak.3 +1 -0
- package/examples/grok_agent.js.bak.4 +124 -0
- package/examples/grok_agent.js.bak.5 +1 -0
- package/examples/grok_agent.js.bak.6 +1 -0
- package/examples/memory_agent.js +152 -0
- package/examples/npm_agent.js +202 -0
- package/examples/npm_agent.js.bak.3 +2 -0
- package/examples/npm_agent.js.bak.4 +205 -0
- package/examples/npm_agent.js.bak.5 +1 -0
- package/examples/npm_agent.js.bak.6 +1 -0
- package/examples/prompt_agent.js +133 -0
- package/examples/readme_agent.js +148 -0
- package/examples/spawn_agent.js +293 -0
- package/examples/test_agent.js +187 -0
- package/examples/todo_agent.js +175 -0
- package/examples.bak.1774780058/ask_agent.js +114 -0
- package/examples.bak.1774780058/code_agent.js +149 -0
- package/examples.bak.1774780058/coderev_agent.js +72 -0
- package/examples.bak.1774780058/codeserver.sh +47 -0
- package/examples.bak.1774780058/daisy_agent.js +177 -0
- package/examples.bak.1774780058/docs_agent.js +119 -0
- package/{bin/hdAsk.js → examples.bak.1774780058/gpt_agent.js} +46 -40
- package/examples.bak.1774780058/grok_agent.js +98 -0
- package/examples.bak.1774780058/memory_agent.js +112 -0
- package/examples.bak.1774780058/npm_agent.js +175 -0
- package/examples.bak.1774780058/prompt_agent.js +112 -0
- package/examples.bak.1774780058/readme_agent.js +144 -0
- package/examples.bak.1774780058/spawn_agent.js +263 -0
- package/examples.bak.1774780058/test_agent.js +162 -0
- package/examples.bak.1774780058/todo_agent.js +138 -0
- package/lib/API/openai.com/reponses/text.js +12 -18
- package/lib/API/x.ai/collections.js +354 -0
- package/lib/API/x.ai/files.js +218 -0
- package/lib/API/x.ai/responses.js +492 -0
- package/lib/API/x.ai/text.js +1 -1
- package/lib/AgentClient.js +13 -6
- package/lib/AgentManager.js +80 -10
- package/lib/AgentServer.js +50 -22
- package/lib/Cli.js +7 -1
- package/lib/Prompt.js +4 -2
- package/lib/ToolSet.js +2 -1
- package/lib/genericToolset.js +258 -88
- package/lib/genericToolset.js.bak_syntax +402 -0
- package/lib/index.js +4 -2
- package/lib/wsCli.js +256 -0
- package/lib/wsIO.js +96 -0
- package/package.json +26 -21
- package/scenarios.bak.1774780058/data/eval_node_message.json +9 -0
- package/scenarios.bak.1774780058/data/hist_oa.json +66 -0
- package/scenarios.bak.1774780058/data/o3_response1.json +96 -0
- package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +112 -0
- package/scenarios.bak.1774780058/data/tool_oa.json +96 -0
- package/scenarios.bak.1774780058/data/tool_xai.json +59 -0
- package/scenarios.bak.1774780058/data/tool_xai2.json +40 -0
- package/scenarios.bak.1774780058/data/xai-response-1.json +59 -0
- package/scenarios.bak.1774780058/data/xai-response-2.json +10 -0
- package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +59 -0
- package/scenarios.bak.1774780058/data/xai_search_response.json +58 -0
- package/scenarios.bak.1774780058/environment.js +10 -0
- package/scenarios.bak.1774780058/example.js +17 -0
- package/scenarios.bak.1774780058/genericToolset.test.js +182 -0
- package/scenarios.bak.1774780058/grok.js +113 -0
- package/scenarios.bak.1774780058/memory-tools.js +51 -0
- package/scenarios.bak.1774780058/openai-o3.js +137 -0
- package/scenarios.bak.1774780058/openai-prompt.js +155 -0
- package/scenarios.bak.1774780058/openai-session.js +148 -0
- package/scenarios.bak.1774780058/openai.js +102 -0
- package/scenarios.bak.1774780058/prompt.js +118 -0
- package/scenarios.bak.1774780058/promptFishbowl.js +76 -0
- package/scenarios.bak.1774780058/search.brave.com.js +25 -0
- package/scenarios.bak.1774780058/sh.js +15 -0
- package/scenarios.bak.1774780058/test-wsio.js +26 -0
- package/scenarios.bak.1774780058/testToolset.js +42 -0
- package/scenarios.bak.1774780058/toolset.js +16 -0
- package/scenarios.bak.1774780058/toolset.test.js +141 -0
- package/scenarios.bak.1774780058/write_file_syntax.test.js +145 -0
- package/scenarios.bak.1774780058/write_file_validation/README.md +30 -0
- package/scenarios.bak.1774780058/write_file_validation/bad.js +3 -0
- package/scenarios.bak.1774780058/write_file_validation/good.js +4 -0
- package/scenarios.bak.1774780058/write_file_validation/test.sh +43 -0
- package/scenarios.bak.1774780058/wsClient.js +69 -0
- package/scenarios.bak.1774780058/xai_responses.integration.test.js +57 -0
- package/scenarios.bak.1774780058/xai_responses.test.js +154 -0
- package/scenarios.bak.1774780058/xaicoll.js +50 -0
- package/scenarios.bak.1774780058/xaifiles.js +48 -0
- package/types/API/openai.com/reponses/text.d.ts +17 -3
- package/types/API/x.ai/collections.d.ts +167 -0
- package/types/API/x.ai/files.d.ts +84 -0
- package/types/API/x.ai/responses.d.ts +379 -0
- package/types/AgentClient.d.ts +5 -0
- package/types/AgentManager.d.ts +25 -31
- package/types/AgentServer.d.ts +5 -1
- package/types/Prompt.d.ts +4 -2
- package/types/ToolSet.d.ts +1 -0
- package/types/index.d.ts +4 -3
- package/types/wsCli.d.ts +3 -0
- package/types/wsIO.d.ts +26 -0
- package/utils/bars.js +40 -0
- package/utils/clear_sessions.sh +54 -0
- package/{bin/hdInspect.js → utils/format_log.js} +5 -0
- package/utils/list_sessions.sh +46 -0
- package/utils/search_sessions.sh +73 -0
- package/utils/syntax_check.sh +61 -0
- package/utils/test.sh +46 -0
- package/bin/hdClear.js +0 -13
- package/bin/hdCode.js +0 -115
- package/bin/hdConnect.js +0 -230
- package/bin/hdNpm.js +0 -114
- package/bin/hdPrompt.js +0 -108
- package/examples/claude-test.js +0 -89
- package/examples/claude.js +0 -143
- package/examples/gpt.js +0 -127
- package/examples/gpt_code.js +0 -125
- package/examples/gpt_note_keeping.js +0 -117
- package/examples/grok.js +0 -119
- package/examples/grok_code.js +0 -114
- package/examples/grok_note_keeping.js +0 -111
- package/module.md +0 -189
package/bin/hdNpm.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import AgentManager from '../lib/AgentManager.js';
|
|
3
|
-
import { parseArgs, readIn } from '@j-o-r/sh';
|
|
4
|
-
import { systemInfo } from '../lib/fafs.js';
|
|
5
|
-
|
|
6
|
-
const name = 'hdNpm';
|
|
7
|
-
const api = 'grok';
|
|
8
|
-
|
|
9
|
-
const input = await readIn();
|
|
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/text.js').XOptions} */
|
|
16
|
-
const options = {}
|
|
17
|
-
// Set properties only if provided via command line (except model which has default)
|
|
18
|
-
if (args['model'] || true) { // model gets default value
|
|
19
|
-
// @ts-ignore
|
|
20
|
-
options.model = args['model'] || 'grok-code-fast-1';
|
|
21
|
-
}
|
|
22
|
-
if (args['temperature']) {
|
|
23
|
-
options.temperature = parseFloat(args['temperature']);
|
|
24
|
-
}
|
|
25
|
-
if (args['tokens']) {
|
|
26
|
-
options.max_completion_tokens = parseInt(args['tokens']);
|
|
27
|
-
}
|
|
28
|
-
if (args['top_p']) {
|
|
29
|
-
options.top_p = parseFloat(args['top_p']);
|
|
30
|
-
}
|
|
31
|
-
options.search_parameters = { mode: 'auto' }
|
|
32
|
-
const reasoning = args['reasoning'] ? args['reasoning'] : null;
|
|
33
|
-
if (reasoning) {
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
options.reasoning_effort = reasoning
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const toolsetMode = 'auto';
|
|
39
|
-
const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
|
|
40
|
-
|
|
41
|
-
// Copy from the generic toolset
|
|
42
|
-
function printHelp() {
|
|
43
|
-
console.log(`
|
|
44
|
-
'${name} --help' You are looking at it.
|
|
45
|
-
'
|
|
46
|
-
OPTIONS:
|
|
47
|
-
--tokens [number]: max generated tokens
|
|
48
|
-
--context [number] : truncate message history to context-windows size default 130000
|
|
49
|
-
--temperature [float] : -2 / +2
|
|
50
|
-
--model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast|grok-code-fast-1]
|
|
51
|
-
--top_p [float]: number > 0, 0.1 means no top_p
|
|
52
|
-
--reasoning [low|high]
|
|
53
|
-
--tools [javascript,bash] comma seperated list
|
|
54
|
-
e.g.
|
|
55
|
-
grok.js --model grok-3-mini --tokens 4000 --context 10000
|
|
56
|
-
|
|
57
|
-
`);
|
|
58
|
-
process.exit()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (help) {
|
|
62
|
-
printHelp();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const prompt = `
|
|
66
|
-
Assume the module's root directory is the current working directory (cwd) and it's already installed. Inspect:
|
|
67
|
-
- package.json: Extract name, version, description, dependencies, scripts, and entry points.
|
|
68
|
-
- README.md: Summarize installation (noting it's already installed), usage examples, and key features.
|
|
69
|
-
- types/ folder: List and describe TypeScript declaration files (e.g., interfaces, types) to explain the API.
|
|
70
|
-
- node_modules/: Check for any 'module.md' files in installed dependencies and incorporate relevant additional information.
|
|
71
|
-
- Additional files: If API or usage is unclear, inspect relevant files like source code or examples for clarification.
|
|
72
|
-
|
|
73
|
-
Focus on enabling API usage. Generate markdown content with sections: Overview, Installation Notes, API Usage Examples, Full API Reference (from types and inspections), and Dependencies.
|
|
74
|
-
Write the full markdown content to './module.md'.
|
|
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
|
-
NPM module expert, creates api usage for this module.
|
|
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
|
-
}
|
package/bin/hdPrompt.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import AgentManager from '../lib/AgentManager.js';
|
|
3
|
-
import { parseArgs, readIn } from '@j-o-r/sh';
|
|
4
|
-
|
|
5
|
-
// const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
|
|
6
|
-
const name = 'hdPrompt';
|
|
7
|
-
const api = 'grok';
|
|
8
|
-
|
|
9
|
-
const input = await readIn();
|
|
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/text.js').XOptions} */
|
|
16
|
-
const options = {}
|
|
17
|
-
// Set properties only if provided via command line (except model which has default)
|
|
18
|
-
if (args['model'] || true) { // model gets default value
|
|
19
|
-
// @ts-ignore
|
|
20
|
-
options.model = args['model'] || 'grok-4';
|
|
21
|
-
}
|
|
22
|
-
if (args['temperature']) {
|
|
23
|
-
options.temperature = parseFloat(args['temperature']);
|
|
24
|
-
}
|
|
25
|
-
if (args['tokens']) {
|
|
26
|
-
options.max_completion_tokens = parseInt(args['tokens']);
|
|
27
|
-
}
|
|
28
|
-
if (args['top_p']) {
|
|
29
|
-
options.top_p = parseFloat(args['top_p']);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
options.search_parameters = { mode: 'auto' }
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
const reasoning = args['reasoning'] ? args['reasoning'] : null;
|
|
35
|
-
if (reasoning) {
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
options.reasoning_effort = reasoning
|
|
38
|
-
}
|
|
39
|
-
const toolsetMode = (args.tools) ? 'auto' : undefined;
|
|
40
|
-
const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
|
|
41
|
-
|
|
42
|
-
function printHelp() {
|
|
43
|
-
console.log(`
|
|
44
|
-
'${name} --help' You are looking at it.
|
|
45
|
-
'
|
|
46
|
-
OPTIONS:
|
|
47
|
-
--tokens [number]: max generated tokens
|
|
48
|
-
--context [number] : truncate message history to context-windows size default 130000
|
|
49
|
-
--temperature [float] : -2 / +2
|
|
50
|
-
--model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast]
|
|
51
|
-
--top_p [float]: number > 0, 0.1 means no top_p
|
|
52
|
-
--reasoning [low|high]
|
|
53
|
-
--tools [javascript,bash] comma seperated list
|
|
54
|
-
e.g.
|
|
55
|
-
grok.js --model grok-3-mini --tokens 4000 --context 10000
|
|
56
|
-
|
|
57
|
-
`);
|
|
58
|
-
process.exit()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (help) {
|
|
62
|
-
printHelp();
|
|
63
|
-
}
|
|
64
|
-
// reason step by step
|
|
65
|
-
|
|
66
|
-
const prompt = `
|
|
67
|
-
You are a prompt optimizer. Check for: 1) Clarity and specificity. 2) Brevity, non-ambiguity, ethics. 3) Token efficiency. If good, say "Approved." If not, rewrite concisely or ask 1-2 questions. Output: - Summary. - Rewritten prompt (if needed). - Questions (if unclear). Be efficient.
|
|
68
|
-
`.trim();
|
|
69
|
-
const agent = new AgentManager({ name });
|
|
70
|
-
agent.setup({
|
|
71
|
-
prompt,
|
|
72
|
-
api,
|
|
73
|
-
options,
|
|
74
|
-
toolsetMode,
|
|
75
|
-
contextWindow
|
|
76
|
-
});
|
|
77
|
-
const toolset = agent.getToolset();
|
|
78
|
-
if (toolset) {
|
|
79
|
-
const addTools = args['tools'].split(',') || [];
|
|
80
|
-
if (addTools.includes('javascript')) {
|
|
81
|
-
agent.addGenericToolcall('javascript_interpreter')
|
|
82
|
-
}
|
|
83
|
-
if (addTools.includes('bash')) {
|
|
84
|
-
agent.addGenericToolcall('execute_bash_script');
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const cliIntro = `
|
|
89
|
-
${name} ${options.model}.
|
|
90
|
-
search ${options.search_parameters.mode}
|
|
91
|
-
`.trim();
|
|
92
|
-
|
|
93
|
-
const description = `
|
|
94
|
-
Given a specific prompt, inspect and adjust it for better readability and clarity.
|
|
95
|
-
`.trim();
|
|
96
|
-
|
|
97
|
-
if (input === '' && serve) {
|
|
98
|
-
agent.enableServer(name, description, serve);
|
|
99
|
-
}
|
|
100
|
-
if (input !== '') {
|
|
101
|
-
// Direct input output
|
|
102
|
-
const res = await agent.directCall(input);
|
|
103
|
-
console.log(res);
|
|
104
|
-
} else if(connect) {
|
|
105
|
-
agent.attach(name, description, connect)
|
|
106
|
-
} else {
|
|
107
|
-
agent.startCli(cliIntro);
|
|
108
|
-
}
|
package/examples/claude-test.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*
|
|
3
|
-
* Claude test with a simple toolset
|
|
4
|
-
*/
|
|
5
|
-
// -------------------------------
|
|
6
|
-
const PROMPT_NAME = 'claude-test'
|
|
7
|
-
// ------------------------------
|
|
8
|
-
import { Prompt, API, CliWrapper, Session, env } from '../lib/index.js';
|
|
9
|
-
import { parseArgs, SH } from '@j-o-r/sh';
|
|
10
|
-
import toolset from '../lib/testToolset.js';
|
|
11
|
-
|
|
12
|
-
const session = new Session(PROMPT_NAME);
|
|
13
|
-
|
|
14
|
-
const args = parseArgs();
|
|
15
|
-
// Get parameter values
|
|
16
|
-
const max_completion_tokens = args['tokens'] ? parseInt(args['tokens']) : 4000;
|
|
17
|
-
const context_window = args['context'] ? parseInt(args['context']) : 7000;
|
|
18
|
-
const temperature = args['temperature'] ? parseFloat(args['temperature']) : 0.4;
|
|
19
|
-
const model = args['model'] ? args['model'] : 'claude-3-7-sonnet-latest';
|
|
20
|
-
const thinking = args['thinking'] ? parseInt(args['thinking']) : 0;
|
|
21
|
-
const search = args['search'] ? parseInt(args['search']) : 0;
|
|
22
|
-
const help = args['help'] || false;
|
|
23
|
-
|
|
24
|
-
function printHelp() {
|
|
25
|
-
console.log(`
|
|
26
|
-
'${PROMPT_NAME} --help' You are looking at it.
|
|
27
|
-
'
|
|
28
|
-
OPTIONS:
|
|
29
|
-
--tokens [number]: max generated tokens default 4000
|
|
30
|
-
--context [number] : truncate message history to context-windows size default 700
|
|
31
|
-
--temperature [float] : -2 / +2 default 0.4
|
|
32
|
-
--model [grok-3|grok-3-mini|grok-3-mini-fast]
|
|
33
|
-
--thinking [number_of_tokens] default 0
|
|
34
|
-
--search [number_of_search_request] default 0 (no search)
|
|
35
|
-
e.g.
|
|
36
|
-
daisy --model grok-3-mini --tokens 4000 --context 10000
|
|
37
|
-
|
|
38
|
-
`);
|
|
39
|
-
process.exit()
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const userInfo = await env();
|
|
43
|
-
/** @type {import('lib/API/anthropic.com/text.js').SearchOptions} */
|
|
44
|
-
const searchOptions = {
|
|
45
|
-
type: 'web_search_20250305',
|
|
46
|
-
name: 'web_search',
|
|
47
|
-
max_uses: 5,
|
|
48
|
-
user_location: {
|
|
49
|
-
type: 'approximate',
|
|
50
|
-
timezone: userInfo.timezone,
|
|
51
|
-
region: userInfo.region,
|
|
52
|
-
city: userInfo.city,
|
|
53
|
-
country: userInfo.country
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (help) {
|
|
57
|
-
printHelp();
|
|
58
|
-
}
|
|
59
|
-
// reason step by step
|
|
60
|
-
|
|
61
|
-
const PROMPT = `
|
|
62
|
-
You an assistant dedicated to answering questions.
|
|
63
|
-
- Reason step by step.
|
|
64
|
-
- Be very brief.
|
|
65
|
-
`.trim();
|
|
66
|
-
const prompt = new Prompt(context_window);
|
|
67
|
-
prompt.add('system', PROMPT.trim(), true);
|
|
68
|
-
/** @type {import('lib/API/anthropic.com/text.js').ANTHOptions} */
|
|
69
|
-
const options = {
|
|
70
|
-
model,
|
|
71
|
-
temperature: temperature,
|
|
72
|
-
max_tokens: max_completion_tokens
|
|
73
|
-
}
|
|
74
|
-
// Enable reasoning
|
|
75
|
-
if (thinking > 0) {
|
|
76
|
-
options.thinking = {
|
|
77
|
-
type: "enabled",
|
|
78
|
-
budget_tokens: thinking
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (search > 0) {
|
|
82
|
-
searchOptions.max_uses = search;
|
|
83
|
-
options.search = searchOptions
|
|
84
|
-
}
|
|
85
|
-
const intro = `
|
|
86
|
-
Hi, I am ${PROMPT_NAME} ${options.model}, your assistant in this project.
|
|
87
|
-
`;
|
|
88
|
-
const cli = new CliWrapper({ request: API.text[PROMPT_NAME], session, intro, prompt, toolset, options });
|
|
89
|
-
cli.start();
|
package/examples/claude.js
DELETED
|
@@ -1,143 +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 { 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
|
-
}
|
package/examples/gpt.js
DELETED
|
@@ -1,127 +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 = '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
|
-
}
|
package/examples/gpt_code.js
DELETED
|
@@ -1,125 +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 = '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
|
-
}
|