@j-o-r/hello-dave 0.1.1 → 0.1.5

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 (173) hide show
  1. package/CHANGELOG.md +42 -25
  2. package/README.md +81 -221
  3. package/TODO.md +173 -35
  4. package/agents/agent_creator.js +105 -0
  5. package/agents/agent_creator.prompt.md +371 -0
  6. package/agents/ask_agent.js +64 -127
  7. package/agents/claude_agent.js +68 -0
  8. package/agents/code_agent.js +55 -135
  9. package/agents/code_agent.prompt.md +50 -0
  10. package/agents/echo_agent.js +76 -0
  11. package/agents/financial_expert.js +75 -0
  12. package/agents/gpt_agent.js +52 -103
  13. package/agents/gpt_code.js +81 -0
  14. package/agents/grok_agent.js +58 -114
  15. package/agents/minimax_agent.js +92 -0
  16. package/agents/mureka_agent.js +77 -0
  17. package/agents/planner_agent.js +172 -0
  18. package/agents/stability_agent.js +87 -0
  19. package/agents/test_agent.js +75 -157
  20. package/agents/weather_agent.js +73 -0
  21. package/agents/workflow_agent.js +189 -0
  22. package/bin/dave.js +436 -184
  23. package/docs/bin-dave.md +85 -35
  24. package/docs/cdn-ssh.md +100 -0
  25. package/docs/creating-agents.md +301 -0
  26. package/docs/creating-toolsets.md +336 -0
  27. package/docs/docs-organization.md +48 -0
  28. package/docs/project-overview.md +86 -51
  29. package/lib/API/elevenlabs.io/music.compose.md +441 -0
  30. package/lib/API/elevenlabs.io/music.create-composition-plan.md +370 -0
  31. package/lib/API/elevenlabs.io/music.stream.md +425 -0
  32. package/lib/API/lalal.ai/lalal.js +445 -0
  33. package/lib/API/lalal.ai/openapi.json +2614 -0
  34. package/lib/API/minimax/ImageToolset.js +82 -37
  35. package/lib/API/minimax/MusicToolset.js +125 -79
  36. package/lib/API/minimax/VideoToolset.js +170 -167
  37. package/lib/API/minimax/image.js +5 -1
  38. package/lib/API/minimax/music.js +210 -23
  39. package/lib/API/minimax/video.js +242 -53
  40. package/lib/API/mureka/MusicToolset.js +646 -0
  41. package/lib/API/mureka/README.md +41 -0
  42. package/lib/API/mureka/index.js +7 -0
  43. package/lib/API/mureka/music.js +658 -0
  44. package/lib/API/openai.com/index.js +7 -0
  45. package/lib/API/openai.com/{reponses/text.js → responses.js} +64 -18
  46. package/lib/API/openai.com/video.create.character.md +40 -0
  47. package/lib/API/openai.com/video.create.md +219 -0
  48. package/lib/API/openai.com/video.delete.md +44 -0
  49. package/lib/API/openai.com/video.download.md +31 -0
  50. package/lib/API/openai.com/video.edit.md +155 -0
  51. package/lib/API/openai.com/video.extend.md +166 -0
  52. package/lib/API/openai.com/video.fetch.character.md +43 -0
  53. package/lib/API/openai.com/video.js +784 -0
  54. package/lib/API/openai.com/video.list.md +201 -0
  55. package/lib/API/openai.com/video.remix.md +175 -0
  56. package/lib/API/openai.com/video.retrieve.md +139 -0
  57. package/lib/API/openai.com/videoToolset.js +616 -0
  58. package/lib/API/stability.ai/ImageToolset.js +131 -40
  59. package/lib/API/stability.ai/MusicToolset.js +79 -47
  60. package/lib/API/stability.ai/audio.js +63 -131
  61. package/lib/API/x.ai/chat.responses.md +1040 -0
  62. package/lib/API/x.ai/image.js +229 -59
  63. package/lib/API/x.ai/imageToolset.js +376 -0
  64. package/lib/API/x.ai/index.js +1 -1
  65. package/lib/API/x.ai/responses.js +9 -18
  66. package/lib/Agent.js +271 -0
  67. package/lib/Agent.js.old +284 -0
  68. package/lib/AgentLauncher.js +593 -0
  69. package/lib/Cli.js +87 -13
  70. package/lib/Prompt.js +23 -1
  71. package/lib/Session.js +5 -4
  72. package/lib/ToolSet.js +102 -6
  73. package/lib/agentLoader.js +369 -0
  74. package/lib/cdn.js +67 -231
  75. package/lib/{CdnToolset.js → cdnToolset.js} +47 -64
  76. package/lib/defaultToolsets.js +43 -0
  77. package/lib/fafs.js +1 -1
  78. package/lib/genericToolset.js +442 -119
  79. package/lib/handOffToolset.js +179 -0
  80. package/lib/index.js +34 -27
  81. package/lib/toolsetLoader.js +248 -0
  82. package/package.json +10 -4
  83. package/types/API/lalal.ai/lalal.d.ts +116 -0
  84. package/types/API/minimax/image.d.ts +2 -1
  85. package/types/API/minimax/music.d.ts +189 -26
  86. package/types/API/minimax/video.d.ts +100 -31
  87. package/types/API/mureka/index.d.ts +7 -0
  88. package/types/API/mureka/music.d.ts +472 -0
  89. package/types/API/openai.com/index.d.ts +7 -0
  90. package/types/API/openai.com/{reponses/text.d.ts → responses.d.ts} +11 -11
  91. package/types/API/openai.com/video.d.ts +409 -0
  92. package/types/API/openai.com/videoToolset.d.ts +24 -0
  93. package/types/API/stability.ai/audio.d.ts +14 -103
  94. package/types/API/stability.ai/image.d.ts +2 -2
  95. package/types/API/x.ai/image.d.ts +138 -26
  96. package/types/API/x.ai/imageToolset.d.ts +3 -0
  97. package/types/API/x.ai/index.d.ts +1 -1
  98. package/types/API/x.ai/responses.d.ts +4 -4
  99. package/types/Agent.d.ts +123 -0
  100. package/types/AgentLauncher.d.ts +250 -0
  101. package/types/Cli.d.ts +28 -8
  102. package/types/Prompt.d.ts +23 -5
  103. package/types/Session.d.ts +1 -1
  104. package/types/ToolSet.d.ts +10 -0
  105. package/types/agentLoader.d.ts +78 -0
  106. package/types/cdn.d.ts +15 -90
  107. package/types/defaultToolsets.d.ts +9 -0
  108. package/types/fafs.d.ts +1 -1
  109. package/types/genericToolset.d.ts +1 -1
  110. package/types/handOffToolset.d.ts +28 -0
  111. package/types/index.d.ts +19 -17
  112. package/types/toolsetLoader.d.ts +114 -0
  113. package/utils/format_log.js +101 -23
  114. package/utils/launch_agent.js +18 -0
  115. package/utils/list_sessions.sh +13 -5
  116. package/utils/search_sessions.sh +65 -29
  117. package/utils/toolsets.js +33 -0
  118. package/README.md.bak.1779452127 +0 -240
  119. package/agents/codeserver.sh +0 -47
  120. package/agents/daisy_agent.js +0 -173
  121. package/agents/docs_agent.js +0 -148
  122. package/agents/memory_agent.js +0 -263
  123. package/agents/minimax.js +0 -173
  124. package/agents/npm_agent.js +0 -202
  125. package/agents/prompt_agent.js +0 -133
  126. package/agents/readme_agent.js +0 -148
  127. package/agents/spawn_agent.js +0 -160
  128. package/agents/stability.js +0 -173
  129. package/agents/todo_agent.js +0 -175
  130. package/bin/codeDave +0 -58
  131. package/docs/agent-dave-websocket-protocol.md +0 -180
  132. package/docs/agent-manager.md +0 -244
  133. package/docs/codeserver-pattern.md +0 -191
  134. package/docs/generic-toolset.md +0 -326
  135. package/docs/howtos/agent-networking.md +0 -253
  136. package/docs/howtos/spawn-agents.md.bak +0 -200
  137. package/docs/howtos/spawn-agents.md.bak_new +0 -200
  138. package/docs/multi-agent-clusters.md +0 -265
  139. package/docs/music-toolsets.md +0 -137
  140. package/docs/path-resolution-best-practices.md +0 -104
  141. package/docs/plans/minimax-music-generation.md +0 -80
  142. package/docs/plans/unified-agent-architecture.md +0 -146
  143. package/docs/plans/websocket-streaming-plan.md.bak +0 -317
  144. package/docs/prompt/spawn_agent.md +0 -175
  145. package/docs/prompt/spawn_agent.md.bak +0 -201
  146. package/docs/prompt/task_clarification_and_documentation.md +0 -35
  147. package/docs/prompt-class.md +0 -141
  148. package/docs/todo-archive-infra-2026-04-21.md +0 -15
  149. package/docs/todo-archive-v0.0.8.md +0 -1
  150. package/docs/todo-archive-v0.1.0.md +0 -32
  151. package/docs/todo-archive.md +0 -44
  152. package/docs/tools-syntax-validation.md +0 -121
  153. package/docs/toolset.md +0 -164
  154. package/docs/xai-responses.md +0 -111
  155. package/docs/xai_collections.md +0 -106
  156. package/lib/API/x.ai/ImageToolset.js +0 -165
  157. package/lib/API/x.ai/text.js +0 -415
  158. package/lib/AgentClient.js +0 -248
  159. package/lib/AgentManager.js +0 -245
  160. package/lib/AgentServer.js +0 -404
  161. package/lib/wsCli.js +0 -287
  162. package/lib/wsIO.js +0 -90
  163. package/types/API/x.ai/text.d.ts +0 -286
  164. package/types/AgentClient.d.ts +0 -109
  165. package/types/AgentManager.d.ts +0 -100
  166. package/types/AgentServer.d.ts +0 -89
  167. package/types/wsCli.d.ts +0 -17
  168. package/types/wsIO.d.ts +0 -30
  169. package/utils/test.sh +0 -46
  170. /package/docs/{suggestions.md → _notes/token-counts.md} +0 -0
  171. /package/lib/API/openai.com/{reponses/MESSAGES.md → MESSAGES.md} +0 -0
  172. /package/types/API/{x.ai/ImageToolset.d.ts → mureka/MusicToolset.d.ts} +0 -0
  173. /package/types/{CdnToolset.d.ts → cdnToolset.d.ts} +0 -0
