@prestyj/ai 4.3.238 → 4.4.0

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.
package/dist/index.d.cts CHANGED
@@ -19,13 +19,23 @@ interface ImageContent {
19
19
  mediaType: string;
20
20
  data: string;
21
21
  }
22
+ interface VideoContent {
23
+ type: "video";
24
+ mediaType: string;
25
+ data: string;
26
+ /** Moonshot/Kimi file id (e.g. "d4f0…") after uploading via the files API.
27
+ * Moonshot rejects inline base64 video; the provider uploads the clip once
28
+ * and caches the id here so later turns reference `ms://<fileId>` instead of
29
+ * re-sending the bytes. */
30
+ fileId?: string;
31
+ }
22
32
  interface ToolCall {
23
33
  type: "tool_call";
24
34
  id: string;
25
35
  name: string;
26
36
  args: Record<string, unknown>;
27
37
  }
28
- type ToolResultContent = string | (TextContent | ImageContent)[];
38
+ type ToolResultContent = string | (TextContent | ImageContent | VideoContent)[];
29
39
  interface ToolResult {
30
40
  type: "tool_result";
31
41
  toolCallId: string;
@@ -49,14 +59,14 @@ interface RawContent {
49
59
  type: "raw";
50
60
  data: Record<string, unknown>;
51
61
  }
52
- type ContentPart = TextContent | ThinkingContent | ImageContent | ToolCall | ServerToolCall | ServerToolResult | RawContent;
62
+ type ContentPart = TextContent | ThinkingContent | ImageContent | VideoContent | ToolCall | ServerToolCall | ServerToolResult | RawContent;
53
63
  interface SystemMessage {
54
64
  role: "system";
55
65
  content: string;
56
66
  }
57
67
  interface UserMessage {
58
68
  role: "user";
59
- content: string | (TextContent | ImageContent)[];
69
+ content: string | (TextContent | ImageContent | VideoContent)[];
60
70
  }
61
71
  interface AssistantMessage {
62
72
  role: "assistant";
@@ -187,6 +197,10 @@ interface StreamOptions {
187
197
  * in user messages and tool_result messages is downgraded to a text placeholder
188
198
  * before being sent to the provider. Default: true. */
189
199
  supportsImages?: boolean;
200
+ /** Whether the target model supports video input. When false, video content
201
+ * in user messages is downgraded to a text placeholder before being sent to
202
+ * the provider. Default: false. */
203
+ supportsVideo?: boolean;
190
204
  /** Use streaming transport (default: true). When false, providers issue a
191
205
  * single non-streaming request and synthesize events from the full response.
192
206
  * The agent loop flips this to `false` as a fallback after repeated stream
@@ -199,6 +213,11 @@ interface StreamOptions {
199
213
  * version should pass it here. Ignored for non-Anthropic providers and for
200
214
  * Anthropic requests using a regular API key. */
201
215
  userAgent?: string;
216
+ /** Extra HTTP headers attached to every model request. Used by providers
217
+ * whose endpoint gates on client identity (e.g. Kimi For Coding requires a
218
+ * `User-Agent: kimi-code-cli/...` and `X-Msh-*` device headers). Merged
219
+ * into the underlying SDK's default headers. */
220
+ defaultHeaders?: Record<string, string>;
202
221
  }
203
222
 
204
223
  /**
@@ -321,7 +340,7 @@ declare const providerRegistry: ProviderRegistryImpl;
321
340
  * Cannot read property 'foo' of undefined
322
341
  * → This is a ezcoder bug — please report it.
323
342
  */
324
- type ErrorSource = "provider" | "ezcoder" | "network" | "auth";
343
+ type ErrorSource = "provider" | "ezcoder" | "network" | "auth" | "capability";
325
344
  interface FormattedError {
326
345
  /** Plain-English headline, e.g. "OpenAI returned an error." */
327
346
  headline: string;
@@ -377,6 +396,13 @@ declare class ProviderError extends EZCoderAIError {
377
396
  * "usage limit reached" message gg-ai stamps onto the ProviderError.
378
397
  */
379
398
  declare function isUsageLimitError(err: unknown): boolean;
399
+ /**
400
+ * Substrings that mark a hard, non-retriable billing/quota stop on ANY provider
401
+ * (credit exhaustion, balance too low, plan quota spent). Single source of truth
402
+ * shared across the OpenAI-compatible and Anthropic provider boundaries and the
403
+ * agent-loop retry classifier, so the lists can't drift. Matched case-insensitively.
404
+ */
405
+ declare function isHardBillingMessage(message: string): boolean;
380
406
  declare function formatError(err: unknown): FormattedError;
381
407
  /**
382
408
  * Render a FormattedError as a multi-line string for terminal display.
@@ -480,4 +506,4 @@ interface PalsuProviderConfig {
480
506
  */
481
507
  declare function registerPalsuProvider(config?: PalsuProviderConfig): PalsuProviderHandle;
482
508
 
483
- export { type AssistantMessage, type CacheRetention, type ContentPart, type DoneEvent, EZCoderAIError, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, type ImageContent, type Message, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type Provider, type ProviderDiagnosticFn, type ProviderEntry, ProviderError, type ProviderStreamFn, type RawContent, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, formatError, formatErrorForDisplay, isUsageLimitError, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, providerRegistry, registerPalsuProvider, setProviderDiagnostic, stream, toAnthropicMessages, toOpenAIMessages };
509
+ export { type AssistantMessage, type CacheRetention, type ContentPart, type DoneEvent, EZCoderAIError, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, type ImageContent, type Message, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type Provider, type ProviderDiagnosticFn, type ProviderEntry, ProviderError, type ProviderStreamFn, type RawContent, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, formatError, formatErrorForDisplay, isHardBillingMessage, isUsageLimitError, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, providerRegistry, registerPalsuProvider, setProviderDiagnostic, stream, toAnthropicMessages, toOpenAIMessages };
package/dist/index.d.ts CHANGED
@@ -19,13 +19,23 @@ interface ImageContent {
19
19
  mediaType: string;
20
20
  data: string;
21
21
  }
22
+ interface VideoContent {
23
+ type: "video";
24
+ mediaType: string;
25
+ data: string;
26
+ /** Moonshot/Kimi file id (e.g. "d4f0…") after uploading via the files API.
27
+ * Moonshot rejects inline base64 video; the provider uploads the clip once
28
+ * and caches the id here so later turns reference `ms://<fileId>` instead of
29
+ * re-sending the bytes. */
30
+ fileId?: string;
31
+ }
22
32
  interface ToolCall {
23
33
  type: "tool_call";
24
34
  id: string;
25
35
  name: string;
26
36
  args: Record<string, unknown>;
27
37
  }
28
- type ToolResultContent = string | (TextContent | ImageContent)[];
38
+ type ToolResultContent = string | (TextContent | ImageContent | VideoContent)[];
29
39
  interface ToolResult {
30
40
  type: "tool_result";
31
41
  toolCallId: string;
@@ -49,14 +59,14 @@ interface RawContent {
49
59
  type: "raw";
50
60
  data: Record<string, unknown>;
51
61
  }
52
- type ContentPart = TextContent | ThinkingContent | ImageContent | ToolCall | ServerToolCall | ServerToolResult | RawContent;
62
+ type ContentPart = TextContent | ThinkingContent | ImageContent | VideoContent | ToolCall | ServerToolCall | ServerToolResult | RawContent;
53
63
  interface SystemMessage {
54
64
  role: "system";
55
65
  content: string;
56
66
  }
57
67
  interface UserMessage {
58
68
  role: "user";
59
- content: string | (TextContent | ImageContent)[];
69
+ content: string | (TextContent | ImageContent | VideoContent)[];
60
70
  }
61
71
  interface AssistantMessage {
62
72
  role: "assistant";
@@ -187,6 +197,10 @@ interface StreamOptions {
187
197
  * in user messages and tool_result messages is downgraded to a text placeholder
188
198
  * before being sent to the provider. Default: true. */
189
199
  supportsImages?: boolean;
200
+ /** Whether the target model supports video input. When false, video content
201
+ * in user messages is downgraded to a text placeholder before being sent to
202
+ * the provider. Default: false. */
203
+ supportsVideo?: boolean;
190
204
  /** Use streaming transport (default: true). When false, providers issue a
191
205
  * single non-streaming request and synthesize events from the full response.
192
206
  * The agent loop flips this to `false` as a fallback after repeated stream
@@ -199,6 +213,11 @@ interface StreamOptions {
199
213
  * version should pass it here. Ignored for non-Anthropic providers and for
200
214
  * Anthropic requests using a regular API key. */
201
215
  userAgent?: string;
216
+ /** Extra HTTP headers attached to every model request. Used by providers
217
+ * whose endpoint gates on client identity (e.g. Kimi For Coding requires a
218
+ * `User-Agent: kimi-code-cli/...` and `X-Msh-*` device headers). Merged
219
+ * into the underlying SDK's default headers. */
220
+ defaultHeaders?: Record<string, string>;
202
221
  }
203
222
 
204
223
  /**
@@ -321,7 +340,7 @@ declare const providerRegistry: ProviderRegistryImpl;
321
340
  * Cannot read property 'foo' of undefined
322
341
  * → This is a ezcoder bug — please report it.
323
342
  */
324
- type ErrorSource = "provider" | "ezcoder" | "network" | "auth";
343
+ type ErrorSource = "provider" | "ezcoder" | "network" | "auth" | "capability";
325
344
  interface FormattedError {
326
345
  /** Plain-English headline, e.g. "OpenAI returned an error." */
327
346
  headline: string;
@@ -377,6 +396,13 @@ declare class ProviderError extends EZCoderAIError {
377
396
  * "usage limit reached" message gg-ai stamps onto the ProviderError.
378
397
  */
379
398
  declare function isUsageLimitError(err: unknown): boolean;
399
+ /**
400
+ * Substrings that mark a hard, non-retriable billing/quota stop on ANY provider
401
+ * (credit exhaustion, balance too low, plan quota spent). Single source of truth
402
+ * shared across the OpenAI-compatible and Anthropic provider boundaries and the
403
+ * agent-loop retry classifier, so the lists can't drift. Matched case-insensitively.
404
+ */
405
+ declare function isHardBillingMessage(message: string): boolean;
380
406
  declare function formatError(err: unknown): FormattedError;
381
407
  /**
382
408
  * Render a FormattedError as a multi-line string for terminal display.
@@ -480,4 +506,4 @@ interface PalsuProviderConfig {
480
506
  */
481
507
  declare function registerPalsuProvider(config?: PalsuProviderConfig): PalsuProviderHandle;
482
508
 
483
- export { type AssistantMessage, type CacheRetention, type ContentPart, type DoneEvent, EZCoderAIError, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, type ImageContent, type Message, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type Provider, type ProviderDiagnosticFn, type ProviderEntry, ProviderError, type ProviderStreamFn, type RawContent, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, formatError, formatErrorForDisplay, isUsageLimitError, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, providerRegistry, registerPalsuProvider, setProviderDiagnostic, stream, toAnthropicMessages, toOpenAIMessages };
509
+ export { type AssistantMessage, type CacheRetention, type ContentPart, type DoneEvent, EZCoderAIError, type ErrorEvent, type ErrorSource, EventStream, type FormattedError, type ImageContent, type Message, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type Provider, type ProviderDiagnosticFn, type ProviderEntry, ProviderError, type ProviderStreamFn, type RawContent, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, formatError, formatErrorForDisplay, isHardBillingMessage, isUsageLimitError, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, providerRegistry, registerPalsuProvider, setProviderDiagnostic, stream, toAnthropicMessages, toOpenAIMessages };