@robota-sdk/agent-core 3.0.0-beta.24 → 3.0.0-beta.26

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.
@@ -4199,6 +4199,9 @@ declare const CLAUDE_MODELS: Record<string, IModelDefinition>;
4199
4199
  declare const DEFAULT_CONTEXT_WINDOW = 200000;
4200
4200
  /** Get context window size for a model ID. Falls back to DEFAULT_CONTEXT_WINDOW. */
4201
4201
  declare function getModelContextWindow(modelId: string): number;
4202
+ declare const DEFAULT_MAX_OUTPUT = 16384;
4203
+ /** Get max output tokens for a model ID. Falls back to DEFAULT_MAX_OUTPUT. */
4204
+ declare function getModelMaxOutput(modelId: string): number;
4202
4205
  /** Get human-readable model name for a model ID. Falls back to the ID itself. */
4203
4206
  declare function getModelName(modelId: string): string;
4204
4207
  /** Format token count as human-readable (e.g., 200K, 1M, 1.2M). Minimum unit is K. */
@@ -4208,18 +4211,42 @@ declare function formatTokenCount(tokens: number): string;
4208
4211
  * Hook system types — Claude Code compatible event/hook model.
4209
4212
  */
4210
4213
  /** Hook lifecycle events */
4211
- type THookEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'Stop' | 'PreCompact' | 'PostCompact';
4212
- /** A single hook definition */
4213
- interface IHookDefinition {
4214
- /** Shell command to execute */
4214
+ type THookEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'Stop' | 'PreCompact' | 'PostCompact' | 'UserPromptSubmit' | 'Notification';
4215
+ /** Command hook executes a shell command */
4216
+ interface ICommandHookDefinition {
4215
4217
  type: 'command';
4216
4218
  command: string;
4219
+ timeout?: number;
4220
+ }
4221
+ /** HTTP hook — sends an HTTP request */
4222
+ interface IHttpHookDefinition {
4223
+ type: 'http';
4224
+ url: string;
4225
+ headers?: Record<string, string>;
4226
+ timeout?: number;
4217
4227
  }
4228
+ /** Prompt hook — evaluates a prompt via an AI model */
4229
+ interface IPromptHookDefinition {
4230
+ type: 'prompt';
4231
+ prompt: string;
4232
+ model?: string;
4233
+ }
4234
+ /** Agent hook — delegates to a sub-agent */
4235
+ interface IAgentHookDefinition {
4236
+ type: 'agent';
4237
+ agent: string;
4238
+ maxTurns?: number;
4239
+ timeout?: number;
4240
+ }
4241
+ /** Discriminated union of all hook definition types */
4242
+ type IHookDefinition = ICommandHookDefinition | IHttpHookDefinition | IPromptHookDefinition | IAgentHookDefinition;
4218
4243
  /** A hook group — matcher + array of hook definitions */
4219
4244
  interface IHookGroup {
4220
4245
  /** Regex pattern to match tool name (empty string = match all) */
4221
4246
  matcher: string;
4222
4247
  hooks: IHookDefinition[];
4248
+ /** Environment variables injected into hook child processes for this group */
4249
+ env?: Record<string, string>;
4223
4250
  }
4224
4251
  /** Complete hooks configuration: event → array of hook groups */
4225
4252
  type THooksConfig = Partial<Record<THookEvent, IHookGroup[]>>;
@@ -4235,6 +4262,14 @@ interface IHookInput {
4235
4262
  trigger?: 'auto' | 'manual';
4236
4263
  /** Compaction summary text (PostCompact only) */
4237
4264
  compact_summary?: string;
4265
+ /** User message text (UserPromptSubmit only) */
4266
+ user_message?: string;
4267
+ /** User prompt text — Claude Code compatible alias for user_message (UserPromptSubmit only) */
4268
+ prompt?: string;
4269
+ /** Assistant response text (Stop only) */
4270
+ response?: string;
4271
+ /** Additional environment variables to pass to hook child processes */
4272
+ env?: Record<string, string>;
4238
4273
  }
4239
4274
  /** Hook execution result */
4240
4275
  interface IHookResult {
@@ -4243,11 +4278,21 @@ interface IHookResult {
4243
4278
  stdout: string;
4244
4279
  stderr: string;
4245
4280
  }
4281
+ /** Strategy interface for hook type executors */
4282
+ interface IHookTypeExecutor {
4283
+ /** The hook type this executor handles */
4284
+ type: IHookDefinition['type'];
4285
+ /** Execute a hook definition with the given input */
4286
+ execute(definition: IHookDefinition, input: IHookInput): Promise<IHookResult>;
4287
+ }
4246
4288
 
4247
4289
  /**
4248
- * Hook runner — executes shell command hooks for lifecycle events.
4290
+ * Hook runner — executes hooks for lifecycle events using the strategy pattern.
4291
+ *
4292
+ * Dispatches to registered IHookTypeExecutor implementations by definition type.
4293
+ * Default executors: CommandExecutor (shell), HttpExecutor (HTTP POST).
4249
4294
  *
4250
- * Hooks receive JSON input on stdin and communicate results via exit codes:
4295
+ * Exit code semantics:
4251
4296
  * - 0: allow/proceed
4252
4297
  * - 2: block/deny (stderr contains reason)
4253
4298
  * - other: proceed (logged as warning)
@@ -4258,10 +4303,19 @@ interface IHookResult {
4258
4303
  *
4259
4304
  * For PreToolUse: if any hook returns exit code 2, the tool call is blocked.
4260
4305
  * Returns { blocked: true, reason: string } if blocked, { blocked: false } otherwise.
4306
+ *
4307
+ * @param config - Hooks configuration mapping events to hook groups
4308
+ * @param event - The lifecycle event being fired
4309
+ * @param input - Hook input data passed to executors
4310
+ * @param executors - Optional array of hook type executors (defaults to command + http)
4261
4311
  */
4262
- declare function runHooks(config: THooksConfig | undefined, event: THookEvent, input: IHookInput): Promise<{
4312
+ /** Result of running hooks for an event. */
4313
+ interface IRunHooksResult {
4263
4314
  blocked: boolean;
4264
4315
  reason?: string;
4265
- }>;
4316
+ /** Collected stdout from all successful hooks (exit code 0). */
4317
+ stdout: string;
4318
+ }
4319
+ declare function runHooks(config: THooksConfig | undefined, event: THookEvent, input: IHookInput, executors?: IHookTypeExecutor[]): Promise<IRunHooksResult>;
4266
4320
 
4267
- export { AGENT_EVENTS, AGENT_EVENT_PREFIX, AbstractAIProvider, AbstractAgent, AbstractExecutor, AbstractManager, AbstractPlugin, AbstractTool, AgentFactory, AgentTemplates, AuthenticationError, CLAUDE_MODELS, CacheIntegrityError, CircuitBreakerOpenError, ConfigurationError, ConversationHistory, ConversationSession, DEFAULT_CONTEXT_WINDOW, EVENT_EMITTER_EVENTS, EXECUTION_EVENTS, EXECUTION_EVENT_PREFIX, ErrorUtils, EventEmitterPlugin, EventHistoryModule, ExecutionProxy, type IAIProvider, type IAIProviderInstance, type IAIProviderManager, type IAbstractTool, type IAbstractToolOptions, type IAgent, type IAgentConfig, type IAgentCreationOptions, type IAgentCreationStats, type IAgentEventData, type IAgentFactory, type IAgentFactoryOptions, type IAgentLifecycleEvents, type IAgentTemplate, type IAssistantMessage, type IBaseEventData, type IBaseMessage, type ICacheEntry, type ICacheKey, type ICacheOptions, type ICacheStats, type ICacheStorage, type IChatExecutionRequest, type IChatOptions, type IConfigValidationResult, type IContextOptions, type IContextTokenUsage, type IContextWindowState, type IConversationContext, type IConversationResponse, type IConversationService, type IConversationServiceOptions, type IEventContext, type IEventEmitterEventData, type IEventEmitterHierarchicalEventData, type IEventEmitterMetrics, type IEventEmitterMetricsSnapshot, type IEventEmitterPlugin, type IEventEmitterPluginOptions, type IEventHistoryModule, type IEventHistoryRecord, type IEventHistorySnapshot, type IEventService, type IEventServiceOwnerBinding, type IExecutionEventData, type IExecutionService, type IExecutionServiceOptions, type IExecutor, type IExecutorAwareProviderConfig, type IFunctionTool, type IHookDefinition, type IHookGroup, type IHookInput, type IHookResult, type IImageComposeRequest, type IImageEditRequest, type IImageGenerationProvider, type IImageGenerationRequest, type IImageGenerationResult, type IInlineImageInputSource, type IInlineImageMessagePart, type ILocalExecutorConfig, type ILogger, type IMCPToolConfig, type IMediaOutputRef, type IModelDefinition, type IOpenAPIToolConfig, type IOwnerPathSegment, type IParameterSchema, type IParameterValidationResult, type IPermissionLists, type IPlugin, type IPluginConfig, type IPluginContext, type IPluginContract, type IPluginData, type IPluginErrorContext, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginHooks, type IPluginOptions, type IPluginStats, type IProgressReportingTool, type IProviderConfig, type IProviderMediaError, type IProviderOptions, type IProviderRequest, type IProviderSpecificOptions, type IRawProviderResponse, type IRemoteExecutorConfig, type IRunOptions, type ISimpleValidationResult, type IStreamExecutionRequest, type IStreamingChunk, type ISystemMessage, type ITemplateApplicationResult, type ITextMessagePart, type ITokenUsage, type ITool, type IToolCall, type IToolContract, type IToolEventData, type IToolExecutionContext, type IToolExecutionRequest, type IToolExecutionResult, type IToolExecutionService, type IToolExecutionStep, type IToolFactory, type IToolManager, type IToolMessage, type IToolRegistry, type IToolResult, type IToolSchema, type IToolWithEventService, type IUniversalObjectValue, type IUriImageInputSource, type IUriImageMessagePart, type IUserMessage, type IUtilLogEntry, type IValidationIssue, type IValidationOptions, type IValidationResult, type IVideoGenerationProvider, type IVideoGenerationRequest, type IVideoJobAccepted, type IVideoJobSnapshot, type IWorkflowConfig, type IWorkflowConversionOptions, type IWorkflowConversionResult, type IWorkflowConverter, type IWorkflowData, type IWorkflowMetadata, type IWorkflowValidator, InMemoryEventEmitterMetrics, LocalExecutor, MODE_POLICY, MessageConverter, ModelNotAvailableError, NetworkError, PluginCategory, PluginError, PluginPriority, ProviderError, RateLimitError, Robota, RobotaError, SilentLogger, StorageError, type TAgentCreationMetadata, type TComplexConfigValue, type TConfigData, type TConfigValue, type TContextData, type TConversationContextMetadata, type TErrorContextData, type TErrorExternalInput, type TEventEmitterListener, type TEventListener, type TEventName, type TExecutionEventName, type TExecutionMetadata, type THookEvent, type THooksConfig, type TImageInputSource, type TJSONSchemaEnum, type TJSONSchemaKind, type TKnownToolName, type TLoggerData, type TManagerToolParameters, type TMetadata, type TMetadataValue, TOOL_EVENTS, TOOL_EVENT_PREFIX, type TParameterDefaultValue, type TPermissionDecision, type TPermissionMode, type TPrimitiveValue, type TProviderConfigValue, type TProviderLoggingData, type TProviderMediaResult, type TProviderOptionValueBase, TRUST_TO_MODE, type TResponseMetadata, type TTextDeltaCallback, type TTimerId, type TToolArgs, type TToolExecutionFunction, type TToolExecutionParameters, type TToolExecutor, type TToolMetadata, type TToolParameters, type TToolProgressCallback, type TTrustLevel, type TUniversalArrayValue, type TUniversalMessage, type TUniversalMessageMetadata, type TUniversalMessagePart, type TUniversalMessageRole, type TUniversalValue, type TUtilLogLevel, ToolExecutionError, UNKNOWN_TOOL_FALLBACK, ValidationError, ValidationSeverity, Validator, createExecutionProxy, createLogger, evaluatePermission, formatTokenCount, getGlobalLogLevel, getModelContextWindow, getModelName, getToolEstimatedDuration, getToolExecutionSteps, isAssistantMessage, isImageGenerationProvider, isProgressReportingTool, isSystemMessage, isToolMessage, isUserMessage, isVideoGenerationProvider, logger, runHooks, setGlobalLogLevel, setToolProgressCallback, startPeriodicTask, stopPeriodicTask, validateAgentConfig, validateApiKey, validateModelName, validateProviderName, validateUserInput, withEventEmission };
4321
+ export { AGENT_EVENTS, AGENT_EVENT_PREFIX, AbstractAIProvider, AbstractAgent, AbstractExecutor, AbstractManager, AbstractPlugin, AbstractTool, AgentFactory, AgentTemplates, AuthenticationError, CLAUDE_MODELS, CacheIntegrityError, CircuitBreakerOpenError, ConfigurationError, ConversationHistory, ConversationSession, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT, EVENT_EMITTER_EVENTS, EXECUTION_EVENTS, EXECUTION_EVENT_PREFIX, ErrorUtils, EventEmitterPlugin, EventHistoryModule, ExecutionProxy, type IAIProvider, type IAIProviderInstance, type IAIProviderManager, type IAbstractTool, type IAbstractToolOptions, type IAgent, type IAgentConfig, type IAgentCreationOptions, type IAgentCreationStats, type IAgentEventData, type IAgentFactory, type IAgentFactoryOptions, type IAgentHookDefinition, type IAgentLifecycleEvents, type IAgentTemplate, type IAssistantMessage, type IBaseEventData, type IBaseMessage, type ICacheEntry, type ICacheKey, type ICacheOptions, type ICacheStats, type ICacheStorage, type IChatExecutionRequest, type IChatOptions, type ICommandHookDefinition, type IConfigValidationResult, type IContextOptions, type IContextTokenUsage, type IContextWindowState, type IConversationContext, type IConversationResponse, type IConversationService, type IConversationServiceOptions, type IEventContext, type IEventEmitterEventData, type IEventEmitterHierarchicalEventData, type IEventEmitterMetrics, type IEventEmitterMetricsSnapshot, type IEventEmitterPlugin, type IEventEmitterPluginOptions, type IEventHistoryModule, type IEventHistoryRecord, type IEventHistorySnapshot, type IEventService, type IEventServiceOwnerBinding, type IExecutionEventData, type IExecutionService, type IExecutionServiceOptions, type IExecutor, type IExecutorAwareProviderConfig, type IFunctionTool, type IHookDefinition, type IHookGroup, type IHookInput, type IHookResult, type IHookTypeExecutor, type IHttpHookDefinition, type IImageComposeRequest, type IImageEditRequest, type IImageGenerationProvider, type IImageGenerationRequest, type IImageGenerationResult, type IInlineImageInputSource, type IInlineImageMessagePart, type ILocalExecutorConfig, type ILogger, type IMCPToolConfig, type IMediaOutputRef, type IModelDefinition, type IOpenAPIToolConfig, type IOwnerPathSegment, type IParameterSchema, type IParameterValidationResult, type IPermissionLists, type IPlugin, type IPluginConfig, type IPluginContext, type IPluginContract, type IPluginData, type IPluginErrorContext, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginHooks, type IPluginOptions, type IPluginStats, type IProgressReportingTool, type IPromptHookDefinition, type IProviderConfig, type IProviderMediaError, type IProviderOptions, type IProviderRequest, type IProviderSpecificOptions, type IRawProviderResponse, type IRemoteExecutorConfig, type IRunOptions, type ISimpleValidationResult, type IStreamExecutionRequest, type IStreamingChunk, type ISystemMessage, type ITemplateApplicationResult, type ITextMessagePart, type ITokenUsage, type ITool, type IToolCall, type IToolContract, type IToolEventData, type IToolExecutionContext, type IToolExecutionRequest, type IToolExecutionResult, type IToolExecutionService, type IToolExecutionStep, type IToolFactory, type IToolManager, type IToolMessage, type IToolRegistry, type IToolResult, type IToolSchema, type IToolWithEventService, type IUniversalObjectValue, type IUriImageInputSource, type IUriImageMessagePart, type IUserMessage, type IUtilLogEntry, type IValidationIssue, type IValidationOptions, type IValidationResult, type IVideoGenerationProvider, type IVideoGenerationRequest, type IVideoJobAccepted, type IVideoJobSnapshot, type IWorkflowConfig, type IWorkflowConversionOptions, type IWorkflowConversionResult, type IWorkflowConverter, type IWorkflowData, type IWorkflowMetadata, type IWorkflowValidator, InMemoryEventEmitterMetrics, LocalExecutor, MODE_POLICY, MessageConverter, ModelNotAvailableError, NetworkError, PluginCategory, PluginError, PluginPriority, ProviderError, RateLimitError, Robota, RobotaError, SilentLogger, StorageError, type TAgentCreationMetadata, type TComplexConfigValue, type TConfigData, type TConfigValue, type TContextData, type TConversationContextMetadata, type TErrorContextData, type TErrorExternalInput, type TEventEmitterListener, type TEventListener, type TEventName, type TExecutionEventName, type TExecutionMetadata, type THookEvent, type THooksConfig, type TImageInputSource, type TJSONSchemaEnum, type TJSONSchemaKind, type TKnownToolName, type TLoggerData, type TManagerToolParameters, type TMetadata, type TMetadataValue, TOOL_EVENTS, TOOL_EVENT_PREFIX, type TParameterDefaultValue, type TPermissionDecision, type TPermissionMode, type TPrimitiveValue, type TProviderConfigValue, type TProviderLoggingData, type TProviderMediaResult, type TProviderOptionValueBase, TRUST_TO_MODE, type TResponseMetadata, type TTextDeltaCallback, type TTimerId, type TToolArgs, type TToolExecutionFunction, type TToolExecutionParameters, type TToolExecutor, type TToolMetadata, type TToolParameters, type TToolProgressCallback, type TTrustLevel, type TUniversalArrayValue, type TUniversalMessage, type TUniversalMessageMetadata, type TUniversalMessagePart, type TUniversalMessageRole, type TUniversalValue, type TUtilLogLevel, ToolExecutionError, UNKNOWN_TOOL_FALLBACK, ValidationError, ValidationSeverity, Validator, createExecutionProxy, createLogger, evaluatePermission, formatTokenCount, getGlobalLogLevel, getModelContextWindow, getModelMaxOutput, getModelName, getToolEstimatedDuration, getToolExecutionSteps, isAssistantMessage, isImageGenerationProvider, isProgressReportingTool, isSystemMessage, isToolMessage, isUserMessage, isVideoGenerationProvider, logger, runHooks, setGlobalLogLevel, setToolProgressCallback, startPeriodicTask, stopPeriodicTask, validateAgentConfig, validateApiKey, validateModelName, validateProviderName, validateUserInput, withEventEmission };