@llmnative/react 1.44.0 → 1.46.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.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { AIModelPricing } from '../../providers/ai/AIProvider';
3
+ import { type BadgeType } from '../ui/Badge';
3
4
  import { type EditorCommand } from '../ui/fields/ContextMenu';
4
5
  /**
5
6
  * Chatbot — l'input/composer AI condiviso, estratto da `Prompt` (CR-071): textarea,
@@ -46,11 +47,18 @@ export interface ChatbotModelOption {
46
47
  /** Section the option is listed under (e.g. its provider). When any option has one, the
47
48
  * picker renders one sticky header per group, in order of first appearance. */
48
49
  group?: string;
50
+ /** A badge on the right of the header of its group (CR-121), e.g. how the group is paid; the
51
+ * first option of a group that has one gives it. */
52
+ groupBadge?: {
53
+ label: string;
54
+ variant?: BadgeType;
55
+ };
49
56
  }
50
57
  /** Consecutive-or-not options sharing a `group` end up in one section, keeping the order in
51
58
  * which each group first appears; options without a group form an unnamed leading section. */
52
59
  export declare const groupModelOptions: (options: ChatbotModelOption[]) => Array<{
53
60
  group?: string;
61
+ badge?: ChatbotModelOption["groupBadge"];
54
62
  options: ChatbotModelOption[];
55
63
  }>;
56
64
  export declare const isFreeModelOption: (option: ChatbotModelOption) => boolean;
@@ -80,7 +80,7 @@ export { loadGoogleMaps } from './providers/googleMaps/loadGoogleMaps';
80
80
  export type { GoogleMapsConfig } from './providers/googleMaps/loadGoogleMaps';
81
81
  export { useEmailProvider, EmailProvider } from './providers/email/EmailProviderContext';
82
82
  export { GmailEmailProvider } from './providers/email/google/GmailEmailProvider';
83
- export type { AIRequestOptions, AIAttachment, AIProviderAdapter, AIKeyValidationResult, AIModelDescriptor, AIModelPricing, DiscoveredAIModel, AIProviderCapabilities, AIModelCatalog, AIProviderDefinition, AICompleteRequest, AICompleteResult, AIConversationTurn, AIToolDefinition, AIToolCall, AIToolResult, CloudflareProviderOptions, ServerAIProviderConnection, ServerAIConnection, ModelIdentity, ModelIdentityEntry, ModelIdentityIndex, ResolvedModel, ModelOffer, ModelCost, } from './providers/ai';
83
+ export type { AIRequestOptions, AIReasoningLevel, AIAttachment, AIProviderAdapter, AIKeyValidationResult, AIModelDescriptor, AIModelPricing, DiscoveredAIModel, AIProviderCapabilities, AIModelCatalog, AIProviderDefinition, AICompleteRequest, AICompleteResult, AIConversationTurn, AIToolDefinition, AIToolCall, AIToolResult, CloudflareProviderOptions, ServerAIProviderConnection, ServerAIConnection, ModelIdentity, ModelIdentityEntry, ModelIdentityIndex, ResolvedModel, ModelOffer, ModelCost, } from './providers/ai';
84
84
  export { createAIProviderRegistry, getAIModelCatalog, formatAIModelRef, parseAIModelRef, isFreeAIModel, AI_PROVIDER_DEFINITIONS, AI_PROVIDER_DESCRIPTORS, OPENAI_COMPATIBLE_PROVIDER_DESCRIPTOR, CLOUDFLARE_PROVIDER_DESCRIPTOR, createCloudflareProviderDefinition, toProviderDescriptor, createServerCredentialAIRegistry, serverCredential, SERVER_CREDENTIAL_PREFIX, AI_PROVIDER_HOSTS, isAIProviderTarget, canonicalModelName, buildModelIdentityIndex, resolveModel, modelOffers, loadModelIdentityIndex } from './providers/ai';
85
85
  export type { ProviderDescriptor, ProviderCredentialField } from './providers/ProviderDescriptor';
86
86
  export { useAIProvider, useAIProviderRegistry, AIProvider } from './providers/ai/AIProviderContext';
@@ -32,6 +32,8 @@ export interface AIAttachment {
32
32
  base64: string;
33
33
  name?: string;
34
34
  }
