art-framework 0.2.5 → 0.2.6

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
@@ -1550,61 +1550,69 @@ declare class OpenAIAdapter implements ProviderAdapter {
1550
1550
  interface AnthropicAdapterOptions {
1551
1551
  /** Your Anthropic API key. Handle securely. */
1552
1552
  apiKey: string;
1553
- /** The default Anthropic model ID to use (e.g., 'claude-3-opus-20240229', 'claude-3-5-sonnet-20240620'). Defaults to 'claude-3-haiku-20240307' if not provided. */
1553
+ /** The default Anthropic model ID to use (e.g., 'claude-3-opus-20240229', 'claude-3-5-sonnet-20240620'). */
1554
1554
  model?: string;
1555
- /** Optional: The Anthropic API version to target (e.g., '2023-06-01'). Defaults to '2023-06-01'. */
1556
- apiVersion?: string;
1557
1555
  /** Optional: Override the base URL for the Anthropic API. */
1558
1556
  apiBaseUrl?: string;
1557
+ /** Optional: Default maximum tokens for responses. */
1558
+ defaultMaxTokens?: number;
1559
+ /** Optional: Default temperature for responses. */
1560
+ defaultTemperature?: number;
1559
1561
  }
1560
1562
  /**
1561
1563
  * Implements the `ProviderAdapter` interface for interacting with Anthropic's
1562
- * Messages API (Claude models).
1564
+ * Messages API (Claude models) using the official SDK.
1563
1565
  *
1564
- * Handles formatting requests and parsing responses for Anthropic.
1565
- * Note: Streaming is **not yet implemented** for this adapter. Calls requesting streaming will yield an error and end.
1566
+ * Handles formatting requests, parsing responses, streaming, and tool use.
1566
1567
  *
1567
1568
  * @implements {ProviderAdapter}
1568
1569
  */
1569
1570
  declare class AnthropicAdapter implements ProviderAdapter {
1570
1571
  readonly providerName = "anthropic";
1571
- private apiKey;
1572
- private model;
1573
- private apiVersion;
1574
- private apiBaseUrl;
1572
+ private client;
1573
+ private defaultModel;
1575
1574
  private defaultMaxTokens;
1575
+ private defaultTemperature?;
1576
1576
  /**
1577
1577
  * Creates an instance of the AnthropicAdapter.
1578
- * @param options - Configuration options including the API key and optional model/apiVersion/baseURL overrides.
1579
- * @throws {Error} If the API key is missing.
1578
+ * @param options - Configuration options including the API key and optional model/baseURL/defaults.
1579
+ * @throws {ARTError} If the API key is missing.
1580
1580
  */
1581
1581
  constructor(options: AnthropicAdapterOptions);
1582
1582
  /**
1583
1583
  * Sends a request to the Anthropic Messages API.
1584
- * Translates `ArtStandardPrompt` to the Anthropic format.
1585
- *
1586
- * **Note:** Streaming is **not yet implemented**.
1584
+ * Translates `ArtStandardPrompt` to the Anthropic format and handles streaming and tool use.
1587
1585
  *
1588
1586
  * @param {ArtStandardPrompt} prompt - The standardized prompt messages.
1589
- * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream`, and any Anthropic-specific generation parameters.
1590
- * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects. If streaming is requested, it yields an error event and ends.
1591
- * @throws {ARTError} If `max_tokens` is missing in options (required by Anthropic).
1587
+ * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream`, `callContext`,
1588
+ * `model` (override), `tools` (available tools), and Anthropic-specific
1589
+ * generation parameters from `providerConfig.adapterOptions`.
1590
+ * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
1592
1591
  */
1593
1592
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
1594
1593
  /**
1595
- * Translates the provider-agnostic `ArtStandardPrompt` into the Anthropic Messages API format.
1594
+ * Prepares request options. Currently a placeholder for potential future additions
1595
+ * like Anthropic beta headers for specific models or features (e.g., prompt caching).
1596
+ * The user's example code shows more advanced beta header logic.
1597
+ */
1598
+ private getRequestOptions;
1599
+ /**
1600
+ * Translates the provider-agnostic `ArtStandardPrompt` into the Anthropic SDK Messages format.
1596
1601
  *
1597
1602
  * @private
1598
1603
  * @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
1599
- * @returns {{ systemPrompt?: string; messages: AnthropicMessage[] }} The system prompt string and the `AnthropicMessage[]` array.
1600
- * @throws {ARTError} If translation encounters an issue (ErrorCode.PROMPT_TRANSLATION_FAILED).
1604
+ * @returns {{ systemPrompt?: string; messages: AnthropicSDKMessageParam[] }}
1605
+ * @throws {ARTError} If translation encounters an issue.
1601
1606
  */
1602
- private translateToAnthropic;
1607
+ private translateToAnthropicSdk;
1603
1608
  /**
1604
- * Helper to map ArtStandardMessage content/tool_calls to Anthropic Content Blocks.
1605
- * @private
1609
+ * Maps a single ArtStandardMessage to Anthropic SDK's content format (string or AnthropicSDKContentBlockParam[]).
1610
+ */
1611
+ private mapArtMessageToAnthropicContent;
1612
+ /**
1613
+ * Translates ART ToolSchema array to Anthropic's tool format.
1606
1614
  */
1607
- private mapArtContentToAnthropicBlocks;
1615
+ private translateArtToolsToAnthropic;
1608
1616
  }
1609
1617
 
1610
1618
  /**
package/dist/index.d.ts CHANGED
@@ -1550,61 +1550,69 @@ declare class OpenAIAdapter implements ProviderAdapter {
1550
1550
  interface AnthropicAdapterOptions {
1551
1551
  /** Your Anthropic API key. Handle securely. */
1552
1552
  apiKey: string;
1553
- /** The default Anthropic model ID to use (e.g., 'claude-3-opus-20240229', 'claude-3-5-sonnet-20240620'). Defaults to 'claude-3-haiku-20240307' if not provided. */
1553
+ /** The default Anthropic model ID to use (e.g., 'claude-3-opus-20240229', 'claude-3-5-sonnet-20240620'). */
1554
1554
  model?: string;
1555
- /** Optional: The Anthropic API version to target (e.g., '2023-06-01'). Defaults to '2023-06-01'. */
1556
- apiVersion?: string;
1557
1555
  /** Optional: Override the base URL for the Anthropic API. */
1558
1556
  apiBaseUrl?: string;
1557
+ /** Optional: Default maximum tokens for responses. */
1558
+ defaultMaxTokens?: number;
1559
+ /** Optional: Default temperature for responses. */
1560
+ defaultTemperature?: number;
1559
1561
  }