@@ -0,0 +1,376 @@
1
+ /**
2
+ * @file lib/API/x.ai/imageToolset.js
3
+ * @module x.ai/imageToolset
4
+ * @description ToolSet wrapper for the xAI Grok Imagine image/video API.
5
+ *
6
+ * Exposes high-level tools for AI agents and LLMs:
7
+ * - generate_image_grok
8
+ * - edit_image_grok
9
+ * - generate_video_grok
10
+ * - poll_video_result_grok
11
+ *
12
+ * Tool responses are intentionally compact, structured JSON. They preserve
13
+ * durable references such as local_path, url, request_id, source_image_url, and
14
+ * revised_prompt so the assistant can repeat those exact values in normal
15
+ * assistant messages before raw function-call history is pruned.
16
+ *
17
+ * @see ./image.js for the underlying implementation and full JSDoc.
18
+ */
19
+
20
+ import ToolSet from '../../ToolSet.js';
21
+ import * as xai from './image.js';
22
+
23
+ const tools = new ToolSet('auto');
24
+
25
+ /**
26
+ * Serialize a tool response as pretty JSON.
27
+ *
28
+ * @param {Record<string, unknown>} value Response payload to serialize.
29
+ * @returns {string} Pretty JSON response for function-calling output.
30
+ */
31
+ function json(value) {
32
+ return JSON.stringify(value, null, 2);
33
+ }
34
+
35
+ /**
36
+ * Normalizes image input that may arrive as a native array, JSON-stringified
37
+ * array, single string URL/path/data URI, or nullish value.
38
+ *
39
+ * @param {unknown} val Raw image input value.
40
+ * @returns {string[]} Clean array of non-empty image references.
41
+ */
42
+ function normalizeImageList(val) {
43
+ if (!val) return [];
44
+
45
+ if (Array.isArray(val)) {
46
+ return val.filter(Boolean).map(String);
47
+ }
48
+
49
+ if (typeof val === 'string') {
50
+ const trimmed = val.trim();
51
+ if (trimmed.startsWith('[') && trimmed.endsWith(']')) {
52
+ try {
53
+ const parsed = JSON.parse(trimmed);
54
+ if (Array.isArray(parsed)) {
55
+ return parsed.filter(Boolean).map(String);
56
+ }
57
+ } catch (_) {
58
+ // Fall through and treat as a single image reference.
59
+ }
60
+ }
61
+ return trimmed ? [trimmed] : [];
62
+ }
63
+
64
+ return [String(val)];
65
+ }
66
+
67
+ /**
68
+ * Build a compact, self-describing image tool response.
69
+ *
70
+ * @param {string} tool Tool/function name.
71
+ * @param {Record<string, unknown>} result Wrapper result.
72
+ * @param {Record<string, unknown>} context Durable input/context fields to echo.
73
+ * @returns {string} JSON function response.
74
+ */
75
+ function imageToolResponse(tool, result, context = {}) {
76
+ return json({
77
+ tool,
78
+ success: true,
79
+ ...context,
80
+ local_path: result.local_path,
81
+ localPath: result.local_path,
82
+ url: result.url,
83
+ image_url: result.url,
84
+ base64_available: Boolean(result.base64),
85
+ revised_prompt: result.revised_prompt,
86
+ note: 'Assistant: tell the user the exact local_path and url/image_url when present. Preserve revised_prompt if it matters for follow-up edits or regeneration. Use image_url/url or local_path as durable references for later image/video tools.'
87
+ });
88
+ }
89
+
90
+ /**
91
+ * Build a compact, self-describing video tool response.
92
+ *
93
+ * @param {string} tool Tool/function name.
94
+ * @param {Record<string, unknown>} result Wrapper result.
95
+ * @param {Record<string, unknown>} context Durable input/context fields to echo.
96
+ * @returns {string} JSON function response.
97
+ */
98
+ function videoToolResponse(tool, result, context = {}) {
99
+ return json({
100
+ tool,
101
+ success: true,
102
+ ...context,
103
+ local_path: result.local_path,
104
+ localPath: result.local_path,
105
+ url: result.url,
106
+ video_url: result.url,
107
+ status: result.status,
108
+ note: 'Assistant: tell the user the exact local_path and video_url/url when present. If request_id is present, repeat it exactly because it is required for poll_video_result_grok. Preserve source_image_url for follow-up edits or regeneration.'
109
+ });
110
+ }
111
+
112
+ /* ============================================================
113
+ GENERATE IMAGE
114
+ ============================================================ */
115
+
116
+ tools.add(
117
+ 'generate_image_grok',
118
+ 'Generate high-quality images from a text prompt using Grok Imagine models. ' +
119
+ 'Default model is "grok-imagine-image-quality" (recommended). Alternative model: "grok-imagine-image". ' +
120
+ 'Supports batch generation (n images), custom aspect ratios, resolutions (1k/2k), and response formats (url or b64_json). ' +
121
+ 'Images are automatically saved locally. After success, include the exact local_path and url/image_url in your normal assistant response so those references remain available after raw function calls are pruned.',
122
+ {
123
+ type: 'object',
124
+ properties: {
125
+ prompt: {
126
+ type: 'string',
127
+ description: 'Detailed English prompt describing the desired image. Be specific about style, lighting, composition, subject, mood, camera angle, and artistic references for best results.'
128
+ },
129
+ n: {
130
+ type: 'integer',
131
+ minimum: 1,
132
+ maximum: 10,
133
+ default: 1,
134
+ description: 'Number of images to generate in a single request. Min: 1, Max: 10, Default: 1. Use higher values for variations.'
135
+ },
136
+ model: {
137
+ type: 'string',
138
+ default: 'grok-imagine-image-quality',
139
+ description: 'Model to use. Recommended: "grok-imagine-image-quality". Alternative: "grok-imagine-image".'
140
+ },
141
+ response_format: {
142
+ type: 'string',
143
+ enum: ['url', 'b64_json'],
144
+ default: 'url',
145
+ description: 'Output format. Prefer "url" when possible because it provides a durable image_url-style reference. "b64_json" returns base64 data for direct embedding.'
146
+ },
147
+ aspect_ratio: {
148
+ type: 'string',
149
+ description: 'Aspect ratio of the output image. Common values: "16:9", "9:16", "1:1", "4:3", "3:2", "auto".'
150
+ },
151
+ resolution: {
152
+ type: 'string',
153
+ enum: ['1k', '2k'],
154
+ description: 'Output resolution. "1k" (default) or "2k" for higher detail.'
155
+ }
156
+ },
157
+ required: ['prompt']
158
+ },
159
+ async (params) => {
160
+ const result = await xai.generateImage(params.prompt, params);
161
+
162
+ return imageToolResponse('generate_image_grok', result, {
163
+ prompt: params.prompt,
164
+ model: params.model || 'grok-imagine-image-quality',
165
+ n: params.n || 1,
166
+ response_format: params.response_format || 'url',
167
+ aspect_ratio: params.aspect_ratio,
168
+ resolution: params.resolution
169
+ });
170
+ }
171
+ );
172
+
173
+ /* ============================================================
174
+ EDIT IMAGE
175
+ ============================================================ */
176
+
177
+ tools.add(
178
+ 'edit_image_grok',
179
+ 'Edit one or more images using natural language instructions with Grok Imagine. ' +
180
+ 'Supports up to 3 reference images for compositing subjects, style transfer, multi-subject scenes, or iterative refinement. ' +
181
+ 'Provide image URLs, local file paths, or base64 data URIs. Prefer image_url/image_urls where possible. ' +
182
+ 'After success, include the exact output local_path and url/image_url plus the exact source_image_url/source_image_urls in your normal assistant response so references remain available after raw function calls are pruned.\n\n' +
183
+ 'OFFICIAL API MAPPING:\n' +
184
+ '- Single image → uses the "image" field (object with url + type).\n' +
185
+ '- Multiple images (2-3) → uses the "images" array of objects.\n' +
186
+ 'When using multiple images, refer to them in the prompt as <IMAGE_0>, <IMAGE_1>, <IMAGE_2> (etc.).\n\n' +
187
+ 'IMPORTANT: Use either "image_url" (for a single image) OR "image_urls" (array of up to 3). Do not use both. ' +
188
+ 'Note: image_urls may arrive as a JSON string; the handler normalizes it automatically.',
189
+ {
190
+ type: 'object',
191
+ properties: {
192
+ prompt: {
193
+ type: 'string',
194
+ description: 'Natural language description of the edit or transformation. For multi-image edits, refer to the inputs as <IMAGE_0>, <IMAGE_1>, etc.'
195
+ },
196
+ image_url: {
197
+ type: 'string',
198
+ description: 'Single source image URL, local path, or base64 data URI. Prefer public image_url where possible. Use this when editing exactly one image. Mutually exclusive with image_urls.'
199
+ },
200
+ image_urls: {
201
+ type: 'array',
202
+ items: { type: 'string' },
203
+ description: 'Array of up to 3 image URLs/paths for multi-image editing. Prefer public image_url values where possible. May be a native array or JSON string.'
204
+ },
205
+ model: {
206
+ type: 'string',
207
+ default: 'grok-imagine-image-quality',
208
+ description: 'Model to use. Recommended: "grok-imagine-image-quality". Alternative: "grok-imagine-image".'
209
+ },
210
+ n: {
211
+ type: 'integer',
212
+ minimum: 1,
213
+ maximum: 10,
214
+ default: 1,
215
+ description: 'Number of edited output images. Min: 1, Max: 10, Default: 1.'
216
+ },
217
+ response_format: {
218
+ type: 'string',
219
+ enum: ['url', 'b64_json'],
220
+ default: 'url',
221
+ description: 'Output format. Prefer "url" when possible because it gives an image_url-style reference for follow-up tools.'
222
+ },
223
+ aspect_ratio: {
224
+ type: 'string',
225
+ description: 'Desired aspect ratio for the output. Single-image edits generally respect the input.'
226
+ },
227
+ resolution: {
228
+ type: 'string',
229
+ enum: ['1k', '2k'],
230
+ description: 'Output resolution: "1k" or "2k".'
231
+ }
232
+ },
233
+ required: ['prompt']
234
+ },
235
+ async (params) => {
236
+ const normalizedUrls = normalizeImageList(params.image_urls);
237
+ const normalizedSingle = params.image_url ? [params.image_url] : [];
238
+ const images = normalizedUrls.length > 0 ? [...normalizedUrls] : [...normalizedSingle];
239
+
240
+ if (normalizedUrls.length > 0 && normalizedSingle.length > 0) {
241
+ const seen = new Set(normalizedUrls);
242
+ for (const url of normalizedSingle) {
243
+ if (!seen.has(url)) images.push(url);
244
+ }
245
+ }
246
+
247
+ if (images.length === 0) {
248
+ throw new Error('edit_image_grok requires at least one image via image_url or image_urls');
249
+ }
250
+ if (images.length > 3) {
251
+ throw new Error('edit_image_grok supports a maximum of 3 reference images');
252
+ }
253
+
254
+ const result = await xai.editImage(params.prompt, images, params);
255
+
256
+ return imageToolResponse('edit_image_grok', result, {
257
+ prompt: params.prompt,
258
+ source_image_url: images.length === 1 ? images[0] : undefined,
259
+ source_image_urls: images,
260
+ model: params.model || 'grok-imagine-image-quality',
261
+ n: params.n || 1,
262
+ response_format: params.response_format || 'url',
263
+ aspect_ratio: params.aspect_ratio,
264
+ resolution: params.resolution
265
+ });
266
+ }
267
+ );
268
+
269
+ /* ============================================================
270
+ GENERATE VIDEO (fully automatic)
271
+ ============================================================ */
272
+
273
+ tools.add(
274
+ 'generate_video_grok',
275
+ 'Generate a video from a still image + text prompt using Grok Imagine Video. ' +
276
+ 'Fully automatic: submits the request and polls internally until the video is ready. Model: grok-imagine-video. ' +
277
+ 'The source image becomes the first frame; the prompt describes motion, camera movement, or animation. ' +
278
+ 'Prefer public image_url where possible. Duration affects pricing and generation time. Max video length is 15 seconds. ' +
279
+ 'After success, include the exact local_path, video_url/url, and source_image_url in your normal assistant response so references remain available after raw function calls are pruned. ' +
280
+ 'If generation times out before returning a video, use poll_video_result_grok only when a request_id is available from the error/logs or a direct async call.',
281
+ {
282
+ type: 'object',
283
+ properties: {
284
+ prompt: {
285
+ type: 'string',
286
+ description: 'Description of the desired motion, camera movement, animation, or scene changes. Be specific.'
287
+ },
288
+ image_url: {
289
+ type: 'string',
290
+ description: 'Source still image. Prefer a public image_url where possible. Local paths and base64 data URIs are also accepted. This becomes the first frame.'
291
+ },
292
+ duration: {
293
+ type: 'number',
294
+ minimum: 1,
295
+ maximum: 15,
296
+ default: 8,
297
+ description: 'Video duration in seconds. Min: 1, Max: 15, Default: 8. Recommended: 8–12 seconds.'
298
+ },
299
+ model: {
300
+ type: 'string',
301
+ default: 'grok-imagine-video',
302
+ description: 'Video model. Currently only "grok-imagine-video" is supported.'
303
+ },
304
+ aspect_ratio: {
305
+ type: 'string',
306
+ default: '16:9',
307
+ description: 'Aspect ratio of the output video. Common values: "16:9", "9:16", "1:1".'
308
+ },
309
+ resolution: {
310
+ type: 'string',
311
+ default: '720p',
312
+ description: 'Output resolution. Common values: "720p", "480p".'
313
+ }
314
+ },
315
+ required: ['prompt', 'image_url']
316
+ },
317
+ async (params) => {
318
+ const result = await xai.generateVideo(params.prompt, params.image_url, params);
319
+
320
+ return videoToolResponse('generate_video_grok', result, {
321
+ prompt: params.prompt,
322
+ source_image_url: params.image_url,
323
+ duration: params.duration || 8,
324
+ model: params.model || 'grok-imagine-video',
325
+ aspect_ratio: params.aspect_ratio || '16:9',
326
+ resolution: params.resolution || '720p'
327
+ });
328
+ }
329
+ );
330
+
331
+ /* ============================================================
332
+ POLL VIDEO RESULT (manual / emergency polling)
333
+ ============================================================ */
334
+
335
+ tools.add(
336
+ 'poll_video_result_grok',
337
+ 'Manually poll the status of an asynchronous video generation request. ' +
338
+ 'Use this tool when a request_id from a previous video generation is available and you need recovery/manual polling. ' +
339
+ 'After success, include the exact request_id, local_path, video_url/url, and status in your normal assistant response so references remain available after raw function calls are pruned.',
340
+ {
341
+ type: 'object',
342
+ properties: {
343
+ request_id: {
344
+ type: 'string',
345
+ description: 'The exact request_id returned by the video generation endpoint. Required for polling; repeat it exactly in follow-up references.'
346
+ },
347
+ maxAttempts: {
348
+ type: 'integer',
349
+ minimum: 1,
350
+ default: 60,
351
+ description: 'Maximum number of polling attempts. Min: 1, Default: 60. Increase for longer videos or slower generations.'
352
+ },
353
+ intervalMs: {
354
+ type: 'integer',
355
+ default: 15000,
356
+ description: 'Delay between polling attempts in milliseconds. Default: 15000. Recommended range: 5000–30000.'
357
+ }
358
+ },
359
+ required: ['request_id']
360
+ },
361
+ async (params) => {
362
+ const result = await xai.pollVideoResult(
363
+ params.request_id,
364
+ params.maxAttempts,
365
+ params.intervalMs
366
+ );
367
+
368
+ return videoToolResponse('poll_video_result_grok', result, {
369
+ request_id: params.request_id,
370
+ maxAttempts: params.maxAttempts || 60,
371
+ intervalMs: params.intervalMs || 15000
372
+ });
373
+ }
374
+ );
375
+
376
+ export default tools;
@@ -1,5 +1,5 @@
1
1
  import * as image from './image.js';