35
+ /** How much a model reasons before it answers (CR-122). */
36
+ export type AIReasoningLevel = 'low' | 'medium' | 'high' | 'max';
35
37
  export interface AIRequestOptions {
36
38
  language?: string;
37
39
  voice?: string;
@@ -40,6 +42,12 @@ export interface AIRequestOptions {
40
42
  model?: string;
41
43
  temperature?: number;
42
44
  attachments?: AIAttachment[];
45
+ /**
46
+ * How much the model reasons (CR-122), on the models that take it: Anthropic `output_config.effort`
47
+ * (Claude 4.6 and later), OpenAI `reasoning_effort` (o-series, GPT-5; `max` as `high`), OpenRouter
48
+ * `reasoning.effort`. Elsewhere (older models, Gemini) nothing is sent. Absent: the default of the model.
49
+ */
50
+ reasoning?: AIReasoningLevel;
43
51
  }
44
52
  /** Definizione di un tool che il modello può scegliere di invocare — la SDK del provider
45
53
  * riceve solo questa forma (JSON-serializzabile); l'implementazione vera resta lato
@@ -1,2 +1,2 @@
1
- import type { AIProviderDefinition } from './shared';
1
+ import { type AIProviderDefinition } from './shared';
2
2
  export declare const ANTHROPIC_PROVIDER_DEFINITION: AIProviderDefinition;
@@ -2,7 +2,7 @@ import type { AIConfig } from '../../Config';
2
2
  import type { ProviderDescriptor } from '../ProviderDescriptor';
3
3
  import type { AIProviderAdapter } from './AIProvider';
4
4
  import { type AIProviderDefinition, type BuiltInAIProviderId } from './shared';
5
- export type { AIProviderAdapter, AIKeyValidationResult, AIModelDescriptor, AIModelPricing, AIProviderCapabilities, AIRequestOptions, AIAttachment, AICompleteRequest, AICompleteResult, AIConversationTurn, AIToolDefinition, AIToolCall, AIToolResult, } from './AIProvider';
5
+ export type { AIProviderAdapter, AIKeyValidationResult, AIModelDescriptor, AIModelPricing, AIProviderCapabilities, AIRequestOptions, AIReasoningLevel, AIAttachment, AICompleteRequest, AICompleteResult, AIConversationTurn, AIToolDefinition, AIToolCall, AIToolResult, } from './AIProvider';
6
6
  export { formatAIModelRef, parseAIModelRef, isFreeAIModel } from './AIProvider';
7
7
  export type { DiscoveredAIModel } from './shared';
8
8
  export type { AIModelCatalog, AIProviderDefinition } from './shared';
@@ -17,6 +17,8 @@ type OpenAICompatibleDefinitionOptions = {
17
17
  validateApiKey?: AIProviderDefinition['validateApiKey'];
18
18
  /** Maps one `/models` entry — for providers whose listing also reports prices (OpenRouter). */
19
19
  mapModelEntry?: (entry: Record<string, unknown>) => string | DiscoveredAIModel | undefined;
20
+ /** How a reasoning level is sent (CR-122): `reasoning_effort` on the reasoning models of OpenAI, or OpenRouter's `reasoning.effort`. */
21
+ reasoningStyle?: 'openai' | 'openrouter';
20
22
  };
21
23
  /** Esportate per riuso da provider "chat completions"-simili ma non costruiti tramite
22
24
  * createOpenAICompatibleProviderDefinition (vedi opencode.ts) — stesso wire format OpenAI,
@@ -39,5 +41,5 @@ export declare function parseOpenAIResponse(response: {
39
41
  message?: Record<string, unknown>;
40
42
  }>;
41
43
  } | null): AICompleteResult | null;
42
- export declare const createOpenAICompatibleProviderDefinition: ({ id, label, description, configKey, requiredConfigKeys, defaultModel, fallbackModels, baseUrl, modelsUrl, chatCompletionsUrl, dashboardUrl, credentialsHint, validateApiKey: validateApiKeyOverride, mapModelEntry, }: OpenAICompatibleDefinitionOptions) => AIProviderDefinition;
44
+ export declare const createOpenAICompatibleProviderDefinition: ({ id, label, description, configKey, requiredConfigKeys, defaultModel, fallbackModels, baseUrl, modelsUrl, chatCompletionsUrl, dashboardUrl, credentialsHint, validateApiKey: validateApiKeyOverride, mapModelEntry, reasoningStyle, }: OpenAICompatibleDefinitionOptions) => AIProviderDefinition;
43
45
  export {};
@@ -1,6 +1,6 @@
1
1
  import { type ProviderConfigurationState } from '../ProviderConfiguration';
2
2
  import type { ProviderCredentialField } from '../ProviderDescriptor';
3
- import type { AICompleteRequest, AICompleteResult, AIKeyValidationResult, AIModelDescriptor, AIModelPricing, AIProviderAdapter, AIProviderCapabilities, AIRequestOptions } from './AIProvider';
3
+ import type { AICompleteRequest, AICompleteResult, AIKeyValidationResult, AIModelDescriptor, AIModelPricing, AIProviderAdapter, AIProviderCapabilities, AIReasoningLevel, AIRequestOptions } from './AIProvider';
4
4
  export type BuiltInAIProviderId = 'openai' | 'openrouter' | 'opencode' | 'opencode-go' | 'openai-compatible' | 'deepseek' | 'gemini' | 'anthropic' | 'mistral' | 'glm' | 'cloudflare' | 'groq';
5
5
  /** A discovered model carrying the price its provider listing already reports (OpenRouter,
6
6
  * Cloudflare). Models discovered as a bare id get their price from models.dev instead. */
