art-framework 0.3.6 → 0.3.8

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
@@ -978,6 +978,8 @@ interface ConversationMessage {
978
978
  declare enum ObservationType {
979
979
  /** The user's inferred intent. */
980
980
  INTENT = "INTENT",
981
+ /** The generated concise thread title. */
982
+ TITLE = "TITLE",
981
983
  /** The agent's step-by-step plan to address the intent. */
982
984
  PLAN = "PLAN",
983
985
  /** The agent's internal monologue or reasoning process. */
@@ -1063,6 +1065,15 @@ interface Observation {
1063
1065
  title: string;
1064
1066
  /**
1065
1067
  * The main data payload of the observation, structure depends on the `type`.
1068
+ *
1069
+ * @remarks
1070
+ * Common content shapes by `type`:
1071
+ * - `TITLE`: `{ title: string }` — a concise thread title (<= 10 words)
1072
+ * - `INTENT`: `{ intent: string }`
1073
+ * - `PLAN`: `{ plan: string; rawOutput?: string }`
1074
+ * - `TOOL_CALL`: `{ toolCalls: ParsedToolCall[] }`
1075
+ * - `TOOL_EXECUTION`: `{ callId: string; toolName: string; status: 'success' | 'error'; output?: any; error?: string }`
1076
+ * - `FINAL_RESPONSE`: `{ message: ConversationMessage; uiMetadata?: object }`
1066
1077
  * @property {any} content
1067
1078
  */
1068
1079
  content: any;
@@ -2834,10 +2845,25 @@ interface OutputParser {
2834
2845
  * @returns A promise resolving to an object containing the extracted intent, plan description, and an array of parsed tool calls.
2835
2846
  * @throws {ARTError} If the output cannot be parsed into the expected structure (typically code `OUTPUT_PARSING_FAILED`).
2836
2847
  */
2848
+ /**
2849
+ * Parses the raw planning LLM output into structured fields.
2850
+ *
2851
+ * @remarks
2852
+ * This method should be resilient to provider-specific wrappers and formats.
2853
+ * Implementations MUST attempt JSON-first parsing and then fall back to parsing
2854
+ * labeled sections. Supported fields:
2855
+ * - `title?`: A concise thread title (<= 10 words), derived from the user's intent and context.
2856
+ * - `intent?`: A short summary of the user's goal.
2857
+ * - `plan?`: A human-readable list/description of steps.
2858
+ * - `toolCalls?`: Structured tool call intents parsed from the output.
2859
+ * - `thoughts?`: Aggregated content extracted from <think> tags when present.
2860
+ */
2837
2861
  parsePlanningOutput(output: string): Promise<{
2862
+ title?: string;
2838
2863
  intent?: string;
2839
2864
  plan?: string;
2840
2865
  toolCalls?: ParsedToolCall[];
2866
+ thoughts?: string;
2841
2867
  }>;
2842
2868
  /**
2843
2869
  * Parses the raw string output from the synthesis LLM call to extract the final, user-facing response content.
@@ -3753,6 +3779,11 @@ declare class PESAgent implements IAgentCore {
3753
3779
  /**
3754
3780
  * Performs the planning phase including LLM call and output parsing.
3755
3781
  * @private
3782
+ *
3783
+ * @remarks
3784
+ * The planning prompt instructs the LLM to produce a concise `title` (<= 10 words)
3785
+ * alongside `intent`, `plan`, and `toolCalls`. After parsing, a `TITLE` observation
3786
+ * is emitted (if present) for UI components to subscribe via `ObservationSocket`.
3756
3787
  */
3757
3788
  private _performPlanning;
3758
3789
  /**
@@ -4198,58 +4229,77 @@ declare class GeminiAdapter implements ProviderAdapter {
4198
4229
  interface OpenAIAdapterOptions {
4199
4230
  /** Your OpenAI API key. Handle securely. */
4200
4231
  apiKey: string;
4201
- /** The default OpenAI model ID to use (e.g., 'gpt-4o', 'gpt-4o-mini'). Defaults to 'gpt-3.5-turbo' if not provided. */
4232
+ /** The default OpenAI model ID to use (e.g., 'gpt-4o', 'gpt-5', 'gpt-5-mini'). */
4202
4233
  model?: string;
4203
4234
  /** Optional: Override the base URL for the OpenAI API (e.g., for Azure OpenAI or custom proxies). */
4204
4235
  apiBaseUrl?: string;
4236
+ /** Optional: Default maximum tokens for responses. */
4237
+ defaultMaxTokens?: number;
4238
+ /** Optional: Default temperature for responses. */
4239
+ defaultTemperature?: number;
4205
4240
  }
4206
4241
  /**
4207
4242
  * Implements the `ProviderAdapter` interface for interacting with OpenAI's
4208
- * Chat Completions API (compatible models like GPT-3.5, GPT-4, GPT-4o).
4243
+ * Responses API (supports reasoning models like GPT-5 family and other models).
4209
4244
  *
4210
- * Handles formatting requests and parsing responses for OpenAI.
4211
- * Uses raw `fetch` for now.
4245
+ * Handles formatting requests, parsing responses, streaming, reasoning token detection, and tool use.
4246
+ * Uses the official OpenAI SDK with the new Responses API for full reasoning model support.
4212
4247
  *
4213
4248
  * @see {@link ProviderAdapter} for the interface definition.
4249
+ * @see {@link OpenAIAdapterOptions} for configuration options.
4214
4250
  */
4215
4251
  declare class OpenAIAdapter implements ProviderAdapter {
4216
4252
  readonly providerName = "openai";
4217
- private apiKey;
4218
- private model;
4219
- private apiBaseUrl;
4253
+ private client;
4254
+ private defaultModel;
4255
+ private defaultMaxTokens;
4256
+ private defaultTemperature;
4220
4257
  /**
4221
4258
  * Creates an instance of the OpenAIAdapter.
4222
- * @param {OpenAIAdapterOptions} options - Configuration options including the API key and optional model/baseURL overrides.
4223
- * @throws {Error} If the API key is missing.
4224
- * @see https://platform.openai.com/docs/api-reference
4259
+ * @param options - Configuration options including the API key and optional model/baseURL/defaults.
4260
+ * @throws {ARTError} If the API key is missing.
4225
4261
  */
4226
4262
  constructor(options: OpenAIAdapterOptions);
4227
4263
  /**
4228
- * Sends a request to the OpenAI Chat Completions API.
4229
- * Translates `ArtStandardPrompt` to the OpenAI format, handles streaming and non-streaming responses.
4264
+ * Sends a request to the OpenAI Responses API.
4265
+ * Translates `ArtStandardPrompt` to the Responses API format and handles streaming/reasoning.
4230
4266
  *
4231
4267
  * @param {ArtStandardPrompt} prompt - The standardized prompt messages.
4232
- * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream` preference, and any OpenAI-specific parameters (like `temperature`, `max_tokens`) passed through.
4268
+ * @param {CallOptions} options - Call options, including streaming, reasoning options, and model parameters.
4233
4269
  * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
4234
- * @see https://platform.openai.com/docs/api-reference/chat/create
4235
4270
  */
4236
4271
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4237
4272
  /**
4238
- * Processes the Server-Sent Events (SSE) stream from OpenAI.
4239
- * @param stream - The ReadableStream from the fetch response.
4240
- * @param options - The original CallOptions containing threadId, traceId, sessionId, and callContext.
4241
- * @returns An AsyncIterable yielding StreamEvent objects.
4242
- */
4243
- private processStream;
4273
+ * Optional: Method for graceful shutdown
4274
+ */
4275
+ shutdown(): Promise<void>;
4244
4276
  /**
4245
- * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI API's `OpenAIMessage[]` format.
4277
+ * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI Responses API format.
4278
+ * Extracts system prompt separately and formats messages as input array.
4246
4279
  *
4247
4280
  * @private
4248
4281
  * @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
4249
- * @returns {OpenAIMessage[]} The `OpenAIMessage[]` array formatted for the OpenAI API.
4250
- * @throws {ARTError} If translation encounters an issue (ErrorCode.PROMPT_TRANSLATION_FAILED).
4282
+ * @returns {{ systemPrompt?: string; input: OpenAIResponsesInputMessage[] }} An object containing the extracted system prompt and the array of Responses API formatted input messages.
4283
+ * @throws {ARTError} If translation encounters an issue.
4251
4284
  */
4252
- private translateToOpenAI;
4285
+ private translateToResponsesFormat;
4286
+ /**
4287
+ * Maps a single `ArtStandardMessage` to OpenAI Responses API input format.
4288
+ *
4289
+ * @private
4290
+ * @param {ArtStandardMessage} artMsg - The ART standard message to map.
4291
+ * @returns {OpenAIResponsesInputMessage | null} The translated message for the Responses API, or null if should be skipped.
4292
+ * @throws {ARTError} If tool call arguments are not valid JSON.
4293
+ */
4294
+ private mapArtMessageToResponsesContent;
4295
+ /**
4296
+ * Translates an array of `ToolSchema` from the ART framework format to OpenAI's Responses API tool format.
4297
+ * @private
4298
+ * @param {ToolSchema[]} artTools - An array of ART tool schemas.
4299
+ * @returns {OpenAIResponsesTool[]} An array of tools formatted for the OpenAI Responses API.
4300
+ * @throws {ARTError} If a tool's `inputSchema` is invalid.
4301
+ */
4302
+ private translateArtToolsToOpenAI;
4253
4303
  }
4254
4304
 
4255
4305
  /**
@@ -4299,9 +4349,12 @@ declare class AnthropicAdapter implements ProviderAdapter {
4299
4349
  * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
4300
4350
  */
4301
4351
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4352
+ /**
4353
+ * Optional: Method for graceful shutdown
4354
+ */
4355
+ shutdown(): Promise<void>;
4302
4356
  /**
4303
4357
  * Prepares request options, adding Anthropic beta headers if applicable for features like prompt caching.
4304
- * This allows opting into experimental features on a per-request basis.
4305
4358
  * @private
4306
4359
  * @param {string} modelId - The model ID being used for the request, to determine which beta features may apply.
4307
4360
  * @returns {Anthropic.RequestOptions} The request options object, potentially with custom headers.
@@ -4338,28 +4391,13 @@ declare class AnthropicAdapter implements ProviderAdapter {
4338
4391
  private translateArtToolsToAnthropic;
4339
4392
  }
4340
4393
 
4341
- /**
4342
- * Configuration options required for the `OpenRouterAdapter`.
4343
- */
4344
4394
  interface OpenRouterAdapterOptions {
4345
- /** Your OpenRouter API key. Handle securely. */
4346
4395
  apiKey: string;
4347
- /** The required OpenRouter model identifier string (e.g., 'google/gemini-pro', 'anthropic/claude-3-haiku', 'openai/gpt-4o'). This specifies which underlying model OpenRouter should use. */
4348
4396
  model: string;
4349
- /** Optional: Override the base URL for the OpenRouter API. Defaults to 'https://openrouter.ai/api/v1'. */
4350
4397
  apiBaseUrl?: string;
4351
- /** Optional: Your application's site URL, sent as the 'HTTP-Referer' header (recommended by OpenRouter). */
4352
4398
  siteUrl?: string;
4353
- /** Optional: Your application's name, sent as the 'X-Title' header (recommended by OpenRouter). */
4354
4399
  appName?: string;
4355
4400
  }
4356
- /**
4357
- * This adapter provides a unified interface for various LLM providers through OpenRouter,
4358
- * handling prompt conversion and response parsing into the ART `StreamEvent` format.
4359
- *
4360
- * @see {@link ProviderAdapter} for the interface it implements.
4361
- * @see {@link OpenRouterAdapterOptions} for configuration options.
4362
- */
4363
4401
  declare class OpenRouterAdapter implements ProviderAdapter {
4364
4402
  readonly providerName = "openrouter";
4365
4403
  private apiKey;
@@ -4367,34 +4405,11 @@ declare class OpenRouterAdapter implements ProviderAdapter {
4367
4405
  private apiBaseUrl;
4368
4406
  private siteUrl?;
4369
4407
  private appName?;
4370
- /**
4371
- * Creates an instance of the OpenRouterAdapter.
4372
- * @param {OpenRouterAdapterOptions} options - Configuration options including the API key, the specific OpenRouter model identifier, and optional headers/baseURL.
4373
- * @throws {Error} If the API key or model identifier is missing.
4374
- * @see https://openrouter.ai/docs
4375
- */
4376
4408
  constructor(options: OpenRouterAdapterOptions);
4377
- /**
4378
- * Sends a request to the OpenRouter Chat Completions API endpoint.
4379
- * Translates `ArtStandardPrompt` to the OpenAI-compatible format.
4380
- *
4381
- * **Note:** Streaming is **not yet implemented**.
4382
- *
4383
- * @param {ArtStandardPrompt} prompt - The standardized prompt messages.
4384
- * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream`, and any OpenAI-compatible generation parameters.
4385
- * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects. If streaming is requested, it yields an error event and ends.
4386
- * @see https://openrouter.ai/docs#api-reference-chat-completions
4387
- */
4388
4409
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4389
- /**
4390
- * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI API's `OpenAIMessage[]` format.
4391
- * (Copied from OpenAIAdapter - assumes OpenRouter compatibility)
4392
- *
4393
- * @private
4394
- * @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
4395
- * @returns {OpenAIMessage[]} The `OpenAIMessage[]` array formatted for the OpenAI API.
4396
- * @throws {ARTError} If translation encounters an issue (ErrorCode.PROMPT_TRANSLATION_FAILED).
4397
- */
4410
+ private processStream;
4411
+ private processNonStreamingResponse;
4412
+ private translateArtToolsToOpenAI;
4398
4413
  private translateToOpenAI;
4399
4414
  }
4400
4415
 
@@ -5236,6 +5251,6 @@ declare const generateUUID: () => string;
5236
5251
  /**
5237
5252
  * The current version of the ART Framework package.
5238
5253
  */
5239
- declare const VERSION = "0.3.5";
5254
+ declare const VERSION = "0.3.8";
5240
5255
 
5241
5256
  export { type A2AAgentInfo, type A2ATask, type A2ATaskEvent, type A2ATaskFilter, type A2ATaskMetadata, A2ATaskPriority, type A2ATaskResult, A2ATaskSocket, A2ATaskStatus, ARTError, AdapterInstantiationError, type AgentDiscoveryConfig, AgentDiscoveryService, type AgentFinalResponse, type AgentOptions, type AgentPersona, type AgentProps, type AgentState, AnthropicAdapter, type AnthropicAdapterOptions, ApiKeyStrategy, ApiQueueTimeoutError, type ArtInstance, type ArtInstanceConfig, type ArtStandardMessage, type ArtStandardMessageRole, ArtStandardMessageSchema, type ArtStandardPrompt, ArtStandardPromptSchema, AuthManager, type AvailableProviderEntry, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, ConversationSocket, type CreateA2ATaskRequest, DeepSeekAdapter, type DeepSeekAdapterOptions, ErrorCode, type ExecutionContext, type ExecutionMetadata, type FilterOptions, type FormattedPrompt, GeminiAdapter, type GeminiAdapterOptions, GenericOAuthStrategy, type IA2ATaskRepository, type IAgentCore, type IAuthStrategy, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, type ITypedSocket, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LLMStreamSocket, LocalInstanceBusyError, LocalProviderConflictError, LogLevel, Logger, type LoggerConfig, type ManagedAdapterAccessor, McpClientController, McpManager, type McpManagerConfig, McpProxyTool, type McpResource, type McpResourceTemplate, type McpServerConfig, type McpServerStatus, type McpToolDefinition, type MessageOptions, MessageRole, ModelCapability, type OAuthConfig, type Observation, type ObservationFilter, type ObservationManager, ObservationSocket, ObservationType, OllamaAdapter, type OllamaAdapterOptions, OpenAIAdapter, type OpenAIAdapterOptions, OpenRouterAdapter, type OpenRouterAdapterOptions, type OutputParser, PESAgent, type PKCEOAuthConfig, PKCEOAuthStrategy, type ParsedToolCall, type PromptBlueprint, type PromptContext, type PromptManager, type ProviderAdapter, type ProviderManagerConfig, ProviderManagerImpl, type ReasoningEngine, type RuntimeProviderConfig, type StageSpecificPrompts, StateManager, type StateSavingStrategy, type StorageAdapter, type StreamEvent, type StreamEventTypeFilter, SupabaseStorageAdapter, type SystemPromptMergeStrategy, type SystemPromptOverride, type SystemPromptResolver, type SystemPromptSpec, type SystemPromptsRegistry, type TaskDelegationConfig, TaskDelegationService, type TaskStatusResponse, type ThreadConfig, type ThreadContext, ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem, TypedSocket, UISystem, UnknownProviderError, type UnsubscribeFunction, type UpdateA2ATaskRequest, VERSION, type ZyntopiaOAuthConfig, ZyntopiaOAuthStrategy, createArtInstance, generateUUID };
package/dist/index.d.ts CHANGED
@@ -978,6 +978,8 @@ interface ConversationMessage {
978
978
  declare enum ObservationType {
979
979
  /** The user's inferred intent. */
980
980
  INTENT = "INTENT",
981
+ /** The generated concise thread title. */
982
+ TITLE = "TITLE",
981
983
  /** The agent's step-by-step plan to address the intent. */
982
984
  PLAN = "PLAN",
983
985
  /** The agent's internal monologue or reasoning process. */
@@ -1063,6 +1065,15 @@ interface Observation {
1063
1065
  title: string;
1064
1066
  /**
1065
1067
  * The main data payload of the observation, structure depends on the `type`.
1068
+ *
1069
+ * @remarks
1070
+ * Common content shapes by `type`:
1071
+ * - `TITLE`: `{ title: string }` — a concise thread title (<= 10 words)
1072
+ * - `INTENT`: `{ intent: string }`
1073
+ * - `PLAN`: `{ plan: string; rawOutput?: string }`
1074
+ * - `TOOL_CALL`: `{ toolCalls: ParsedToolCall[] }`
1075
+ * - `TOOL_EXECUTION`: `{ callId: string; toolName: string; status: 'success' | 'error'; output?: any; error?: string }`
1076
+ * - `FINAL_RESPONSE`: `{ message: ConversationMessage; uiMetadata?: object }`
1066
1077
  * @property {any} content
1067
1078
  */
1068
1079
  content: any;
@@ -2834,10 +2845,25 @@ interface OutputParser {
2834
2845
  * @returns A promise resolving to an object containing the extracted intent, plan description, and an array of parsed tool calls.
2835
2846
  * @throws {ARTError} If the output cannot be parsed into the expected structure (typically code `OUTPUT_PARSING_FAILED`).
2836
2847
  */
2848
+ /**
2849
+ * Parses the raw planning LLM output into structured fields.
2850
+ *
2851
+ * @remarks
2852
+ * This method should be resilient to provider-specific wrappers and formats.
2853
+ * Implementations MUST attempt JSON-first parsing and then fall back to parsing
2854
+ * labeled sections. Supported fields:
2855
+ * - `title?`: A concise thread title (<= 10 words), derived from the user's intent and context.
2856
+ * - `intent?`: A short summary of the user's goal.
2857
+ * - `plan?`: A human-readable list/description of steps.
2858
+ * - `toolCalls?`: Structured tool call intents parsed from the output.
2859
+ * - `thoughts?`: Aggregated content extracted from <think> tags when present.
2860
+ */
2837
2861
  parsePlanningOutput(output: string): Promise<{
2862
+ title?: string;
2838
2863
  intent?: string;
2839
2864
  plan?: string;
2840
2865
  toolCalls?: ParsedToolCall[];
2866
+ thoughts?: string;
2841
2867
  }>;
2842
2868
  /**
2843
2869
  * Parses the raw string output from the synthesis LLM call to extract the final, user-facing response content.
@@ -3753,6 +3779,11 @@ declare class PESAgent implements IAgentCore {
3753
3779
  /**
3754
3780
  * Performs the planning phase including LLM call and output parsing.
3755
3781
  * @private
3782
+ *
3783
+ * @remarks
3784
+ * The planning prompt instructs the LLM to produce a concise `title` (<= 10 words)
3785
+ * alongside `intent`, `plan`, and `toolCalls`. After parsing, a `TITLE` observation
3786
+ * is emitted (if present) for UI components to subscribe via `ObservationSocket`.
3756
3787
  */
3757
3788
  private _performPlanning;
3758
3789
  /**
@@ -4198,58 +4229,77 @@ declare class GeminiAdapter implements ProviderAdapter {
4198
4229
  interface OpenAIAdapterOptions {
4199
4230
  /** Your OpenAI API key. Handle securely. */
4200
4231
  apiKey: string;
4201
- /** The default OpenAI model ID to use (e.g., 'gpt-4o', 'gpt-4o-mini'). Defaults to 'gpt-3.5-turbo' if not provided. */
4232
+ /** The default OpenAI model ID to use (e.g., 'gpt-4o', 'gpt-5', 'gpt-5-mini'). */
4202
4233
  model?: string;
4203
4234
  /** Optional: Override the base URL for the OpenAI API (e.g., for Azure OpenAI or custom proxies). */
4204
4235
  apiBaseUrl?: string;
4236
+ /** Optional: Default maximum tokens for responses. */
4237
+ defaultMaxTokens?: number;
4238
+ /** Optional: Default temperature for responses. */
4239
+ defaultTemperature?: number;
4205
4240
  }
4206
4241
  /**
4207
4242
  * Implements the `ProviderAdapter` interface for interacting with OpenAI's
4208
- * Chat Completions API (compatible models like GPT-3.5, GPT-4, GPT-4o).
4243
+ * Responses API (supports reasoning models like GPT-5 family and other models).
4209
4244
  *
4210
- * Handles formatting requests and parsing responses for OpenAI.
4211
- * Uses raw `fetch` for now.
4245
+ * Handles formatting requests, parsing responses, streaming, reasoning token detection, and tool use.
4246
+ * Uses the official OpenAI SDK with the new Responses API for full reasoning model support.
4212
4247
  *
4213
4248
  * @see {@link ProviderAdapter} for the interface definition.
4249
+ * @see {@link OpenAIAdapterOptions} for configuration options.
4214
4250
  */
4215
4251
  declare class OpenAIAdapter implements ProviderAdapter {
4216
4252
  readonly providerName = "openai";
4217
- private apiKey;
4218
- private model;
4219
- private apiBaseUrl;
4253
+ private client;
4254
+ private defaultModel;
4255
+ private defaultMaxTokens;
4256
+ private defaultTemperature;
4220
4257
  /**
4221
4258
  * Creates an instance of the OpenAIAdapter.
4222
- * @param {OpenAIAdapterOptions} options - Configuration options including the API key and optional model/baseURL overrides.
4223
- * @throws {Error} If the API key is missing.
4224
- * @see https://platform.openai.com/docs/api-reference
4259
+ * @param options - Configuration options including the API key and optional model/baseURL/defaults.
4260
+ * @throws {ARTError} If the API key is missing.
4225
4261
  */
4226
4262
  constructor(options: OpenAIAdapterOptions);
4227
4263
  /**
4228
- * Sends a request to the OpenAI Chat Completions API.
4229
- * Translates `ArtStandardPrompt` to the OpenAI format, handles streaming and non-streaming responses.
4264
+ * Sends a request to the OpenAI Responses API.
4265
+ * Translates `ArtStandardPrompt` to the Responses API format and handles streaming/reasoning.
4230
4266
  *
4231
4267
  * @param {ArtStandardPrompt} prompt - The standardized prompt messages.
4232
- * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream` preference, and any OpenAI-specific parameters (like `temperature`, `max_tokens`) passed through.
4268
+ * @param {CallOptions} options - Call options, including streaming, reasoning options, and model parameters.
4233
4269
  * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
4234
- * @see https://platform.openai.com/docs/api-reference/chat/create
4235
4270
  */
4236
4271
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4237
4272
  /**
4238
- * Processes the Server-Sent Events (SSE) stream from OpenAI.
4239
- * @param stream - The ReadableStream from the fetch response.
4240
- * @param options - The original CallOptions containing threadId, traceId, sessionId, and callContext.
4241
- * @returns An AsyncIterable yielding StreamEvent objects.
4242
- */
4243
- private processStream;
4273
+ * Optional: Method for graceful shutdown
4274
+ */
4275
+ shutdown(): Promise<void>;
4244
4276
  /**
4245
- * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI API's `OpenAIMessage[]` format.
4277
+ * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI Responses API format.
4278
+ * Extracts system prompt separately and formats messages as input array.
4246
4279
  *
4247
4280
  * @private
4248
4281
  * @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
4249
- * @returns {OpenAIMessage[]} The `OpenAIMessage[]` array formatted for the OpenAI API.
4250
- * @throws {ARTError} If translation encounters an issue (ErrorCode.PROMPT_TRANSLATION_FAILED).
4282
+ * @returns {{ systemPrompt?: string; input: OpenAIResponsesInputMessage[] }} An object containing the extracted system prompt and the array of Responses API formatted input messages.
4283
+ * @throws {ARTError} If translation encounters an issue.
4251
4284
  */
4252
- private translateToOpenAI;
4285
+ private translateToResponsesFormat;
4286
+ /**
4287
+ * Maps a single `ArtStandardMessage` to OpenAI Responses API input format.
4288
+ *
4289
+ * @private
4290
+ * @param {ArtStandardMessage} artMsg - The ART standard message to map.
4291
+ * @returns {OpenAIResponsesInputMessage | null} The translated message for the Responses API, or null if should be skipped.
4292
+ * @throws {ARTError} If tool call arguments are not valid JSON.
4293
+ */
4294
+ private mapArtMessageToResponsesContent;
4295
+ /**
4296
+ * Translates an array of `ToolSchema` from the ART framework format to OpenAI's Responses API tool format.
4297
+ * @private
4298
+ * @param {ToolSchema[]} artTools - An array of ART tool schemas.
4299
+ * @returns {OpenAIResponsesTool[]} An array of tools formatted for the OpenAI Responses API.
4300
+ * @throws {ARTError} If a tool's `inputSchema` is invalid.
4301
+ */
4302
+ private translateArtToolsToOpenAI;
4253
4303
  }
4254
4304
 
4255
4305
  /**
@@ -4299,9 +4349,12 @@ declare class AnthropicAdapter implements ProviderAdapter {
4299
4349
  * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
4300
4350
  */
4301
4351
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4352
+ /**
4353
+ * Optional: Method for graceful shutdown
4354
+ */
4355
+ shutdown(): Promise<void>;
4302
4356
  /**
4303
4357
  * Prepares request options, adding Anthropic beta headers if applicable for features like prompt caching.
4304
- * This allows opting into experimental features on a per-request basis.
4305
4358
  * @private
4306
4359
  * @param {string} modelId - The model ID being used for the request, to determine which beta features may apply.
4307
4360
  * @returns {Anthropic.RequestOptions} The request options object, potentially with custom headers.
@@ -4338,28 +4391,13 @@ declare class AnthropicAdapter implements ProviderAdapter {
4338
4391
  private translateArtToolsToAnthropic;
4339
4392
  }
4340
4393
 
4341
- /**
4342
- * Configuration options required for the `OpenRouterAdapter`.
4343
- */
4344
4394
  interface OpenRouterAdapterOptions {
4345
- /** Your OpenRouter API key. Handle securely. */
4346
4395
  apiKey: string;
4347
- /** The required OpenRouter model identifier string (e.g., 'google/gemini-pro', 'anthropic/claude-3-haiku', 'openai/gpt-4o'). This specifies which underlying model OpenRouter should use. */
4348
4396
  model: string;
4349
- /** Optional: Override the base URL for the OpenRouter API. Defaults to 'https://openrouter.ai/api/v1'. */
4350
4397
  apiBaseUrl?: string;
4351
- /** Optional: Your application's site URL, sent as the 'HTTP-Referer' header (recommended by OpenRouter). */
4352
4398
  siteUrl?: string;
4353
- /** Optional: Your application's name, sent as the 'X-Title' header (recommended by OpenRouter). */
4354
4399
  appName?: string;
4355
4400
  }
4356
- /**
4357
- * This adapter provides a unified interface for various LLM providers through OpenRouter,
4358
- * handling prompt conversion and response parsing into the ART `StreamEvent` format.
4359
- *
4360
- * @see {@link ProviderAdapter} for the interface it implements.
4361
- * @see {@link OpenRouterAdapterOptions} for configuration options.
4362
- */
4363
4401
  declare class OpenRouterAdapter implements ProviderAdapter {
4364
4402
  readonly providerName = "openrouter";
4365
4403
  private apiKey;
@@ -4367,34 +4405,11 @@ declare class OpenRouterAdapter implements ProviderAdapter {
4367
4405
  private apiBaseUrl;
4368
4406
  private siteUrl?;
4369
4407
  private appName?;
4370
- /**
4371
- * Creates an instance of the OpenRouterAdapter.
4372
- * @param {OpenRouterAdapterOptions} options - Configuration options including the API key, the specific OpenRouter model identifier, and optional headers/baseURL.
4373
- * @throws {Error} If the API key or model identifier is missing.
4374
- * @see https://openrouter.ai/docs
4375
- */
4376
4408
  constructor(options: OpenRouterAdapterOptions);
4377
- /**
4378
- * Sends a request to the OpenRouter Chat Completions API endpoint.
4379
- * Translates `ArtStandardPrompt` to the OpenAI-compatible format.
4380
- *
4381
- * **Note:** Streaming is **not yet implemented**.
4382
- *
4383
- * @param {ArtStandardPrompt} prompt - The standardized prompt messages.
4384
- * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream`, and any OpenAI-compatible generation parameters.
4385
- * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects. If streaming is requested, it yields an error event and ends.
4386
- * @see https://openrouter.ai/docs#api-reference-chat-completions
4387
- */
4388
4409
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4389
- /**
4390
- * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI API's `OpenAIMessage[]` format.
4391
- * (Copied from OpenAIAdapter - assumes OpenRouter compatibility)
4392
- *
4393
- * @private
4394
- * @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
4395
- * @returns {OpenAIMessage[]} The `OpenAIMessage[]` array formatted for the OpenAI API.
4396
- * @throws {ARTError} If translation encounters an issue (ErrorCode.PROMPT_TRANSLATION_FAILED).
4397
- */
4410
+ private processStream;
4411
+ private processNonStreamingResponse;
4412
+ private translateArtToolsToOpenAI;
4398
4413
  private translateToOpenAI;
4399
4414
  }
4400
4415
 
@@ -5236,6 +5251,6 @@ declare const generateUUID: () => string;
5236
5251
  /**
5237
5252
  * The current version of the ART Framework package.
5238
5253
  */
5239
- declare const VERSION = "0.3.5";
5254
+ declare const VERSION = "0.3.8";
5240
5255
 
5241
5256
  export { type A2AAgentInfo, type A2ATask, type A2ATaskEvent, type A2ATaskFilter, type A2ATaskMetadata, A2ATaskPriority, type A2ATaskResult, A2ATaskSocket, A2ATaskStatus, ARTError, AdapterInstantiationError, type AgentDiscoveryConfig, AgentDiscoveryService, type AgentFinalResponse, type AgentOptions, type AgentPersona, type AgentProps, type AgentState, AnthropicAdapter, type AnthropicAdapterOptions, ApiKeyStrategy, ApiQueueTimeoutError, type ArtInstance, type ArtInstanceConfig, type ArtStandardMessage, type ArtStandardMessageRole, ArtStandardMessageSchema, type ArtStandardPrompt, ArtStandardPromptSchema, AuthManager, type AvailableProviderEntry, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, ConversationSocket, type CreateA2ATaskRequest, DeepSeekAdapter, type DeepSeekAdapterOptions, ErrorCode, type ExecutionContext, type ExecutionMetadata, type FilterOptions, type FormattedPrompt, GeminiAdapter, type GeminiAdapterOptions, GenericOAuthStrategy, type IA2ATaskRepository, type IAgentCore, type IAuthStrategy, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, type ITypedSocket, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LLMStreamSocket, LocalInstanceBusyError, LocalProviderConflictError, LogLevel, Logger, type LoggerConfig, type ManagedAdapterAccessor, McpClientController, McpManager, type McpManagerConfig, McpProxyTool, type McpResource, type McpResourceTemplate, type McpServerConfig, type McpServerStatus, type McpToolDefinition, type MessageOptions, MessageRole, ModelCapability, type OAuthConfig, type Observation, type ObservationFilter, type ObservationManager, ObservationSocket, ObservationType, OllamaAdapter, type OllamaAdapterOptions, OpenAIAdapter, type OpenAIAdapterOptions, OpenRouterAdapter, type OpenRouterAdapterOptions, type OutputParser, PESAgent, type PKCEOAuthConfig, PKCEOAuthStrategy, type ParsedToolCall, type PromptBlueprint, type PromptContext, type PromptManager, type ProviderAdapter, type ProviderManagerConfig, ProviderManagerImpl, type ReasoningEngine, type RuntimeProviderConfig, type StageSpecificPrompts, StateManager, type StateSavingStrategy, type StorageAdapter, type StreamEvent, type StreamEventTypeFilter, SupabaseStorageAdapter, type SystemPromptMergeStrategy, type SystemPromptOverride, type SystemPromptResolver, type SystemPromptSpec, type SystemPromptsRegistry, type TaskDelegationConfig, TaskDelegationService, type TaskStatusResponse, type ThreadConfig, type ThreadContext, ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem, TypedSocket, UISystem, UnknownProviderError, type UnsubscribeFunction, type UpdateA2ATaskRequest, VERSION, type ZyntopiaOAuthConfig, ZyntopiaOAuthStrategy, createArtInstance, generateUUID };