@zds-ai/cli 0.1.3 → 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 (53) hide show
  1. package/README.md +32 -0
  2. package/dist/agent/grok-agent.d.ts +23 -1
  3. package/dist/agent/grok-agent.js +274 -112
  4. package/dist/agent/grok-agent.js.map +1 -1
  5. package/dist/agent/prompt-variables.d.ts +99 -0
  6. package/dist/agent/prompt-variables.js +191 -0
  7. package/dist/agent/prompt-variables.js.map +1 -0
  8. package/dist/bin/fastcaption.sh +55 -0
  9. package/dist/bin/generate_image_sd.sh +252 -0
  10. package/dist/grok/client.d.ts +4 -0
  11. package/dist/grok/client.js +79 -1
  12. package/dist/grok/client.js.map +1 -1
  13. package/dist/grok/tools.js +16 -3
  14. package/dist/grok/tools.js.map +1 -1
  15. package/dist/hooks/use-input-handler.d.ts +2 -0
  16. package/dist/hooks/use-input-handler.js +99 -39
  17. package/dist/hooks/use-input-handler.js.map +1 -1
  18. package/dist/index.js +97 -7
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp/client.js +3 -4
  21. package/dist/mcp/client.js.map +1 -1
  22. package/dist/tools/file-conversion-tool.js +4 -11
  23. package/dist/tools/file-conversion-tool.js.map +1 -1
  24. package/dist/tools/image-tool.d.ts +8 -3
  25. package/dist/tools/image-tool.js +59 -19
  26. package/dist/tools/image-tool.js.map +1 -1
  27. package/dist/ui/components/chat-history.js +25 -12
  28. package/dist/ui/components/chat-history.js.map +1 -1
  29. package/dist/ui/components/chat-interface.js +16 -9
  30. package/dist/ui/components/chat-interface.js.map +1 -1
  31. package/dist/ui/components/rephrase-menu.d.ts +8 -0
  32. package/dist/ui/components/rephrase-menu.js +25 -0
  33. package/dist/ui/components/rephrase-menu.js.map +1 -0
  34. package/dist/utils/chat-history-manager.d.ts +1 -0
  35. package/dist/utils/chat-history-manager.js +16 -6
  36. package/dist/utils/chat-history-manager.js.map +1 -1
  37. package/dist/utils/content-utils.d.ts +5 -0
  38. package/dist/utils/content-utils.js +15 -0
  39. package/dist/utils/content-utils.js.map +1 -0
  40. package/dist/utils/image-encoder.d.ts +35 -0
  41. package/dist/utils/image-encoder.js +134 -0
  42. package/dist/utils/image-encoder.js.map +1 -0
  43. package/dist/utils/rephrase-handler.d.ts +15 -0
  44. package/dist/utils/rephrase-handler.js +106 -0
  45. package/dist/utils/rephrase-handler.js.map +1 -0
  46. package/dist/utils/slash-commands.d.ts +1 -1
  47. package/dist/utils/slash-commands.js +32 -23
  48. package/dist/utils/slash-commands.js.map +1 -1
  49. package/dist/utils/startup-hook.js +21 -12
  50. package/dist/utils/startup-hook.js.map +1 -1
  51. package/dist/utils/token-counter.js +17 -2
  52. package/dist/utils/token-counter.js.map +1 -1
  53. package/package.json +6 -3
package/README.md CHANGED
@@ -339,6 +339,38 @@ Add to `~/.grok/user-settings.json`:
339
339
 
340
340
  **Model Priority**: `--model` flag > `GROK_MODEL` environment variable > user default model > system default (grok-code-fast-1)
341
341
 
