agent-pulse 1.4.0 → 1.4.1

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.
@@ -18,6 +18,33 @@ class GrokProvider {
18
18
  });
19
19
  }
20
20
  async generate(system, prompt, files, tools, config, output_schema, onToken) {
21
+ // Image generation mode — route to images API instead of chat completions
22
+ if (this.model.includes('imagine')) {
23
+ const promptText = Array.isArray(prompt)
24
+ ? prompt.filter(m => m.role === 'user').map(m => m.content).join('\n')
25
+ : String(prompt);
26
+ const response = await this.client.images.generate({
27
+ model: this.model,
28
+ prompt: promptText,
29
+ n: config?.n || 1,
30
+ response_format: config?.response_format || 'b64_json',
31
+ ...(config?.aspect_ratio && { aspect_ratio: config.aspect_ratio }),
32
+ });
33
+ const images = response.data;
34
+ const markdownParts = images.map((img, i) => {
35
+ if (img.b64_json) {
36
+ return `![Generated Image${images.length > 1 ? ` ${i + 1}` : ''}](data:image/png;base64,${img.b64_json})`;
37
+ }
38
+ return `![Generated Image${images.length > 1 ? ` ${i + 1}` : ''}](${img.url})`;
39
+ });
40
+ const content = markdownParts.join('\n\n');
41
+ onToken(content);
42
+ return {
43
+ content,
44
+ usage: { input_tokens: 0, output_tokens: 0, total_tokens: 0 },
45
+ meta: { model: this.model, latency_ms: 0 }
46
+ };
47
+ }
21
48
  // 1. Prepare messages
22
49
  const messages = [];
23
50
  if (system) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-pulse",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "A lightweight, agentic AI framework for JavaScript/TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",