@j-o-r/hello-dave 0.0.5 → 0.0.7

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 (127) hide show
  1. package/CHANGELOG.md +13 -26
  2. package/README.md +161 -522
  3. package/README.md.bak +144 -449
  4. package/{examples → agents}/ask_agent.js +5 -5
  5. package/{examples → agents}/codeserver.sh +14 -14
  6. package/{examples → agents}/daisy_agent.js +5 -5
  7. package/{examples → agents}/docs_agent.js +5 -5
  8. package/{examples → agents}/gpt_agent.js +5 -5
  9. package/{examples → agents}/grok_agent.js +5 -5
  10. package/agents/memory_agent.js +263 -0
  11. package/{examples → agents}/npm_agent.js +5 -5
  12. package/{examples → agents}/prompt_agent.js +5 -5
  13. package/agents/spawn_agent.js +137 -0
  14. package/{examples → agents}/test_agent.js +6 -8
  15. package/{examples → agents}/todo_agent.js +5 -5
  16. package/bin/codeDave +58 -0
  17. package/bin/dave.js +114 -96
  18. package/lib/AgentClient.js +111 -67
  19. package/lib/AgentManager.js +111 -80
  20. package/lib/AgentServer.js +144 -104
  21. package/lib/Cli.js +126 -93
  22. package/lib/Prompt.js +38 -5
  23. package/lib/Session.js +102 -79
  24. package/lib/ToolSet.js +79 -60
  25. package/lib/fafs.js +54 -19
  26. package/lib/genericToolset.js +109 -213
  27. package/lib/wsCli.js +50 -19
  28. package/lib/wsIO.js +11 -17
  29. package/package.json +2 -2
  30. package/types/AgentClient.d.ts +69 -35
  31. package/types/AgentManager.d.ts +50 -56
  32. package/types/AgentServer.d.ts +63 -16
  33. package/types/Cli.d.ts +56 -10
  34. package/types/Prompt.d.ts +36 -4
  35. package/types/Session.d.ts +23 -9
  36. package/types/ToolSet.d.ts +49 -32
  37. package/types/fafs.d.ts +68 -25
  38. package/types/wsCli.d.ts +14 -0
  39. package/types/wsIO.d.ts +9 -5
  40. package/utils/search_sessions.sh +100 -53
  41. package/README.md.backup +0 -269
  42. package/README.md.bak.1774780058 +0 -338
  43. package/README.md.bak2 +0 -531
  44. package/bin/spawn_agent.js +0 -293
  45. package/docs.bak.1774780058/agent-manager.md +0 -167
  46. package/docs.bak.1774780058/agent-manager.md.bak +0 -137
  47. package/docs.bak.1774780058/agent-manager.md.bak2 +0 -157
  48. package/docs.bak.1774780058/codeserver-pattern.md +0 -191
  49. package/docs.bak.1774780058/path-resolution-best-practices.md +0 -104
  50. package/docs.bak.1774780058/project-overview.md +0 -67
  51. package/docs.bak.1774780058/project-overview.md.bak +0 -67
  52. package/docs.bak.1774780058/prompt-class.md +0 -141
  53. package/docs.bak.1774780058/prompt-class.md.bak +0 -142
  54. package/docs.bak.1774780058/tools-syntax-validation.md +0 -121
  55. package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +0 -125
  56. package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +0 -125
  57. package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +0 -106
  58. package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +0 -106
  59. package/docs.bak.1774780058/toolset.md +0 -164
  60. package/docs.bak.1774780058/toolset.md.bak +0 -94
  61. package/docs.bak.1774780058/toolset.md.bak3 +0 -161
  62. package/docs.bak.1774780058/toolset.md.bak4 +0 -161
  63. package/docs.bak.1774780058/toolset.md.bak5 +0 -161
  64. package/docs.bak.1774780058/toolset.md.bak6 +0 -163
  65. package/docs.bak.1774780058/toolset.md.bak_path +0 -163
  66. package/docs.bak.1774780058/toolset.md.bak_syntax +0 -161
  67. package/docs.bak.1774780058/xai-responses.md +0 -111
  68. package/docs.bak.1774780058/xai-responses.md.bak +0 -107
  69. package/docs.bak.1774780058/xai-responses.md.bak2 +0 -107
  70. package/docs.bak.1774780058/xai_collections.md +0 -106
  71. package/examples/memory_agent.js +0 -152
  72. package/examples.bak.1774780058/ask_agent.js +0 -114
  73. package/examples.bak.1774780058/code_agent.js +0 -149
  74. package/examples.bak.1774780058/coderev_agent.js +0 -72
  75. package/examples.bak.1774780058/codeserver.sh +0 -47
  76. package/examples.bak.1774780058/daisy_agent.js +0 -177
  77. package/examples.bak.1774780058/docs_agent.js +0 -119
  78. package/examples.bak.1774780058/gpt_agent.js +0 -109
  79. package/examples.bak.1774780058/grok_agent.js +0 -98
  80. package/examples.bak.1774780058/memory_agent.js +0 -112
  81. package/examples.bak.1774780058/npm_agent.js +0 -175
  82. package/examples.bak.1774780058/prompt_agent.js +0 -112
  83. package/examples.bak.1774780058/readme_agent.js +0 -144
  84. package/examples.bak.1774780058/spawn_agent.js +0 -263
  85. package/examples.bak.1774780058/test_agent.js +0 -162
  86. package/examples.bak.1774780058/todo_agent.js +0 -138
  87. package/lib/genericToolset.js.bak_syntax +0 -402
  88. package/scenarios.bak.1774780058/data/eval_node_message.json +0 -9
  89. package/scenarios.bak.1774780058/data/hist_oa.json +0 -66
  90. package/scenarios.bak.1774780058/data/o3_response1.json +0 -96
  91. package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +0 -112
  92. package/scenarios.bak.1774780058/data/tool_oa.json +0 -96
  93. package/scenarios.bak.1774780058/data/tool_xai.json +0 -59
  94. package/scenarios.bak.1774780058/data/tool_xai2.json +0 -40
  95. package/scenarios.bak.1774780058/data/xai-response-1.json +0 -59
  96. package/scenarios.bak.1774780058/data/xai-response-2.json +0 -10
  97. package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +0 -59
  98. package/scenarios.bak.1774780058/data/xai_search_response.json +0 -58
  99. package/scenarios.bak.1774780058/environment.js +0 -10
  100. package/scenarios.bak.1774780058/example.js +0 -17
  101. package/scenarios.bak.1774780058/genericToolset.test.js +0 -182
  102. package/scenarios.bak.1774780058/grok.js +0 -113
  103. package/scenarios.bak.1774780058/memory-tools.js +0 -51
  104. package/scenarios.bak.1774780058/openai-o3.js +0 -137
  105. package/scenarios.bak.1774780058/openai-prompt.js +0 -155
  106. package/scenarios.bak.1774780058/openai-session.js +0 -148
  107. package/scenarios.bak.1774780058/openai.js +0 -102
  108. package/scenarios.bak.1774780058/prompt.js +0 -118
  109. package/scenarios.bak.1774780058/promptFishbowl.js +0 -76
  110. package/scenarios.bak.1774780058/search.brave.com.js +0 -25
  111. package/scenarios.bak.1774780058/sh.js +0 -15
  112. package/scenarios.bak.1774780058/test-wsio.js +0 -26
  113. package/scenarios.bak.1774780058/testToolset.js +0 -42
  114. package/scenarios.bak.1774780058/toolset.js +0 -16
  115. package/scenarios.bak.1774780058/toolset.test.js +0 -141
  116. package/scenarios.bak.1774780058/write_file_syntax.test.js +0 -145
  117. package/scenarios.bak.1774780058/write_file_validation/README.md +0 -30
  118. package/scenarios.bak.1774780058/write_file_validation/bad.js +0 -3
  119. package/scenarios.bak.1774780058/write_file_validation/good.js +0 -4
  120. package/scenarios.bak.1774780058/write_file_validation/test.sh +0 -43
  121. package/scenarios.bak.1774780058/wsClient.js +0 -69
  122. package/scenarios.bak.1774780058/xai_responses.integration.test.js +0 -57
  123. package/scenarios.bak.1774780058/xai_responses.test.js +0 -154
  124. package/scenarios.bak.1774780058/xaicoll.js +0 -50
  125. package/scenarios.bak.1774780058/xaifiles.js +0 -48
  126. /package/{examples → agents}/code_agent.js +0 -0
  127. /package/{examples → agents}/readme_agent.js +0 -0
