@directive-run/ai 1.12.0 → 1.13.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
@@ -3304,6 +3304,49 @@ interface PredicateFromIntentOptions<_F = Record<string, unknown>> {
3304
3304
  * content that looks like prompt-injection.
3305
3305
  */
3306
3306
  redact?: (intent: string) => string;
3307
+ /**
3308
+ * Hard cap on the length of each `$in` / `$nin` array operand the LLM
3309
+ * may emit. Defaults to 1000. Forwarded to
3310
+ * `validatePredicateAgainstSchema`'s `maxArrayOperandLength`.
3311
+ */
3312
+ maxArrayOperandLength?: number;
3313
+ /**
3314
+ * Optional `AbortSignal` for cooperative cancellation. (N6)
3315
+ *
3316
+ * The retry loop checks `signal.aborted` between attempts AND forwards
3317
+ * the signal into the runner call itself (`runner(agent, input, { signal })`).
3318
+ * Whether the in-flight LLM call honors the signal depends on the runner:
3319
+ * fetch-based adapters (the bundled OpenAI / Anthropic / Ollama runners)
3320
+ * thread it through to `fetch`, so the network call aborts mid-stream.
3321
+ * A custom runner that ignores the signal still delivers cancellation
3322
+ * at the next retry boundary.
3323
+ *
3324
+ * On abort: throws `Error("aborted")`.
3325
+ *
3326
+ * NOTE: `predicateFromIntent` does NOT limit in-flight calls — callers
3327
+ * MUST wrap with a concurrency limiter (e.g. `p-limit`) to bound
3328
+ * fan-out under load.
3329
+ */
3330
+ signal?: AbortSignal;
3331
+ /**
3332
+ * When `true`, the {@link PredicateFromIntentProvenance} returned by
3333
+ * `predicateFromIntentWithProvenance` omits the raw `intent` string and
3334
+ * stores only the SHA-256 `intentHash`. Use this in PII-sensitive
3335
+ * contexts where the original intent must not be persisted. (M6)
3336
+ *
3337
+ * **Default `false` for back-compat.** For PII-sensitive deployments,
3338
+ * ALWAYS set `redactIntent: true` — the raw intent may contain
3339
+ * user-supplied content (names, emails, medical or financial details,
3340
+ * customer messages) that becomes a permanent record in
3341
+ * `provenance.intent`. The default is opt-in only because flipping it
3342
+ * now would silently strip diagnostic data from existing callers; v2
3343
+ * may flip this default (tracked in IDEAS.md).
3344
+ *
3345
+ * Pair with a `redact:` sanitizer when the intent itself must be
3346
+ * scrubbed BEFORE it lands in the LLM prompt — `redactIntent` controls
3347
+ * only what enters the provenance record, not what the LLM sees.
3348
+ */
3349
+ redactIntent?: boolean;
3307
3350
  }
