@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.
Files changed (119) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +216 -56
  3. package/README.md.bak +481 -0
  4. package/README.md.bak.1774780058 +338 -0
  5. package/README.md.bak2 +455 -0
  6. package/docs.bak.1774780058/agent-manager.md +167 -0
  7. package/docs.bak.1774780058/agent-manager.md.bak +137 -0
  8. package/docs.bak.1774780058/agent-manager.md.bak2 +157 -0
  9. package/docs.bak.1774780058/codeserver-pattern.md +191 -0
  10. package/docs.bak.1774780058/path-resolution-best-practices.md +104 -0
  11. package/docs.bak.1774780058/project-overview.md +67 -0
  12. package/docs.bak.1774780058/project-overview.md.bak +67 -0
  13. package/docs.bak.1774780058/prompt-class.md +141 -0
  14. package/docs.bak.1774780058/prompt-class.md.bak +142 -0
  15. package/docs.bak.1774780058/tools-syntax-validation.md +121 -0
  16. package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +125 -0
  17. package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +125 -0
  18. package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +106 -0
  19. package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +106 -0
  20. package/docs.bak.1774780058/toolset.md +164 -0
  21. package/docs.bak.1774780058/toolset.md.bak +94 -0
  22. package/docs.bak.1774780058/toolset.md.bak3 +161 -0
  23. package/docs.bak.1774780058/toolset.md.bak4 +161 -0
  24. package/docs.bak.1774780058/toolset.md.bak5 +161 -0
  25. package/docs.bak.1774780058/toolset.md.bak6 +163 -0
  26. package/docs.bak.1774780058/toolset.md.bak_path +163 -0
  27. package/docs.bak.1774780058/toolset.md.bak_syntax +161 -0
  28. package/docs.bak.1774780058/xai-responses.md +111 -0
  29. package/docs.bak.1774780058/xai-responses.md.bak +107 -0
  30. package/docs.bak.1774780058/xai-responses.md.bak2 +107 -0
  31. package/docs.bak.1774780058/xai_collections.md +106 -0
  32. package/examples/ask_agent.js +137 -0
  33. package/examples/code_agent.js +149 -0
  34. package/examples/coderev_agent.js +136 -0
  35. package/examples/codeserver.sh +47 -0
  36. package/examples/daisy_agent.js +170 -0
  37. package/examples/docs_agent.js +148 -0
  38. package/examples/gpt_agent.js +125 -0
  39. package/examples/grok_agent.js +132 -0
  40. package/examples/grok_agent.js.bak +98 -0
  41. package/examples/grok_agent.js.bak.2 +99 -0
  42. package/examples/grok_agent.js.bak.3 +1 -0
  43. package/examples/grok_agent.js.bak.4 +124 -0
  44. package/examples/grok_agent.js.bak.5 +1 -0
  45. package/examples/grok_agent.js.bak.6 +1 -0
  46. package/examples/memory_agent.js +152 -0
  47. package/examples/npm_agent.js +202 -0
  48. package/examples/npm_agent.js.bak.3 +2 -0
  49. package/examples/npm_agent.js.bak.4 +205 -0
  50. package/examples/npm_agent.js.bak.5 +1 -0
  51. package/examples/npm_agent.js.bak.6 +1 -0
  52. package/examples/prompt_agent.js +133 -0
  53. package/examples/readme_agent.js +148 -0
  54. package/examples/spawn_agent.js +293 -0
  55. package/examples/test_agent.js +187 -0
  56. package/examples/todo_agent.js +175 -0
  57. package/{examples/codeDave.js → examples.bak.1774780058/code_agent.js} +40 -6
  58. package/{examples/CodeServer → examples.bak.1774780058/codeserver.sh} +9 -5
  59. package/examples.bak.1774780058/memory_agent.js +112 -0
  60. package/{examples/spawndave.js → examples.bak.1774780058/spawn_agent.js} +29 -6
  61. package/examples.bak.1774780058/test_agent.js +162 -0
  62. package/{examples/todoDave.js → examples.bak.1774780058/todo_agent.js} +8 -2
  63. package/lib/API/x.ai/responses.js +7 -9
  64. package/lib/AgentManager.js +3 -2
  65. package/lib/AgentServer.js +23 -19
  66. package/lib/genericToolset.js +159 -26
  67. package/lib/genericToolset.js.bak_syntax +402 -0
  68. package/lib/wsCli.js +0 -1
  69. package/package.json +4 -5
  70. package/scenarios.bak.1774780058/data/eval_node_message.json +9 -0
  71. package/scenarios.bak.1774780058/data/hist_oa.json +66 -0
  72. package/scenarios.bak.1774780058/data/o3_response1.json +96 -0
  73. package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +112 -0
  74. package/scenarios.bak.1774780058/data/tool_oa.json +96 -0
  75. package/scenarios.bak.1774780058/data/tool_xai.json +59 -0
  76. package/scenarios.bak.1774780058/data/tool_xai2.json +40 -0
  77. package/scenarios.bak.1774780058/data/xai-response-1.json +59 -0
  78. package/scenarios.bak.1774780058/data/xai-response-2.json +10 -0
  79. package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +59 -0
  80. package/scenarios.bak.1774780058/data/xai_search_response.json +58 -0
  81. package/scenarios.bak.1774780058/environment.js +10 -0
  82. package/scenarios.bak.1774780058/example.js +17 -0
  83. package/scenarios.bak.1774780058/genericToolset.test.js +182 -0
  84. package/scenarios.bak.1774780058/grok.js +113 -0
  85. package/scenarios.bak.1774780058/memory-tools.js +51 -0
  86. package/scenarios.bak.1774780058/openai-o3.js +137 -0
  87. package/scenarios.bak.1774780058/openai-prompt.js +155 -0
  88. package/scenarios.bak.1774780058/openai-session.js +148 -0
  89. package/scenarios.bak.1774780058/openai.js +102 -0
  90. package/scenarios.bak.1774780058/prompt.js +118 -0
  91. package/scenarios.bak.1774780058/promptFishbowl.js +76 -0
  92. package/scenarios.bak.1774780058/search.brave.com.js +25 -0
  93. package/scenarios.bak.1774780058/sh.js +15 -0
  94. package/scenarios.bak.1774780058/test-wsio.js +26 -0
  95. package/scenarios.bak.1774780058/testToolset.js +42 -0
  96. package/scenarios.bak.1774780058/toolset.js +16 -0
  97. package/scenarios.bak.1774780058/toolset.test.js +141 -0
  98. package/scenarios.bak.1774780058/write_file_syntax.test.js +145 -0
  99. package/scenarios.bak.1774780058/write_file_validation/README.md +30 -0
  100. package/scenarios.bak.1774780058/write_file_validation/bad.js +3 -0
  101. package/scenarios.bak.1774780058/write_file_validation/good.js +4 -0
  102. package/scenarios.bak.1774780058/write_file_validation/test.sh +43 -0
  103. package/scenarios.bak.1774780058/wsClient.js +69 -0
  104. package/scenarios.bak.1774780058/xai_responses.integration.test.js +57 -0
  105. package/scenarios.bak.1774780058/xai_responses.test.js +154 -0
  106. package/scenarios.bak.1774780058/xaicoll.js +50 -0
  107. package/scenarios.bak.1774780058/xaifiles.js +48 -0
  108. package/types/AgentManager.d.ts +4 -3
  109. package/utils/syntax_check.sh +61 -0
  110. package/utils/test.sh +46 -0
  111. /package/{examples/askDave.js → examples.bak.1774780058/ask_agent.js} +0 -0
  112. /package/{examples/coderev.js → examples.bak.1774780058/coderev_agent.js} +0 -0
  113. /package/{examples/daisy.js → examples.bak.1774780058/daisy_agent.js} +0 -0
  114. /package/{examples/docsDave.js → examples.bak.1774780058/docs_agent.js} +0 -0
  115. /package/{examples/gpt.js → examples.bak.1774780058/gpt_agent.js} +0 -0
  116. /package/{examples/grok.js → examples.bak.1774780058/grok_agent.js} +0 -0
  117. /package/{examples/npmDave.js → examples.bak.1774780058/npm_agent.js} +0 -0
  118. /package/{examples/promptDave.js → examples.bak.1774780058/prompt_agent.js} +0 -0
  119. /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();
@@ -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
- * Add (copy) a pre-defined toolcall to the function_calls
90
- * @param {'read_file'|'write_file'|'get_user_env'|'execute_bash_script'|'send_email'|'open_link'|'execute_remote_script'|'history_search'|'javascript_interpreter'} name - name /^[a-z_0-9]{2,}$/ e.g. 'execute_bash_script'
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: "read_file" | "write_file" | "get_user_env" | "execute_bash_script" | "send_email" | "open_link" | "execute_remote_script" | "history_search" | "javascript_interpreter"): void;
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!"