@@ -1,402 +0,0 @@
1
- import { SH, bashEscape } from '@j-o-r/sh'
2
- import { ToolSet, env } from './index.js'
3
- import path from 'node:path';
4
- import { promises as fs } from 'node:fs';
5
- import { fileURLToPath } from 'node:url';
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
-
10
- const user = await env();
11
- const environment = `
12
- Name: ${user.name}
13
- System: ${user.system}
14
- City: ${user.city}
15
- Region: ${user.region}
16
- Country: ${user.country}
17
- Timezone: ${user.timezone}
18
- ExternalIp: ${user.external_ip}
19
- `.trim();
20
- const tools = new ToolSet('auto');
21
-
22
- /**
23
- * reduce the error output to essential info only, if possible
24
- * @param {string} errorStr
25
- * @returns {string}
26
- */
27
- const getJSError = (errorStr) => {
28
- let result = '';
29
- const linematch = errorStr.match(/\[eval\]:(\d+)/);
30
- const lineNumber = linematch ? linematch[1] : '';
31
- const match = errorStr.split(/\" \"\[eval\]:\d+/s);
32
- if (match.length > 1) {
33
- // Remove last 10 lines
34
- const res = match[1].split('\n').slice(0, -10).join('\n');
35
- result = `Error: line ${lineNumber}\n${res} `
36
- } else {
37
- result = errorStr;
38
- }
39
- return result;
40
- }
41
-
42
- tools.add(
43
- 'javascript_interpreter',
44
- `Execute ESM ES6 javascript on \`node\`.`,
45
- {
46
- type: 'object',
47
- properties: {
48
- script: {
49
- type: 'string',
50
- description: `ES6 ESM Javascript eval. 'console.log' to capture the response. cwd: ${user.cwd}`,
51
- }
52
- },
53
- required: ['script']
54
- },
55
- async (params) => {
56
- let response = '';
57
- try {
58
- const delim = `JS_STDIN_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`;
59
- response = await SH`cat <<'${delim}' | node --input-type=module -
60
- ${params.script}
61
- ${delim}
62
- `.run();
63
- } catch (e) {
64
- const errorStr = e.toString();
65
- response = getJSError(errorStr);
66
- }
67
- return response;
68
- }
69
- );
70
- tools.add(
71
- 'get_user_env', // name
72
- 'Get the user location, name and OS environment', // desciption
73
- {
74
- type: 'object',
75
- properties: {
76
- }
77
- },
78
- async (_params) => {
79
- return environment;
80
- }
81
- );
82
-
83
- tools.add(
84
- 'execute_bash_script',
85
- 'Execute a bash script or command. (char escaping not needed)',
86
- {
87
- type: 'object',
88
- properties: {
89
- bash_script: { type: 'string', description: `RAW bash script (LITERAL TEXT: NO ESCAPING—output $, |, <, >, &, ", ', \\, \` , newlines, $(()), [[ ]] verbatim. Heredoc delimiter handles safely. EX: echo "$((1+1)) | grep \'<&>\"hi$USER\"\' && ls -la\`. (${user.system})` }
90
- },
91
- required: ['bash_script']
92
- },
93
- async (params) => {
94
- const delim = `END_SCRIPT_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
95
- return await SH`bash <<'${delim}'
96
- ${params.bash_script}
97
- ${delim}
98
- `.run()
99
- }
100
- );
101
-
102
- tools.add(
103
- 'send_email',
104
- 'Send an email.',
105
- {
106
- type: 'object',
107
- properties: {
108
- to: { type: 'string', description: 'Recipient email' },
109
- subject: { type: 'string', description: 'Subject' },
110
- body: { type: 'string', description: 'Message body' }
111
- },
112
- required: ['to', 'subject', 'body']
113
- },
114
- async (params) => {
115
- const delim = `END_EMAIL_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
116
- return await SH`msmtp ${params.to} <<'${delim}'
117
- To: ${params.to}
118
- Subject: ${params.subject}
119
-
120
- ${params.body}
121
- ${delim}
122
- `.run();
123
- }
124
- );
125
- tools.add(
126
- 'open_link',
127
- 'Open an url or file in the local user environment. (xdg-open)',
128
- {
129
- type: 'object',
130
- properties: {
131
- url: { type: 'string', description: 'file | URL' }
132
- },
133
- required: ['url']
134
- },
135
- async (params) => {
136
- return await SH`xdg-open ${[params.url]}`.run();
137
- }
138
- );
139
- tools.add(
140
- 'execute_remote_script',
141
- 'Execute bash script on a remote machine via SSH.',
142
- {
143
- type: 'object',
144
- properties: {
145
- url: { type: 'string', description: 'SSH URL, e.g., ssh://user@host or ssh://user@host:port' },
146
- script: { type: 'string', description: 'RAW script code to execute remotely (no escaping needed)' }
147
- },
148
- required: ['url', 'script']
149
- },
150
- async (params) => {
151
- const { url, script } = params;
152
- if (!url.startsWith('ssh://')) throw new Error('Invalid SSH URL');
153
- const withoutProto = url.slice(6);
154
- const parts = withoutProto.split(':');
155
- let port = 22;
156
- let userHost = withoutProto;
157
- if (parts.length > 1) {
158
- userHost = parts[0];
159
- port = parseInt(parts[1]);
160
- }
161
- const [user, host] = userHost.split('@');
162
- if (!user || !host) throw new Error('Invalid SSH URL format: use ssh://user@host[:port]');
163
-
164
- const delim = `END_SCRIPT_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
165
- return await SH`ssh -p ${port} ${user}@${host} bash <<'${delim}'
166
- ${script}
167
- ${delim}
168
- `.run();
169
-
170
- }
171
- );
172
- tools.add(
173
- 'history_search',
174
- `Search previous LLM chat sessions or list them hierarchically.
175
- Example query: "(todo|task)" or "package.json".
176
- Searches filenames & content in .cache/[app]/[prompt]/sessions/*.ndjson (case-insensitive regex, with context).
177
- Omit query (or use empty string) to list sessions (see utils/list_sessions.sh).`,
178
- {
179
- type: 'object',
180
- properties: {
181
- query: {
182
- type: 'string',
183
- description: `Search query or regex (quoted for multi-word/regex). Omit or empty for list mode.`
184
- }
185
- },
186
- required: []
187
- },
188
- async (params) => {
189
- const history_search = path.resolve(__dirname, '..', 'utils', 'search_sessions.sh');
190
- const list_sessions = path.resolve(__dirname, '..', 'utils', 'list_sessions.sh');
191
- if (typeof params.query === 'string' && params.query.trim() !== '') {
192
- const escapedQuery = bashEscape(params.query);
193
- return await SH`${history_search} "${escapedQuery}"`.run();
194
- } else {
195
- return await SH`${list_sessions}`.run();
196
- }
197
- }
198
- );
199
- tools.add(
200
- 'read_file',
201
- 'Read the raw content of a file strictly within the current working directory (CWD). Paths must be relative (no leading /, no ..).',
202
- {
203
- type: 'object',
204
- properties: {
205
- file: {
206
- type: 'string',
207
- description: `Relative path to the file within CWD, e.g., 'path/to/file.txt' (no escaping needed). cwd: ${user.cwd}`
208
- }
209
- },
210
- required: ['file']
211
- },
212
- async (params) => {
213
- const file = params.file?.trim();
214
- if (typeof file !== 'string' || !file) {
215
- throw new Error('Valid relative file path required.');
216
- }
217
- if (file.startsWith('/') || file.includes('..') || file.includes('\\\\')) {
218
- throw new Error('Path must be relative within CWD only (no `/`, `..`, or `\\\\`).');
219
- }
220
- const resolvedPath = path.resolve(process.cwd(), file);
221
- if (!resolvedPath.startsWith(process.cwd())) {
222
- throw new Error(`Path '${file}' escapes CWD scope.`);
223
- }
224
- try {
225
- const content = await fs.readFile(resolvedPath, 'utf8');
226
- return content;
227
- } catch (e) {
228
- throw new Error(`Failed to read '${file}': ${e.message}`);
229
- }
230
- }
231
- );
232
-
233
- tools.add(
234
- 'write_file',
235
- 'Write raw content to a file strictly within the current working directory (CWD). Paths must be relative (no leading /, no ..). Content written as-is (no escaping). **AUTO-VALIDATES** JS/Python/Bash/JSON/etc. via `utils/syntax_check.sh`; chmod +x shebangs. Retries syntax errors force LLM fix.',
236
- {
237
- type: 'object',
238
- properties: {
239
- file: {
240
- type: 'string',
241
- description: `Relative path to the file within CWD, e.g., 'path/to/file.txt' (no escaping needed).`
242
- },
243
- content: {
244
- type: 'string',
245
- description: `Raw content to write (as-is, no char escaping needed; supports newlines, $, |, <, >, &, ", ', \\, etc.).`
246
- }
247
- },
248
- required: ['file', 'content']
249
- },
250
- async (params) => {
251
- const file = params.file?.trim();
252
- const content = params.content ?? '';
253
- if (typeof file !== 'string' || !file) {
254
- throw new Error('Valid relative file path required.');
255
- }
256
- if (file.startsWith('/') || file.includes('..') || file.includes('\\\\')) {
257
- throw new Error('Path must be relative within CWD only (no `/`, `..`, or `\\\\`).');
258
- }
259
- const resolvedPath = path.resolve(process.cwd(), file);
260
- if (!resolvedPath.startsWith(process.cwd())) {
261
- throw new Error(`Path '${file}' escapes CWD scope.`);
262
- }
263
- try {
264
- await fs.writeFile(resolvedPath, content, 'utf8');
265
-
266
- // AUTO-VALIDATE: Multi-lang syntax check via utils/syntax_check.sh + chmod shebang
267
- const syntaxChecker = path.resolve(process.cwd(), 'utils/syntax_check.sh');
268
- const hasShebang = content.startsWith('#!');
269
-
270
- let validationMsg = '';
271
- try {
272
- await SH`${syntaxChecker} ${[resolvedPath]}`.run();
273
- validationMsg = ' ✓ Multi-lang syntax OK';
274
- } catch (e) {
275
- const errPreview = content.slice(0, 1000).split('\n').slice(0, 20).join('\n');
276
- throw new Error(`❌ SYNTAX ERROR in '${file}' (syntax_check.sh failed):\n${e.message}\n\nPREVIEW:\n${errPreview}\n\n... Fix syntax (quotes/backticks) and retry write_file.`);
277
- }
278
- if (hasShebang) {
279
- await SH`chmod +x ${[resolvedPath]}`.run();
280
- validationMsg += ' ✓ chmod +x';
281
- }
282
-
283
- return `Successfully wrote to '${file}' (${Buffer.byteLength(content, 'utf8')} bytes).${validationMsg}`;
284
- } catch (e) {
285
- throw new Error(`Failed to write '${file}': ${e.message}`);
286
- }
287
- }
288
- );
289
-
290
- tools.add(
291
- 'syntax_check',
292
- 'Standalone syntax validation for files (JS/Python/Bash/JSON/etc.) via utils/syntax_check.sh. Detects lang from ext/shebang.',
293
- {
294
- type: 'object',
295
- properties: {
296
- file: {
297
- type: 'string',
298
- description: `Relative path to the file within CWD.`
299
- }
300
- },
301
- required: ['file']
302
- },
303
- async (params) => {
304
- const file = params.file?.trim();
305
- if (typeof file !== 'string' || !file) {
306
- throw new Error('Valid relative file path required.');
307
- }
308
- const resolvedPath = path.resolve(process.cwd(), file);
309
- if (!resolvedPath.startsWith(process.cwd())) {
310
- throw new Error(`Path '${file}' escapes CWD scope.`);
311
- }
312
- const syntaxChecker = path.resolve(process.cwd(), 'utils/syntax_check.sh');
313
- return await SH`${syntaxChecker} ${[resolvedPath]}`.run();
314
- }
315
- );
316
-
317
- tools.add(
318
- 'memory_write',
319
- `Persist agent memory for tasks, errors, or user preferences to .cache/memory.ndjson in CWD (${user.cwd}). Use to store decisions, tasks, errors, or prefs for later recall. Agent should use this to avoid repeating work or token burn on loops.`,
320
- {
321
- type: 'object',
322
- properties: {
323
- category: {
324
- type: 'string',
325
- enum: ['tasks', 'errors', 'prefs'],
326
- description: 'Category: one of "tasks", "errors", "prefs"'
327
- },
328
- content: {
329
- type: 'string',
330
- description: 'Detailed content (e.g., "Pending task: implement runWithMemory optimization", "Error: loop burning tokens", "Pref: temperature=0.2 for decisions")'
331
- }
332
- },
333
- required: ['category', 'content']
334
- },
335
- async ({category, content}) => {
336
- if (!['tasks', 'errors', 'prefs'].includes(category)) {
337
- throw new Error(`Invalid category '${category}'. Must be 'tasks', 'errors', or 'prefs'.`);
338
- }
339
- const memoryPath = path.join(process.cwd(), '.cache', 'memory.ndjson');
340
- const dir = path.dirname(memoryPath);
341
- try {
342
- await fs.mkdir(dir, { recursive: true });
343
- } catch (e) {
344
- // Dir likely exists
345
- }
346
- const entry = {
347
- timestamp: new Date().toISOString(),
348
- category,
349
- content: content.trim()
350
- };
351
- await fs.appendFile(memoryPath, JSON.stringify(entry) + '\n', 'utf8');
352
- return `✓ Memory stored: [${category}] ${content.length > 50 ? content.slice(0, 47) + '...' : content}`;
353
- }
354
- );
355
-
356
- tools.add(
357
- 'memory_recall',
358
- `Retrieve stored agent memories (tasks, errors, prefs) from .cache/memory.ndjson in CWD (${user.cwd}). Use before acting to check prior decisions/tasks/errors/prefs. Query by keyword or category; empty lists recent.`,
359
- {
360
- type: 'object',
361
- properties: {
362
- query: {
363
- type: 'string',
364
- description: 'Keyword, category (tasks/errors/prefs), or phrase to filter (case-insensitive). Empty/omit lists last 20.'
365
- }
366
- },
367
- required: []
368
- },
369
- async (params = {}) => {
370
- const memoryPath = path.join(process.cwd(), '.cache', 'memory.ndjson');
371
- let content;
372
- try {
373
- content = await fs.readFile(memoryPath, 'utf8');
374
- } catch (e) {
375
- return 'No memories stored yet. Use memory_write first.';
376
- }
377
- const lines = content.trim().split('\n').filter(l => l.trim());
378
- const memories = [];
379
- for (const line of lines) {
380
- try {
381
- memories.push(JSON.parse(line));
382
- } catch {
383
- // Skip invalid lines
384
- }
385
- }
386
- if (!params.query || !params.query.toString().trim()) {
387
- const recent = memories.slice(-20).reverse();
388
- return recent.length
389
- ? 'Recent memories:\n' + recent.map(m => `• ${m.timestamp.slice(0, 19).replace('T', ' ')} [${m.category}] ${m.content}`).join('\n')
390
- : 'No memories stored.';
391
- }
392
- const q = params.query.toString().toLowerCase();
393
- const matches = memories.filter(m =>
394
- m.category.toLowerCase().includes(q) || m.content.toLowerCase().includes(q)
395
- );
396
- return matches.length
397
- ? `Matches for "${params.query}":\n` + matches.slice(0, 20).map(m => `• ${m.timestamp.slice(0, 19).replace('T', ' ')} [${m.category}] ${m.content}`).join('\n')
398
- : `No memories match "${params.query}".`;
399
- }
400
- );
401
-
402
- export default tools
@@ -1,9 +0,0 @@
1
- {
2
- "type": "function_request",
3
- "function_request": {
4
- "name": "execute_javascript",
5
- "id": "fc_686284be7fec81a0af404739ec17e29f09dcb726e1aa6681",
6
- "call_id": "call_w0WnYfQiqFey5UiF4jG0XQcn",
7
- "parameters": "{\"script\": \"/*\\n * Function: parseMessages\\n * Description: Parses the 'response' object and adds messages to the given Prompt instance.\\n * The function supports two types of response items:\\n * 1. function_call: These are mapped to a function_request message with role 'assistant'.\\n * The function_request content fields are: name, id, call_id, and parameters (from arguments).\\n * 2. message: These are mapped to text messages. In case the content array contains items with type 'output_text',\\n * they are converted into PRTextMessage objects (i.e., with type \\\"text\\\") and added to the prompt.\\n * In the case where there is more than one piece of content, addMultiModal is used.\\n *\\n * Note: This function assumes that the response is already parsed (i.e., a JS object) and that prompt is an instance\\n * of the Prompt class imported from lib/Prompt.js.\\n */\\n\\nexport function parseMessages(response, prompt) {\\n if (!response || !Array.isArray(response.output)) {\\n console.warn('Invalid response format. Expected an object with an output array.');\\n return;\\n }\\n\\n response.output.forEach(item => {\\n if (item.type === 'function_call') {\\n // Convert function_call to a function_request message\\n const functionRequestContent = {\\n type: 'function_request',\\n function_request: {\\n id: item.id,\\n name: item.name,\\n call_id: item.call_id,\\n parameters: item.arguments\\n }\\n };\\n // Add as a multi-modal assistant message\\n try {\\n prompt.addMultiModal('assistant', [functionRequestContent]);\\n } catch (err) {\\n console.error('Error adding function_request message:', err);\\n }\\n } else if (item.type === 'message') {\\n // Determine the role; if not provided, use 'assistant' by default\\n const role = item.role || 'assistant';\\n let prContents = [];\\n\\n if (Array.isArray(item.content)) {\\n item.content.forEach(contentItem => {\\n if (contentItem.type === 'output_text') {\\n prContents.push({\\n type: 'text',\\n text: contentItem.text\\n });\\n } else if (contentItem.type === 'image_url') {\\n prContents.push({\\n type: 'image_url',\\n image_url: contentItem.image_url\\n });\\n } else {\\n // If another type is encountered, you may want to add additional handling here.\\n console.warn('Unhandled content type in message:', contentItem.type);\\n }\\n });\\n }\\n\\n if (prContents.length > 0) {\\n try {\\n // If there is only one text message and no multi-modal requirements, use add\\n if (prContents.length === 1 && prContents[0].type === 'text') {\\n prompt.add(role, prContents[0].text);\\n } else {\\n prompt.addMultiModal(role, prContents);\\n }\\n } catch (err) {\\n console.error('Error adding message:', err);\\n }\\n }\\n } else {\\n console.warn('Unhandled item type:', item.type);\\n }\\n });\\n}\\n\\n// Example usage:\\n// import Prompt from './lib/Prompt.js';\\n// import { parseMessages } from './parseMessages.js';\\n// \\n// const prompt = new Prompt(1000);\\n// const response = {\\n// output: [\\n// {\\n// id: 'fc_68624cb486148191b2078ec2a76e389a068902ce013ce130',\\n// type: 'function_call',\\n// status: 'completed',\\n// arguments: '{}',\\n// call_id: 'call_6YNYwCZRbmMPr5WaEo1FkbXx',\\n// name: 'get_date_time'\\n// },\\n// {\\n// id: 'msg_68624cb7c28c8191aff3106ebea965d4068902ce013ce130',\\n// type: 'message',\\n// status: 'completed',\\n// content: [\\n// {\\n// type: 'output_text',\\n// annotations: [],\\n// logprobs: [],\\n// text: 'Today is Friday, 12 May 2025. The current weather in Amsterdam, The Netherlands is 24°C.'\\n// }\\n// ],\\n// role: 'assistant'\\n// }\\n// ]\\n// };\\n// \\n// parseMessages(response, prompt);\\n// console.log(prompt.messages);\\n\"}"
8
- }
9
- }
@@ -1,66 +0,0 @@
1
- {
2
- "background": false,
3
- "include": null,
4
- "input": [
5
- {
6
- "role": "user",
7
- "content": [
8
- {
9
- "type": "input_text",
10
- "text": "What is your task?"
11
- }
12
- ]
13
- },
14
- {
15
- "role": "assistant",
16
- "content": [
17
- {
18
- "type": "output_text",
19
- "text": "My task is to assist with administrative duties, such as answering questions, scheduling, providing information, and supporting office operations efficiently."
20
- }
21
- ]
22
- },
23
- {
24
- "role": "user",
25
- "content": [
26
- {
27
- "type": "input_text",
28
- "text": "What day is today and what is the weather forcast in Amsterdam, The Netherlands"
29
- }
30
- ]
31
- }
32
- ],
33
- "instructions": "You are an assistant for an administrative office. Respond precise and concise",
34
- "max_output_tokens": 4000,
35
- "model": "gpt-4.1",
36
- "store": false,
37
- "tool_choice": "auto",
38
- "tools": [
39
- {
40
- "type": "function",
41
- "name": "get_current_weather",
42
- "description": "Get the current weather in a given location",
43
- "parameters": {
44
- "type": "object",
45
- "properties": {
46
- "location": {
47
- "type": "string",
48
- "description": "The city and country"
49
- }
50
- },
51
- "required": [
52
- "location"
53
- ]
54
- }
55
- },
56
- {
57
- "type": "function",
58
- "name": "get_date_time",
59
- "description": "Get the current date and time",
60
- "parameters": {
61
- "type": "object",
62
- "properties": {}
63
- }
64
- }
65
- ]
66
- }
@@ -1,96 +0,0 @@
1
- {
2
- "status": 200,
3
- "responseType": "js",
4
- "response": {
5
- "id": "resp_6874b24814cc819ea71f8eb6e91232ca02f4bf761199143a",
6
- "object": "response",
7
- "created_at": 1752478280,
8
- "status": "completed",
9
- "background": false,
10
- "error": null,
11
- "incomplete_details": null,
12
- "instructions": "Respond precise and concise",
13
- "max_output_tokens": null,
14
- "max_tool_calls": 10,
15
- "model": "gpt-4.1-2025-04-14",
16
- "output": [
17
- {
18
- "id": "fc_6874b24891c0819e9062bad90155a54c02f4bf761199143a",
19
- "type": "function_call",
20
- "status": "completed",
21
- "arguments": "{}",
22
- "call_id": "call_VxiUGAEYYi6vIB2Pvii7BjfC",
23
- "name": "get_date_time"
24
- },
25
- {
26
- "id": "fc_6874b248a410819ea277914240709c9d02f4bf761199143a",
27
- "type": "function_call",
28
- "status": "completed",
29
- "arguments": "{\"location\":\"Amsterdam, The Netherlands\"}",
30
- "call_id": "call_4R7UXEUNHODywjbuqCvtoj0K",
31
- "name": "get_current_weather"
32
- }
33
- ],
34
- "parallel_tool_calls": true,
35
- "previous_response_id": null,
36
- "reasoning": {
37
- "effort": null,
38
- "summary": null
39
- },
40
- "service_tier": "default",
41
- "store": true,
42
- "temperature": 1,
43
- "text": {
44
- "format": {
45
- "type": "text"
46
- }
47
- },
48
- "tool_choice": "auto",
49
- "tools": [
50
- {
51
- "type": "function",
52
- "description": "Get the current weather in a given location",
53
- "name": "get_current_weather",
54
- "parameters": {
55
- "type": "object",
56
- "properties": {
57
- "location": {
58
- "type": "string",
59
- "description": "The city and country"
60
- }
61
- },
62
- "required": [
63
- "location"
64
- ]
65
- },
66
- "strict": true
67
- },
68
- {
69
- "type": "function",
70
- "description": "Get the current date and time",
71
- "name": "get_date_time",
72
- "parameters": {
73
- "type": "object",
74
- "properties": {}
75
- },
76
- "strict": true
77
- }
78
- ],
79
- "top_logprobs": 0,
80
- "top_p": 1,
81
- "truncation": "disabled",
82
- "usage": {
83
- "input_tokens": 86,
84
- "input_tokens_details": {
85
- "cached_tokens": 0
86
- },
87
- "output_tokens": 46,
88
- "output_tokens_details": {
89
- "reasoning_tokens": 0
90
- },
91
- "total_tokens": 132
92
- },
93
- "user": null,
94
- "metadata": {}
95
- }
96
- }
@@ -1,112 +0,0 @@
1
- {
2
- "status": 200,
3
- "responseType": "js",
4
- "response": {
5
- "id": "resp_6863d9370ab48192b83fae94e9782ecd0019502d0d1a63e8",
6
- "object": "response",
7
- "created_at": 1751374135,
8
- "status": "completed",
9
- "background": false,
10
- "error": null,
11
- "incomplete_details": null,
12
- "instructions": "You are Dave, an assistant for this project, which is a Node.js 22 / JavaScript ESM ES2022 project with minimal external dependencies. Comments are in JSDoc format.\n\nThe goal is to create a multi-endpoint API for AI models and system integration that can be easily tested with a CLI interface and utilized in other projects.\n\nBe helpful, but keep responses brief and concise. User input may include new questions, remarks about previous conversations, or opinions on past answers.\n\nAsk a clarifying question to establish context before providing an answer when necessary, and reason explicitly before reaching a conclusion.",
13
- "max_output_tokens": 4000,
14
- "max_tool_calls": null,
15
- "model": "o3-mini-2025-01-31",
16
- "output": [
17
- {
18
- "id": "rs_6863d938a7008192bfd00349682585390019502d0d1a63e8",
19
- "type": "reasoning",
20
- "summary": [
21
- {
22
- "type": "summary_text",
23
- "text": "**Defining core functionalities**\n\nI need to outline core functionalities, focusing on aspects like multi-endpoint API, AI integration, and CLI testing. Each functionality should be described clearly and concisely. For the multi-endpoint API, I might explain its role in allowing different interfaces to interact efficiently. Regarding AI integration, I can highlight how it enhances automation and data processing. Finally, for CLI testing, I'll emphasize enabling user interaction through the command line, streamlining testing processes. I'll ensure the explanations are specific yet straightforward."
24
- }
25
- ]
26
- },
27
- {
28
- "id": "msg_6863d93a45508192919451d43bb4462b0019502d0d1a63e8",
29
- "type": "message",
30
- "status": "completed",
31
- "content": [
32
- {
33
- "type": "output_text",
34
- "annotations": [],
35
- "logprobs": [],
36
- "text": "The project's core functionalities include:\n\n1. Multiple API endpoints that support various AI model integrations.\n2. A command-line interface for testing and interacting with the endpoints.\n3. System integration capabilities, making it adaptable for deployment in other projects.\n4. Minimal external dependencies, leveraging Node.js 22 and modern JavaScript (ES2022).\n5. A modular design that allows for easy extension of both API and CLI functionalities.\n\nLet me know if you'd like more details on any specific functionality."
37
- }
38
- ],
39
- "role": "assistant"
40
- }
41
- ],
42
- "parallel_tool_calls": true,
43
- "previous_response_id": null,
44
- "reasoning": {
45
- "effort": "low",
46
- "summary": "detailed"
47
- },
48
- "service_tier": "default",
49
- "store": false,
50
- "temperature": 1,
51
- "text": {
52
- "format": {
53
- "type": "text"
54
- }
55
- },
56
- "tool_choice": "auto",
57
- "tools": [
58
- {
59
- "type": "function",
60
- "description": "Execute a Bash command on Ubuntu 25.04 x86_64GNU/Linux and with xdg-open ,msmtp ,node ,curl.",
61
- "name": "execute_bash",
62
- "parameters": {
63
- "type": "object",
64
- "properties": {
65
- "command": {
66
- "type": "string",
67
- "description": "The bash command."
68
- }
69
- },
70
- "required": [
71
- "command"
72
- ]
73
- },
74
- "strict": true
75
- },
76
- {
77
- "type": "function",
78
- "description": "Execute ESM ES6 javascript on `node`.",
79
- "name": "execute_javascript",
80
- "parameters": {
81
- "type": "object",
82
- "properties": {
83
- "script": {
84
- "type": "string",
85
- "description": "ES6 ESM Javascript to execute"
86
- }
87
- },
88
- "required": [
89
- "script"
90
- ]
91
- },
92
- "strict": true
93
- }
94
- ],
95
- "top_logprobs": 0,
96
- "top_p": 1,
97
- "truncation": "disabled",
98
- "usage": {
99
- "input_tokens": 321,
100
- "input_tokens_details": {
101
- "cached_tokens": 0
102
- },
103
- "output_tokens": 99,
104
- "output_tokens_details": {
105
- "reasoning_tokens": 0
106
- },
107
- "total_tokens": 420
108
- },
109
- "user": null,
110
- "metadata": {}
111
- }
112
- }