3308
3351
  interface PredicateFromIntentDiagnostics<F = Record<string, unknown>> {
3309
3352
  /** The validated predicate (`null` if all retries failed). */
@@ -3343,6 +3386,11 @@ declare class PredicateFromIntentError extends Error {
3343
3386
  * Throws {@link PredicateFromIntentError} on retry exhaustion. NEVER
3344
3387
  * returns a partial / unvalidated predicate.
3345
3388
  *
3389
+ * **Rate limiting:** this function does NOT limit in-flight calls. Wrap
3390
+ * with a concurrency limiter (e.g. `p-limit` / `Bottleneck`) before
3391
+ * exposing it to user-driven traffic. Pass an `AbortSignal` via `opts.signal`
3392
+ * for cooperative cancellation between retry attempts.
3393
+ *
3346
3394
  * @example
3347
3395
  * ```ts
3348
3396
  * import { createOpenAIRunner } from "@directive-run/ai/openai";
@@ -3374,7 +3422,11 @@ interface PredicateToolSpecOptions {
3374
3422
  /** Optional dotted-path namespace to restrict the tool's scope. */
3375
3423
  factPath?: string;
3376
3424
  }
3377
- interface PredicateToolSpec {
3425
+ /**
3426
+ * Anthropic Messages API tool shape. Drop into the `tools: [...]` array.
3427
+ * Anthropic's API expects `input_schema` at the top level of the tool.
3428
+ */
3429
+ interface PredicateToolSpecAnthropic {
3378
3430
  name: string;
3379
3431
  description: string;
3380
3432
  input_schema: {
@@ -3390,24 +3442,170 @@ interface PredicateToolSpec {
3390
3442
  schemaSummary: string;
3391
3443
  }
3392
3444
  /**
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.
3445
+ * OpenAI Chat Completions / Responses API tool shape. Drop into the
3446
+ * `tools: [...]` array. OpenAI nests the function payload under
3447
+ * `function: { name, description, parameters }`.
3448
+ */
3449
+ interface PredicateToolSpecOpenAI {
3450
+ type: "function";
3451
+ function: {
3452
+ name: string;
3453
+ description: string;
3454
+ parameters: {
3455
+ type: "object";
3456
+ properties: {
3457
+ predicate: {
3458
+ type: "object";
3459
+ };
3460
+ };
3461
+ required: ["predicate"];
3462
+ };
3463
+ };
3464
+ /** Human-readable schema description — embed in your tool's "description" if your provider concatenates them. */
3465
+ schemaSummary: string;
3466
+ }
3467
+ /**
3468
+ * @deprecated Use {@link PredicateToolSpecAnthropic} (or
3469
+ * {@link PredicateToolSpecOpenAI}) directly. Kept as an alias for the
3470
+ * pre-split shape that v1.12.x callers depend on; identical to
3471
+ * `PredicateToolSpecAnthropic`.
3472
+ */
3473
+ type PredicateToolSpec = PredicateToolSpecAnthropic;
3474
+ /**
3475
+ * OpenAI Chat Completions / Responses API tool spec for predicate
3476
+ * emission. Drop the result into your `tools: [...]` array; the model
3477
+ * will be told to emit a predicate matching this schema.
3398
3478
  *
3399
3479
  * @example
3400
3480
  * ```ts
3401
- * const tool = predicateToolSpec(myModule.schema, { name: "set_checkout_rule" });
3481
+ * const tool = predicateToolSpecOpenAI(myModule.schema, { name: "set_checkout_rule" });
3402
3482
  *
3403
- * await openai.messages.create({
3483
+ * await openai.chat.completions.create({
3404
3484
  * model: "gpt-4o-mini",
3405
3485
  * tools: [tool],
3406
3486
  * messages: [...],
3407
3487
  * });
3408
3488
  * ```
3409
3489
  */
3490
+ declare function predicateToolSpecOpenAI(schema: unknown, opts?: PredicateToolSpecOptions): PredicateToolSpecOpenAI;
3491
+ /**
3492
+ * Anthropic Messages API tool spec for predicate emission. Drop the
3493
+ * result into your `tools: [...]` array; the model will be told to emit
3494
+ * a predicate matching this schema.
3495
+ *
3496
+ * @example
3497
+ * ```ts
3498
+ * const tool = predicateToolSpecAnthropic(myModule.schema, { name: "set_checkout_rule" });
3499
+ *
3500
+ * await anthropic.messages.create({
3501
+ * model: "claude-3-5-sonnet-latest",
3502
+ * tools: [tool],
3503
+ * messages: [...],
3504
+ * });
3505
+ * ```
3506
+ */
3507
+ declare function predicateToolSpecAnthropic(schema: unknown, opts?: PredicateToolSpecOptions): PredicateToolSpecAnthropic;
3508
+ /**
3509
+ * @deprecated Use {@link predicateToolSpecAnthropic} (or
3510
+ * {@link predicateToolSpecOpenAI}) directly. Back-compat alias for
3511
+ * v1.12.x callers — emits the Anthropic shape, unchanged.
3512
+ */
3410
3513
  declare function predicateToolSpec(schema: unknown, opts?: PredicateToolSpecOptions): PredicateToolSpec;
3514
+ interface PredicateFromIntentProvenance {
3515
+ /**
3516
+ * Resolved model name when the caller passes `agent: { model }`,
3517
+ * otherwise `"unknown"`.
3518
+ *
3519
+ * NOTE: most callers omit `agent` (the default `predicate-emitter`
3520
+ * agent has no model field set), so `model` is `"unknown"` by default.
3521
+ * v1 does NOT read provider-detected model strings from `RunResult` —
3522
+ * that requires every adapter to surface `runResult.model`, which the
3523
+ * current `AgentRunner` contract does not. Tracked for v2; callers who
3524
+ * need provider attribution today should pass `agent: { name, model: "..." }`.
3525
+ */
3526
+ readonly model: string;
3527
+ /**
3528
+ * Sanitized intent string actually sent to the LLM (post-redact). When
3529
+ * `redactIntent: true` was passed, this field is omitted entirely — only
3530
+ * `intentHash` is populated.
3531
+ */
3532
+ readonly intent?: string;
3533
+ /**
3534
+ * SHA-256 hex hash of the sanitized intent string (or djb2 fallback
3535
+ * when `crypto.subtle` is unavailable). Always present — even when
3536
+ * `intent` is omitted via `redactIntent`. (M6)
3537
+ */
3538
+ readonly intentHash: string;
3539
+ /** Number of LLM calls that ran before the final predicate was accepted. */
3540
+ readonly attemptCount: number;
3541
+ /** ISO timestamp when the predicate was returned. */
3542
+ readonly emittedAt: string;
3543
+ /**
3544
+ * Hash of the VALIDATED predicate (canonicalized via stableStringify
3545
+ * before hashing). Two semantically-identical predicates emitted with
3546
+ * different whitespace or key order produce the SAME `predicateHash`.
3547
+ * Sufficient as a tamper-evident pointer alongside the persisted
3548
+ * predicate. (N3)
3549
+ *
3550
+ * Renamed from `rawOutputHash` in v1.13.x — the old name hashed the
3551
+ * raw LLM output string, which made two whitespace-different responses
3552
+ * for the same logical predicate hash differently. Callers persisting
3553
+ * the old `rawOutputHash` value should re-derive it from the stored
3554
+ * predicate using `hashObject(predicate)` from `@directive-run/core/internals`.
3555
+ */
3556
+ readonly predicateHash: string;
3557
+ }
3558
+ interface PredicateFromIntentWithProvenanceResult<F = Record<string, unknown>> {
3559
+ readonly predicate: FactPredicate<F>;
3560
+ readonly provenance: PredicateFromIntentProvenance;
3561
+ }
3562
+ /**
3563
+ * Like {@link predicateFromIntent} but additionally returns a structured
3564
+ * provenance record — the model name, sanitized intent (or its hash),
3565
+ * attempt count, timestamp, and a canonical hash of the validated
3566
+ * predicate.
3567
+ *
3568
+ * **Production deployments MUST persist the provenance record alongside
3569
+ * the predicate.** Without it, auditing "where did this rule come from?"
3570
+ * becomes guesswork.
3571
+ *
3572
+ * Throws {@link PredicateFromIntentError} on retry exhaustion — same
3573
+ * semantics as the un-provenanced variant.
3574
+ *
3575
+ * **PII guidance (M6):** pass `redactIntent: true` to omit the raw
3576
+ * intent from the provenance record and persist only the `intentHash`.
3577
+ * Useful when the intent itself is sensitive (medical, financial,
3578
+ * customer messages, etc.).
3579
+ *
3580
+ * **Hash semantics (N3):**
3581
+ * - `predicateHash` hashes the VALIDATED predicate object via stable
3582
+ * stringification — two whitespace-different LLM outputs that parse to
3583
+ * the same predicate produce the same hash.
3584
+ * - `intentHash` hashes the sanitized intent STRING (SHA-256 when
3585
+ * available, djb2 fallback).
3586
+ *
3587
+ * @example
3588
+ * ```ts
3589
+ * const { predicate, provenance } = await predicateFromIntentWithProvenance({
3590
+ * intent: "block checkout when cart > 10k",
3591
+ * schema: checkoutModule.schema,
3592
+ * runner,
3593
+ * agent: { name: "predicate-emitter", model: "gpt-4o-mini" },
3594
+ * redactIntent: false, // default: store both intent + intentHash
3595
+ * });
3596
+ *
3597
+ * await db.predicates.insert({
3598
+ * predicate,
3599
+ * model: provenance.model,
3600
+ * intent: provenance.intent, // omitted when redactIntent: true
3601
+ * intentHash: provenance.intentHash,
3602
+ * emittedAt: provenance.emittedAt,
3603
+ * predicateHash: provenance.predicateHash,
3604
+ * attempts: provenance.attemptCount,
3605
+ * });
3606
+ * ```
3607
+ */
3608
+ declare function predicateFromIntentWithProvenance<F = Record<string, unknown>>(opts: PredicateFromIntentOptions<F>): Promise<PredicateFromIntentWithProvenanceResult<F>>;
3411
3609
 
3412
3610
  /**
3413
3611
  * P5: Batch Queue — Application-level batching for agent calls.
@@ -5146,4 +5344,4 @@ interface OtelPlugin {
5146
5344
  */
5147
5345
  declare function createOtelPlugin(config: OtelPluginConfig): OtelPlugin;
5148
5346
 
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 };
5347
+ 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 PredicateFromIntentProvenance, type PredicateFromIntentWithProvenanceResult, type PredicateToolSpec, type PredicateToolSpecAnthropic, type PredicateToolSpecOpenAI, 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, predicateFromIntentWithProvenance, predicateToolSpec, predicateToolSpecAnthropic, predicateToolSpecOpenAI, race, redactPII, reflect, runAgentRequirement, runDebate, sanitizeInjection, selectAgent, sequential, spawnOnCondition, spawnPool, supervisor, toAIContext, validateBaseURL, validateGoal, withBudget, withFallback, withModelSelection, withRetry };
package/dist/index.d.ts CHANGED
@@ -3304,6 +3304,49 @@ interface PredicateFromIntentOptions<_F = Record<string, unknown>> {
3304
3304
  * content that looks like prompt-injection.
3305
3305
  */
3306
3306
  redact?: (intent: string) => string;
3307
+ /**
3308
+ * Hard cap on the length of each `$in` / `$nin` array operand the LLM
3309
+ * may emit. Defaults to 1000. Forwarded to
3310
+ * `validatePredicateAgainstSchema`'s `maxArrayOperandLength`.
3311
+ */
3312
+ maxArrayOperandLength?: number;
3313
+ /**
3314
+ * Optional `AbortSignal` for cooperative cancellation. (N6)
3315
+ *
3316
+ * The retry loop checks `signal.aborted` between attempts AND forwards
3317
+ * the signal into the runner call itself (`runner(agent, input, { signal })`).
3318
+ * Whether the in-flight LLM call honors the signal depends on the runner:
3319
+ * fetch-based adapters (the bundled OpenAI / Anthropic / Ollama runners)
3320
+ * thread it through to `fetch`, so the network call aborts mid-stream.
3321
+ * A custom runner that ignores the signal still delivers cancellation
3322
+ * at the next retry boundary.
3323
+ *
3324
+ * On abort: throws `Error("aborted")`.
3325
+ *
3326
+ * NOTE: `predicateFromIntent` does NOT limit in-flight calls — callers
3327
+ * MUST wrap with a concurrency limiter (e.g. `p-limit`) to bound
3328
+ * fan-out under load.
3329
+ */
3330
+ signal?: AbortSignal;
3331
+ /**
3332
+ * When `true`, the {@link PredicateFromIntentProvenance} returned by
3333
+ * `predicateFromIntentWithProvenance` omits the raw `intent` string and
3334
+ * stores only the SHA-256 `intentHash`. Use this in PII-sensitive
3335
+ * contexts where the original intent must not be persisted. (M6)
3336
+ *
3337
+ * **Default `false` for back-compat.** For PII-sensitive deployments,
3338
+ * ALWAYS set `redactIntent: true` — the raw intent may contain
3339
+ * user-supplied content (names, emails, medical or financial details,
3340
+ * customer messages) that becomes a permanent record in
3341
+ * `provenance.intent`. The default is opt-in only because flipping it
3342
+ * now would silently strip diagnostic data from existing callers; v2
3343
+ * may flip this default (tracked in IDEAS.md).
3344
+ *
3345
+ * Pair with a `redact:` sanitizer when the intent itself must be
3346
+ * scrubbed BEFORE it lands in the LLM prompt — `redactIntent` controls
3347
+ * only what enters the provenance record, not what the LLM sees.
3348
+ */
3349
+ redactIntent?: boolean;
3307
3350
  }
3308
3351
  interface PredicateFromIntentDiagnostics<F = Record<string, unknown>> {
3309
3352
  /** The validated predicate (`null` if all retries failed). */
@@ -3343,6 +3386,11 @@ declare class PredicateFromIntentError extends Error {
3343
3386
  * Throws {@link PredicateFromIntentError} on retry exhaustion. NEVER
3344
3387
  * returns a partial / unvalidated predicate.
3345
3388
  *
3389
+ * **Rate limiting:** this function does NOT limit in-flight calls. Wrap
3390
+ * with a concurrency limiter (e.g. `p-limit` / `Bottleneck`) before
3391
+ * exposing it to user-driven traffic. Pass an `AbortSignal` via `opts.signal`
3392
+ * for cooperative cancellation between retry attempts.
3393
+ *
3346
3394
  * @example
3347
3395
  * ```ts
3348
3396
  * import { createOpenAIRunner } from "@directive-run/ai/openai";
@@ -3374,7 +3422,11 @@ interface PredicateToolSpecOptions {
3374
3422
  /** Optional dotted-path namespace to restrict the tool's scope. */
3375
3423
  factPath?: string;
3376
3424
  }
3377
- interface PredicateToolSpec {
3425
+ /**
3426
+ * Anthropic Messages API tool shape. Drop into the `tools: [...]` array.
3427
+ * Anthropic's API expects `input_schema` at the top level of the tool.
3428
+ */
3429
+ interface PredicateToolSpecAnthropic {
3378
3430
  name: string;
3379
3431
  description: string;
3380
3432
  input_schema: {
@@ -3390,24 +3442,170 @@ interface PredicateToolSpec {
3390
3442
  schemaSummary: string;
3391
3443
  }
3392
3444
  /**
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.
3445
+ * OpenAI Chat Completions / Responses API tool shape. Drop into the
3446
+ * `tools: [...]` array. OpenAI nests the function payload under
3447
+ * `function: { name, description, parameters }`.
3448
+ */
3449
+ interface PredicateToolSpecOpenAI {
3450
+ type: "function";
3451
+ function: {
3452
+ name: string;
3453
+ description: string;
3454
+ parameters: {
3455
+ type: "object";
3456
+ properties: {
3457
+ predicate: {
3458
+ type: "object";
3459
+ };
3460
+ };
3461
+ required: ["predicate"];
3462
+ };
3463
+ };
3464
+ /** Human-readable schema description — embed in your tool's "description" if your provider concatenates them. */
3465
+ schemaSummary: string;
3466
+ }
3467
+ /**
3468
+ * @deprecated Use {@link PredicateToolSpecAnthropic} (or
3469
+ * {@link PredicateToolSpecOpenAI}) directly. Kept as an alias for the
3470
+ * pre-split shape that v1.12.x callers depend on; identical to
3471
+ * `PredicateToolSpecAnthropic`.
3472
+ */
3473
+ type PredicateToolSpec = PredicateToolSpecAnthropic;
3474
+ /**
3475
+ * OpenAI Chat Completions / Responses API tool spec for predicate
3476
+ * emission. Drop the result into your `tools: [...]` array; the model
3477
+ * will be told to emit a predicate matching this schema.
3398
3478
  *
3399
3479
  * @example
3400
3480
  * ```ts
3401
- * const tool = predicateToolSpec(myModule.schema, { name: "set_checkout_rule" });
3481
+ * const tool = predicateToolSpecOpenAI(myModule.schema, { name: "set_checkout_rule" });
3402
3482
  *
3403
- * await openai.messages.create({
3483
+ * await openai.chat.completions.create({
3404
3484
  * model: "gpt-4o-mini",
3405
3485
  * tools: [tool],
3406
3486
  * messages: [...],
3407
3487
  * });
3408
3488
  * ```
3409
3489
  */
3490
+ declare function predicateToolSpecOpenAI(schema: unknown, opts?: PredicateToolSpecOptions): PredicateToolSpecOpenAI;
3491
+ /**
3492
+ * Anthropic Messages API tool spec for predicate emission. Drop the
3493
+ * result into your `tools: [...]` array; the model will be told to emit
3494
+ * a predicate matching this schema.
3495
+ *
3496
+ * @example
3497
+ * ```ts
3498
+ * const tool = predicateToolSpecAnthropic(myModule.schema, { name: "set_checkout_rule" });
3499
+ *
3500
+ * await anthropic.messages.create({
3501
+ * model: "claude-3-5-sonnet-latest",
3502
+ * tools: [tool],
3503
+ * messages: [...],
3504
+ * });
3505
+ * ```
3506
+ */
3507
+ declare function predicateToolSpecAnthropic(schema: unknown, opts?: PredicateToolSpecOptions): PredicateToolSpecAnthropic;
3508
+ /**
3509
+ * @deprecated Use {@link predicateToolSpecAnthropic} (or
3510
+ * {@link predicateToolSpecOpenAI}) directly. Back-compat alias for
3511
+ * v1.12.x callers — emits the Anthropic shape, unchanged.
3512
+ */
3410
3513
  declare function predicateToolSpec(schema: unknown, opts?: PredicateToolSpecOptions): PredicateToolSpec;
3514
+ interface PredicateFromIntentProvenance {
3515
+ /**
3516
+ * Resolved model name when the caller passes `agent: { model }`,
3517
+ * otherwise `"unknown"`.
3518
+ *
3519
+ * NOTE: most callers omit `agent` (the default `predicate-emitter`
3520
+ * agent has no model field set), so `model` is `"unknown"` by default.
3521
+ * v1 does NOT read provider-detected model strings from `RunResult` —
3522
+ * that requires every adapter to surface `runResult.model`, which the
3523
+ * current `AgentRunner` contract does not. Tracked for v2; callers who
3524
+ * need provider attribution today should pass `agent: { name, model: "..." }`.
3525
+ */
3526
+ readonly model: string;
3527
+ /**
3528
+ * Sanitized intent string actually sent to the LLM (post-redact). When
3529
+ * `redactIntent: true` was passed, this field is omitted entirely — only
3530
+ * `intentHash` is populated.
3531
+ */
3532
+ readonly intent?: string;
3533
+ /**
3534
+ * SHA-256 hex hash of the sanitized intent string (or djb2 fallback
3535
+ * when `crypto.subtle` is unavailable). Always present — even when
3536
+ * `intent` is omitted via `redactIntent`. (M6)
3537
+ */
3538
+ readonly intentHash: string;
3539
+ /** Number of LLM calls that ran before the final predicate was accepted. */
3540
+ readonly attemptCount: number;
3541
+ /** ISO timestamp when the predicate was returned. */
3542
+ readonly emittedAt: string;
3543
+ /**
3544
+ * Hash of the VALIDATED predicate (canonicalized via stableStringify
3545
+ * before hashing). Two semantically-identical predicates emitted with
3546
+ * different whitespace or key order produce the SAME `predicateHash`.
3547
+ * Sufficient as a tamper-evident pointer alongside the persisted
3548
+ * predicate. (N3)
3549
+ *
3550
+ * Renamed from `rawOutputHash` in v1.13.x — the old name hashed the
3551
+ * raw LLM output string, which made two whitespace-different responses
3552
+ * for the same logical predicate hash differently. Callers persisting
3553
+ * the old `rawOutputHash` value should re-derive it from the stored
3554
+ * predicate using `hashObject(predicate)` from `@directive-run/core/internals`.
3555
+ */
3556
+ readonly predicateHash: string;
3557
+ }
3558
+ interface PredicateFromIntentWithProvenanceResult<F = Record<string, unknown>> {
3559
+ readonly predicate: FactPredicate<F>;
3560
+ readonly provenance: PredicateFromIntentProvenance;
3561
+ }
3562
+ /**
3563
+ * Like {@link predicateFromIntent} but additionally returns a structured
3564
+ * provenance record — the model name, sanitized intent (or its hash),
3565
+ * attempt count, timestamp, and a canonical hash of the validated
3566
+ * predicate.
3567
+ *
3568
+ * **Production deployments MUST persist the provenance record alongside
3569
+ * the predicate.** Without it, auditing "where did this rule come from?"
3570
+ * becomes guesswork.
3571
+ *
3572
+ * Throws {@link PredicateFromIntentError} on retry exhaustion — same
3573
+ * semantics as the un-provenanced variant.
3574
+ *
3575
+ * **PII guidance (M6):** pass `redactIntent: true` to omit the raw
3576
+ * intent from the provenance record and persist only the `intentHash`.
3577
+ * Useful when the intent itself is sensitive (medical, financial,
3578
+ * customer messages, etc.).
3579
+ *
3580
+ * **Hash semantics (N3):**
3581
+ * - `predicateHash` hashes the VALIDATED predicate object via stable
3582
+ * stringification — two whitespace-different LLM outputs that parse to
3583
+ * the same predicate produce the same hash.
3584
+ * - `intentHash` hashes the sanitized intent STRING (SHA-256 when
3585
+ * available, djb2 fallback).
3586
+ *
3587
+ * @example
3588
+ * ```ts
3589
+ * const { predicate, provenance } = await predicateFromIntentWithProvenance({
3590
+ * intent: "block checkout when cart > 10k",
3591
+ * schema: checkoutModule.schema,
3592
+ * runner,
3593
+ * agent: { name: "predicate-emitter", model: "gpt-4o-mini" },
3594
+ * redactIntent: false, // default: store both intent + intentHash
3595
+ * });
3596
+ *
3597
+ * await db.predicates.insert({
3598
+ * predicate,
3599
+ * model: provenance.model,
3600
+ * intent: provenance.intent, // omitted when redactIntent: true
3601
+ * intentHash: provenance.intentHash,
3602
+ * emittedAt: provenance.emittedAt,
3603
+ * predicateHash: provenance.predicateHash,
3604
+ * attempts: provenance.attemptCount,
3605
+ * });
3606
+ * ```
3607
+ */
3608
+ declare function predicateFromIntentWithProvenance<F = Record<string, unknown>>(opts: PredicateFromIntentOptions<F>): Promise<PredicateFromIntentWithProvenanceResult<F>>;
3411
3609
 
3412
3610
  /**
3413
3611
  * P5: Batch Queue — Application-level batching for agent calls.
@@ -5146,4 +5344,4 @@ interface OtelPlugin {
5146
5344
  */
5147
5345
  declare function createOtelPlugin(config: OtelPluginConfig): OtelPlugin;
5148
5346
 
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 };
5347
+ 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 PredicateFromIntentProvenance, type PredicateFromIntentWithProvenanceResult, type PredicateToolSpec, type PredicateToolSpecAnthropic, type PredicateToolSpecOpenAI, 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, predicateFromIntentWithProvenance, predicateToolSpec, predicateToolSpecAnthropic, predicateToolSpecOpenAI, race, redactPII, reflect, runAgentRequirement, runDebate, sanitizeInjection, selectAgent, sequential, spawnOnCondition, spawnPool, supervisor, toAIContext, validateBaseURL, validateGoal, withBudget, withFallback, withModelSelection, withRetry };