2
- import imageToolset from './ImageToolset.js'
2
+ import imageToolset from './imageToolset.js'
3
3
 
4
4
  export default {
5
5
  image,
@@ -1,6 +1,6 @@
1
1
  /*
2
- Allthough we can use store = true and previous_response_id: response.id,
3
- Stil all tokens are billed.
2
+ Although we can use store = true and previous_response_id: response.id,
3
+ Still all tokens are billed.
4
4
  */
5
5
  import { GLOBAL } from '../../fafs.js'
6
6
  import { request as doRequest } from '@j-o-r/apiserver';
@@ -20,7 +20,7 @@ import { sleep } from '@j-o-r/sh';
20
20
  * @property {number} [max_output_tokens=4000] - Maximum number of output tokens.
21
21
  * @property {number} [max_tool_calls=10] - Maximum number of tool calls allowed.
22
22
  * @property {?Object} [metadata=null] - Optional metadata object.
23
- * @property {'grok-4-1-fast-reasoning'|'grok-4-1-fast-non-reasoning'|'grok-code-fast-1'|'grok-4-fast-reasoning'|'grok-4-fast-non-reasoning'} [model='grok-4-fast-non-reasoning'] - Model version to use.
23
+ * @property {'grok-build-0.1'|'grok-4.3'|'grok-4.20'|'grok-4.20-multi-agent'|'grok-4.20-non-reasoning'} [model='grok-4.3'] - Model version to use.
24
24
  * @property {?string} [prompt=null] - Reusable prompt string.
25
25
  * @property {Object} [reasoning={effort: 'medium', summary: 'auto'}] - Reasoning configuration.
26
26
  * @property {'low'|'medium'|'high'|null} reasoning.effort - Effort level for reasoning.
@@ -37,7 +37,7 @@ import { sleep } from '@j-o-r/sh';
37
37
  * @property {Array<XSearchTool|XAIFunctionTool|MCPTool|CodeInterpreterTool|FileSearchTool|XAIWebSearchTool>} [tools=[]] Array of tool call objects.
38
38
  * @property {?number } [top_logprobs=null] - An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
39
39
  * @property {?number } [top_p] Top-p sampling value between 0 and 1.
40
- * @property {?string} [previous_response_id] - Needed reponse_id to validate tool calls on the next request
40
+ * @property {?string} [previous_response_id] - Needed response_id to validate tool calls on the next request
41
41
  */
42
42
  /// [start] ----- tools ----
43
43
  /**
@@ -267,7 +267,7 @@ const webSearch = [
267
267
 
268
268
  /** @type {XAIOptions} */
269
269
  const defaultSettings = {
270
- model: 'grok-4-fast-reasoning',
270
+ model: 'grok-4.3',
271
271
  input: [
272
272
  {
273
273
  role: 'system',
@@ -304,6 +304,9 @@ function getBody(prompt, toolset, options) {
304
304
  const body = { ...defaultSettings, ...(options || {}) };
305
305
  // const body = options ? mergeOptions(DEFAULT_OPTIONS, options) : DEFAULT_OPTIONS;
306
306
  body.instructions = prompt.hasSystemprompt ? prompt.system_prompt : '';
307
+ // All previous resolved funtioncalls are deleted
308
+ // except for the last one
309
+ prompt.pruneResolvedFunctionCallsExceptLast();
307
310
  // the last messages should be a role tool or user else the model cannot handle the request
308
311
  const messages = prompt.messages;
309
312
  if (!['user', 'tool'].includes(messages[messages.length - 1].role)) {
@@ -318,18 +321,6 @@ function getBody(prompt, toolset, options) {
318
321
  body.parallel_tool_calls = true;
319
322
  // parallel_tool_calls
320
323
  }
321
- // Add OPENAI SEARCH
322
- // in the toolset
323
- // if (body.search) {
324
- // if (!body.tools) {
325
- // body.tools = [];
326
- // }
327
- // body.tools.push({
328
- // type: 'web_search_preview',
329
- // // @ts-ignore
330
- // search_context_size: body.search
331
- // })
332
- // }
333
324
  delete body.search;
334
325
  return body;
335
326
  }
@@ -477,7 +468,7 @@ async function request(prompt, toolset = null, options = {}, counter = 0) {
477
468
  const lastMessage = prompt.getLastMessage();
478
469
  if (!lastMessage) throw new Error('No message found');
479
470
  if (lastMessage.role === 'tool') {
480
- // need to do another roundtrip to include the funtion_responses
471
+ // need to do another roundtrip to include the function_responses
481
472
  // And add the previousId for toolsets to work
482
473
  if (!options) {
483
474
  options = {};