ai-pipeline-orchestrator 0.1.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/CHANGELOG.md +32 -0
- package/CONTRIBUTING.md +77 -0
- package/LICENSE +21 -0
- package/README.md +466 -0
- package/dist/context/index.cjs +75 -0
- package/dist/context/index.cjs.map +1 -0
- package/dist/context/index.d.cts +38 -0
- package/dist/context/index.d.ts +38 -0
- package/dist/context/index.mjs +48 -0
- package/dist/context/index.mjs.map +1 -0
- package/dist/core/index.cjs +203 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +36 -0
- package/dist/core/index.d.ts +36 -0
- package/dist/core/index.mjs +175 -0
- package/dist/core/index.mjs.map +1 -0
- package/dist/handlers/index.cjs +564 -0
- package/dist/handlers/index.cjs.map +1 -0
- package/dist/handlers/index.d.cts +105 -0
- package/dist/handlers/index.d.ts +105 -0
- package/dist/handlers/index.mjs +522 -0
- package/dist/handlers/index.mjs.map +1 -0
- package/dist/index.cjs +971 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +920 -0
- package/dist/index.mjs.map +1 -0
- package/dist/intent/index.cjs +265 -0
- package/dist/intent/index.cjs.map +1 -0
- package/dist/intent/index.d.cts +26 -0
- package/dist/intent/index.d.ts +26 -0
- package/dist/intent/index.mjs +226 -0
- package/dist/intent/index.mjs.map +1 -0
- package/dist/llm-classifier-Cq-QHJc4.d.ts +59 -0
- package/dist/llm-classifier-pOp7OO-V.d.cts +59 -0
- package/dist/providers/index.cjs +64 -0
- package/dist/providers/index.cjs.map +1 -0
- package/dist/providers/index.d.cts +13 -0
- package/dist/providers/index.d.ts +13 -0
- package/dist/providers/index.mjs +29 -0
- package/dist/providers/index.mjs.map +1 -0
- package/dist/types-DGSj206n.d.cts +42 -0
- package/dist/types-DGSj206n.d.ts +42 -0
- package/dist/utils/index.cjs +74 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +10 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.mjs +46 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +147 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/logger.ts","../src/core/orchestrator.ts","../src/intent/classifier.ts","../src/intent/llm-classifier.ts","../src/providers/index.ts","../src/intent/llm-classifier-text.ts","../src/context/optimizer.ts","../src/handlers/intent-handler.ts","../src/handlers/context-handler.ts","../src/handlers/rate-limit.ts","../src/handlers/content-moderation.ts","../src/handlers/ai-handler.ts"],"sourcesContent":["export * from './core'\nexport * from './intent'\nexport * from './context'\nexport * from './handlers'\nexport * from './providers'\nexport * from './utils'\n","export interface Logger {\n debug(obj: unknown, msg?: string): void\n info(obj: unknown, msg?: string): void\n warn(obj: unknown, msg?: string): void\n error(obj: unknown, msg?: string): void\n}\n\nexport const consoleLogger: Logger = {\n debug: (obj, msg) => {\n if (msg) {\n console.debug(msg, obj)\n } else {\n console.debug(obj)\n }\n },\n info: (obj, msg) => {\n if (msg) {\n console.info(msg, obj)\n } else {\n console.info(obj)\n }\n },\n warn: (obj, msg) => {\n if (msg) {\n console.warn(msg, obj)\n } else {\n console.warn(obj)\n }\n },\n error: (obj, msg) => {\n if (msg) {\n console.error(msg, obj)\n } else {\n console.error(obj)\n }\n },\n}\n\nexport const silentLogger: Logger = {\n debug: () => {},\n info: () => {},\n warn: () => {},\n error: () => {},\n}\n","import type { OrchestrationContext, OrchestrationResult, OrchestrationStep } from './types'\n\nimport { consoleLogger, type Logger } from '../utils/logger'\n\nexport interface OrchestratorConfig {\n logger?: Logger\n onStepComplete?: (step: string, durationMs: number) => void\n onError?: (error: { step: string; message: string; statusCode: number; details?: string }) => void\n includeErrorDetails?: boolean\n}\n\n/**\n * Execute the orchestration pipeline.\n * Runs handlers sequentially, stops immediately if any handler sets context.error or throws.\n */\nexport async function executeOrchestration(\n context: OrchestrationContext,\n steps: OrchestrationStep[],\n config?: OrchestratorConfig\n): Promise<OrchestrationResult> {\n const logger = config?.logger ?? consoleLogger\n const includeErrorDetails = config?.includeErrorDetails ?? process.env.NODE_ENV !== 'production'\n\n let currentContext = { ...context }\n const startTime = Date.now()\n\n try {\n logger.debug(\n {\n messageCount: context.request.messages.length,\n metadata: context.request.metadata,\n },\n 'Starting AI orchestration'\n )\n\n for (const step of steps) {\n if (step.enabled === false) {\n logger.debug({ step: step.name }, 'Skipping disabled step')\n continue\n }\n\n const stepStartTime = Date.now()\n\n try {\n currentContext = await step.handler(currentContext)\n\n const stepDuration = Date.now() - stepStartTime\n logger.debug(\n {\n step: step.name,\n durationMs: stepDuration,\n },\n 'Orchestration step completed'\n )\n\n config?.onStepComplete?.(step.name, stepDuration)\n\n if (currentContext.error) {\n logger.warn(\n {\n step: step.name,\n error: currentContext.error.message,\n statusCode: currentContext.error.statusCode,\n },\n 'Orchestration stopped due to error'\n )\n\n config?.onError?.({\n step: step.name,\n message: currentContext.error.message,\n statusCode: currentContext.error.statusCode,\n details: currentContext.error.details,\n })\n\n return {\n success: false,\n context: currentContext,\n error: currentContext.error,\n }\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n logger.error(\n {\n step: step.name,\n error: errorMessage,\n },\n 'Orchestration step failed'\n )\n\n currentContext.error = {\n message: 'An error occurred while processing your request. Please try again.',\n statusCode: 500,\n step: step.name,\n details: includeErrorDetails ? errorMessage : undefined,\n }\n\n config?.onError?.({\n step: step.name,\n message: currentContext.error.message,\n statusCode: currentContext.error.statusCode,\n details: currentContext.error.details,\n })\n\n return {\n success: false,\n context: currentContext,\n error: currentContext.error,\n }\n }\n }\n\n const totalDuration = Date.now() - startTime\n\n logger.info(\n {\n totalDurationMs: totalDuration,\n stepsExecuted: steps.filter(s => s.enabled !== false).length,\n },\n 'AI orchestration completed successfully'\n )\n\n return {\n success: true,\n context: currentContext,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n logger.error(\n {\n error: errorMessage,\n stack: error instanceof Error ? error.stack : undefined,\n },\n 'Unexpected error in orchestration'\n )\n\n currentContext.error = {\n message: 'An unexpected error occurred. Please try again.',\n statusCode: 500,\n step: 'orchestration',\n details: includeErrorDetails ? errorMessage : undefined,\n }\n\n return {\n success: false,\n context: currentContext,\n error: currentContext.error,\n }\n }\n}\n\n/**\n * Class-based orchestrator for stateful pipeline management.\n * Alternative to functional executeOrchestration API.\n */\nexport class Orchestrator {\n private config: OrchestratorConfig\n private steps: OrchestrationStep[]\n\n constructor(steps: OrchestrationStep[], config?: OrchestratorConfig) {\n this.steps = steps\n this.config = config ?? {}\n }\n\n async execute(context: OrchestrationContext): Promise<OrchestrationResult> {\n return executeOrchestration(context, this.steps, this.config)\n }\n\n addHandler(step: OrchestrationStep): void {\n this.steps.push(step)\n }\n\n removeHandler(name: string): void {\n this.steps = this.steps.filter(s => s.name !== name)\n }\n\n toggleStep(name: string, enabled: boolean): void {\n const step = this.steps.find(s => s.name === name)\n if (step) {\n step.enabled = enabled\n }\n }\n\n getSteps(): OrchestrationStep[] {\n return [...this.steps]\n }\n}\n","import type { IntentConfig, IntentPattern, IntentResult } from './types'\n\nfunction detectIntent(message: string, config: IntentConfig): IntentResult {\n const lowerMessage = message.toLowerCase()\n const { patterns, metadata } = config\n\n const intentScores: Array<{\n intent: string\n score: number\n keywords: string[]\n }> = []\n\n for (const { category, keywords } of patterns) {\n let score = 0\n const matchedKeywords: string[] = []\n\n for (const keyword of keywords) {\n if (lowerMessage.includes(keyword)) {\n const wordCount = keyword.split(' ').length\n score += wordCount\n matchedKeywords.push(keyword)\n }\n }\n\n if (score > 0) {\n intentScores.push({\n intent: category,\n score,\n keywords: matchedKeywords,\n })\n }\n }\n\n intentScores.sort((a, b) => b.score - a.score)\n\n const bestResult = intentScores[0]\n const secondBestResult = intentScores[1]\n\n if (!bestResult) {\n return {\n intent: 'general',\n confidence: 0,\n matchedKeywords: [],\n }\n }\n\n const bestScore = bestResult.score\n const secondBestScore = secondBestResult?.score || 0\n const margin = bestScore - secondBestScore\n const confidence = Math.min(margin / Math.max(bestScore, 1), 1)\n\n const result: IntentResult = {\n intent: bestResult.intent,\n confidence,\n matchedKeywords: bestResult.keywords,\n }\n\n if (metadata) {\n result.metadata = {}\n if (metadata.deepLinks?.[bestResult.intent]) {\n result.metadata.deepLink = metadata.deepLinks[bestResult.intent]\n }\n if (metadata.tones?.[bestResult.intent]) {\n result.metadata.tone = metadata.tones[bestResult.intent]\n }\n if (metadata.requiresAuth?.includes(bestResult.intent)) {\n result.metadata.requiresAuth = true\n }\n }\n\n return result\n}\n\n/**\n * Keyword-based intent classifier using pattern matching.\n * Fast and free - no LLM calls required.\n * Will fallback to LLM if confidence is low.\n *\n */\nexport class IntentClassifier {\n constructor(private config: IntentConfig) {}\n\n classify(message: string): IntentResult {\n return detectIntent(message, this.config)\n }\n\n addPattern(pattern: IntentPattern): void {\n this.config.patterns.push(pattern)\n }\n\n removePattern(category: string): void {\n this.config.patterns = this.config.patterns.filter(p => p.category !== category)\n }\n\n getPatterns(): IntentPattern[] {\n return [...this.config.patterns]\n }\n}\n","import { z } from 'zod'\n\nimport { createModel, type ProviderConfig } from '../providers'\n\nexport interface LLMClassifierConfig extends ProviderConfig {\n categories: string[]\n categoryDescriptions: Record<string, string>\n promptTemplate?: (message: string, categories: string, descriptions: string) => string\n temperature?: number\n}\n\nasync function classifyWithLLM(\n message: string,\n config: LLMClassifierConfig\n): Promise<{\n intent: string\n confidence: number\n reasoning?: string\n usage?: any\n}> {\n try {\n const { generateObject } = await import('ai')\n\n const schema = z.object({\n intent: z.enum(config.categories as [string, ...string[]]),\n confidence: z.number().min(0).max(1),\n reasoning: z.string().optional(),\n })\n\n const categoryList = config.categories\n .map(cat => `- ${cat}: ${config.categoryDescriptions[cat] || ''}`)\n .join('\\n')\n\n const prompt = config.promptTemplate\n ? config.promptTemplate(message, config.categories.join(', '), categoryList)\n : buildDefaultPrompt(message, categoryList)\n\n const model = await createModel(config)\n\n const result = await generateObject({\n model,\n schema,\n prompt,\n temperature: config.temperature ?? 0.3,\n })\n\n const usage = await result.usage\n\n return {\n ...result.object,\n usage,\n }\n } catch (error) {\n return {\n intent: 'general',\n confidence: 0,\n reasoning: error instanceof Error ? error.message : 'LLM classification failed',\n }\n }\n}\n\nfunction buildDefaultPrompt(message: string, categoryList: string): string {\n return `Classify this message into ONE of these intent categories:\n\n${categoryList}\n\nUser message: \"${message}\"\n\nReturn the most likely intent, confidence (0-1), and brief reasoning.`\n}\n\n/**\n * LLM-based intent classifier.\n * More accurate than keyword matching but requires API calls.\n */\nexport class LLMIntentClassifier {\n constructor(private config: LLMClassifierConfig) {}\n\n async classify(message: string): Promise<{\n intent: string\n confidence: number\n reasoning?: string\n usage?: any\n }> {\n return classifyWithLLM(message, this.config)\n }\n}\n","export type AIProvider = 'anthropic' | 'openai' | 'ollama'\n\nexport interface ProviderConfig {\n provider: AIProvider\n model: string\n apiKey?: string\n baseURL?: string\n}\n\n/**\n * Creates an AI model instance from the specified provider.\n */\nexport async function createModel(config: ProviderConfig): Promise<any> {\n if (config.provider === 'anthropic') {\n const { createAnthropic } = await import('@ai-sdk/anthropic')\n const anthropic = createAnthropic({ apiKey: config.apiKey })\n return anthropic(config.model)\n }\n\n if (config.provider === 'openai') {\n const { createOpenAI } = await import('@ai-sdk/openai')\n const openai = createOpenAI({ apiKey: config.apiKey })\n return openai(config.model)\n }\n\n if (config.provider === 'ollama') {\n if (!config.baseURL) {\n throw new Error('baseURL is required for Ollama provider')\n }\n const { createOllama } = await import('ai-sdk-ollama')\n const ollama = createOllama({\n baseURL: config.baseURL,\n ...(config.apiKey && { headers: { Authorization: `Bearer ${config.apiKey}` } }),\n })\n return ollama(config.model)\n }\n\n throw new Error(`Unsupported provider: ${config.provider}`)\n}\n","import { createModel, type ProviderConfig } from '../providers'\n\nexport interface TextLLMClassifierConfig extends ProviderConfig {\n categories: string[]\n categoryDescriptions: Record<string, string>\n promptTemplate?: (message: string, categories: string, descriptions: string) => string\n temperature?: number\n}\n\nasync function classifyWithTextLLM(\n message: string,\n config: TextLLMClassifierConfig\n): Promise<{\n intent: string\n confidence: number\n reasoning?: string\n usage?: any\n}> {\n try {\n const { generateText } = await import('ai')\n\n const categoryList = config.categories\n .map(cat => `- ${cat}: ${config.categoryDescriptions[cat] || ''}`)\n .join('\\n')\n\n const prompt =\n config.promptTemplate?.(message, config.categories.join(', '), categoryList) ||\n buildDefaultPrompt(message, categoryList, config.categories)\n\n const model = await createModel(config)\n\n const result = await generateText({\n model,\n prompt,\n temperature: config.temperature ?? 0.3,\n })\n\n const usage = await result.usage\n\n // Parse the response\n const parsed = parseResponse(result.text, config.categories)\n\n return {\n ...parsed,\n usage,\n }\n } catch (error) {\n return {\n intent: 'general',\n confidence: 0,\n reasoning: error instanceof Error ? error.message : 'LLM classification failed',\n }\n }\n}\n\nfunction buildDefaultPrompt(message: string, categoryList: string, categories: string[]): string {\n return `Classify this message into ONE of these intent categories:\n\n${categoryList}\n\nUser message: \"${message}\"\n\nRespond in this exact format:\nINTENT: [one of: ${categories.join(', ')}]\nCONFIDENCE: [number between 0.0 and 1.0]\nREASONING: [brief explanation]\n\nExample:\nINTENT: greeting\nCONFIDENCE: 0.95\nREASONING: User is saying hello`\n}\n\nfunction parseResponse(\n text: string,\n validCategories: string[]\n): {\n intent: string\n confidence: number\n reasoning?: string\n} {\n // Extract intent\n const intentMatch = text.match(/INTENT:\\s*(\\w+)/i)\n let intent = intentMatch ? intentMatch[1].toLowerCase() : 'general'\n\n // Validate intent is in categories\n if (!validCategories.includes(intent)) {\n intent = 'general'\n }\n\n // Extract confidence\n const confidenceMatch = text.match(/CONFIDENCE:\\s*([\\d.]+)/i)\n const confidence = confidenceMatch ? parseFloat(confidenceMatch[1]) : 0.5\n\n // Extract reasoning\n const reasoningMatch = text.match(/REASONING:\\s*(.+?)(?:\\n|$)/i)\n const reasoning = reasoningMatch ? reasoningMatch[1].trim() : undefined\n\n return {\n intent,\n confidence: Math.max(0, Math.min(1, confidence)), // Clamp to 0-1\n reasoning,\n }\n}\n\n/**\n * Text-based LLM intent classifier.\n * Works with models that don't support structured output (like some Ollama models).\n * Uses text generation with manual parsing instead of generateObject.\n */\nexport class TextLLMIntentClassifier {\n constructor(private config: TextLLMClassifierConfig) {}\n\n async classify(message: string): Promise<{\n intent: string\n confidence: number\n reasoning?: string\n usage?: any\n }> {\n return classifyWithTextLLM(message, this.config)\n }\n}\n","import type { ContextConfig, ContextResult, ContextSection } from './types'\n\nfunction buildContext(\n topics: string[],\n isFirstMessage: boolean,\n config: ContextConfig\n): ContextResult {\n const { sections, strategy } = config\n\n const useFullContext =\n (isFirstMessage && strategy?.firstMessage !== 'selective') ||\n (!isFirstMessage && strategy?.followUp === 'full')\n\n let selectedSections: ContextSection[]\n\n if (useFullContext) {\n selectedSections = sections\n } else {\n selectedSections = sections.filter(section => {\n if (section.alwaysInclude) return true\n\n if (!section.topics || section.topics.length === 0) return false\n\n return section.topics.some(topic => topics.includes(topic))\n })\n\n selectedSections.sort((a, b) => (b.priority || 0) - (a.priority || 0))\n }\n\n const systemPrompt = selectedSections.map(section => section.content).join('\\n\\n')\n\n // Calculate token estimates\n const tokenEstimate = Math.ceil(systemPrompt.length / 4)\n\n // Calculate what tokens WOULD be if all sections were loaded (for savings calculation)\n const allSectionsPrompt = sections.map(section => section.content).join('\\n\\n')\n const maxTokenEstimate = Math.ceil(allSectionsPrompt.length / 4)\n\n return {\n systemPrompt,\n sectionsIncluded: selectedSections.map(s => s.id),\n totalSections: sections.length,\n tokenEstimate,\n maxTokenEstimate,\n }\n}\n\n/**\n * Dynamic context optimizer for token reduction.\n * Selectively loads context sections based on topics and message position.\n */\nexport class ContextOptimizer {\n constructor(private config: ContextConfig) {}\n\n build(topics: string[], isFirstMessage: boolean): ContextResult {\n return buildContext(topics, isFirstMessage, this.config)\n }\n\n addSection(section: ContextSection): void {\n this.config.sections.push(section)\n }\n\n removeSection(id: string): void {\n this.config.sections = this.config.sections.filter(s => s.id !== id)\n }\n\n getSections(): ContextSection[] {\n return [...this.config.sections]\n }\n}\n","import type { OrchestrationContext, OrchestrationHandler } from '../core/types'\nimport type { IntentClassifier } from '../intent/classifier'\nimport type { LLMIntentClassifier } from '../intent/llm-classifier'\nimport { consoleLogger, type Logger } from '../utils/logger'\n\nexport interface IntentHandlerConfig {\n classifier: IntentClassifier\n llmFallback?: {\n enabled: boolean\n classifier: LLMIntentClassifier\n confidenceThreshold?: number\n }\n contextKey?: string\n onFallback?: (data: {\n message: string\n keywordIntent: string\n keywordConfidence: number\n llmIntent: string\n llmConfidence: number\n matchedKeywords?: string[]\n }) => void | Promise<void>\n logger?: Logger\n}\n\n/**\n * Creates intent detection handler with hybrid classification.\n * Uses keyword matching first, falls back to LLM if confidence is low and LLM is enabled.\n *\n * Keyword matching algorithm:\n * - Scoring: Each keyword match adds points equal to the keyword's word count.\n * - Single-word keywords (e.g., \"hello\") score 1 point\n * - Multi-word keywords (e.g., \"help me\") score 2 points\n *\n * - Selection: The category with the highest score wins. Confidence is calculated as the margin between the best and second-best scores, normalized to 0-1.\n *\n * Note: This is a simple heuristic. For production use, consider the LLM fallback option in createIntentHandler when confidence is low.\n */\nexport function createIntentHandler(config: IntentHandlerConfig): OrchestrationHandler {\n const logger = config.logger ?? consoleLogger\n const confidenceThreshold = config.llmFallback?.confidenceThreshold ?? 0.5\n const contextKey = config.contextKey ?? 'intent'\n\n return async (context: OrchestrationContext) => {\n const messages = context.request.messages\n const lastMessage = messages[messages.length - 1]\n\n if (!lastMessage || lastMessage.role !== 'user') {\n return {\n ...context,\n [contextKey]: {\n intent: 'general',\n confidence: 0,\n },\n }\n }\n\n const content =\n typeof lastMessage.content === 'string'\n ? lastMessage.content\n : Array.isArray(lastMessage.content)\n ? lastMessage.content\n .map(part => (typeof part === 'string' ? part : part.text || ''))\n .join(' ')\n : ''\n\n try {\n const keywordResult = config.classifier.classify(content)\n\n if (keywordResult.confidence >= confidenceThreshold || !config.llmFallback?.enabled) {\n logger.debug(\n {\n intent: keywordResult.intent,\n confidence: keywordResult.confidence,\n matchedKeywords: keywordResult.matchedKeywords,\n method: 'keyword',\n },\n 'Intent detected via keyword matching'\n )\n\n return {\n ...context,\n [contextKey]: {\n ...keywordResult,\n method: 'keyword',\n },\n }\n }\n\n logger.debug(\n {\n keywordIntent: keywordResult.intent,\n keywordConfidence: keywordResult.confidence,\n threshold: confidenceThreshold,\n },\n 'Keyword confidence low - using LLM fallback'\n )\n\n const llmResult = await config.llmFallback.classifier.classify(content)\n\n // If LLM classification failed (0 confidence with error message), fall back to keyword result\n const hasError =\n llmResult.reasoning &&\n (llmResult.reasoning.includes('failed') ||\n llmResult.reasoning.includes('Error') ||\n llmResult.reasoning.includes('Unsupported') ||\n llmResult.reasoning.includes('not available'))\n\n if (llmResult.confidence === 0 && hasError) {\n logger.warn(\n {\n error: llmResult.reasoning,\n fallingBackTo: 'keyword',\n },\n 'LLM classification failed - using keyword result'\n )\n\n return {\n ...context,\n [contextKey]: {\n ...keywordResult,\n method: 'keyword',\n metadata: {\n ...keywordResult.metadata,\n llmFallbackAttempted: true,\n llmError: llmResult.reasoning,\n },\n },\n }\n }\n\n if (config.onFallback) {\n Promise.resolve(\n config.onFallback({\n message: content,\n keywordIntent: keywordResult.intent,\n keywordConfidence: keywordResult.confidence,\n llmIntent: llmResult.intent,\n llmConfidence: llmResult.confidence,\n matchedKeywords: keywordResult.matchedKeywords,\n })\n ).catch((err: unknown) => {\n logger.error({ error: err }, 'Failed to log intent fallback')\n })\n }\n\n logger.debug(\n {\n intent: llmResult.intent,\n confidence: llmResult.confidence,\n method: 'llm-fallback',\n reasoning: llmResult.reasoning,\n },\n 'Intent detected via LLM fallback'\n )\n\n return {\n ...context,\n [contextKey]: {\n intent: llmResult.intent,\n confidence: llmResult.confidence,\n metadata: {\n ...keywordResult.metadata,\n classificationMethod: 'llm',\n reasoning: llmResult.reasoning,\n },\n method: 'llm',\n llmTokens: llmResult.usage?.totalTokens || 0,\n usage: llmResult.usage,\n },\n }\n } catch (error) {\n logger.error(\n {\n error: error instanceof Error ? error.message : String(error),\n },\n 'Intent detection failed - using defaults'\n )\n\n return {\n ...context,\n [contextKey]: {\n intent: 'general',\n confidence: 0,\n },\n }\n }\n }\n}\n","import type { ContextOptimizer } from '../context/optimizer'\nimport type { OrchestrationContext, OrchestrationHandler } from '../core/types'\nimport { consoleLogger, type Logger } from '../utils/logger'\n\nexport interface ContextHandlerConfig {\n optimizer: ContextOptimizer\n getTopics?: (context: OrchestrationContext) => string[]\n isFirstMessage?: (context: OrchestrationContext) => boolean\n outputKey?: string\n logger?: Logger\n}\n\n/**\n * Creates context building handler for dynamic prompt generation.\n */\nexport function createContextHandler(config: ContextHandlerConfig): OrchestrationHandler {\n const logger = config.logger ?? consoleLogger\n const outputKey = config.outputKey ?? 'promptContext'\n\n return async (context: OrchestrationContext) => {\n try {\n const topics = config.getTopics?.(context) ?? []\n const isFirstMessage =\n config.isFirstMessage?.(context) ?? context.request.messages.length === 1\n\n const result = config.optimizer.build(topics, isFirstMessage)\n\n logger.debug(\n {\n topics,\n isFirstMessage,\n sectionsIncluded: result.sectionsIncluded,\n tokenEstimate: result.tokenEstimate,\n },\n 'Context built successfully'\n )\n\n return {\n ...context,\n [outputKey]: result,\n }\n } catch (error) {\n logger.error(\n {\n error: error instanceof Error ? error.message : String(error),\n },\n 'Context building failed'\n )\n\n return context\n }\n }\n}\n","import type { OrchestrationContext, OrchestrationHandler } from '../core/types'\nimport { consoleLogger, type Logger } from '../utils/logger'\n\nexport interface RateLimiter {\n check(identifier: string): Promise<{\n allowed: boolean\n retryAfter?: number\n }>\n}\n\nexport interface RateLimitHandlerConfig {\n limiter: RateLimiter\n identifierKey?: string\n getIdentifier?: (context: OrchestrationContext) => string\n outputKey?: string\n logger?: Logger\n}\n\n/**\n * Creates rate limiting handler to prevent abuse.\n */\nexport function createRateLimitHandler(config: RateLimitHandlerConfig): OrchestrationHandler {\n const logger = config.logger ?? consoleLogger\n const outputKey = config.outputKey ?? 'rateLimit'\n\n return async (context: OrchestrationContext) => {\n try {\n const identifier =\n config.getIdentifier?.(context) ??\n (config.identifierKey\n ? (context.request.metadata?.[config.identifierKey] as string)\n : undefined) ??\n 'anonymous'\n\n const result = await config.limiter.check(identifier)\n\n if (!result.allowed) {\n logger.warn(\n {\n identifier,\n retryAfter: result.retryAfter,\n },\n 'Rate limit exceeded'\n )\n\n return {\n ...context,\n [outputKey]: result,\n error: {\n message: 'Too many requests. Please try again later.',\n statusCode: 429,\n retryAfter: result.retryAfter,\n step: 'rateLimit',\n },\n }\n }\n\n return {\n ...context,\n [outputKey]: result,\n }\n } catch (error) {\n logger.error(\n {\n error: error instanceof Error ? error.message : String(error),\n },\n 'Rate limit check failed - allowing request'\n )\n\n return {\n ...context,\n [outputKey]: {\n allowed: true,\n error: error instanceof Error ? error.message : String(error),\n },\n }\n }\n }\n}\n","import type { OrchestrationContext, OrchestrationHandler } from '../core/types'\nimport { consoleLogger, type Logger } from '../utils/logger'\n\nexport interface ModerationRule {\n pattern: RegExp\n reason: string\n}\n\nexport interface ModerationConfig {\n spamPatterns?: string[]\n profanityWords?: string[]\n customRules?: ModerationRule[]\n outputKey?: string\n logger?: Logger\n}\n\nconst DEFAULT_SPAM_PATTERNS = [/(.)\\1{10,}/i, /^[A-Z\\s!]{20,}$/]\n\n/**\n * Creates content moderation handler for spam and profanity filtering.\n */\nexport function createModerationHandler(config: ModerationConfig = {}): OrchestrationHandler {\n const logger = config.logger ?? consoleLogger\n const outputKey = config.outputKey ?? 'contentModeration'\n\n const spamPatterns = config.spamPatterns?.map(p => new RegExp(p, 'i')) ?? DEFAULT_SPAM_PATTERNS\n const profanityWords = config.profanityWords ?? []\n const customRules = config.customRules ?? []\n\n return async (context: OrchestrationContext) => {\n const messages = context.request.messages\n const lastMessage = messages[messages.length - 1]\n\n if (!lastMessage || lastMessage.role !== 'user') {\n return {\n ...context,\n [outputKey]: {\n passed: true,\n },\n }\n }\n\n const content =\n typeof lastMessage.content === 'string'\n ? lastMessage.content\n : Array.isArray(lastMessage.content)\n ? lastMessage.content\n .map(part => (typeof part === 'string' ? part : part.text || ''))\n .join(' ')\n : ''\n\n try {\n for (const pattern of spamPatterns) {\n if (pattern.test(content)) {\n logger.warn(\n {\n reason: 'spam_pattern',\n pattern: pattern.source,\n },\n 'Content moderation failed'\n )\n\n return {\n ...context,\n [outputKey]: {\n passed: false,\n reason: 'Message appears to be spam',\n },\n error: {\n message: 'Your message was flagged as inappropriate. Please try again.',\n statusCode: 400,\n step: 'contentModeration',\n },\n }\n }\n }\n\n const lowerContent = content.toLowerCase()\n for (const word of profanityWords) {\n if (lowerContent.includes(word.toLowerCase())) {\n logger.warn(\n {\n reason: 'profanity',\n word,\n },\n 'Content moderation failed'\n )\n\n return {\n ...context,\n [outputKey]: {\n passed: false,\n reason: 'Message contains inappropriate language',\n },\n error: {\n message: 'Your message contains inappropriate language. Please revise and try again.',\n statusCode: 400,\n step: 'contentModeration',\n },\n }\n }\n }\n\n for (const rule of customRules) {\n if (rule.pattern.test(content)) {\n logger.warn(\n {\n reason: 'custom_rule',\n rule: rule.reason,\n },\n 'Content moderation failed'\n )\n\n return {\n ...context,\n [outputKey]: {\n passed: false,\n reason: rule.reason,\n },\n error: {\n message: 'Your message was flagged as inappropriate. Please try again.',\n statusCode: 400,\n step: 'contentModeration',\n },\n }\n }\n }\n\n return {\n ...context,\n [outputKey]: {\n passed: true,\n },\n }\n } catch (error) {\n logger.error(\n {\n error: error instanceof Error ? error.message : String(error),\n },\n 'Content moderation check failed - allowing message'\n )\n\n return {\n ...context,\n [outputKey]: {\n passed: true,\n error: error instanceof Error ? error.message : String(error),\n },\n }\n }\n }\n}\n","import type { OrchestrationContext, OrchestrationHandler } from '../core/types'\nimport { createModel, type ProviderConfig } from '../providers'\nimport { consoleLogger, type Logger } from '../utils/logger'\n\nexport interface AIHandlerConfig extends ProviderConfig {\n maxTokens?: number\n temperature?: number\n getSystemPrompt?: (context: OrchestrationContext) => string\n outputKey?: string\n logger?: Logger\n}\n\nexport interface StreamingAIHandlerConfig extends AIHandlerConfig {\n onChunk: (chunk: string) => void | Promise<void>\n}\n\n/**\n * Creates AI generation handler.\n */\nexport function createAIHandler(config: AIHandlerConfig): OrchestrationHandler {\n const logger = config.logger ?? consoleLogger\n const outputKey = config.outputKey ?? 'aiResponse'\n\n return async (context: OrchestrationContext) => {\n try {\n const { generateText } = await import('ai')\n\n const systemPrompt = config.getSystemPrompt\n ? config.getSystemPrompt(context)\n : ((context.promptContext as { systemPrompt?: string })?.systemPrompt ?? '')\n\n if (!systemPrompt) {\n logger.warn({}, 'No system prompt found, using empty prompt')\n }\n\n const model = await createModel(config)\n\n logger.debug(\n {\n provider: config.provider,\n model: config.model,\n messageCount: context.request.messages.length,\n },\n 'Calling AI model'\n )\n\n const startTime = Date.now()\n\n const response = await generateText({\n model,\n system: systemPrompt,\n messages: context.request.messages as any,\n ...(config.maxTokens && { maxTokens: config.maxTokens }),\n ...(config.temperature !== undefined && { temperature: config.temperature }),\n })\n\n const duration = Date.now() - startTime\n\n logger.info(\n {\n durationMs: duration,\n finishReason: response.finishReason,\n usage: response.usage,\n },\n 'AI generation completed'\n )\n\n return {\n ...context,\n [outputKey]: {\n text: response.text,\n finishReason: response.finishReason,\n usage: response.usage,\n },\n }\n } catch (error) {\n logger.error(\n {\n error: error instanceof Error ? error.message : String(error),\n },\n 'AI generation failed'\n )\n\n return {\n ...context,\n error: {\n message: 'Failed to generate AI response. Please try again.',\n statusCode: 500,\n step: 'aiGeneration',\n details: error instanceof Error ? error.message : undefined,\n },\n }\n }\n }\n}\n\n/**\n * Creates streaming AI generation handler.\n */\nexport function createStreamingAIHandler(config: StreamingAIHandlerConfig): OrchestrationHandler {\n const logger = config.logger ?? consoleLogger\n const outputKey = config.outputKey ?? 'aiResponse'\n\n return async (context: OrchestrationContext) => {\n try {\n const { streamText } = await import('ai')\n\n const systemPrompt = config.getSystemPrompt\n ? config.getSystemPrompt(context)\n : ((context.promptContext as { systemPrompt?: string })?.systemPrompt ?? '')\n\n if (!systemPrompt) {\n logger.warn({}, 'No system prompt found, using empty prompt')\n }\n\n const model = await createModel(config)\n\n logger.debug(\n {\n provider: config.provider,\n model: config.model,\n messageCount: context.request.messages.length,\n },\n 'Starting AI streaming'\n )\n\n const startTime = Date.now()\n\n const result = await streamText({\n model,\n system: systemPrompt,\n messages: context.request.messages as any,\n ...(config.maxTokens && { maxTokens: config.maxTokens }),\n ...(config.temperature !== undefined && { temperature: config.temperature }),\n })\n\n let fullText = ''\n\n for await (const textPart of result.textStream) {\n fullText += textPart\n await Promise.resolve(config.onChunk(textPart))\n }\n\n const duration = Date.now() - startTime\n\n logger.info(\n {\n durationMs: duration,\n finishReason: result.finishReason,\n usage: result.usage,\n },\n 'AI streaming completed'\n )\n\n return {\n ...context,\n [outputKey]: {\n text: fullText,\n finishReason: result.finishReason,\n usage: await result.usage,\n },\n }\n } catch (error) {\n logger.error(\n {\n error: error instanceof Error ? error.message : String(error),\n },\n 'AI streaming failed'\n )\n\n return {\n ...context,\n error: {\n message: 'Failed to generate AI response. Please try again.',\n statusCode: 500,\n step: 'aiGeneration',\n details: error instanceof Error ? error.message : undefined,\n },\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,gBAAwB;AAAA,EACnC,OAAO,CAAC,KAAK,QAAQ;AACnB,QAAI,KAAK;AACP,cAAQ,MAAM,KAAK,GAAG;AAAA,IACxB,OAAO;AACL,cAAQ,MAAM,GAAG;AAAA,IACnB;AAAA,EACF;AAAA,EACA,MAAM,CAAC,KAAK,QAAQ;AAClB,QAAI,KAAK;AACP,cAAQ,KAAK,KAAK,GAAG;AAAA,IACvB,OAAO;AACL,cAAQ,KAAK,GAAG;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AAA,UACT,YAAY;AAAA,UACZ,MAAM;AAAA,UACN,SAAS,iBAAiB,QAAQ,MAAM,UAAU;AAAA,QACpD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["buildDefaultPrompt"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Orchestrator, OrchestratorConfig, executeOrchestration } from './core/index.cjs';
|
|
2
|
+
export { M as Message, O as OrchestrationContext, a as OrchestrationHandler, c as OrchestrationResult, b as OrchestrationStep } from './types-DGSj206n.cjs';
|
|
3
|
+
export { I as IntentClassifier, c as IntentConfig, b as IntentPattern, d as IntentResult, a as LLMClassifierConfig, L as LLMIntentClassifier } from './llm-classifier-pOp7OO-V.cjs';
|
|
4
|
+
export { TextLLMClassifierConfig, TextLLMIntentClassifier } from './intent/index.cjs';
|
|
5
|
+
export { ContextConfig, ContextOptimizer, ContextResult, ContextSection, ContextStrategy } from './context/index.cjs';
|
|
6
|
+
export { AIHandlerConfig, ContextHandlerConfig, IntentHandlerConfig, ModerationConfig, ModerationRule, RateLimitHandlerConfig, RateLimiter, StreamingAIHandlerConfig, createAIHandler, createContextHandler, createIntentHandler, createModerationHandler, createRateLimitHandler, createStreamingAIHandler } from './handlers/index.cjs';
|
|
7
|
+
export { AIProvider, ProviderConfig, createModel } from './providers/index.cjs';
|
|
8
|
+
export { Logger, consoleLogger, silentLogger } from './utils/index.cjs';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Orchestrator, OrchestratorConfig, executeOrchestration } from './core/index.js';
|
|
2
|
+
export { M as Message, O as OrchestrationContext, a as OrchestrationHandler, c as OrchestrationResult, b as OrchestrationStep } from './types-DGSj206n.js';
|
|
3
|
+
export { I as IntentClassifier, c as IntentConfig, b as IntentPattern, d as IntentResult, a as LLMClassifierConfig, L as LLMIntentClassifier } from './llm-classifier-Cq-QHJc4.js';
|
|
4
|
+
export { TextLLMClassifierConfig, TextLLMIntentClassifier } from './intent/index.js';
|
|
5
|
+
export { ContextConfig, ContextOptimizer, ContextResult, ContextSection, ContextStrategy } from './context/index.js';
|
|
6
|
+
export { AIHandlerConfig, ContextHandlerConfig, IntentHandlerConfig, ModerationConfig, ModerationRule, RateLimitHandlerConfig, RateLimiter, StreamingAIHandlerConfig, createAIHandler, createContextHandler, createIntentHandler, createModerationHandler, createRateLimitHandler, createStreamingAIHandler } from './handlers/index.js';
|
|
7
|
+
export { AIProvider, ProviderConfig, createModel } from './providers/index.js';
|
|
8
|
+
export { Logger, consoleLogger, silentLogger } from './utils/index.js';
|