art-framework 0.3.7 → 0.3.9

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
@@ -2787,41 +2787,6 @@ interface ReasoningEngine {
2787
2787
  */
2788
2788
  call(prompt: FormattedPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
2789
2789
  }
2790
- /**
2791
- * Interface for the stateless prompt assembler.
2792
- * Uses a blueprint (template) and context provided by Agent Logic
2793
- * to create a standardized prompt format (`ArtStandardPrompt`).
2794
- */
2795
- interface PromptManager {
2796
- /**
2797
- * Retrieves a named prompt fragment (e.g., a piece of instruction text).
2798
- * Optionally allows for simple variable substitution if the fragment is a basic template.
2799
- *
2800
- * @param name - The unique identifier for the fragment.
2801
- * @param context - Optional data for simple variable substitution within the fragment.
2802
- * @returns The processed prompt fragment string.
2803
- * @throws {ARTError} If the fragment is not found.
2804
- */
2805
- getFragment(name: string, context?: Record<string, any>): string;
2806
- /**
2807
- * Validates a constructed prompt object against the standard schema.
2808
- *
2809
- * @param prompt - The ArtStandardPrompt object constructed by the agent.
2810
- * @returns The validated prompt object (potentially after normalization if the schema does that).
2811
- * @throws {ZodError} If validation fails (can be caught and wrapped in ARTError).
2812
- */
2813
- validatePrompt(prompt: ArtStandardPrompt): ArtStandardPrompt;
2814
- /**
2815
- * Assembles a prompt using a Mustache template (blueprint) and context data.
2816
- * Renders the template with the provided context and parses the result as an ArtStandardPrompt.
2817
- *
2818
- * @param blueprint - The Mustache template containing the prompt structure.
2819
- * @param context - The context data to inject into the template.
2820
- * @returns A promise resolving to the assembled ArtStandardPrompt.
2821
- * @throws {ARTError} If template rendering or JSON parsing fails.
2822
- */
2823
- assemblePrompt(blueprint: PromptBlueprint, context: PromptContext): Promise<ArtStandardPrompt>;
2824
- }
2825
2790
  /**
2826
2791
  * Resolves the final system prompt from base + instance/thread/call overrides
2827
2792
  * using tag+variables and merge strategies.
@@ -3691,11 +3656,6 @@ declare class TaskDelegationService {
3691
3656
  interface PESAgentDependencies {
3692
3657
  /** Manages thread configuration and state. */
3693
3658
  stateManager: StateManager$1;
3694
- /**
3695
- * Optional default system prompt string provided at the ART instance level.
3696
- * This serves as a custom prompt part if no thread-specific or call-specific
3697
- * system prompt is provided. It's appended to the agent's base system prompt.
3698
- */
3699
3659
  /** Manages conversation history. */
3700
3660
  conversationManager: ConversationManager;
3701
3661
  /** Registry for available tools. */
@@ -3730,11 +3690,6 @@ interface PESAgentDependencies {
3730
3690
  *
3731
3691
  * It constructs standardized prompts (`ArtStandardPrompt`) directly as JavaScript objects
3732
3692
  * for the `ReasoningEngine`. It processes the `StreamEvent` output from the reasoning engine for both planning and synthesis.
3733
- *
3734
- * // @see {PromptManager} // Removed
3735
- * @see {ReasoningEngine}
3736
- * @see {ArtStandardPrompt}
3737
- * @see {StreamEvent}
3738
3693
  */
3739
3694
  declare class PESAgent implements IAgentCore {
3740
3695
  private readonly deps;
@@ -3750,11 +3705,13 @@ declare class PESAgent implements IAgentCore {
3750
3705
  * **Workflow:**
3751
3706
  * 1. **Initiation & Config:** Loads thread configuration and resolves system prompt
3752
3707
  * 2. **Data Gathering:** Gathers history, available tools
3753
- * 3. **Planning:** LLM call for planning and parsing
3754
- * 4. **A2A Discovery & Delegation:** Identifies and delegates A2A tasks to remote agents
3755
- * 5. **Tool Execution:** Executes identified local tool calls
3756
- * 6. **Synthesis:** LLM call for final response generation including A2A results
3757
- * 7. **Finalization:** Saves messages and cleanup
3708
+ * 3. **Loop (ReAct-like):**
3709
+ * - **Planning:** LLM call for planning and parsing (with access to history of previous steps).
3710
+ * - **A2A Discovery & Delegation:** Identifies and delegates A2A tasks.
3711
+ * - **Tool Execution:** Executes identified local tool calls.
3712
+ * - **Observation:** Results are fed back into the next iteration.
3713
+ * 4. **Synthesis:** LLM call for final response generation including all results
3714
+ * 5. **Finalization:** Saves messages and cleanup
3758
3715
  *
3759
3716
  * @param {AgentProps} props - The input properties containing the user query, threadId, userId, traceId, etc.
3760
3717
  * @returns {Promise<AgentFinalResponse>} A promise resolving to the final response, including the AI message and execution metadata.
@@ -3779,11 +3736,6 @@ declare class PESAgent implements IAgentCore {
3779
3736
  /**
3780
3737
  * Performs the planning phase including LLM call and output parsing.
3781
3738
  * @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`.
3787
3739
  */
3788
3740
  private _performPlanning;
3789
3741
  /**
@@ -3793,7 +3745,6 @@ declare class PESAgent implements IAgentCore {
3793
3745
  private _delegateA2ATasks;
3794
3746
  /**
3795
3747
  * Waits for A2A tasks to complete with configurable timeout.
3796
- * Polls task status periodically and updates local repository with results.
3797
3748
  * @private
3798
3749
  */
3799
3750
  private _waitForA2ACompletion;
@@ -4229,58 +4180,77 @@ declare class GeminiAdapter implements ProviderAdapter {
4229
4180
  interface OpenAIAdapterOptions {
4230
4181
  /** Your OpenAI API key. Handle securely. */
4231
4182
  apiKey: string;
4232
- /** The default OpenAI model ID to use (e.g., 'gpt-4o', 'gpt-4o-mini'). Defaults to 'gpt-3.5-turbo' if not provided. */
4183
+ /** The default OpenAI model ID to use (e.g., 'gpt-4o', 'gpt-5', 'gpt-5-mini'). */
4233
4184
  model?: string;
4234
4185
  /** Optional: Override the base URL for the OpenAI API (e.g., for Azure OpenAI or custom proxies). */
4235
4186
  apiBaseUrl?: string;
4187
+ /** Optional: Default maximum tokens for responses. */
4188
+ defaultMaxTokens?: number;
4189
+ /** Optional: Default temperature for responses. */
4190
+ defaultTemperature?: number;
4236
4191
  }
4237
4192
  /**
4238
4193
  * Implements the `ProviderAdapter` interface for interacting with OpenAI's
4239
- * Chat Completions API (compatible models like GPT-3.5, GPT-4, GPT-4o).
4194
+ * Responses API (supports reasoning models like GPT-5 family and other models).
4240
4195
  *
4241
- * Handles formatting requests and parsing responses for OpenAI.
4242
- * Uses raw `fetch` for now.
4196
+ * Handles formatting requests, parsing responses, streaming, reasoning token detection, and tool use.
4197
+ * Uses the official OpenAI SDK with the new Responses API for full reasoning model support.
4243
4198
  *
4244
4199
  * @see {@link ProviderAdapter} for the interface definition.
4200
+ * @see {@link OpenAIAdapterOptions} for configuration options.
4245
4201
  */
4246
4202
  declare class OpenAIAdapter implements ProviderAdapter {
4247
4203
  readonly providerName = "openai";
4248
- private apiKey;
4249
- private model;
4250
- private apiBaseUrl;
4204
+ private client;
4205
+ private defaultModel;
4206
+ private defaultMaxTokens;
4207
+ private defaultTemperature;
4251
4208
  /**
4252
4209
  * Creates an instance of the OpenAIAdapter.
4253
- * @param {OpenAIAdapterOptions} options - Configuration options including the API key and optional model/baseURL overrides.
4254
- * @throws {Error} If the API key is missing.
4255
- * @see https://platform.openai.com/docs/api-reference
4210
+ * @param options - Configuration options including the API key and optional model/baseURL/defaults.
4211
+ * @throws {ARTError} If the API key is missing.
4256
4212
  */
4257
4213
  constructor(options: OpenAIAdapterOptions);
4258
4214
  /**
4259
- * Sends a request to the OpenAI Chat Completions API.
4260
- * Translates `ArtStandardPrompt` to the OpenAI format, handles streaming and non-streaming responses.
4215
+ * Sends a request to the OpenAI Responses API.
4216
+ * Translates `ArtStandardPrompt` to the Responses API format and handles streaming/reasoning.
4261
4217
  *
4262
4218
  * @param {ArtStandardPrompt} prompt - The standardized prompt messages.
4263
- * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream` preference, and any OpenAI-specific parameters (like `temperature`, `max_tokens`) passed through.
4219
+ * @param {CallOptions} options - Call options, including streaming, reasoning options, and model parameters.
4264
4220
  * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
4265
- * @see https://platform.openai.com/docs/api-reference/chat/create
4266
4221
  */
4267
4222
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4268
4223
  /**
4269
- * Processes the Server-Sent Events (SSE) stream from OpenAI.
4270
- * @param stream - The ReadableStream from the fetch response.
4271
- * @param options - The original CallOptions containing threadId, traceId, sessionId, and callContext.
4272
- * @returns An AsyncIterable yielding StreamEvent objects.
4273
- */
4274
- private processStream;
4224
+ * Optional: Method for graceful shutdown
4225
+ */
4226
+ shutdown(): Promise<void>;
4275
4227
  /**
4276
- * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI API's `OpenAIMessage[]` format.
4228
+ * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI Responses API format.
4229
+ * Extracts system prompt separately and formats messages as input array.
4277
4230
  *
4278
4231
  * @private
4279
4232
  * @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
4280
- * @returns {OpenAIMessage[]} The `OpenAIMessage[]` array formatted for the OpenAI API.
4281
- * @throws {ARTError} If translation encounters an issue (ErrorCode.PROMPT_TRANSLATION_FAILED).
4233
+ * @returns {{ systemPrompt?: string; input: OpenAIResponsesInputMessage[] }} An object containing the extracted system prompt and the array of Responses API formatted input messages.
4234
+ * @throws {ARTError} If translation encounters an issue.
4282
4235
  */
4283
- private translateToOpenAI;
4236
+ private translateToResponsesFormat;
4237
+ /**
4238
+ * Maps a single `ArtStandardMessage` to OpenAI Responses API input format.
4239
+ *
4240
+ * @private
4241
+ * @param {ArtStandardMessage} artMsg - The ART standard message to map.
4242
+ * @returns {OpenAIResponsesInputMessage | null} The translated message for the Responses API, or null if should be skipped.
4243
+ * @throws {ARTError} If tool call arguments are not valid JSON.
4244
+ */
4245
+ private mapArtMessageToResponsesContent;
4246
+ /**
4247
+ * Translates an array of `ToolSchema` from the ART framework format to OpenAI's Responses API tool format.
4248
+ * @private
4249
+ * @param {ToolSchema[]} artTools - An array of ART tool schemas.
4250
+ * @returns {OpenAIResponsesTool[]} An array of tools formatted for the OpenAI Responses API.
4251
+ * @throws {ARTError} If a tool's `inputSchema` is invalid.
4252
+ */
4253
+ private translateArtToolsToOpenAI;
4284
4254
  }
4285
4255
 
4286
4256
  /**
@@ -4330,9 +4300,12 @@ declare class AnthropicAdapter implements ProviderAdapter {
4330
4300
  * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
4331
4301
  */
4332
4302
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4303
+ /**
4304
+ * Optional: Method for graceful shutdown
4305
+ */
4306
+ shutdown(): Promise<void>;
4333
4307
  /**
4334
4308
  * Prepares request options, adding Anthropic beta headers if applicable for features like prompt caching.
4335
- * This allows opting into experimental features on a per-request basis.
4336
4309
  * @private
4337
4310
  * @param {string} modelId - The model ID being used for the request, to determine which beta features may apply.
4338
4311
  * @returns {Anthropic.RequestOptions} The request options object, potentially with custom headers.
@@ -4369,28 +4342,13 @@ declare class AnthropicAdapter implements ProviderAdapter {
4369
4342
  private translateArtToolsToAnthropic;
4370
4343
  }
4371
4344
 
4372
- /**
4373
- * Configuration options required for the `OpenRouterAdapter`.
4374
- */
4375
4345
  interface OpenRouterAdapterOptions {
4376
- /** Your OpenRouter API key. Handle securely. */
4377
4346
  apiKey: string;
4378
- /** 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. */
4379
4347
  model: string;
4380
- /** Optional: Override the base URL for the OpenRouter API. Defaults to 'https://openrouter.ai/api/v1'. */
4381
4348
  apiBaseUrl?: string;
4382
- /** Optional: Your application's site URL, sent as the 'HTTP-Referer' header (recommended by OpenRouter). */
4383
4349
  siteUrl?: string;
4384
- /** Optional: Your application's name, sent as the 'X-Title' header (recommended by OpenRouter). */
4385
4350
  appName?: string;
4386
4351
  }
4387
- /**
4388
- * This adapter provides a unified interface for various LLM providers through OpenRouter,
4389
- * handling prompt conversion and response parsing into the ART `StreamEvent` format.
4390
- *
4391
- * @see {@link ProviderAdapter} for the interface it implements.
4392
- * @see {@link OpenRouterAdapterOptions} for configuration options.
4393
- */
4394
4352
  declare class OpenRouterAdapter implements ProviderAdapter {
4395
4353
  readonly providerName = "openrouter";
4396
4354
  private apiKey;
@@ -4398,34 +4356,11 @@ declare class OpenRouterAdapter implements ProviderAdapter {
4398
4356
  private apiBaseUrl;
4399
4357
  private siteUrl?;
4400
4358
  private appName?;
4401
- /**
4402
- * Creates an instance of the OpenRouterAdapter.
4403
- * @param {OpenRouterAdapterOptions} options - Configuration options including the API key, the specific OpenRouter model identifier, and optional headers/baseURL.
4404
- * @throws {Error} If the API key or model identifier is missing.
4405
- * @see https://openrouter.ai/docs
4406
- */
4407
4359
  constructor(options: OpenRouterAdapterOptions);
4408
- /**
4409
- * Sends a request to the OpenRouter Chat Completions API endpoint.
4410
- * Translates `ArtStandardPrompt` to the OpenAI-compatible format.
4411
- *
4412
- * **Note:** Streaming is **not yet implemented**.
4413
- *
4414
- * @param {ArtStandardPrompt} prompt - The standardized prompt messages.
4415
- * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream`, and any OpenAI-compatible generation parameters.
4416
- * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects. If streaming is requested, it yields an error event and ends.
4417
- * @see https://openrouter.ai/docs#api-reference-chat-completions
4418
- */
4419
4360
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4420
- /**
4421
- * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI API's `OpenAIMessage[]` format.
4422
- * (Copied from OpenAIAdapter - assumes OpenRouter compatibility)
4423
- *
4424
- * @private
4425
- * @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
4426
- * @returns {OpenAIMessage[]} The `OpenAIMessage[]` array formatted for the OpenAI API.
4427
- * @throws {ARTError} If translation encounters an issue (ErrorCode.PROMPT_TRANSLATION_FAILED).
4428
- */
4361
+ private processStream;
4362
+ private processNonStreamingResponse;
4363
+ private translateArtToolsToOpenAI;
4429
4364
  private translateToOpenAI;
4430
4365
  }
4431
4366
 
@@ -5267,6 +5202,6 @@ declare const generateUUID: () => string;
5267
5202
  /**
5268
5203
  * The current version of the ART Framework package.
5269
5204
  */
5270
- declare const VERSION = "0.3.7";
5205
+ declare const VERSION = "0.3.8";
5271
5206
 
5272
- 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 };
5207
+ 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 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
@@ -2787,41 +2787,6 @@ interface ReasoningEngine {
2787
2787
  */
2788
2788
  call(prompt: FormattedPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
2789
2789
  }
2790
- /**
2791
- * Interface for the stateless prompt assembler.
2792
- * Uses a blueprint (template) and context provided by Agent Logic
2793
- * to create a standardized prompt format (`ArtStandardPrompt`).
2794
- */
2795
- interface PromptManager {
2796
- /**
2797
- * Retrieves a named prompt fragment (e.g., a piece of instruction text).
2798
- * Optionally allows for simple variable substitution if the fragment is a basic template.
2799
- *
2800
- * @param name - The unique identifier for the fragment.
2801
- * @param context - Optional data for simple variable substitution within the fragment.
2802
- * @returns The processed prompt fragment string.
2803
- * @throws {ARTError} If the fragment is not found.
2804
- */
2805
- getFragment(name: string, context?: Record<string, any>): string;
2806
- /**
2807
- * Validates a constructed prompt object against the standard schema.
2808
- *
2809
- * @param prompt - The ArtStandardPrompt object constructed by the agent.
2810
- * @returns The validated prompt object (potentially after normalization if the schema does that).
2811
- * @throws {ZodError} If validation fails (can be caught and wrapped in ARTError).
2812
- */
2813
- validatePrompt(prompt: ArtStandardPrompt): ArtStandardPrompt;
2814
- /**
2815
- * Assembles a prompt using a Mustache template (blueprint) and context data.
2816
- * Renders the template with the provided context and parses the result as an ArtStandardPrompt.
2817
- *
2818
- * @param blueprint - The Mustache template containing the prompt structure.
2819
- * @param context - The context data to inject into the template.
2820
- * @returns A promise resolving to the assembled ArtStandardPrompt.
2821
- * @throws {ARTError} If template rendering or JSON parsing fails.
2822
- */
2823
- assemblePrompt(blueprint: PromptBlueprint, context: PromptContext): Promise<ArtStandardPrompt>;
2824
- }
2825
2790
  /**
2826
2791
  * Resolves the final system prompt from base + instance/thread/call overrides
2827
2792
  * using tag+variables and merge strategies.
@@ -3691,11 +3656,6 @@ declare class TaskDelegationService {
3691
3656
  interface PESAgentDependencies {
3692
3657
  /** Manages thread configuration and state. */
3693
3658
  stateManager: StateManager$1;
3694
- /**
3695
- * Optional default system prompt string provided at the ART instance level.
3696
- * This serves as a custom prompt part if no thread-specific or call-specific
3697
- * system prompt is provided. It's appended to the agent's base system prompt.
3698
- */
3699
3659
  /** Manages conversation history. */
3700
3660
  conversationManager: ConversationManager;
3701
3661
  /** Registry for available tools. */
@@ -3730,11 +3690,6 @@ interface PESAgentDependencies {
3730
3690
  *
3731
3691
  * It constructs standardized prompts (`ArtStandardPrompt`) directly as JavaScript objects
3732
3692
  * for the `ReasoningEngine`. It processes the `StreamEvent` output from the reasoning engine for both planning and synthesis.
3733
- *
3734
- * // @see {PromptManager} // Removed
3735
- * @see {ReasoningEngine}
3736
- * @see {ArtStandardPrompt}
3737
- * @see {StreamEvent}
3738
3693
  */
3739
3694
  declare class PESAgent implements IAgentCore {
3740
3695
  private readonly deps;
@@ -3750,11 +3705,13 @@ declare class PESAgent implements IAgentCore {
3750
3705
  * **Workflow:**
3751
3706
  * 1. **Initiation & Config:** Loads thread configuration and resolves system prompt
3752
3707
  * 2. **Data Gathering:** Gathers history, available tools
3753
- * 3. **Planning:** LLM call for planning and parsing
3754
- * 4. **A2A Discovery & Delegation:** Identifies and delegates A2A tasks to remote agents
3755
- * 5. **Tool Execution:** Executes identified local tool calls
3756
- * 6. **Synthesis:** LLM call for final response generation including A2A results
3757
- * 7. **Finalization:** Saves messages and cleanup
3708
+ * 3. **Loop (ReAct-like):**
3709
+ * - **Planning:** LLM call for planning and parsing (with access to history of previous steps).
3710
+ * - **A2A Discovery & Delegation:** Identifies and delegates A2A tasks.
3711
+ * - **Tool Execution:** Executes identified local tool calls.
3712
+ * - **Observation:** Results are fed back into the next iteration.
3713
+ * 4. **Synthesis:** LLM call for final response generation including all results
3714
+ * 5. **Finalization:** Saves messages and cleanup
3758
3715
  *
3759
3716
  * @param {AgentProps} props - The input properties containing the user query, threadId, userId, traceId, etc.
3760
3717
  * @returns {Promise<AgentFinalResponse>} A promise resolving to the final response, including the AI message and execution metadata.
@@ -3779,11 +3736,6 @@ declare class PESAgent implements IAgentCore {
3779
3736
  /**
3780
3737
  * Performs the planning phase including LLM call and output parsing.
3781
3738
  * @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`.
3787
3739
  */
3788
3740
  private _performPlanning;
3789
3741
  /**
@@ -3793,7 +3745,6 @@ declare class PESAgent implements IAgentCore {
3793
3745
  private _delegateA2ATasks;
3794
3746
  /**
3795
3747
  * Waits for A2A tasks to complete with configurable timeout.
3796
- * Polls task status periodically and updates local repository with results.
3797
3748
  * @private
3798
3749
  */
3799
3750
  private _waitForA2ACompletion;
@@ -4229,58 +4180,77 @@ declare class GeminiAdapter implements ProviderAdapter {
4229
4180
  interface OpenAIAdapterOptions {
4230
4181
  /** Your OpenAI API key. Handle securely. */
4231
4182
  apiKey: string;
4232
- /** The default OpenAI model ID to use (e.g., 'gpt-4o', 'gpt-4o-mini'). Defaults to 'gpt-3.5-turbo' if not provided. */
4183
+ /** The default OpenAI model ID to use (e.g., 'gpt-4o', 'gpt-5', 'gpt-5-mini'). */
4233
4184
  model?: string;
4234
4185
  /** Optional: Override the base URL for the OpenAI API (e.g., for Azure OpenAI or custom proxies). */
4235
4186
  apiBaseUrl?: string;
4187
+ /** Optional: Default maximum tokens for responses. */
4188
+ defaultMaxTokens?: number;
4189
+ /** Optional: Default temperature for responses. */
4190
+ defaultTemperature?: number;
4236
4191
  }
4237
4192
  /**
4238
4193
  * Implements the `ProviderAdapter` interface for interacting with OpenAI's
4239
- * Chat Completions API (compatible models like GPT-3.5, GPT-4, GPT-4o).
4194
+ * Responses API (supports reasoning models like GPT-5 family and other models).
4240
4195
  *
4241
- * Handles formatting requests and parsing responses for OpenAI.
4242
- * Uses raw `fetch` for now.
4196
+ * Handles formatting requests, parsing responses, streaming, reasoning token detection, and tool use.
4197
+ * Uses the official OpenAI SDK with the new Responses API for full reasoning model support.
4243
4198
  *
4244
4199
  * @see {@link ProviderAdapter} for the interface definition.
4200
+ * @see {@link OpenAIAdapterOptions} for configuration options.
4245
4201
  */
4246
4202
  declare class OpenAIAdapter implements ProviderAdapter {
4247
4203
  readonly providerName = "openai";
4248
- private apiKey;
4249
- private model;
4250
- private apiBaseUrl;
4204
+ private client;
4205
+ private defaultModel;
4206
+ private defaultMaxTokens;
4207
+ private defaultTemperature;
4251
4208
  /**
4252
4209
  * Creates an instance of the OpenAIAdapter.
4253
- * @param {OpenAIAdapterOptions} options - Configuration options including the API key and optional model/baseURL overrides.
4254
- * @throws {Error} If the API key is missing.
4255
- * @see https://platform.openai.com/docs/api-reference
4210
+ * @param options - Configuration options including the API key and optional model/baseURL/defaults.
4211
+ * @throws {ARTError} If the API key is missing.
4256
4212
  */
4257
4213
  constructor(options: OpenAIAdapterOptions);
4258
4214
  /**
4259
- * Sends a request to the OpenAI Chat Completions API.
4260
- * Translates `ArtStandardPrompt` to the OpenAI format, handles streaming and non-streaming responses.
4215
+ * Sends a request to the OpenAI Responses API.
4216
+ * Translates `ArtStandardPrompt` to the Responses API format and handles streaming/reasoning.
4261
4217
  *
4262
4218
  * @param {ArtStandardPrompt} prompt - The standardized prompt messages.
4263
- * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream` preference, and any OpenAI-specific parameters (like `temperature`, `max_tokens`) passed through.
4219
+ * @param {CallOptions} options - Call options, including streaming, reasoning options, and model parameters.
4264
4220
  * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
4265
- * @see https://platform.openai.com/docs/api-reference/chat/create
4266
4221
  */
4267
4222
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4268
4223
  /**
4269
- * Processes the Server-Sent Events (SSE) stream from OpenAI.
4270
- * @param stream - The ReadableStream from the fetch response.
4271
- * @param options - The original CallOptions containing threadId, traceId, sessionId, and callContext.
4272
- * @returns An AsyncIterable yielding StreamEvent objects.
4273
- */
4274
- private processStream;
4224
+ * Optional: Method for graceful shutdown
4225
+ */
4226
+ shutdown(): Promise<void>;
4275
4227
  /**
4276
- * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI API's `OpenAIMessage[]` format.
4228
+ * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI Responses API format.
4229
+ * Extracts system prompt separately and formats messages as input array.
4277
4230
  *
4278
4231
  * @private
4279
4232
  * @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
4280
- * @returns {OpenAIMessage[]} The `OpenAIMessage[]` array formatted for the OpenAI API.
4281
- * @throws {ARTError} If translation encounters an issue (ErrorCode.PROMPT_TRANSLATION_FAILED).
4233
+ * @returns {{ systemPrompt?: string; input: OpenAIResponsesInputMessage[] }} An object containing the extracted system prompt and the array of Responses API formatted input messages.
4234
+ * @throws {ARTError} If translation encounters an issue.
4282
4235
  */
4283
- private translateToOpenAI;
4236
+ private translateToResponsesFormat;
4237
+ /**
4238
+ * Maps a single `ArtStandardMessage` to OpenAI Responses API input format.
4239
+ *
4240
+ * @private
4241
+ * @param {ArtStandardMessage} artMsg - The ART standard message to map.
4242
+ * @returns {OpenAIResponsesInputMessage | null} The translated message for the Responses API, or null if should be skipped.
4243
+ * @throws {ARTError} If tool call arguments are not valid JSON.
4244
+ */
4245
+ private mapArtMessageToResponsesContent;
4246
+ /**
4247
+ * Translates an array of `ToolSchema` from the ART framework format to OpenAI's Responses API tool format.
4248
+ * @private
4249
+ * @param {ToolSchema[]} artTools - An array of ART tool schemas.
4250
+ * @returns {OpenAIResponsesTool[]} An array of tools formatted for the OpenAI Responses API.
4251
+ * @throws {ARTError} If a tool's `inputSchema` is invalid.
4252
+ */
4253
+ private translateArtToolsToOpenAI;
4284
4254
  }
4285
4255
 
4286
4256
  /**
@@ -4330,9 +4300,12 @@ declare class AnthropicAdapter implements ProviderAdapter {
4330
4300
  * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects.
4331
4301
  */
4332
4302
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4303
+ /**
4304
+ * Optional: Method for graceful shutdown
4305
+ */
4306
+ shutdown(): Promise<void>;
4333
4307
  /**
4334
4308
  * Prepares request options, adding Anthropic beta headers if applicable for features like prompt caching.
4335
- * This allows opting into experimental features on a per-request basis.
4336
4309
  * @private
4337
4310
  * @param {string} modelId - The model ID being used for the request, to determine which beta features may apply.
4338
4311
  * @returns {Anthropic.RequestOptions} The request options object, potentially with custom headers.
@@ -4369,28 +4342,13 @@ declare class AnthropicAdapter implements ProviderAdapter {
4369
4342
  private translateArtToolsToAnthropic;
4370
4343
  }
4371
4344
 
4372
- /**
4373
- * Configuration options required for the `OpenRouterAdapter`.
4374
- */
4375
4345
  interface OpenRouterAdapterOptions {
4376
- /** Your OpenRouter API key. Handle securely. */
4377
4346
  apiKey: string;
4378
- /** 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. */
4379
4347
  model: string;
4380
- /** Optional: Override the base URL for the OpenRouter API. Defaults to 'https://openrouter.ai/api/v1'. */
4381
4348
  apiBaseUrl?: string;
4382
- /** Optional: Your application's site URL, sent as the 'HTTP-Referer' header (recommended by OpenRouter). */
4383
4349
  siteUrl?: string;
4384
- /** Optional: Your application's name, sent as the 'X-Title' header (recommended by OpenRouter). */
4385
4350
  appName?: string;
4386
4351
  }
4387
- /**
4388
- * This adapter provides a unified interface for various LLM providers through OpenRouter,
4389
- * handling prompt conversion and response parsing into the ART `StreamEvent` format.
4390
- *
4391
- * @see {@link ProviderAdapter} for the interface it implements.
4392
- * @see {@link OpenRouterAdapterOptions} for configuration options.
4393
- */
4394
4352
  declare class OpenRouterAdapter implements ProviderAdapter {
4395
4353
  readonly providerName = "openrouter";
4396
4354
  private apiKey;
@@ -4398,34 +4356,11 @@ declare class OpenRouterAdapter implements ProviderAdapter {
4398
4356
  private apiBaseUrl;
4399
4357
  private siteUrl?;
4400
4358
  private appName?;
4401
- /**
4402
- * Creates an instance of the OpenRouterAdapter.
4403
- * @param {OpenRouterAdapterOptions} options - Configuration options including the API key, the specific OpenRouter model identifier, and optional headers/baseURL.
4404
- * @throws {Error} If the API key or model identifier is missing.
4405
- * @see https://openrouter.ai/docs
4406
- */
4407
4359
  constructor(options: OpenRouterAdapterOptions);
4408
- /**
4409
- * Sends a request to the OpenRouter Chat Completions API endpoint.
4410
- * Translates `ArtStandardPrompt` to the OpenAI-compatible format.
4411
- *
4412
- * **Note:** Streaming is **not yet implemented**.
4413
- *
4414
- * @param {ArtStandardPrompt} prompt - The standardized prompt messages.
4415
- * @param {CallOptions} options - Call options, including `threadId`, `traceId`, `stream`, and any OpenAI-compatible generation parameters.
4416
- * @returns {Promise<AsyncIterable<StreamEvent>>} A promise resolving to an AsyncIterable of StreamEvent objects. If streaming is requested, it yields an error event and ends.
4417
- * @see https://openrouter.ai/docs#api-reference-chat-completions
4418
- */
4419
4360
  call(prompt: ArtStandardPrompt, options: CallOptions): Promise<AsyncIterable<StreamEvent>>;
4420
- /**
4421
- * Translates the provider-agnostic `ArtStandardPrompt` into the OpenAI API's `OpenAIMessage[]` format.
4422
- * (Copied from OpenAIAdapter - assumes OpenRouter compatibility)
4423
- *
4424
- * @private
4425
- * @param {ArtStandardPrompt} artPrompt - The input `ArtStandardPrompt` array.
4426
- * @returns {OpenAIMessage[]} The `OpenAIMessage[]` array formatted for the OpenAI API.
4427
- * @throws {ARTError} If translation encounters an issue (ErrorCode.PROMPT_TRANSLATION_FAILED).
4428
- */
4361
+ private processStream;
4362
+ private processNonStreamingResponse;
4363
+ private translateArtToolsToOpenAI;
4429
4364
  private translateToOpenAI;
4430
4365
  }
4431
4366
 
@@ -5267,6 +5202,6 @@ declare const generateUUID: () => string;
5267
5202
  /**
5268
5203
  * The current version of the ART Framework package.
5269
5204
  */
5270
- declare const VERSION = "0.3.7";
5205
+ declare const VERSION = "0.3.8";
5271
5206
 
5272
- 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 };
5207
+ 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 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 };