'use strict';

var chunkRACFGTZY_cjs = require('../chunk-RACFGTZY.cjs');
var v4 = require('zod/v4');

// src/processor-provider/types.ts
var ALL_PROCESSOR_PHASES = [
  "processInput",
  "processInputStep",
  "processOutputStream",
  "processOutputResult",
  "processOutputStep"
];

// src/processor-provider/phase-filtered-processor.ts
var PhaseFilteredProcessor = class {
  id;
  name;
  description;
  processorIndex;
  #inner;
  #enabledPhases;
  constructor(inner, enabledPhases) {
    this.#inner = inner;
    this.#enabledPhases = new Set(enabledPhases);
    this.id = inner.id;
    this.name = inner.name;
    this.description = inner.description;
    if (this.#enabledPhases.has("processInput") && inner.processInput) {
      this.processInput = inner.processInput.bind(inner);
    }
    if (this.#enabledPhases.has("processInputStep") && inner.processInputStep) {
      this.processInputStep = inner.processInputStep.bind(inner);
    }
    if (this.#enabledPhases.has("processOutputStream") && inner.processOutputStream) {
      this.processOutputStream = inner.processOutputStream.bind(inner);
    }
    if (this.#enabledPhases.has("processOutputResult") && inner.processOutputResult) {
      this.processOutputResult = inner.processOutputResult.bind(inner);
    }
    if (this.#enabledPhases.has("processOutputStep") && inner.processOutputStep) {
      this.processOutputStep = inner.processOutputStep.bind(inner);
    }
  }
  processInput;
  processInputStep;
  processOutputStream;
  processOutputResult;
  processOutputStep;
  __registerMastra(mastra) {
    this.#inner.__registerMastra?.(mastra);
  }
};
var structuredOutputOptionsSchema = v4.z.object({ jsonPromptInjection: v4.z.boolean().optional() }).optional();
var providerOptionsSchema = v4.z.record(v4.z.string(), v4.z.any()).optional();
var unicodeNormalizerProvider = {
  info: {
    id: "unicode-normalizer",
    name: "Unicode Normalizer",
    description: "Normalizes Unicode text by stripping control characters, collapsing whitespace, and trimming."
  },
  configSchema: v4.z.object({
    stripControlChars: v4.z.boolean().optional(),
    preserveEmojis: v4.z.boolean().optional(),
    collapseWhitespace: v4.z.boolean().optional(),
    trim: v4.z.boolean().optional()
  }),
  availablePhases: ["processInput"],
  createProcessor(config) {
    return new chunkRACFGTZY_cjs.UnicodeNormalizer(config);
  }
};
var tokenLimiterProvider = {
  info: {
    id: "token-limiter",
    name: "Token Limiter",
    description: "Limits the number of tokens in messages, supporting both input filtering and output truncation."
  },
  configSchema: v4.z.object({
    limit: v4.z.number(),
    strategy: v4.z.enum(["truncate", "abort"]).optional(),
    countMode: v4.z.enum(["cumulative", "part"]).optional()
  }),
  availablePhases: ["processInput", "processOutputStream", "processOutputResult"],
  createProcessor(config) {
    return new chunkRACFGTZY_cjs.TokenLimiterProcessor(
      config
    );
  }
};
var toolCallFilterProvider = {
  info: {
    id: "tool-call-filter",
    name: "Tool Call Filter",
    description: "Filters out tool calls and results from messages, optionally targeting specific tools."
  },
  configSchema: v4.z.object({
    exclude: v4.z.array(v4.z.string()).optional()
  }),
  availablePhases: ["processInput"],
  createProcessor(config) {
    return new chunkRACFGTZY_cjs.ToolCallFilter(config);
  }
};
var batchPartsProvider = {
  info: {
    id: "batch-parts",
    name: "Batch Parts",
    description: "Batches multiple stream parts together to reduce stream overhead."
  },
  configSchema: v4.z.object({
    batchSize: v4.z.number().optional(),
    maxWaitTime: v4.z.number().optional(),
    emitOnNonText: v4.z.boolean().optional()
  }),
  availablePhases: ["processOutputStream"],
  createProcessor(config) {
    return new chunkRACFGTZY_cjs.BatchPartsProcessor(config);
  }
};
var moderationProvider = {
  info: {
    id: "moderation",
    name: "Moderation",
    description: "Evaluates content against configurable moderation categories for content safety."
  },
  configSchema: v4.z.object({
    model: v4.z.string(),
    categories: v4.z.array(v4.z.string()).optional(),
    threshold: v4.z.number().optional(),
    strategy: v4.z.enum(["block", "warn", "filter"]).optional(),
    instructions: v4.z.string().optional(),
    includeScores: v4.z.boolean().optional(),
    chunkWindow: v4.z.number().optional(),
    structuredOutputOptions: structuredOutputOptionsSchema,
    providerOptions: providerOptionsSchema
  }),
  availablePhases: ["processInput", "processOutputResult", "processOutputStream"],
  createProcessor(config) {
    return new chunkRACFGTZY_cjs.ModerationProcessor(config);
  }
};
var promptInjectionDetectorProvider = {
  info: {
    id: "prompt-injection-detector",
    name: "Prompt Injection Detector",
    description: "Identifies and handles prompt injection attacks, jailbreaks, and data exfiltration attempts."
  },
  configSchema: v4.z.object({
    model: v4.z.string(),
    detectionTypes: v4.z.array(v4.z.string()).optional(),
    threshold: v4.z.number().optional(),
    strategy: v4.z.enum(["block", "warn", "filter", "rewrite"]).optional(),
    instructions: v4.z.string().optional(),
    includeScores: v4.z.boolean().optional(),
    structuredOutputOptions: structuredOutputOptionsSchema,
    providerOptions: providerOptionsSchema
  }),
  availablePhases: ["processInput"],
  createProcessor(config) {
    return new chunkRACFGTZY_cjs.PromptInjectionDetector(config);
  }
};
var piiDetectorProvider = {
  info: {
    id: "pii-detector",
    name: "PII Detector",
    description: "Identifies and redacts personally identifiable information for privacy compliance."
  },
  configSchema: v4.z.object({
    model: v4.z.string(),
    detectionTypes: v4.z.array(v4.z.string()).optional(),
    threshold: v4.z.number().optional(),
    strategy: v4.z.enum(["block", "warn", "filter", "redact"]).optional(),
    redactionMethod: v4.z.enum(["mask", "hash", "remove", "placeholder"]).optional(),
    instructions: v4.z.string().optional(),
    includeDetections: v4.z.boolean().optional(),
    preserveFormat: v4.z.boolean().optional(),
    structuredOutputOptions: structuredOutputOptionsSchema,
    providerOptions: providerOptionsSchema
  }),
  availablePhases: ["processInput"],
  createProcessor(config) {
    return new chunkRACFGTZY_cjs.PIIDetector(config);
  }
};
var languageDetectorProvider = {
  info: {
    id: "language-detector",
    name: "Language Detector",
    description: "Detects the language of input text and optionally translates it to a target language."
  },
  configSchema: v4.z.object({
    model: v4.z.string(),
    targetLanguages: v4.z.array(v4.z.string()),
    threshold: v4.z.number().optional(),
    strategy: v4.z.enum(["detect", "translate", "block", "warn"]).optional(),
    preserveOriginal: v4.z.boolean().optional(),
    instructions: v4.z.string().optional(),
    minTextLength: v4.z.number().optional(),
    includeDetectionDetails: v4.z.boolean().optional(),
    translationQuality: v4.z.enum(["speed", "quality", "balanced"]).optional(),
    providerOptions: providerOptionsSchema
  }),
  availablePhases: ["processInput"],
  createProcessor(config) {
    return new chunkRACFGTZY_cjs.LanguageDetector(config);
  }
};
var systemPromptScrubberProvider = {
  info: {
    id: "system-prompt-scrubber",
    name: "System Prompt Scrubber",
    description: "Detects and removes system prompt leakage from model outputs."
  },
  configSchema: v4.z.object({
    model: v4.z.string(),
    strategy: v4.z.enum(["block", "warn", "filter", "redact"]).optional(),
    customPatterns: v4.z.array(v4.z.string()).optional(),
    includeDetections: v4.z.boolean().optional(),
    instructions: v4.z.string().optional(),
    redactionMethod: v4.z.enum(["mask", "placeholder", "remove"]).optional(),
    placeholderText: v4.z.string().optional(),
    structuredOutputOptions: structuredOutputOptionsSchema
  }),
  availablePhases: ["processOutputStream", "processOutputResult"],
  createProcessor(config) {
    return new chunkRACFGTZY_cjs.SystemPromptScrubber(config);
  }
};
var BUILT_IN_PROCESSOR_PROVIDERS = {
  "unicode-normalizer": unicodeNormalizerProvider,
  "token-limiter": tokenLimiterProvider,
  "tool-call-filter": toolCallFilterProvider,
  "batch-parts": batchPartsProvider,
  moderation: moderationProvider,
  "prompt-injection-detector": promptInjectionDetectorProvider,
  "pii-detector": piiDetectorProvider,
  "language-detector": languageDetectorProvider,
  "system-prompt-scrubber": systemPromptScrubberProvider
};

exports.ALL_PROCESSOR_PHASES = ALL_PROCESSOR_PHASES;
exports.BUILT_IN_PROCESSOR_PROVIDERS = BUILT_IN_PROCESSOR_PROVIDERS;
exports.PhaseFilteredProcessor = PhaseFilteredProcessor;
exports.batchPartsProvider = batchPartsProvider;
exports.languageDetectorProvider = languageDetectorProvider;
exports.moderationProvider = moderationProvider;
exports.piiDetectorProvider = piiDetectorProvider;
exports.promptInjectionDetectorProvider = promptInjectionDetectorProvider;
exports.systemPromptScrubberProvider = systemPromptScrubberProvider;
exports.tokenLimiterProvider = tokenLimiterProvider;
exports.toolCallFilterProvider = toolCallFilterProvider;
exports.unicodeNormalizerProvider = unicodeNormalizerProvider;
//# sourceMappingURL=index.cjs.map
//# sourceMappingURL=index.cjs.map