1560
1562
  /**
1561
1563
  * Implements the `ProviderAdapter` interface for interacting with Anthropic's
1562
- * Messages API (Claude models).
1564
+ * Messages API (Claude models) using the official SDK.
1563
1565
  *
1564
- * Handles formatting requests and parsing responses for Anthropic.
1565
- * Note: Streaming is **not yet implemented** for this adapter. Calls requesting streaming will yield an error and end.
1566
+ * Handles formatting requests, parsing responses, streaming, and tool use.
1566
1567
  *
1567
1568
  * @implements {ProviderAdapter}
1568
1569
  */
1569
1570
  declare class AnthropicAdapter implements ProviderAdapter {
1570
1571
  readonly providerName = "anthropic";
1571
- private apiKey;
1572
- private model;
1573
- private apiVersion;
1574
- private apiBaseUrl;
1572
+ private client;
1573
+ private defaultModel;
1575
1574
  private defaultMaxTokens;
1575
+ private defaultTemperature?;
1576
1576
  /**
1577
1577
  * Creates an instance of the AnthropicAdapter.
1578
- * @param options - Configuration options including the API key and optional model/apiVersion/baseURL overrides.
1579
- * @throws {Error} If the API key is missing.
1578
+ * @param options - Configuration options including the API key and optional model/baseURL/defaults.
1579
+ * @throws {ARTError} If the API key is missing.
1580
1580
  */
1581
1581
  constructor(options: AnthropicAdapterOptions);
1582
1582
  /**
1583
1583
  * Sends a request to the Anthropic Messages API.
1584
- * Translates `ArtStandardPrompt` to the Anthropic format.
1585
- *
1586
- * **Note:** Streaming is **not yet implemented**.
1584
+ * Translates `ArtStandardPrompt` to the Anthropic format and handles streaming and tool use.
1587
1585
  *
1588
1586
  * @param {ArtStandardPrompt} prompt - The standardized prompt messages.
1589
- * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream`, and any Anthropic-specific generation parameters.
1590
- * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects. If streaming is requested, it yields an error event and ends.
1591
- * @throws {ARTError} If `max_tokens` is missing in options (required by Anthropic).
1587
+ * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream`, `callContext`,
1588
+ * `model` (override), `tools` (available tools), and Anthropic-specific
1589
+ * generation parameters from `providerConfig.adapterOptions`.
1590
+ * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
1592
1591
  */
1593
1592
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
1594
1593
  /**
1595
- * Translates the provider-agnostic `ArtStandardPrompt` into the Anthropic Messages API format.
1594
+ * Prepares request options. Currently a placeholder for potential future additions
1595
+ * like Anthropic beta headers for specific models or features (e.g., prompt caching).
1596
+ * The user's example code shows more advanced beta header logic.
1597
+ */
1598
+ private getRequestOptions;
1599
+ /**
1600
+ * Translates the provider-agnostic `ArtStandardPrompt` into the Anthropic SDK Messages format.
1596
1601
  *
1597
1602
  * @private
1598
1603
  * @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
1599
- * @returns {{ systemPrompt?: string; messages: AnthropicMessage[] }} The system prompt string and the `AnthropicMessage[]` array.
1600
- * @throws {ARTError} If translation encounters an issue (ErrorCode.PROMPT_TRANSLATION_FAILED).
1604
+ * @returns {{ systemPrompt?: string; messages: AnthropicSDKMessageParam[] }}
1605
+ * @throws {ARTError} If translation encounters an issue.
1601
1606
  */
1602
- private translateToAnthropic;
1607
+ private translateToAnthropicSdk;
1603
1608
  /**
1604
- * Helper to map ArtStandardMessage content/tool_calls to Anthropic Content Blocks.
1605
- * @private
1609
+ * Maps a single ArtStandardMessage to Anthropic SDK's content format (string or AnthropicSDKContentBlockParam[]).
1610
+ */
1611
+ private mapArtMessageToAnthropicContent;
1612
+ /**
1613
+ * Translates ART ToolSchema array to Anthropic's tool format.
1606
1614
  */
1607
- private mapArtContentToAnthropicBlocks;
1615
+ private translateArtToolsToAnthropic;
1608
1616
  }
1609
1617
 
1610
1618
  /**