@@ -41,6 +41,14 @@ export type AIModelCatalog = {
41
41
  modelsByProvider: Record<string, AIModelDescriptor[]>;
42
42
  capabilitiesByProvider: Record<string, AIProviderCapabilities>;
43
43
  };
44
+ /** What an Anthropic Messages request carries for a reasoning level (CR-122); nothing for a model that does not take it. */
45
+ export declare function anthropicReasoning(model: string | undefined, level: AIReasoningLevel | undefined): Record<string, unknown>;
46
+ /**
47
+ * What an OpenAI Chat Completions request carries for a reasoning level (CR-122): `reasoning_effort` on the
48
+ * reasoning models of OpenAI (`max` as `high`, their top); OpenRouter `reasoning.effort` on any model, which
49
+ * it maps itself. Nothing otherwise.
50
+ */
51
+ export declare function openAIReasoning(model: string | undefined, level: AIReasoningLevel | undefined, style?: 'openai' | 'openrouter'): Record<string, unknown>;
44
52
  export declare const extractProviderError: (err: unknown) => string;
45
53
  export declare const createBrowserTransportError: (label: string) => Error;
46
54
  export declare const parseTextResponse: (value: unknown) => string | null;
package/llms-full.txt CHANGED
@@ -1150,6 +1150,8 @@ const catalog = getAIModelCatalog() // modelli disponibili
1150
1150
  // non trovato (il modello resta in lista). isFreeAIModel(m) → input e output a 0.
1151
1151
  // Il model picker di Prompt/Chatbot mostra "$in / $out", evidenzia i free, segnala i mancanti,
1152
1152
  // e raggruppa per provider (ChatbotModelOption.group = providerLabel) con header sticky.
1153
+ // CR-121: il pulsante mostra la `label` del modello scelto (non il suo valore); `groupBadge: { label, variant? }`
1154
+ // su un'opzione mette un Badge a destra nell'header del suo gruppo (es. Abbonamento / A consumo).
1153
1155
 
1154
1156
  // Provider adapter restituito da useAIProvider()
1155
1157
  const text = await provider.fetch("Scrivi un titolo per: {keyword}", { keyword: "React" })
@@ -1163,6 +1165,13 @@ class MyAIProvider implements AIProviderAdapter {
1163
1165
  async array(prompt: string, options?: AIRequestOptions): Promise<string[]> { ... }
1164
1166
  }
1165
1167
 
1168
+ // Quanto ragiona il modello (CR-122): `reasoning: 'low' | 'medium' | 'high' | 'max'` (AIReasoningLevel) su
1169
+ // una richiesta. Anthropic: `output_config.effort` sui Claude 4.6 e successivi (+ thinking adaptive su Opus
1170
+ // 4.6-4.8 e Sonnet 4.6); OpenAI e compatibili (OpenCode, DeepSeek, Groq…): `reasoning_effort` solo sui modelli
1171
+ // di ragionamento di OpenAI (serie o, GPT-5; max = high); OpenRouter: `reasoning.effort` su ogni modello.
1172
+ // Altrove (modelli più vecchi, Gemini) non si manda nulla: il default del modello.
1173
+ await ai.complete({ prompt: 'Rivedi questo piano', model: 'claude-opus-5-5', reasoning: 'high' })
1174
+
1166
1175
  // Factory per registri esterni
1167
1176
  const registry = createAIProviderRegistry(definitions)
1168
1177
  // Azioni di Chatbot (CR-107): con `content` aprono un menu; senza, sono pulsanti con `onClick`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmnative/react",
3
- "version": "1.44.0",
3
+ "version": "1.46.0",
4
4
  "description": "LLM-native React framework for deterministic UI generation. Data-driven by default, schema-driven optional. Ultra-low token consumption — built for AI agents, not just humans.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",