342
+ ### Image Support
343
+
344
+ zai-cli supports sending images to vision-capable AI models. Use the `@` prefix to reference image files in your messages:
345
+
346
+ ```sh
347
+ # Absolute path
348
+ zai-cli --prompt "What's in this image? @/Users/joseph/photos/image.jpg"
349
+
350
+ # Relative path
351
+ zai-cli --prompt "Analyze @./screenshot.png"
352
+
353
+ # Tilde expansion
354
+ zai-cli --prompt "Describe @~/Pictures/photo.jpg"
355
+
356
+ # Paths with spaces (quoted)
357
+ zai-cli --prompt 'Compare these images: @"~/My Pictures/photo1.jpg" @"~/My Pictures/photo2.jpg"'
358
+
359
+ # Paths with spaces (escaped)
360
+ zai-cli --prompt "What's here? @/Users/joseph/My\ Documents/image.png"
361
+ ```
362
+
363
+ **Supported Image Formats**: .jpg, .jpeg, .png, .gif, .webp, .bmp
364
+
365
+ **Vision-Capable Models**: Image support works with vision models like:
366
+ - `grok-4-1-fast-reasoning`
367
+ - `grok-vision-beta`
368
+ - Other vision-enabled models (via custom base URLs)
369
+
370
+ **Automatic Fallback**: If you send an image to a model that doesn't support vision, zai-cli will automatically detect the error and retry with text-only content.
371
+
372
+ **Interactive Mode**: The `@` syntax works in both interactive and headless (`--prompt`) modes.
373
+
342
374
  ### Command Line Options
343
375
 
344
376
  ```sh
@@ -1,9 +1,10 @@
1
1
  import { GrokMessage, GrokToolCall } from "../grok/client.js";
2
+ import type { ChatCompletionContentPart } from "openai/resources/chat/completions.js";
2
3
  import { ToolResult } from "../types/index.js";
3
4
  import { EventEmitter } from "events";
4
5
  export interface ChatEntry {
5
6
  type: "user" | "assistant" | "tool_result" | "tool_call" | "system";
6
- content?: string;
7
+ content?: string | ChatCompletionContentPart[];
7
8
  timestamp: Date;
8
9
  tool_calls?: GrokToolCall[];
9
10
  toolCall?: GrokToolCall;
@@ -15,6 +16,10 @@ export interface ChatEntry {
15
16
  };
16
17
  isStreaming?: boolean;
17
18
  preserveFormatting?: boolean;
19
+ metadata?: {
20
+ rephrased_note?: string;
21
+ [key: string]: any;
22
+ };
18
23
  }
19
24
  export interface StreamingChunk {
20
25
  type: "content" | "tool_calls" | "tool_result" | "done" | "token_count" | "user_message";
@@ -62,6 +67,7 @@ export declare class GrokAgent extends EventEmitter {
62
67
  private activeTaskColor;
63
68
  private apiKeyEnvVar;
64
69
  private pendingContextEditSession;
70
+ private rephraseState;
65
71
  constructor(apiKey: string, baseURL?: string, model?: string, maxToolRounds?: number, debugLogFile?: string, startupHookOutput?: string, temperature?: number, maxTokens?: number);
66
72
  private startupHookOutput?;
67
73
  private systemPrompt;
@@ -125,6 +131,14 @@ export declare class GrokAgent extends EventEmitter {
125
131
  contextFilePath: string;
126
132
  } | null;
127
133
  clearPendingContextEditSession(): void;
134
+ setRephraseState(originalAssistantMessageIndex: number, rephraseRequestIndex: number, newResponseIndex: number, messageType: "user" | "system"): void;
135
+ getRephraseState(): {
136
+ originalAssistantMessageIndex: number;
137
+ rephraseRequestIndex: number;
138
+ newResponseIndex: number;
139
+ messageType: "user" | "system";
140
+ } | null;
141
+ clearRephraseState(): void;
128
142
  setPersona(persona: string, color?: string): Promise<{
129
143
  success: boolean;
130
144
  error?: string;
@@ -215,6 +229,7 @@ export declare class GrokAgent extends EventEmitter {
215
229
  baseUrl: string;
216
230
  apiKeyEnvVar: string;
217
231
  model: string;
232
+ supportsVision: boolean;
218
233
  };
219
234
  /**
220
235
  * Restore session state from persistence
@@ -235,7 +250,14 @@ export declare class GrokAgent extends EventEmitter {
235
250
  baseUrl?: string;
236
251
  apiKeyEnvVar?: string;
237
252
  model?: string;
253
+ supportsVision?: boolean;
238
254
  }): Promise<void>;
255
+ /**
256
+ * Compact conversation context by keeping system prompt and last N messages
257
+ * Reduces context size when it grows too large for backend to handle
258
+ * @returns Number of messages removed
259
+ */
260
+ compactContext(keepLastMessages?: number): number;
239
261
  /**
240
262
  * Get all tool instances and their class names for display purposes
241
263
  */