@j-o-r/hello-dave 0.0.3 → 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 +216 -56
- package/README.md.bak +481 -0
- package/README.md.bak.1774780058 +338 -0
- package/README.md.bak2 +455 -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/codeDave.js → examples.bak.1774780058/code_agent.js} +40 -6
- package/{examples/CodeServer → examples.bak.1774780058/codeserver.sh} +9 -5
- package/examples.bak.1774780058/memory_agent.js +112 -0
- package/{examples/spawndave.js → examples.bak.1774780058/spawn_agent.js} +29 -6
- package/examples.bak.1774780058/test_agent.js +162 -0
- package/{examples/todoDave.js → examples.bak.1774780058/todo_agent.js} +8 -2
- package/lib/API/x.ai/responses.js +7 -9
- package/lib/AgentManager.js +3 -2
- package/lib/AgentServer.js +23 -19
- package/lib/genericToolset.js +159 -26
- package/lib/genericToolset.js.bak_syntax +402 -0
- package/lib/wsCli.js +0 -1
- package/package.json +4 -5
- 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/AgentManager.d.ts +4 -3
- package/utils/syntax_check.sh +61 -0
- package/utils/test.sh +46 -0
- /package/{examples/askDave.js → examples.bak.1774780058/ask_agent.js} +0 -0
- /package/{examples/coderev.js → examples.bak.1774780058/coderev_agent.js} +0 -0
- /package/{examples/daisy.js → examples.bak.1774780058/daisy_agent.js} +0 -0
- /package/{examples/docsDave.js → examples.bak.1774780058/docs_agent.js} +0 -0
- /package/{examples/gpt.js → examples.bak.1774780058/gpt_agent.js} +0 -0
- /package/{examples/grok.js → examples.bak.1774780058/grok_agent.js} +0 -0
- /package/{examples/npmDave.js → examples.bak.1774780058/npm_agent.js} +0 -0
- /package/{examples/promptDave.js → examples.bak.1774780058/prompt_agent.js} +0 -0
- /package/{examples/readmeDave.js → examples.bak.1774780058/readme_agent.js} +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Test, assert, SH } from '@j-o-r/sh'
|
|
3
|
+
import collections from '../lib/API/x.ai/collections.js';
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import Prompt from '../lib/Prompt.js';
|
|
8
|
+
import tools from './testToolset.js';
|
|
9
|
+
|
|
10
|
+
function LOG(me) {
|
|
11
|
+
console.log(JSON.stringify(me, null, ' '));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const test = new Test();
|
|
15
|
+
|
|
16
|
+
test.add('List collections, start in a clean state', async () => {
|
|
17
|
+
const list = await collections.list();
|
|
18
|
+
let i = 0;
|
|
19
|
+
const len = list.length;
|
|
20
|
+
for (; i < len; i++) {
|
|
21
|
+
const col = list[i];
|
|
22
|
+
if (col.collection_name === 'test_col' || col.collection_name === 'test_col2') {
|
|
23
|
+
const check = await collections.get(col.collection_id);
|
|
24
|
+
assert.equal(check.collection_id, col.collection_id);
|
|
25
|
+
// Delete all test collections
|
|
26
|
+
await collections.del(check.collection_id);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test.add('Add, update, delete a collection', async () => {
|
|
32
|
+
const coll_id = await collections.create('test_col');
|
|
33
|
+
let coll = await collections.get(coll_id);
|
|
34
|
+
assert.strictEqual(coll_id, coll.collection_id);
|
|
35
|
+
await collections.update(coll_id, 'test_col2');
|
|
36
|
+
coll = await collections.get(coll_id);
|
|
37
|
+
assert.strictEqual(coll.collection_name, 'test_col2');
|
|
38
|
+
await collections.del(coll_id);
|
|
39
|
+
// DELETED
|
|
40
|
+
await assert.rejects(
|
|
41
|
+
async () => await collections.get(coll_id),
|
|
42
|
+
(err) => {
|
|
43
|
+
return err.toString().includes('doesn\'t exist or your team');
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
await test.run();
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Test, assert, SH } from '@j-o-r/sh'
|
|
3
|
+
import { files } from '../lib/API/x.ai/files.js';
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
|
|
6
|
+
import Prompt from '../lib/Prompt.js';
|
|
7
|
+
import tools from './testToolset.js';
|
|
8
|
+
|
|
9
|
+
function LOG(me) {
|
|
10
|
+
console.log(JSON.stringify(me, null, ' '));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const test = new Test();
|
|
14
|
+
|
|
15
|
+
test.add('List files', async () => {
|
|
16
|
+
const fp = path.resolve('docs', 'toolset.md');
|
|
17
|
+
const list = (await files.list()).data;
|
|
18
|
+
let i = 0;
|
|
19
|
+
const len = list.length;
|
|
20
|
+
for(;i < len; i++) {
|
|
21
|
+
const f = list[i];
|
|
22
|
+
if (f.filename === 'test.md' || f.filename === fp) {
|
|
23
|
+
await files.rm(f.id);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test.add('create, add and remove files', async () => {
|
|
29
|
+
const fp = path.resolve('docs', 'toolset.md');
|
|
30
|
+
const res = await files.upload(fp);
|
|
31
|
+
const content = await files.get(res.id);
|
|
32
|
+
assert.equal(content.length, res.bytes);
|
|
33
|
+
const meta = await files.getMeta(res.id);
|
|
34
|
+
assert.equal(content.length, meta.bytes);
|
|
35
|
+
await files.rm(res.id);
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
test.add('create, add and remove files with custom content', async () => {
|
|
39
|
+
const fp = 'test.md';
|
|
40
|
+
// Add custom content to a file instead of reading the file itself
|
|
41
|
+
const res = await files.upload(fp, 'Hello World');
|
|
42
|
+
const content = await files.get(res.id);
|
|
43
|
+
assert.equal(content, 'Hello World');
|
|
44
|
+
const meta = await files.getMeta(res.id);
|
|
45
|
+
assert.equal(content.length, meta.bytes);
|
|
46
|
+
await files.rm(res.id);
|
|
47
|
+
})
|
|
48
|
+
await test.run();
|
package/types/AgentManager.d.ts
CHANGED
|
@@ -86,10 +86,11 @@ declare class AgentManager {
|
|
|
86
86
|
/** @returns {Promise<import('./fafs.js').EnvironmentInfo>} */
|
|
87
87
|
environment(): Promise<import("./fafs.js").EnvironmentInfo>;
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
90
|
-
* @param {'
|
|
89
|
+
* Adds a pre-defined generic tool from lib/genericToolset.js to this agent's ToolSet.
|
|
90
|
+
* @param {'execute_bash_script'|'execute_remote_script'|'get_user_env'|'history_search'|'javascript_interpreter'|'memory_recall'|'memory_write'|'open_link'|'read_file'|'send_email'|'syntax_check'|'write_file'} name - Valid generic tool name (validated /^[a-z_0-9]{2,}$/).
|
|
91
|
+
* @throws {Error} If toolset not initialized or tool not found in pool.
|
|
91
92
|
*/
|
|
92
|
-
addGenericToolcall(name: "
|
|
93
|
+
addGenericToolcall(name: "execute_bash_script" | "execute_remote_script" | "get_user_env" | "history_search" | "javascript_interpreter" | "memory_recall" | "memory_write" | "open_link" | "read_file" | "send_email" | "syntax_check" | "write_file"): void;
|
|
93
94
|
/**
|
|
94
95
|
* Smart launcher: Dispatches to CLI/server/attach/direct. Auto-gens cliIntro/desc if empty.
|
|
95
96
|
* @param {number} [servePort] - Server port (if no input).
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# utils/syntax_check.sh - Multi-language syntax validation
|
|
3
|
+
# Usage: ./utils/syntax_check.sh <file> [--fix|--verbose]
|
|
4
|
+
# Detects lang from ext/shebang, runs checker. Returns 0=OK, 1=error.
|
|
5
|
+
# Integrates with write_file tool retries.
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
FILE="${1?Error: Provide file path}"
|
|
10
|
+
VERBOSE="${2:-}"
|
|
11
|
+
FIX="${VERBOSE:0:4}==--fix"
|
|
12
|
+
|
|
13
|
+
[ ! -f "$FILE" ] && { echo "❌ File not found: $FILE"; exit 1; }
|
|
14
|
+
|
|
15
|
+
# Detect language
|
|
16
|
+
EXT="${FILE##*.}"
|
|
17
|
+
SHEBANG=$(head -n1 "$FILE" 2>/dev/null | cut -d' ' -f1)
|
|
18
|
+
|
|
19
|
+
detect_lang() {
|
|
20
|
+
case "$SHEBANG" in
|
|
21
|
+
*node|*/node|*js) echo "js" ;;
|
|
22
|
+
*python*|*/python|*py) echo "py" ;;
|
|
23
|
+
*bash|*sh) echo "bash" ;;
|
|
24
|
+
*/bin/sh|*/bin/bash) echo "bash" ;;
|
|
25
|
+
*) case "$EXT" in
|
|
26
|
+
js|jsx|mjs) echo "js" ;;
|
|
27
|
+
py) echo "py" ;;
|
|
28
|
+
sh|bash) echo "bash" ;;
|
|
29
|
+
json) echo "json" ;;
|
|
30
|
+
*) echo "unknown" ;;
|
|
31
|
+
esac
|
|
32
|
+
esac
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
LANG=$(detect_lang)
|
|
36
|
+
echo "🔍 Validating $FILE (lang: $LANG)"
|
|
37
|
+
|
|
38
|
+
case "$LANG" in
|
|
39
|
+
js)
|
|
40
|
+
node --check "$FILE" && echo "✅ JS OK" || { echo "❌ JS syntax error"; exit 1; }
|
|
41
|
+
;;
|
|
42
|
+
py)
|
|
43
|
+
python3 -m py_compile "$FILE" && echo "✅ Python OK" || { echo "❌ Python syntax error"; exit 1; }
|
|
44
|
+
;;
|
|
45
|
+
bash|sh)
|
|
46
|
+
bash -n "$FILE" && echo "✅ Bash OK" || { echo "❌ Bash syntax error"; exit 1; }
|
|
47
|
+
# Optional: shellcheck if installed
|
|
48
|
+
if command -v shellcheck >/dev/null; then
|
|
49
|
+
shellcheck "$FILE" || echo "⚠️ Shellcheck warnings"
|
|
50
|
+
fi
|
|
51
|
+
;;
|
|
52
|
+
json)
|
|
53
|
+
node -e "JSON.parse(require('fs').readFileSync(process.argv[1], 'utf8'))" "$FILE" && echo "✅ JSON OK" || { echo "❌ JSON invalid"; exit 1; }
|
|
54
|
+
;;
|
|
55
|
+
unknown)
|
|
56
|
+
echo "⚠️ Unknown lang for $EXT / shebang: $SHEBANG"
|
|
57
|
+
exit 0 # Non-fatal
|
|
58
|
+
;;
|
|
59
|
+
esac
|
|
60
|
+
|
|
61
|
+
echo "✅ Syntax validation passed for $FILE"
|
package/utils/test.sh
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
TEST_DIR="${1:-scenarios}"
|
|
5
|
+
echo "=== TestDave: Running all tests in $TEST_DIR/ ==="
|
|
6
|
+
|
|
7
|
+
shopt -s nullglob
|
|
8
|
+
TEST_FILES=("$TEST_DIR"/*.test.js)
|
|
9
|
+
|
|
10
|
+
if [ ${#TEST_FILES[@]} -eq 0 ]; then
|
|
11
|
+
echo "No *.test.js files found in $TEST_DIR/"
|
|
12
|
+
exit 0
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
echo "Found ${#TEST_FILES[@]} test files."
|
|
16
|
+
|
|
17
|
+
TOTAL=${#TEST_FILES[@]}
|
|
18
|
+
PASSED=0
|
|
19
|
+
FAILED=()
|
|
20
|
+
|
|
21
|
+
for test_file in "${TEST_FILES[@]}"; do
|
|
22
|
+
echo ""
|
|
23
|
+
echo "=== $test_file ==="
|
|
24
|
+
RC=$(timeout 60s "$test_file");
|
|
25
|
+
XT=$?
|
|
26
|
+
echo "$RC";
|
|
27
|
+
if [ "$XT" -eq 0 ]; then
|
|
28
|
+
echo "✅ PASS"
|
|
29
|
+
((PASSED = PASSED + 1))
|
|
30
|
+
else
|
|
31
|
+
echo "❌ FAIL (exit code $XT)"
|
|
32
|
+
FAILED+=("$test_file")
|
|
33
|
+
fi
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
echo ""
|
|
37
|
+
echo "=== SUMMARY ==="
|
|
38
|
+
echo "Total: $TOTAL"
|
|
39
|
+
echo "Passed: $PASSED"
|
|
40
|
+
echo "Failed: ${#FAILED[@]}"
|
|
41
|
+
if [ ${#FAILED[@]} -gt 0 ]; then
|
|
42
|
+
echo "Failed tests:"
|
|
43
|
+
for f in "${FAILED[@]}"; do echo " $f"; done
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
echo "🎉 All tests passed!"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|