@prestyj/ai 4.3.210 → 4.3.238

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
@@ -1,7 +1,9 @@
1
1
  import { z } from 'zod';
2
+ import Anthropic from '@anthropic-ai/sdk';
3
+ import OpenAI from 'openai';
2
4
 
3
5
  type Provider = "anthropic" | "xiaomi" | "openai" | "gemini" | "glm" | "moonshot" | "minimax" | "deepseek" | "openrouter" | "palsu";
4
- type ThinkingLevel = "low" | "medium" | "high" | "xhigh";
6
+ type ThinkingLevel = "low" | "medium" | "high" | "xhigh" | "max";
5
7
  type CacheRetention = "none" | "short" | "long";
6
8
  interface TextContent {
7
9
  type: "text";
@@ -335,6 +337,8 @@ interface FormattedError {
335
337
  statusCode?: number;
336
338
  /** Provider request ID, kept for telemetry / debug — not shown by default. */
337
339
  requestId?: string;
340
+ /** Unix seconds when a usage/rate limit resets, when the provider reports it. */
341
+ resetsAt?: number;
338
342
  }
339
343
  declare class EZCoderAIError extends Error {
340
344
  readonly source: ErrorSource;
@@ -350,11 +354,14 @@ declare class EZCoderAIError extends Error {
350
354
  declare class ProviderError extends EZCoderAIError {
351
355
  readonly provider: string;
352
356
  readonly statusCode?: number;
357
+ /** Unix seconds when a usage/rate limit resets, when the provider reports it. */
358
+ readonly resetsAt?: number;
353
359
  constructor(provider: string, message: string, options?: {
354
360
  statusCode?: number;
355
361
  requestId?: string;
356
362
  hint?: string;
357
363
  cause?: unknown;
364
+ resetsAt?: number;
358
365
  });
359
366
  }
360
367
  /**
@@ -362,6 +369,14 @@ declare class ProviderError extends EZCoderAIError {
362
369
  * a non-empty `headline` and `guidance` so the UI never has to second-guess
363
370
  * what to show the user.
364
371
  */
372
+ /**
373
+ * Is this a subscription/plan usage-window exhaustion error (as opposed to a
374
+ * transient per-minute throttle)? These don't clear with a quick retry — the
375
+ * user has to wait for the window to reset — so callers must surface them as a
376
+ * hard stop, not silently retry for minutes. Detected from the canonical
377
+ * "usage limit reached" message gg-ai stamps onto the ProviderError.
378
+ */
379
+ declare function isUsageLimitError(err: unknown): boolean;
365
380
  declare function formatError(err: unknown): FormattedError;
366
381
  /**
367
382
  * Render a FormattedError as a multi-line string for terminal display.
@@ -383,6 +398,19 @@ type ProviderDiagnosticFn = (phase: string, data?: Record<string, unknown>) => v
383
398
  /** Register a diagnostic callback for provider-level tracing. */
384
399
  declare function setProviderDiagnostic(fn: ProviderDiagnosticFn | null): void;
385
400
 
401
+ declare function toAnthropicMessages(messages: Message[], cacheControl?: {
402
+ type: "ephemeral";
403
+ ttl?: "1h";
404
+ }): {
405
+ system: Anthropic.TextBlockParam[] | undefined;
406
+ messages: Anthropic.MessageParam[];
407
+ };
408
+ declare function toOpenAIMessages(messages: Message[], options?: {
409
+ provider?: string;
410
+ thinking?: boolean;
411
+ supportsImages?: boolean;
412
+ }): OpenAI.ChatCompletionMessageParam[];
413
+
386
414
  interface PalsuProviderState {
387
415
  callCount: number;
388
416
  }
@@ -452,4 +480,4 @@ interface PalsuProviderConfig {
452
480
  */
453
481
  declare function registerPalsuProvider(config?: PalsuProviderConfig): PalsuProviderHandle;
454
482
 
455
- 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, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, providerRegistry, registerPalsuProvider, setProviderDiagnostic, stream };
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 };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { z } from 'zod';
2
+ import Anthropic from '@anthropic-ai/sdk';
3
+ import OpenAI from 'openai';
2
4
 
3
5
  type Provider = "anthropic" | "xiaomi" | "openai" | "gemini" | "glm" | "moonshot" | "minimax" | "deepseek" | "openrouter" | "palsu";
4
- type ThinkingLevel = "low" | "medium" | "high" | "xhigh";
6
+ type ThinkingLevel = "low" | "medium" | "high" | "xhigh" | "max";
5
7
  type CacheRetention = "none" | "short" | "long";
6
8
  interface TextContent {
7
9
  type: "text";
@@ -335,6 +337,8 @@ interface FormattedError {
335
337
  statusCode?: number;
336
338
  /** Provider request ID, kept for telemetry / debug — not shown by default. */
337
339
  requestId?: string;
340
+ /** Unix seconds when a usage/rate limit resets, when the provider reports it. */
341
+ resetsAt?: number;
338
342
  }
339
343
  declare class EZCoderAIError extends Error {
340
344
  readonly source: ErrorSource;
@@ -350,11 +354,14 @@ declare class EZCoderAIError extends Error {
350
354
  declare class ProviderError extends EZCoderAIError {
351
355
  readonly provider: string;
352
356
  readonly statusCode?: number;
357
+ /** Unix seconds when a usage/rate limit resets, when the provider reports it. */
358
+ readonly resetsAt?: number;
353
359
  constructor(provider: string, message: string, options?: {
354
360
  statusCode?: number;
355
361
  requestId?: string;
356
362
  hint?: string;
357
363
  cause?: unknown;
364
+ resetsAt?: number;
358
365
  });
359
366
  }
360
367
  /**
@@ -362,6 +369,14 @@ declare class ProviderError extends EZCoderAIError {
362
369
  * a non-empty `headline` and `guidance` so the UI never has to second-guess
363
370
  * what to show the user.
364
371
  */
372
+ /**
373
+ * Is this a subscription/plan usage-window exhaustion error (as opposed to a
374
+ * transient per-minute throttle)? These don't clear with a quick retry — the
375
+ * user has to wait for the window to reset — so callers must surface them as a
376
+ * hard stop, not silently retry for minutes. Detected from the canonical
377
+ * "usage limit reached" message gg-ai stamps onto the ProviderError.
378
+ */
379
+ declare function isUsageLimitError(err: unknown): boolean;
365
380
  declare function formatError(err: unknown): FormattedError;
366
381
  /**
367
382
  * Render a FormattedError as a multi-line string for terminal display.
@@ -383,6 +398,19 @@ type ProviderDiagnosticFn = (phase: string, data?: Record<string, unknown>) => v
383
398
  /** Register a diagnostic callback for provider-level tracing. */
384
399
  declare function setProviderDiagnostic(fn: ProviderDiagnosticFn | null): void;
385
400
 
401
+ declare function toAnthropicMessages(messages: Message[], cacheControl?: {
402
+ type: "ephemeral";
403
+ ttl?: "1h";
404
+ }): {
405
+ system: Anthropic.TextBlockParam[] | undefined;
406
+ messages: Anthropic.MessageParam[];
407
+ };
408
+ declare function toOpenAIMessages(messages: Message[], options?: {
409
+ provider?: string;
410
+ thinking?: boolean;
411
+ supportsImages?: boolean;
412
+ }): OpenAI.ChatCompletionMessageParam[];
413
+
386
414
  interface PalsuProviderState {
387
415
  callCount: number;
388
416
  }
@@ -452,4 +480,4 @@ interface PalsuProviderConfig {
452
480
  */
453
481
  declare function registerPalsuProvider(config?: PalsuProviderConfig): PalsuProviderHandle;
454
482
 
455
- 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, palsuAssistantMessage, palsuText, palsuThinking, palsuToolCall, providerRegistry, registerPalsuProvider, setProviderDiagnostic, stream };
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 };