@directive-run/ai 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ export { s as AgentCircuitBreakerConfig, t as AgentCompleteEvent, u as AgentErro
3
3
  import { M as MultiAgentOrchestratorOptions, a as MultiAgentOrchestrator, P as ParallelPattern, R as RacePattern, b as ReflectionEvaluation, c as ReflectIterationRecord, d as ReflectPattern, S as SequentialPattern, e as SupervisorPattern, E as ExecutionPattern, D as DebatePattern, A as AgentRegistry, f as RunAgentRequirement, g as DebateResult, h as AgentHealthMetrics, i as DebugTimeline, H as HealthMonitor } from './orchestrator-types-Bh8r3_Sq.cjs';
4
4
  export { j as AgentMemory, k as AgentMemoryConfig, l as AgentOrchestrator, m as AgentRegistration, B as BackpressureStrategy, n as DebugTimelineListener, o as DebugTimelineOptions, p as DoneChunk, q as ErrorChunk, G as GuardrailTriggeredChunk, r as HandoffRequest, s as HandoffResult, t as HealthCircuitState, u as MemoryManageResult, v as MemoryState, w as MemoryStrategy, x as MemoryStrategyConfig, y as MemoryStrategyResult, z as MergedTaggedStreamResult, C as MessageChunk, F as MessageSummarizer, I as MultiAgentRunCallOptions, J as MultiAgentState, K as MultiplexedStreamChunk, L as MultiplexedStreamResult, O as OrchestratorOptions, N as OrchestratorStreamChunk, Q as OrchestratorStreamResult, T as ProgressChunk, U as RaceResult, V as RaceSuccessEntry, W as ReflectionConfig, X as ReflectionContext, Y as ReflectionEvaluator, Z as ReflectionExhaustedError, _ as RunCallOptions, $ as SafeParseResult, a0 as SafeParseable, a1 as StreamChunk, a2 as StreamRunOptions, a3 as StreamRunner, a4 as StreamingGuardrail, a5 as StreamingGuardrailResult, a6 as StreamingRunResult, a7 as StructuredOutputConfig, a8 as StructuredOutputError, a9 as TaskContext, aa as TaskRegistration, ab as TokenChunk, ac as ToolEndChunk, ad as ToolStartChunk, ae as adaptOutputGuardrail, af as collectTokens, ag as combineStreamingGuardrails, ah as createAgentMemory, ai as createAgentOrchestrator, aj as createDebugTimeline, ak as createDebugTimelinePlugin, al as createHealthMonitor, am as createHybridStrategy, an as createKeyPointsSummarizer, ao as createLLMSummarizer, ap as createLengthStreamingGuardrail, aq as createPatternStreamingGuardrail, ar as createSlidingWindowStrategy, as as createStreamingRunner, at as createTokenBasedStrategy, au as createToxicityStreamingGuardrail, av as createTruncationSummarizer, aw as extractJsonFromOutput, ax as filterStream, ay as mapStream, az as mergeTaggedStreams, aA as tapStream, aB as withReflection, aC as withStructuredOutput } from './orchestrator-types-Bh8r3_Sq.cjs';
5
5
  export { AggregatedMetric, AlertConfig, AlertEvent, CircuitBreaker, CircuitBreakerConfig, CircuitBreakerOpenError, CircuitBreakerStats, CircuitState, DashboardData, MetricDataPoint, MetricType, OTLPExporter, OTLPExporterConfig, ObservabilityConfig, ObservabilityInstance, TraceSpan, createCircuitBreaker, createOTLPExporter } from '@directive-run/core/plugins';
6
- import { ModuleSchema, Plugin, SystemInspection } from '@directive-run/core';
6
+ import { ModuleSchema, Plugin, FactPredicate, SchemaValidationError, SystemInspection } from '@directive-run/core';
7
7
  import { E as Embedding, a as EmbedderFn } from './semantic-cache-nBpQqILc.cjs';
8
8
  export { B as BatchedEmbedder, C as CacheEntry, b as CacheLookupResult, c as CacheStats, S as SemanticCache, d as SemanticCacheConfig, e as SemanticCacheStorage, f as createBatchedEmbedder, g as createInMemoryStorage, h as createSemanticCache, i as createSemanticCacheGuardrail, j as createTestEmbedder } from './semantic-cache-nBpQqILc.cjs';
9
9
 
@@ -3240,6 +3240,175 @@ declare function byPattern(pattern: RegExp, model: string): ModelRule;
3240
3240
  */
3241
3241
  declare function withModelSelection(runner: AgentRunner, configOrRules: ModelSelectionConfig | ModelRule[]): AgentRunner;
3242
3242
 
3243
+ /**
3244
+ * predicateFromIntent — let an LLM emit a typed FactPredicate as JSON,
3245
+ * structurally + semantically validated before it ever reaches your
3246
+ * constraint engine.
3247
+ *
3248
+ * Pipeline per call attempt:
3249
+ *
3250
+ * 1. Output-size check (reject before JSON.parse for DoS guard)
3251
+ * 2. JSON.parse via extractJsonFromOutput (handles surrounding prose)
3252
+ * 3. validatePredicate (structural: closed operator set, depth, JSON safety)
3253
+ * 4. Operator-count check
3254
+ * 5. validatePredicateAgainstSchema (semantic: operator-on-kind matrix)
3255
+ *
3256
+ * On any failure: a structured error message — including the offending
3257
+ * clause's path, the allowed operators for that fact's kind, and the
3258
+ * original schema kinds — is fed back to the LLM in the next attempt.
3259
+ *
3260
+ * Returns the validated FactPredicate. Throws PredicateFromIntentError
3261
+ * on retry exhaustion. NEVER returns a partial / unvalidated predicate.
3262
+ */
3263
+
3264
+ interface PredicateFromIntentOptions<_F = Record<string, unknown>> {
3265
+ /** Natural-language intent (untrusted user input — sanitize via `redact`). */
3266
+ intent: string;
3267
+ /**
3268
+ * Module schema (must expose builders with `_typeName` or `_kind`).
3269
+ * Pass either `{ facts: {...} }` or a bare `Record<string, builder>`.
3270
+ */
3271
+ schema: unknown;
3272
+ /** AgentRunner from `@directive-run/ai` adapters (createOpenAIRunner, etc.). */
3273
+ runner: AgentRunner;
3274
+ /**
3275
+ * Optional agent override. Default is `{ name: "predicate-emitter" }`
3276
+ * with our system prompt; pass `instructions` to append additional
3277
+ * context.
3278
+ */
3279
+ agent?: AgentLike;
3280
+ /**
3281
+ * Optional dotted-path namespace; useful for cross-module systems
3282
+ * where the LLM should emit a predicate over `auth.token` (default:
3283
+ * the schema's root facts).
3284
+ */
3285
+ factPath?: string;
3286
+ /** Max retries on validation failure. Default 3. */
3287
+ maxRetries?: number;
3288
+ /**
3289
+ * Hard byte cap on the LLM's raw output, BEFORE JSON.parse. Defaults
3290
+ * to 64 KiB. A larger predicate is rejected outright; protects
3291
+ * against multi-MB-payload DoS where the predicate is technically
3292
+ * structurally valid.
3293
+ */
3294
+ maxPredicateBytes?: number;
3295
+ /**
3296
+ * Hard cap on the number of operator clauses in the predicate.
3297
+ * Defaults to 256. Protects against `{ $any: [{ x: 1 }, … x100,000 ] }`
3298
+ * style operator-count exhaustion.
3299
+ */
3300
+ maxOperatorCount?: number;
3301
+ /**
3302
+ * Optional sanitizer applied to `intent` BEFORE it lands in the
3303
+ * system prompt. Useful for stripping or redacting user-controlled
3304
+ * content that looks like prompt-injection.
3305
+ */
3306
+ redact?: (intent: string) => string;
3307
+ }
3308
+ interface PredicateFromIntentDiagnostics<F = Record<string, unknown>> {
3309
+ /** The validated predicate (`null` if all retries failed). */
3310
+ predicate: FactPredicate<F> | null;
3311
+ /** Number of LLM calls actually made. */
3312
+ attempts: number;
3313
+ /** Errors encountered across all attempts (most recent last). */
3314
+ errors: ReadonlyArray<{
3315
+ attempt: number;
3316
+ reason: string;
3317
+ details?: readonly SchemaValidationError[];
3318
+ }>;
3319
+ /** The raw LLM output from the final attempt — useful for debugging. */
3320
+ lastRawOutput?: string;
3321
+ }
3322
+ /** Thrown by `predicateFromIntent` on retry exhaustion. `predicateFromIntentRaw` returns these as a diagnostics payload instead. */
3323
+ declare class PredicateFromIntentError extends Error {
3324
+ readonly attempts: number;
3325
+ readonly errors: ReadonlyArray<{
3326
+ attempt: number;
3327
+ reason: string;
3328
+ details?: readonly SchemaValidationError[];
3329
+ }>;
3330
+ readonly lastRawOutput: string | undefined;
3331
+ readonly name = "PredicateFromIntentError";
3332
+ constructor(message: string, attempts: number, errors: ReadonlyArray<{
3333
+ attempt: number;
3334
+ reason: string;
3335
+ details?: readonly SchemaValidationError[];
3336
+ }>, lastRawOutput: string | undefined);
3337
+ }
3338
+ /**
3339
+ * Ask an LLM to emit a FactPredicate matching the user's intent, then
3340
+ * validate it structurally + semantically before returning. On validation
3341
+ * failure, retries with structured error feedback in the next prompt.
3342
+ *
3343
+ * Throws {@link PredicateFromIntentError} on retry exhaustion. NEVER
3344
+ * returns a partial / unvalidated predicate.
3345
+ *
3346
+ * @example
3347
+ * ```ts
3348
+ * import { createOpenAIRunner } from "@directive-run/ai/openai";
3349
+ * import { predicateFromIntent } from "@directive-run/ai";
3350
+ *
3351
+ * const runner = createOpenAIRunner({ apiKey, model: "gpt-4o-mini" });
3352
+ *
3353
+ * const predicate = await predicateFromIntent({
3354
+ * intent: "checkout is unblocked when the cart total is at least 50",
3355
+ * schema: myModule.schema,
3356
+ * runner,
3357
+ * });
3358
+ * // → { cartTotal: { $gte: 50 } }
3359
+ * ```
3360
+ */
3361
+ declare function predicateFromIntent<F = Record<string, unknown>>(opts: PredicateFromIntentOptions<F>): Promise<FactPredicate<F>>;
3362
+ /**
3363
+ * Lower-level variant — returns the validated predicate (or null) plus
3364
+ * full diagnostics. Use when you want to surface validation telemetry,
3365
+ * preview the LLM's last raw output, or display per-attempt errors in
3366
+ * a UI.
3367
+ */
3368
+ declare function predicateFromIntentRaw<F = Record<string, unknown>>(opts: PredicateFromIntentOptions<F>): Promise<PredicateFromIntentDiagnostics<F>>;
3369
+ interface PredicateToolSpecOptions {
3370
+ /** Tool name. Default `"emit_predicate"`. */
3371
+ name?: string;
3372
+ /** Tool description. Default: a one-liner describing predicate emission. */
3373
+ description?: string;
3374
+ /** Optional dotted-path namespace to restrict the tool's scope. */
3375
+ factPath?: string;
3376
+ }
3377
+ interface PredicateToolSpec {
3378
+ name: string;
3379
+ description: string;
3380
+ input_schema: {
3381
+ type: "object";
3382
+ properties: {
3383
+ predicate: {
3384
+ type: "object";
3385
+ };
3386
+ };
3387
+ required: ["predicate"];
3388
+ };
3389
+ /** Human-readable schema description — embed in your tool's "description" if your provider concatenates them. */
3390
+ schemaSummary: string;
3391
+ }
3392
+ /**
3393
+ * Produce a function-calling tool spec for OpenAI / Anthropic / similar
3394
+ * APIs. Drop the result into your `tools: [...]` array; the model will
3395
+ * be told to emit a predicate matching this schema, and the resulting
3396
+ * tool call payload can be passed to `predicateFromIntent` /
3397
+ * `validatePredicateAgainstSchema` for safety.
3398
+ *
3399
+ * @example
3400
+ * ```ts
3401
+ * const tool = predicateToolSpec(myModule.schema, { name: "set_checkout_rule" });
3402
+ *
3403
+ * await openai.messages.create({
3404
+ * model: "gpt-4o-mini",
3405
+ * tools: [tool],
3406
+ * messages: [...],
3407
+ * });
3408
+ * ```
3409
+ */
3410
+ declare function predicateToolSpec(schema: unknown, opts?: PredicateToolSpecOptions): PredicateToolSpec;
3411
+
3243
3412
  /**
3244
3413
  * P5: Batch Queue — Application-level batching for agent calls.
3245
3414
  *
@@ -4977,4 +5146,4 @@ interface OtelPlugin {
4977
5146
  */
4978
5147
  declare function createOtelPlugin(config: OtelPluginConfig): OtelPlugin;
4979
5148
 
4980
- export { type ANNIndex, type ANNSearchResult, AdapterHooks, AgentHealthMetrics, type AgentInfo, AgentLike, type AgentMessage, type AgentMessageType, type AgentNetwork, type AgentNetworkConfig, AgentRegistry, AgentRunner, AgentSelectionStrategy, AgentState, AllProvidersFailedError, ApprovalState, type AuditEventType, type AuditInstance, type AuditPluginConfig, type BatchQueue, type BatchQueueConfig, type BidirectionalStream, type BudgetConfig, type BudgetExceededDetails, BudgetExceededError, type BudgetRunner, type BudgetWindow, CheckpointDiff, CheckpointProgress, CheckpointStore, type ComplianceConfig, type ComplianceInstance, type ComplianceStorage, type ConnectDevToolsOptions, type ConstraintRouterConfig, type ConstraintRouterRunner, type CreateRunnerOptions, DEFAULT_INJECTION_PATTERNS, DagExecutionContext, DagNode, DagPattern, type DebateConfig, DebatePattern, DebateResult, DebugEvent, DebugTimeline, type DelegationMessage, type DelegationResultMessage, type DetectedPII, type DevToolsClient, type DevToolsClientMessage, type DevToolsCompatibleOrchestrator, type DevToolsServer, type DevToolsServerConfig, type DevToolsServerMessage, type DevToolsSnapshot, type DevToolsTransport, EmbedderFn, Embedding, type EnhancedPIIGuardrailOptions, type EvalAgentSummary, type EvalAssertOptions, type EvalCase, type EvalCaseResult, type EvalContext, type EvalCostOptions, type EvalCriterion, type EvalCriterionFn, type EvalJudgeOptions, type EvalLatencyOptions, type EvalMatchOptions, type EvalOutputLengthOptions, type EvalResults, type EvalSafetyOptions, type EvalScore, type EvalSemanticOptions, type EvalStructureOptions, type EvalSuite, type EvalSuiteConfig, ExecutionPattern, type FallbackConfig, type GoalAgentDeclaration, type GoalDependencyEdge, type GoalDependencyGraph, type GoalExecutionPlan, type GoalExplanation, type GoalExplanationStep, GoalMetrics, GoalNode, GoalPattern, type GoalPlanStep, GoalResult, type GoalValidationResult, GuardrailFn, HealthMonitor, type InformMessage, type InjectionDetectionResult, InputGuardrailData, type JSONFileStoreOptions, type MCPAdapter, type MCPAdapterConfig, type MCPApprovalRequest, type MCPCallToolRequirement, type MCPGetPromptRequirement, type MCPReadResourceRequirement, type MCPRequirement, type MCPResource, type MCPServerConfig, type MCPSyncResourcesRequirement, type MCPTool, type MCPToolConstraint, type MCPToolResult, type MermaidDirection, type MermaidNodeShapes, type MermaidOptions, Message, type MessageBus, type MessageBusConfig, type MessageFilter, type MessageHandler, type ModelRule, type ModelSelectionConfig, MultiAgentOrchestrator, MultiAgentOrchestratorOptions, OrchestratorConstraint, type OtelPlugin, type OtelPluginConfig, type OtelSpan, OtelStatusCode, type OtelTracer, OutputGuardrailData, type PIIDetectionResult, type PIIDetector, type PIIType, ParallelPattern, type ParsedResponse, PatternCheckpointConfig, PatternCheckpointState, type PromptInjectionGuardrailOptions, type ProviderStats, type QueryMessage, type RAGChunk, type RAGEnrichOptions, type RAGEnricher, type RAGEnricherConfig, type RAGStorage, RacePattern, type RateLimitGuardrail, type RedactionStyle, ReflectIterationRecord, ReflectPattern, ReflectionEvaluation, RelaxationTier, type RequestMessage, type ResponseMessage, type RetryConfig, RetryExhaustedError, type RoutingConstraint, type RoutingFacts, type RoutingProvider, RunAgentRequirement, RunOptions, RunResult, type RunnerMiddleware, type SSEEvent, type SSETransport, type SSETransportConfig, STRICT_INJECTION_PATTERNS, SchemaValidator, Semaphore, SequentialPattern, type SerializedDagNode, type SerializedGoalNode, type SerializedPattern, type SpanData, type SpawnOnConditionOptions, type SpawnPoolConfig, type StreamChannel, type StreamChannelConfig, type StreamChannelState, type Subscription, SupervisorPattern, type TokenPricing, ToolCallGuardrailData, type TypedAgentMessage, type UpdateMessage, type VPTreeIndexConfig, type WsTransportConfig, aggregateTokens, allReadyStrategy, byAgentName, byInputLength, byPattern, capabilityRoute, collectOutputs, composePatterns, concatResults, connectDevTools, convertToolsForLLM, costEfficientStrategy, createAgentAuditHandlers, createAgentNetwork, createAuditTrail, createBatchQueue, createBidirectionalStream, createBruteForceIndex, createCompliance, createConstraintRouter, createContentFilterGuardrail, createDelegator, createDevToolsServer, createEnhancedPIIGuardrail, createEvalSuite, createInMemoryComplianceStorage, createJSONFileStore, createLengthGuardrail, createMCPAdapter, createMessageBus, createModerationGuardrail, createMultiAgentOrchestrator, createOtelPlugin, createOutputPIIGuardrail, createOutputSchemaGuardrail, createOutputTypeGuardrail, createPIIGuardrail, createPromptInjectionGuardrail, createPubSub, createRAGEnricher, createRateLimitGuardrail, createResponder, createRunner, createSSETransport, createStreamChannel, createToolGuardrail, createUntrustedContentGuardrail, createVPTreeIndex, createWsTransport, dag, debate, derivedConstraint, detectAndRedactPII, detectPII, detectPromptInjection, diffCheckpoints, estimateCost, evalAssert, evalCoherence, evalCost, evalFaithfulness, evalJudge, evalLatency, evalMatch, evalOutputLength, evalRelevance, evalSafety, evalStructure, explainGoal, findAgentsByCapability, forkFromCheckpoint, formatSystemMeta, getCheckpointProgress, getDependencyGraph, getPatternStep, goal, hasPendingApprovals, highestImpactStrategy, isAgentRunning, markUntrustedContent, mcpCallTool, mcpGetPrompt, mcpReadResource, mcpSyncResources, mergeStreams, parallel, parseHttpStatus, parseRetryAfter, patternFromJSON, patternToJSON, patternToMermaid, pickBestResult, pipe, pipeThrough, planGoal, race, redactPII, reflect, runAgentRequirement, runDebate, sanitizeInjection, selectAgent, sequential, spawnOnCondition, spawnPool, supervisor, toAIContext, validateBaseURL, validateGoal, withBudget, withFallback, withModelSelection, withRetry };
5149
+ export { type ANNIndex, type ANNSearchResult, AdapterHooks, AgentHealthMetrics, type AgentInfo, AgentLike, type AgentMessage, type AgentMessageType, type AgentNetwork, type AgentNetworkConfig, AgentRegistry, AgentRunner, AgentSelectionStrategy, AgentState, AllProvidersFailedError, ApprovalState, type AuditEventType, type AuditInstance, type AuditPluginConfig, type BatchQueue, type BatchQueueConfig, type BidirectionalStream, type BudgetConfig, type BudgetExceededDetails, BudgetExceededError, type BudgetRunner, type BudgetWindow, CheckpointDiff, CheckpointProgress, CheckpointStore, type ComplianceConfig, type ComplianceInstance, type ComplianceStorage, type ConnectDevToolsOptions, type ConstraintRouterConfig, type ConstraintRouterRunner, type CreateRunnerOptions, DEFAULT_INJECTION_PATTERNS, DagExecutionContext, DagNode, DagPattern, type DebateConfig, DebatePattern, DebateResult, DebugEvent, DebugTimeline, type DelegationMessage, type DelegationResultMessage, type DetectedPII, type DevToolsClient, type DevToolsClientMessage, type DevToolsCompatibleOrchestrator, type DevToolsServer, type DevToolsServerConfig, type DevToolsServerMessage, type DevToolsSnapshot, type DevToolsTransport, EmbedderFn, Embedding, type EnhancedPIIGuardrailOptions, type EvalAgentSummary, type EvalAssertOptions, type EvalCase, type EvalCaseResult, type EvalContext, type EvalCostOptions, type EvalCriterion, type EvalCriterionFn, type EvalJudgeOptions, type EvalLatencyOptions, type EvalMatchOptions, type EvalOutputLengthOptions, type EvalResults, type EvalSafetyOptions, type EvalScore, type EvalSemanticOptions, type EvalStructureOptions, type EvalSuite, type EvalSuiteConfig, ExecutionPattern, type FallbackConfig, type GoalAgentDeclaration, type GoalDependencyEdge, type GoalDependencyGraph, type GoalExecutionPlan, type GoalExplanation, type GoalExplanationStep, GoalMetrics, GoalNode, GoalPattern, type GoalPlanStep, GoalResult, type GoalValidationResult, GuardrailFn, HealthMonitor, type InformMessage, type InjectionDetectionResult, InputGuardrailData, type JSONFileStoreOptions, type MCPAdapter, type MCPAdapterConfig, type MCPApprovalRequest, type MCPCallToolRequirement, type MCPGetPromptRequirement, type MCPReadResourceRequirement, type MCPRequirement, type MCPResource, type MCPServerConfig, type MCPSyncResourcesRequirement, type MCPTool, type MCPToolConstraint, type MCPToolResult, type MermaidDirection, type MermaidNodeShapes, type MermaidOptions, Message, type MessageBus, type MessageBusConfig, type MessageFilter, type MessageHandler, type ModelRule, type ModelSelectionConfig, MultiAgentOrchestrator, MultiAgentOrchestratorOptions, OrchestratorConstraint, type OtelPlugin, type OtelPluginConfig, type OtelSpan, OtelStatusCode, type OtelTracer, OutputGuardrailData, type PIIDetectionResult, type PIIDetector, type PIIType, ParallelPattern, type ParsedResponse, PatternCheckpointConfig, PatternCheckpointState, type PredicateFromIntentDiagnostics, PredicateFromIntentError, type PredicateFromIntentOptions, type PredicateToolSpec, type PredicateToolSpecOptions, type PromptInjectionGuardrailOptions, type ProviderStats, type QueryMessage, type RAGChunk, type RAGEnrichOptions, type RAGEnricher, type RAGEnricherConfig, type RAGStorage, RacePattern, type RateLimitGuardrail, type RedactionStyle, ReflectIterationRecord, ReflectPattern, ReflectionEvaluation, RelaxationTier, type RequestMessage, type ResponseMessage, type RetryConfig, RetryExhaustedError, type RoutingConstraint, type RoutingFacts, type RoutingProvider, RunAgentRequirement, RunOptions, RunResult, type RunnerMiddleware, type SSEEvent, type SSETransport, type SSETransportConfig, STRICT_INJECTION_PATTERNS, SchemaValidator, Semaphore, SequentialPattern, type SerializedDagNode, type SerializedGoalNode, type SerializedPattern, type SpanData, type SpawnOnConditionOptions, type SpawnPoolConfig, type StreamChannel, type StreamChannelConfig, type StreamChannelState, type Subscription, SupervisorPattern, type TokenPricing, ToolCallGuardrailData, type TypedAgentMessage, type UpdateMessage, type VPTreeIndexConfig, type WsTransportConfig, aggregateTokens, allReadyStrategy, byAgentName, byInputLength, byPattern, capabilityRoute, collectOutputs, composePatterns, concatResults, connectDevTools, convertToolsForLLM, costEfficientStrategy, createAgentAuditHandlers, createAgentNetwork, createAuditTrail, createBatchQueue, createBidirectionalStream, createBruteForceIndex, createCompliance, createConstraintRouter, createContentFilterGuardrail, createDelegator, createDevToolsServer, createEnhancedPIIGuardrail, createEvalSuite, createInMemoryComplianceStorage, createJSONFileStore, createLengthGuardrail, createMCPAdapter, createMessageBus, createModerationGuardrail, createMultiAgentOrchestrator, createOtelPlugin, createOutputPIIGuardrail, createOutputSchemaGuardrail, createOutputTypeGuardrail, createPIIGuardrail, createPromptInjectionGuardrail, createPubSub, createRAGEnricher, createRateLimitGuardrail, createResponder, createRunner, createSSETransport, createStreamChannel, createToolGuardrail, createUntrustedContentGuardrail, createVPTreeIndex, createWsTransport, dag, debate, derivedConstraint, detectAndRedactPII, detectPII, detectPromptInjection, diffCheckpoints, estimateCost, evalAssert, evalCoherence, evalCost, evalFaithfulness, evalJudge, evalLatency, evalMatch, evalOutputLength, evalRelevance, evalSafety, evalStructure, explainGoal, findAgentsByCapability, forkFromCheckpoint, formatSystemMeta, getCheckpointProgress, getDependencyGraph, getPatternStep, goal, hasPendingApprovals, highestImpactStrategy, isAgentRunning, markUntrustedContent, mcpCallTool, mcpGetPrompt, mcpReadResource, mcpSyncResources, mergeStreams, parallel, parseHttpStatus, parseRetryAfter, patternFromJSON, patternToJSON, patternToMermaid, pickBestResult, pipe, pipeThrough, planGoal, predicateFromIntent, predicateFromIntentRaw, predicateToolSpec, race, redactPII, reflect, runAgentRequirement, runDebate, sanitizeInjection, selectAgent, sequential, spawnOnCondition, spawnPool, supervisor, toAIContext, validateBaseURL, validateGoal, withBudget, withFallback, withModelSelection, withRetry };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { s as AgentCircuitBreakerConfig, t as AgentCompleteEvent, u as AgentErro
3
3
  import { M as MultiAgentOrchestratorOptions, a as MultiAgentOrchestrator, P as ParallelPattern, R as RacePattern, b as ReflectionEvaluation, c as ReflectIterationRecord, d as ReflectPattern, S as SequentialPattern, e as SupervisorPattern, E as ExecutionPattern, D as DebatePattern, A as AgentRegistry, f as RunAgentRequirement, g as DebateResult, h as AgentHealthMetrics, i as DebugTimeline, H as HealthMonitor } from './orchestrator-types-CTfIKk0W.js';
4
4
  export { j as AgentMemory, k as AgentMemoryConfig, l as AgentOrchestrator, m as AgentRegistration, B as BackpressureStrategy, n as DebugTimelineListener, o as DebugTimelineOptions, p as DoneChunk, q as ErrorChunk, G as GuardrailTriggeredChunk, r as HandoffRequest, s as HandoffResult, t as HealthCircuitState, u as MemoryManageResult, v as MemoryState, w as MemoryStrategy, x as MemoryStrategyConfig, y as MemoryStrategyResult, z as MergedTaggedStreamResult, C as MessageChunk, F as MessageSummarizer, I as MultiAgentRunCallOptions, J as MultiAgentState, K as MultiplexedStreamChunk, L as MultiplexedStreamResult, O as OrchestratorOptions, N as OrchestratorStreamChunk, Q as OrchestratorStreamResult, T as ProgressChunk, U as RaceResult, V as RaceSuccessEntry, W as ReflectionConfig, X as ReflectionContext, Y as ReflectionEvaluator, Z as ReflectionExhaustedError, _ as RunCallOptions, $ as SafeParseResult, a0 as SafeParseable, a1 as StreamChunk, a2 as StreamRunOptions, a3 as StreamRunner, a4 as StreamingGuardrail, a5 as StreamingGuardrailResult, a6 as StreamingRunResult, a7 as StructuredOutputConfig, a8 as StructuredOutputError, a9 as TaskContext, aa as TaskRegistration, ab as TokenChunk, ac as ToolEndChunk, ad as ToolStartChunk, ae as adaptOutputGuardrail, af as collectTokens, ag as combineStreamingGuardrails, ah as createAgentMemory, ai as createAgentOrchestrator, aj as createDebugTimeline, ak as createDebugTimelinePlugin, al as createHealthMonitor, am as createHybridStrategy, an as createKeyPointsSummarizer, ao as createLLMSummarizer, ap as createLengthStreamingGuardrail, aq as createPatternStreamingGuardrail, ar as createSlidingWindowStrategy, as as createStreamingRunner, at as createTokenBasedStrategy, au as createToxicityStreamingGuardrail, av as createTruncationSummarizer, aw as extractJsonFromOutput, ax as filterStream, ay as mapStream, az as mergeTaggedStreams, aA as tapStream, aB as withReflection, aC as withStructuredOutput } from './orchestrator-types-CTfIKk0W.js';
5
5
  export { AggregatedMetric, AlertConfig, AlertEvent, CircuitBreaker, CircuitBreakerConfig, CircuitBreakerOpenError, CircuitBreakerStats, CircuitState, DashboardData, MetricDataPoint, MetricType, OTLPExporter, OTLPExporterConfig, ObservabilityConfig, ObservabilityInstance, TraceSpan, createCircuitBreaker, createOTLPExporter } from '@directive-run/core/plugins';
6
- import { ModuleSchema, Plugin, SystemInspection } from '@directive-run/core';
6
+ import { ModuleSchema, Plugin, FactPredicate, SchemaValidationError, SystemInspection } from '@directive-run/core';
7
7
  import { E as Embedding, a as EmbedderFn } from './semantic-cache-nBpQqILc.js';
8
8
  export { B as BatchedEmbedder, C as CacheEntry, b as CacheLookupResult, c as CacheStats, S as SemanticCache, d as SemanticCacheConfig, e as SemanticCacheStorage, f as createBatchedEmbedder, g as createInMemoryStorage, h as createSemanticCache, i as createSemanticCacheGuardrail, j as createTestEmbedder } from './semantic-cache-nBpQqILc.js';
9
9
 
@@ -3240,6 +3240,175 @@ declare function byPattern(pattern: RegExp, model: string): ModelRule;
3240
3240
  */
3241
3241
  declare function withModelSelection(runner: AgentRunner, configOrRules: ModelSelectionConfig | ModelRule[]): AgentRunner;
3242
3242
 
3243
+ /**
3244
+ * predicateFromIntent — let an LLM emit a typed FactPredicate as JSON,
3245
+ * structurally + semantically validated before it ever reaches your
3246
+ * constraint engine.
3247
+ *
3248
+ * Pipeline per call attempt:
3249
+ *
3250
+ * 1. Output-size check (reject before JSON.parse for DoS guard)
3251
+ * 2. JSON.parse via extractJsonFromOutput (handles surrounding prose)
3252
+ * 3. validatePredicate (structural: closed operator set, depth, JSON safety)
3253
+ * 4. Operator-count check
3254
+ * 5. validatePredicateAgainstSchema (semantic: operator-on-kind matrix)
3255
+ *
3256
+ * On any failure: a structured error message — including the offending
3257
+ * clause's path, the allowed operators for that fact's kind, and the
3258
+ * original schema kinds — is fed back to the LLM in the next attempt.
3259
+ *
3260
+ * Returns the validated FactPredicate. Throws PredicateFromIntentError
3261
+ * on retry exhaustion. NEVER returns a partial / unvalidated predicate.
3262
+ */
3263
+
3264
+ interface PredicateFromIntentOptions<_F = Record<string, unknown>> {
3265
+ /** Natural-language intent (untrusted user input — sanitize via `redact`). */
3266
+ intent: string;
3267
+ /**
3268
+ * Module schema (must expose builders with `_typeName` or `_kind`).
3269
+ * Pass either `{ facts: {...} }` or a bare `Record<string, builder>`.
3270
+ */
3271
+ schema: unknown;
3272
+ /** AgentRunner from `@directive-run/ai` adapters (createOpenAIRunner, etc.). */
3273
+ runner: AgentRunner;
3274
+ /**
3275
+ * Optional agent override. Default is `{ name: "predicate-emitter" }`
3276
+ * with our system prompt; pass `instructions` to append additional
3277
+ * context.
3278
+ */
3279
+ agent?: AgentLike;
3280
+ /**
3281
+ * Optional dotted-path namespace; useful for cross-module systems
3282
+ * where the LLM should emit a predicate over `auth.token` (default:
3283
+ * the schema's root facts).
3284
+ */
3285
+ factPath?: string;
3286
+ /** Max retries on validation failure. Default 3. */
3287
+ maxRetries?: number;
3288
+ /**
3289
+ * Hard byte cap on the LLM's raw output, BEFORE JSON.parse. Defaults
3290
+ * to 64 KiB. A larger predicate is rejected outright; protects
3291
+ * against multi-MB-payload DoS where the predicate is technically
3292
+ * structurally valid.
3293
+ */
3294
+ maxPredicateBytes?: number;
3295
+ /**
3296
+ * Hard cap on the number of operator clauses in the predicate.
3297
+ * Defaults to 256. Protects against `{ $any: [{ x: 1 }, … x100,000 ] }`
3298
+ * style operator-count exhaustion.
3299
+ */
3300
+ maxOperatorCount?: number;
3301
+ /**
3302
+ * Optional sanitizer applied to `intent` BEFORE it lands in the
3303
+ * system prompt. Useful for stripping or redacting user-controlled
3304
+ * content that looks like prompt-injection.
3305
+ */
3306
+ redact?: (intent: string) => string;
3307
+ }
3308
+ interface PredicateFromIntentDiagnostics<F = Record<string, unknown>> {
3309
+ /** The validated predicate (`null` if all retries failed). */
3310
+ predicate: FactPredicate<F> | null;
3311
+ /** Number of LLM calls actually made. */
3312
+ attempts: number;
3313
+ /** Errors encountered across all attempts (most recent last). */
3314
+ errors: ReadonlyArray<{
3315
+ attempt: number;
3316
+ reason: string;
3317
+ details?: readonly SchemaValidationError[];
3318
+ }>;
3319
+ /** The raw LLM output from the final attempt — useful for debugging. */
3320
+ lastRawOutput?: string;
3321
+ }
3322
+ /** Thrown by `predicateFromIntent` on retry exhaustion. `predicateFromIntentRaw` returns these as a diagnostics payload instead. */
3323
+ declare class PredicateFromIntentError extends Error {
3324
+ readonly attempts: number;
3325
+ readonly errors: ReadonlyArray<{
3326
+ attempt: number;
3327
+ reason: string;
3328
+ details?: readonly SchemaValidationError[];
3329
+ }>;
3330
+ readonly lastRawOutput: string | undefined;
3331
+ readonly name = "PredicateFromIntentError";
3332
+ constructor(message: string, attempts: number, errors: ReadonlyArray<{
3333
+ attempt: number;
3334
+ reason: string;
3335
+ details?: readonly SchemaValidationError[];
3336
+ }>, lastRawOutput: string | undefined);
3337
+ }
3338
+ /**
3339
+ * Ask an LLM to emit a FactPredicate matching the user's intent, then
3340
+ * validate it structurally + semantically before returning. On validation
3341
+ * failure, retries with structured error feedback in the next prompt.
3342
+ *
3343
+ * Throws {@link PredicateFromIntentError} on retry exhaustion. NEVER
3344
+ * returns a partial / unvalidated predicate.
3345
+ *
3346
+ * @example
3347
+ * ```ts
3348
+ * import { createOpenAIRunner } from "@directive-run/ai/openai";
3349
+ * import { predicateFromIntent } from "@directive-run/ai";
3350
+ *
3351
+ * const runner = createOpenAIRunner({ apiKey, model: "gpt-4o-mini" });
3352
+ *
3353
+ * const predicate = await predicateFromIntent({
3354
+ * intent: "checkout is unblocked when the cart total is at least 50",
3355
+ * schema: myModule.schema,
3356
+ * runner,
3357
+ * });
3358
+ * // → { cartTotal: { $gte: 50 } }
3359
+ * ```
3360
+ */
3361
+ declare function predicateFromIntent<F = Record<string, unknown>>(opts: PredicateFromIntentOptions<F>): Promise<FactPredicate<F>>;
3362
+ /**
3363
+ * Lower-level variant — returns the validated predicate (or null) plus
3364
+ * full diagnostics. Use when you want to surface validation telemetry,
3365
+ * preview the LLM's last raw output, or display per-attempt errors in
3366
+ * a UI.
3367
+ */
3368
+ declare function predicateFromIntentRaw<F = Record<string, unknown>>(opts: PredicateFromIntentOptions<F>): Promise<PredicateFromIntentDiagnostics<F>>;
3369
+ interface PredicateToolSpecOptions {
3370
+ /** Tool name. Default `"emit_predicate"`. */
3371
+ name?: string;
3372
+ /** Tool description. Default: a one-liner describing predicate emission. */
3373
+ description?: string;
3374
+ /** Optional dotted-path namespace to restrict the tool's scope. */
3375
+ factPath?: string;
3376
+ }
3377
+ interface PredicateToolSpec {
3378
+ name: string;
3379
+ description: string;
3380
+ input_schema: {
3381
+ type: "object";
3382
+ properties: {
3383
+ predicate: {
3384
+ type: "object";
3385
+ };
3386
+ };
3387
+ required: ["predicate"];
3388
+ };
3389
+ /** Human-readable schema description — embed in your tool's "description" if your provider concatenates them. */
3390
+ schemaSummary: string;
3391
+ }
3392
+ /**
3393
+ * Produce a function-calling tool spec for OpenAI / Anthropic / similar
3394
+ * APIs. Drop the result into your `tools: [...]` array; the model will
3395
+ * be told to emit a predicate matching this schema, and the resulting
3396
+ * tool call payload can be passed to `predicateFromIntent` /
3397
+ * `validatePredicateAgainstSchema` for safety.
3398
+ *
3399
+ * @example
3400
+ * ```ts
3401
+ * const tool = predicateToolSpec(myModule.schema, { name: "set_checkout_rule" });
3402
+ *
3403
+ * await openai.messages.create({
3404
+ * model: "gpt-4o-mini",
3405
+ * tools: [tool],
3406
+ * messages: [...],
3407
+ * });
3408
+ * ```
3409
+ */
3410
+ declare function predicateToolSpec(schema: unknown, opts?: PredicateToolSpecOptions): PredicateToolSpec;
3411
+
3243
3412
  /**
3244
3413
  * P5: Batch Queue — Application-level batching for agent calls.
3245
3414
  *
@@ -4977,4 +5146,4 @@ interface OtelPlugin {
4977
5146
  */
4978
5147
  declare function createOtelPlugin(config: OtelPluginConfig): OtelPlugin;
4979
5148
 
4980
- export { type ANNIndex, type ANNSearchResult, AdapterHooks, AgentHealthMetrics, type AgentInfo, AgentLike, type AgentMessage, type AgentMessageType, type AgentNetwork, type AgentNetworkConfig, AgentRegistry, AgentRunner, AgentSelectionStrategy, AgentState, AllProvidersFailedError, ApprovalState, type AuditEventType, type AuditInstance, type AuditPluginConfig, type BatchQueue, type BatchQueueConfig, type BidirectionalStream, type BudgetConfig, type BudgetExceededDetails, BudgetExceededError, type BudgetRunner, type BudgetWindow, CheckpointDiff, CheckpointProgress, CheckpointStore, type ComplianceConfig, type ComplianceInstance, type ComplianceStorage, type ConnectDevToolsOptions, type ConstraintRouterConfig, type ConstraintRouterRunner, type CreateRunnerOptions, DEFAULT_INJECTION_PATTERNS, DagExecutionContext, DagNode, DagPattern, type DebateConfig, DebatePattern, DebateResult, DebugEvent, DebugTimeline, type DelegationMessage, type DelegationResultMessage, type DetectedPII, type DevToolsClient, type DevToolsClientMessage, type DevToolsCompatibleOrchestrator, type DevToolsServer, type DevToolsServerConfig, type DevToolsServerMessage, type DevToolsSnapshot, type DevToolsTransport, EmbedderFn, Embedding, type EnhancedPIIGuardrailOptions, type EvalAgentSummary, type EvalAssertOptions, type EvalCase, type EvalCaseResult, type EvalContext, type EvalCostOptions, type EvalCriterion, type EvalCriterionFn, type EvalJudgeOptions, type EvalLatencyOptions, type EvalMatchOptions, type EvalOutputLengthOptions, type EvalResults, type EvalSafetyOptions, type EvalScore, type EvalSemanticOptions, type EvalStructureOptions, type EvalSuite, type EvalSuiteConfig, ExecutionPattern, type FallbackConfig, type GoalAgentDeclaration, type GoalDependencyEdge, type GoalDependencyGraph, type GoalExecutionPlan, type GoalExplanation, type GoalExplanationStep, GoalMetrics, GoalNode, GoalPattern, type GoalPlanStep, GoalResult, type GoalValidationResult, GuardrailFn, HealthMonitor, type InformMessage, type InjectionDetectionResult, InputGuardrailData, type JSONFileStoreOptions, type MCPAdapter, type MCPAdapterConfig, type MCPApprovalRequest, type MCPCallToolRequirement, type MCPGetPromptRequirement, type MCPReadResourceRequirement, type MCPRequirement, type MCPResource, type MCPServerConfig, type MCPSyncResourcesRequirement, type MCPTool, type MCPToolConstraint, type MCPToolResult, type MermaidDirection, type MermaidNodeShapes, type MermaidOptions, Message, type MessageBus, type MessageBusConfig, type MessageFilter, type MessageHandler, type ModelRule, type ModelSelectionConfig, MultiAgentOrchestrator, MultiAgentOrchestratorOptions, OrchestratorConstraint, type OtelPlugin, type OtelPluginConfig, type OtelSpan, OtelStatusCode, type OtelTracer, OutputGuardrailData, type PIIDetectionResult, type PIIDetector, type PIIType, ParallelPattern, type ParsedResponse, PatternCheckpointConfig, PatternCheckpointState, type PromptInjectionGuardrailOptions, type ProviderStats, type QueryMessage, type RAGChunk, type RAGEnrichOptions, type RAGEnricher, type RAGEnricherConfig, type RAGStorage, RacePattern, type RateLimitGuardrail, type RedactionStyle, ReflectIterationRecord, ReflectPattern, ReflectionEvaluation, RelaxationTier, type RequestMessage, type ResponseMessage, type RetryConfig, RetryExhaustedError, type RoutingConstraint, type RoutingFacts, type RoutingProvider, RunAgentRequirement, RunOptions, RunResult, type RunnerMiddleware, type SSEEvent, type SSETransport, type SSETransportConfig, STRICT_INJECTION_PATTERNS, SchemaValidator, Semaphore, SequentialPattern, type SerializedDagNode, type SerializedGoalNode, type SerializedPattern, type SpanData, type SpawnOnConditionOptions, type SpawnPoolConfig, type StreamChannel, type StreamChannelConfig, type StreamChannelState, type Subscription, SupervisorPattern, type TokenPricing, ToolCallGuardrailData, type TypedAgentMessage, type UpdateMessage, type VPTreeIndexConfig, type WsTransportConfig, aggregateTokens, allReadyStrategy, byAgentName, byInputLength, byPattern, capabilityRoute, collectOutputs, composePatterns, concatResults, connectDevTools, convertToolsForLLM, costEfficientStrategy, createAgentAuditHandlers, createAgentNetwork, createAuditTrail, createBatchQueue, createBidirectionalStream, createBruteForceIndex, createCompliance, createConstraintRouter, createContentFilterGuardrail, createDelegator, createDevToolsServer, createEnhancedPIIGuardrail, createEvalSuite, createInMemoryComplianceStorage, createJSONFileStore, createLengthGuardrail, createMCPAdapter, createMessageBus, createModerationGuardrail, createMultiAgentOrchestrator, createOtelPlugin, createOutputPIIGuardrail, createOutputSchemaGuardrail, createOutputTypeGuardrail, createPIIGuardrail, createPromptInjectionGuardrail, createPubSub, createRAGEnricher, createRateLimitGuardrail, createResponder, createRunner, createSSETransport, createStreamChannel, createToolGuardrail, createUntrustedContentGuardrail, createVPTreeIndex, createWsTransport, dag, debate, derivedConstraint, detectAndRedactPII, detectPII, detectPromptInjection, diffCheckpoints, estimateCost, evalAssert, evalCoherence, evalCost, evalFaithfulness, evalJudge, evalLatency, evalMatch, evalOutputLength, evalRelevance, evalSafety, evalStructure, explainGoal, findAgentsByCapability, forkFromCheckpoint, formatSystemMeta, getCheckpointProgress, getDependencyGraph, getPatternStep, goal, hasPendingApprovals, highestImpactStrategy, isAgentRunning, markUntrustedContent, mcpCallTool, mcpGetPrompt, mcpReadResource, mcpSyncResources, mergeStreams, parallel, parseHttpStatus, parseRetryAfter, patternFromJSON, patternToJSON, patternToMermaid, pickBestResult, pipe, pipeThrough, planGoal, race, redactPII, reflect, runAgentRequirement, runDebate, sanitizeInjection, selectAgent, sequential, spawnOnCondition, spawnPool, supervisor, toAIContext, validateBaseURL, validateGoal, withBudget, withFallback, withModelSelection, withRetry };
5149
+ export { type ANNIndex, type ANNSearchResult, AdapterHooks, AgentHealthMetrics, type AgentInfo, AgentLike, type AgentMessage, type AgentMessageType, type AgentNetwork, type AgentNetworkConfig, AgentRegistry, AgentRunner, AgentSelectionStrategy, AgentState, AllProvidersFailedError, ApprovalState, type AuditEventType, type AuditInstance, type AuditPluginConfig, type BatchQueue, type BatchQueueConfig, type BidirectionalStream, type BudgetConfig, type BudgetExceededDetails, BudgetExceededError, type BudgetRunner, type BudgetWindow, CheckpointDiff, CheckpointProgress, CheckpointStore, type ComplianceConfig, type ComplianceInstance, type ComplianceStorage, type ConnectDevToolsOptions, type ConstraintRouterConfig, type ConstraintRouterRunner, type CreateRunnerOptions, DEFAULT_INJECTION_PATTERNS, DagExecutionContext, DagNode, DagPattern, type DebateConfig, DebatePattern, DebateResult, DebugEvent, DebugTimeline, type DelegationMessage, type DelegationResultMessage, type DetectedPII, type DevToolsClient, type DevToolsClientMessage, type DevToolsCompatibleOrchestrator, type DevToolsServer, type DevToolsServerConfig, type DevToolsServerMessage, type DevToolsSnapshot, type DevToolsTransport, EmbedderFn, Embedding, type EnhancedPIIGuardrailOptions, type EvalAgentSummary, type EvalAssertOptions, type EvalCase, type EvalCaseResult, type EvalContext, type EvalCostOptions, type EvalCriterion, type EvalCriterionFn, type EvalJudgeOptions, type EvalLatencyOptions, type EvalMatchOptions, type EvalOutputLengthOptions, type EvalResults, type EvalSafetyOptions, type EvalScore, type EvalSemanticOptions, type EvalStructureOptions, type EvalSuite, type EvalSuiteConfig, ExecutionPattern, type FallbackConfig, type GoalAgentDeclaration, type GoalDependencyEdge, type GoalDependencyGraph, type GoalExecutionPlan, type GoalExplanation, type GoalExplanationStep, GoalMetrics, GoalNode, GoalPattern, type GoalPlanStep, GoalResult, type GoalValidationResult, GuardrailFn, HealthMonitor, type InformMessage, type InjectionDetectionResult, InputGuardrailData, type JSONFileStoreOptions, type MCPAdapter, type MCPAdapterConfig, type MCPApprovalRequest, type MCPCallToolRequirement, type MCPGetPromptRequirement, type MCPReadResourceRequirement, type MCPRequirement, type MCPResource, type MCPServerConfig, type MCPSyncResourcesRequirement, type MCPTool, type MCPToolConstraint, type MCPToolResult, type MermaidDirection, type MermaidNodeShapes, type MermaidOptions, Message, type MessageBus, type MessageBusConfig, type MessageFilter, type MessageHandler, type ModelRule, type ModelSelectionConfig, MultiAgentOrchestrator, MultiAgentOrchestratorOptions, OrchestratorConstraint, type OtelPlugin, type OtelPluginConfig, type OtelSpan, OtelStatusCode, type OtelTracer, OutputGuardrailData, type PIIDetectionResult, type PIIDetector, type PIIType, ParallelPattern, type ParsedResponse, PatternCheckpointConfig, PatternCheckpointState, type PredicateFromIntentDiagnostics, PredicateFromIntentError, type PredicateFromIntentOptions, type PredicateToolSpec, type PredicateToolSpecOptions, type PromptInjectionGuardrailOptions, type ProviderStats, type QueryMessage, type RAGChunk, type RAGEnrichOptions, type RAGEnricher, type RAGEnricherConfig, type RAGStorage, RacePattern, type RateLimitGuardrail, type RedactionStyle, ReflectIterationRecord, ReflectPattern, ReflectionEvaluation, RelaxationTier, type RequestMessage, type ResponseMessage, type RetryConfig, RetryExhaustedError, type RoutingConstraint, type RoutingFacts, type RoutingProvider, RunAgentRequirement, RunOptions, RunResult, type RunnerMiddleware, type SSEEvent, type SSETransport, type SSETransportConfig, STRICT_INJECTION_PATTERNS, SchemaValidator, Semaphore, SequentialPattern, type SerializedDagNode, type SerializedGoalNode, type SerializedPattern, type SpanData, type SpawnOnConditionOptions, type SpawnPoolConfig, type StreamChannel, type StreamChannelConfig, type StreamChannelState, type Subscription, SupervisorPattern, type TokenPricing, ToolCallGuardrailData, type TypedAgentMessage, type UpdateMessage, type VPTreeIndexConfig, type WsTransportConfig, aggregateTokens, allReadyStrategy, byAgentName, byInputLength, byPattern, capabilityRoute, collectOutputs, composePatterns, concatResults, connectDevTools, convertToolsForLLM, costEfficientStrategy, createAgentAuditHandlers, createAgentNetwork, createAuditTrail, createBatchQueue, createBidirectionalStream, createBruteForceIndex, createCompliance, createConstraintRouter, createContentFilterGuardrail, createDelegator, createDevToolsServer, createEnhancedPIIGuardrail, createEvalSuite, createInMemoryComplianceStorage, createJSONFileStore, createLengthGuardrail, createMCPAdapter, createMessageBus, createModerationGuardrail, createMultiAgentOrchestrator, createOtelPlugin, createOutputPIIGuardrail, createOutputSchemaGuardrail, createOutputTypeGuardrail, createPIIGuardrail, createPromptInjectionGuardrail, createPubSub, createRAGEnricher, createRateLimitGuardrail, createResponder, createRunner, createSSETransport, createStreamChannel, createToolGuardrail, createUntrustedContentGuardrail, createVPTreeIndex, createWsTransport, dag, debate, derivedConstraint, detectAndRedactPII, detectPII, detectPromptInjection, diffCheckpoints, estimateCost, evalAssert, evalCoherence, evalCost, evalFaithfulness, evalJudge, evalLatency, evalMatch, evalOutputLength, evalRelevance, evalSafety, evalStructure, explainGoal, findAgentsByCapability, forkFromCheckpoint, formatSystemMeta, getCheckpointProgress, getDependencyGraph, getPatternStep, goal, hasPendingApprovals, highestImpactStrategy, isAgentRunning, markUntrustedContent, mcpCallTool, mcpGetPrompt, mcpReadResource, mcpSyncResources, mergeStreams, parallel, parseHttpStatus, parseRetryAfter, patternFromJSON, patternToJSON, patternToMermaid, pickBestResult, pipe, pipeThrough, planGoal, predicateFromIntent, predicateFromIntentRaw, predicateToolSpec, race, redactPII, reflect, runAgentRequirement, runDebate, sanitizeInjection, selectAgent, sequential, spawnOnCondition, spawnPool, supervisor, toAIContext, validateBaseURL, validateGoal, withBudget, withFallback, withModelSelection, withRetry };