@operor/core 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/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # @operor/core
2
+
3
+ Core framework for Operor — provides the agent runtime, message routing, intent classification, and extensibility points.
4
+
5
+ ## Knowledge Base Integration
6
+
7
+ Agents can opt into knowledge base (KB) powered responses via configuration:
8
+
9
+ - `OperorConfig.knowledgeStore` — configure the KB backend (SQLite path, embedding provider/model, dimensions)
10
+ - `AgentConfig.knowledgeBase: true` — opt-in per agent to use KB for context retrieval
11
+
12
+ ```typescript
13
+ const os = new Operor({
14
+ knowledgeStore: {
15
+ dbPath: './my-kb.db',
16
+ embeddingProvider: 'openai',
17
+ embeddingModel: 'text-embedding-3-small',
18
+ dimensions: 1536,
19
+ },
20
+ });
21
+
22
+ os.createAgent({
23
+ name: 'support',
24
+ triggers: ['*'],
25
+ knowledgeBase: true, // this agent uses KB
26
+ });
27
+ ```
28
+
29
+ ## Training Mode
30
+
31
+ Training mode allows whitelisted phone numbers to manage KB content via chat commands.
32
+
33
+ ```typescript
34
+ const os = new Operor({
35
+ trainingMode: {
36
+ enabled: true,
37
+ whitelist: ['+1234567890'],
38
+ },
39
+ });
40
+ ```
41
+
42
+ Available commands (sent as chat messages by whitelisted users):
43
+
44
+ | Command | Description |
45
+ |---------|-------------|
46
+ | `/teach <content>` | Add knowledge to the KB |
47
+ | `/faq list` | List all FAQ entries |
48
+ | `/faq delete <id>` | Delete an FAQ entry |
49
+ | `/faq search <query>` | Search FAQ entries |
50
+ | `/test <question>` | Test KB response |
51
+ | `/status` | Show KB status |
52
+ | `/help` | Show available commands |
53
+
54
+ Training commands emit `training:command` events for external handlers to implement the actual KB operations.
55
+
56
+ ## Guardrails
57
+
58
+ Per-agent guardrails control what messages are accepted and what responses are allowed.
59
+
60
+ ```typescript
61
+ os.createAgent({
62
+ name: 'support',
63
+ triggers: ['*'],
64
+ guardrails: {
65
+ systemRules: ['Always be polite', 'Never share internal pricing'],
66
+ blockedTopics: ['politics', 'religion'],
67
+ escalationTriggers: ['speak to a human', 'talk to manager'],
68
+ maxResponseLength: 2000,
69
+ },
70
+ });
71
+ ```
72
+
73
+ - `systemRules` — injected into the LLM system prompt
74
+ - `blockedTopics` — messages containing these topics are refused (case-insensitive substring match)
75
+ - `escalationTriggers` — phrases that trigger human handoff
76
+ - `maxResponseLength` — caps response character length
77
+
78
+ The `GuardrailEngine` class provides `checkInput()` and `checkOutput()` methods for use in agent processing pipelines.
@@ -0,0 +1,611 @@
1
+ import EventEmitter from "eventemitter3";
2
+
3
+ //#region src/types.d.ts
4
+ interface IncomingMessage {
5
+ id: string;
6
+ from: string;
7
+ text: string;
8
+ timestamp: number;
9
+ channel: 'whatsapp' | 'instagram' | 'facebook' | 'sms' | 'telegram';
10
+ provider: string;
11
+ metadata?: Record<string, any>;
12
+ /** Raw file/media buffer (e.g. downloaded WhatsApp document) */
13
+ mediaBuffer?: Buffer;
14
+ /** Original file name of the attachment */
15
+ mediaFileName?: string;
16
+ /** MIME type of the attachment */
17
+ mediaMimeType?: string;
18
+ }
19
+ interface OutgoingMessage {
20
+ to: string;
21
+ text: string;
22
+ metadata?: Record<string, any>;
23
+ /** Optional file/media buffer for document attachments */
24
+ mediaBuffer?: Buffer;
25
+ /** File name for the attachment */
26
+ mediaFileName?: string;
27
+ /** MIME type of the attachment */
28
+ mediaMimeType?: string;
29
+ }
30
+ interface Customer {
31
+ id: string;
32
+ phone?: string;
33
+ email?: string;
34
+ name?: string;
35
+ whatsappId?: string;
36
+ instagramId?: string;
37
+ facebookId?: string;
38
+ metadata?: Record<string, any>;
39
+ lifetimeValue?: number;
40
+ firstInteraction?: Date;
41
+ lastInteraction?: Date;
42
+ }
43
+ interface Intent {
44
+ intent: string;
45
+ confidence: number;
46
+ entities: Record<string, any>;
47
+ }
48
+ interface IntentClassifier {
49
+ classify(message: string, agents: AgentConfig[], history?: ConversationMessage[]): Promise<Intent>;
50
+ }
51
+ interface ToolCall {
52
+ id: string;
53
+ name: string;
54
+ params: Record<string, any>;
55
+ result?: any;
56
+ duration?: number;
57
+ success?: boolean;
58
+ error?: string;
59
+ }
60
+ interface ConversationMessage {
61
+ role: 'user' | 'assistant';
62
+ content: string;
63
+ timestamp: number;
64
+ toolCalls?: ToolCall[];
65
+ }
66
+ interface AgentResponse {
67
+ text: string;
68
+ toolCalls?: ToolCall[];
69
+ duration: number;
70
+ cost?: number;
71
+ usage?: {
72
+ promptTokens: number;
73
+ completionTokens: number;
74
+ };
75
+ metadata?: Record<string, any>;
76
+ mediaBuffer?: Buffer;
77
+ mediaFileName?: string;
78
+ mediaMimeType?: string;
79
+ }
80
+ interface Tool {
81
+ name: string;
82
+ description: string;
83
+ parameters: Record<string, any>;
84
+ execute: (params: any) => Promise<any>;
85
+ }
86
+ interface BusinessRule {
87
+ name: string;
88
+ description?: string;
89
+ condition: (context: any, toolResults: any[]) => Promise<boolean> | boolean;
90
+ action: (context: any, toolResults: any[]) => Promise<any> | any;
91
+ }
92
+ interface AgentConfig {
93
+ name: string;
94
+ purpose?: string;
95
+ personality?: string;
96
+ triggers?: string[];
97
+ channels?: string[];
98
+ tools?: Tool[];
99
+ rules?: BusinessRule[];
100
+ guardrails?: GuardrailConfig;
101
+ knowledgeBase?: boolean;
102
+ skills?: string[];
103
+ systemPrompt?: string;
104
+ priority?: number;
105
+ escalateTo?: string;
106
+ /** Raw markdown body from INSTRUCTIONS.md (after YAML frontmatter) */
107
+ _rawInstructions?: string;
108
+ /** Raw content from IDENTITY.md */
109
+ _rawIdentity?: string;
110
+ /** Raw content from SOUL.md (agent-level or inherited from _defaults) */
111
+ _rawSoul?: string;
112
+ }
113
+ interface MessageProvider {
114
+ name: string;
115
+ connect(): Promise<void>;
116
+ disconnect(): Promise<void>;
117
+ sendMessage(to: string, message: OutgoingMessage): Promise<void>;
118
+ /** Show a typing indicator to the user (e.g. "composing…" in WhatsApp, "typing…" in Telegram). */
119
+ sendTypingIndicator?(to: string): Promise<void>;
120
+ on(event: string, handler: (...args: any[]) => void): void;
121
+ off(event: string, handler: (...args: any[]) => void): void;
122
+ }
123
+ interface Skill {
124
+ name: string;
125
+ initialize(): Promise<void>;
126
+ isReady(): boolean;
127
+ tools: Record<string, Tool>;
128
+ close?(): Promise<void>;
129
+ }
130
+ interface LLMConfig {
131
+ provider: 'openai' | 'anthropic' | 'ollama' | 'mock';
132
+ apiKey?: string;
133
+ model?: string;
134
+ temperature?: number;
135
+ maxTokens?: number;
136
+ }
137
+ interface LLMResponse {
138
+ text: string;
139
+ toolCalls?: ToolCall[];
140
+ usage?: {
141
+ promptTokens: number;
142
+ completionTokens: number;
143
+ totalTokens: number;
144
+ };
145
+ cost?: number;
146
+ }
147
+ interface MemoryConfig {
148
+ type: 'memory' | 'redis' | 'postgres';
149
+ connectionString?: string;
150
+ }
151
+ interface MemoryStore {
152
+ getCustomer(id: string): Promise<Customer | null>;
153
+ getCustomerByPhone(phone: string): Promise<Customer | null>;
154
+ upsertCustomer(customer: Customer): Promise<void>;
155
+ getHistory(customerId: string, limit?: number, agentId?: string): Promise<ConversationMessage[]>;
156
+ addMessage(customerId: string, message: ConversationMessage, agentId?: string): Promise<void>;
157
+ initialize(): Promise<void>;
158
+ close(): Promise<void>;
159
+ getSetting?(key: string): Promise<string | null>;
160
+ setSetting?(key: string, value: string | null): Promise<void>;
161
+ clearHistory?(customerId?: string, agentId?: string): Promise<{
162
+ deletedCount: number;
163
+ }>;
164
+ }
165
+ interface ConversationContext {
166
+ customer: Customer;
167
+ history: ConversationMessage[];
168
+ currentMessage: IncomingMessage;
169
+ intent?: Intent;
170
+ }
171
+ interface KnowledgeStoreConfig {
172
+ dbPath?: string;
173
+ embeddingProvider?: 'openai' | 'ollama';
174
+ embeddingModel?: string;
175
+ embeddingApiKey?: string;
176
+ embeddingBaseUrl?: string;
177
+ dimensions?: number;
178
+ }
179
+ interface TrainingModeConfig {
180
+ enabled: boolean;
181
+ whitelist: string[];
182
+ }
183
+ interface GuardrailConfig {
184
+ systemRules?: string[];
185
+ blockedTopics?: string[];
186
+ escalationTriggers?: string[];
187
+ maxResponseLength?: number;
188
+ }
189
+ /** Runtime KB interface for training mode. Keeps core decoupled from @operor/knowledge. */
190
+ interface KnowledgeBaseRuntime {
191
+ ingestFaq(question: string, answer: string, metadata?: Record<string, any>): Promise<{
192
+ id: string;
193
+ existingMatch?: {
194
+ id: string;
195
+ question: string;
196
+ answer: string;
197
+ score: number;
198
+ };
199
+ }>;
200
+ listDocuments(): Promise<KBDocumentSummary[]>;
201
+ deleteDocument(id: string): Promise<void>;
202
+ retrieve(query: string): Promise<{
203
+ results: KBRetrievalHit[];
204
+ context: string;
205
+ isFaqMatch: boolean;
206
+ }>;
207
+ getStats(): Promise<{
208
+ documentCount: number;
209
+ chunkCount: number;
210
+ embeddingDimensions: number;
211
+ dbSizeBytes: number;
212
+ }>;
213
+ /** Ingest a single URL (webpage). */
214
+ ingestUrl?(url: string): Promise<{
215
+ id: string;
216
+ title?: string;
217
+ chunks: number;
218
+ }>;
219
+ /** Crawl and ingest an entire website. */
220
+ ingestSite?(url: string, options?: {
221
+ maxDepth?: number;
222
+ maxPages?: number;
223
+ onProgress?: (crawled: number, total: number, url: string) => void;
224
+ }): Promise<{
225
+ documents: number;
226
+ chunks: number;
227
+ }>;
228
+ /** Ingest a file from a Buffer (e.g. media attachment from messaging). */
229
+ ingestFile?(buffer: Buffer, fileName: string): Promise<{
230
+ id: string;
231
+ title?: string;
232
+ chunks: number;
233
+ }>;
234
+ /** Rebuild all vector embeddings using the current embedding provider. */
235
+ rebuild?(): Promise<{
236
+ documentsRebuilt: number;
237
+ chunksRebuilt: number;
238
+ oldDimensions: number;
239
+ newDimensions: number;
240
+ }>;
241
+ }
242
+ interface KBDocumentSummary {
243
+ id: string;
244
+ sourceType: string;
245
+ sourceUrl?: string;
246
+ fileName?: string;
247
+ title?: string;
248
+ content: string;
249
+ createdAt: number;
250
+ }
251
+ interface KBRetrievalHit {
252
+ chunk: {
253
+ content: string;
254
+ };
255
+ document: {
256
+ title?: string;
257
+ };
258
+ score: number;
259
+ }
260
+ interface OperorConfig {
261
+ apiKey?: string;
262
+ llm?: LLMConfig;
263
+ /** LLM provider instance — used by /model commands for runtime switching */
264
+ llmProvider?: any;
265
+ memory?: MemoryStore;
266
+ intentClassifier?: IntentClassifier;
267
+ debug?: boolean;
268
+ batchWindowMs?: number;
269
+ autoAddAssistantMessages?: boolean;
270
+ knowledgeStore?: KnowledgeStoreConfig;
271
+ trainingMode?: TrainingModeConfig;
272
+ kb?: KnowledgeBaseRuntime;
273
+ /** Directory where agent definitions are stored (for /import to write files) */
274
+ agentsDir?: string;
275
+ /** Training Copilot command handler — injected when COPILOT_ENABLED=true */
276
+ copilotHandler?: {
277
+ handleCommand(command: string, args: string, adminPhone: string, reply: (text: string) => Promise<void>): Promise<void>;
278
+ };
279
+ /** Training Copilot query tracker — called after each message is processed */
280
+ copilotTracker?: {
281
+ maybeTrack(event: any): Promise<void>;
282
+ };
283
+ /** Analytics collector — attaches to Operor events to record message analytics */
284
+ analyticsCollector?: {
285
+ attach(os: any): void;
286
+ detach?(os: any): void;
287
+ };
288
+ /** Analytics store — exposed so training commands (/stats) can query metrics */
289
+ analyticsStore?: any;
290
+ /** Skills module — injected from CLI to avoid circular dependency (core cannot depend on skills) */
291
+ skillsModule?: any;
292
+ /** Project root directory — used for mcp.json path resolution */
293
+ projectRoot?: string;
294
+ }
295
+ interface AgentDefinition {
296
+ config: AgentConfig;
297
+ systemPrompt: string;
298
+ instructionsPath: string;
299
+ }
300
+ interface AgentEvent {
301
+ type: 'message' | 'response' | 'tool_call' | 'error';
302
+ timestamp: number;
303
+ data: any;
304
+ }
305
+ //#endregion
306
+ //#region src/Agent.d.ts
307
+ declare class Agent extends EventEmitter {
308
+ readonly id: string;
309
+ readonly name: string;
310
+ readonly config: AgentConfig;
311
+ private tools;
312
+ constructor(config: AgentConfig);
313
+ /**
314
+ * Check if this agent should handle the given intent
315
+ */
316
+ matchesIntent(intent: string): boolean;
317
+ /**
318
+ * Process a message
319
+ */
320
+ process(context: ConversationContext): Promise<AgentResponse>;
321
+ /**
322
+ * Generate response (simplified - would use LLM in production)
323
+ */
324
+ private generateResponse;
325
+ /**
326
+ * Apply business rules
327
+ */
328
+ private applyBusinessRules;
329
+ /**
330
+ * Get agent configuration
331
+ */
332
+ getConfig(): AgentConfig;
333
+ /**
334
+ * Get available tools
335
+ */
336
+ getTools(): Tool[];
337
+ /**
338
+ * Register tools dynamically (e.g., from integrations)
339
+ */
340
+ registerTools(tools: Tool[]): void;
341
+ }
342
+ //#endregion
343
+ //#region src/Operor.d.ts
344
+ declare class Operor extends EventEmitter {
345
+ private config;
346
+ private providers;
347
+ private agents;
348
+ private skills;
349
+ private memory;
350
+ private intentClassifier;
351
+ private isRunning;
352
+ private messageBatches;
353
+ private batchTimers;
354
+ private batchWindowMs;
355
+ private autoAddAssistantMessages;
356
+ private pendingEdits;
357
+ private pendingQuickstarts;
358
+ private pendingSkillAdds;
359
+ private pendingFaqReplacements;
360
+ private versionStore;
361
+ constructor(config?: OperorConfig);
362
+ /**
363
+ * Register a message provider (WhatsApp, Instagram, etc.)
364
+ */
365
+ addProvider(provider: MessageProvider): Promise<void>;
366
+ /**
367
+ * Create and register an agent
368
+ */
369
+ createAgent(config: AgentConfig): Agent;
370
+ /**
371
+ * Add a skill (MCP server, etc.)
372
+ */
373
+ addSkill(skill: Skill): Promise<void>;
374
+ removeSkill(name: string): Promise<void>;
375
+ /**
376
+ * Start Operor
377
+ */
378
+ start(): Promise<void>;
379
+ /**
380
+ * Stop Operor
381
+ */
382
+ stop(): Promise<void>;
383
+ /**
384
+ * Handle incoming message from any provider
385
+ */
386
+ private handleIncomingMessage;
387
+ /**
388
+ * Process a batch of messages from the same sender
389
+ */
390
+ private processBatch;
391
+ /**
392
+ * Get or create customer from message
393
+ */
394
+ private getOrCreateCustomer;
395
+ /**
396
+ * Handle training commands from whitelisted users.
397
+ * Returns true if the message was a training command, false otherwise.
398
+ */
399
+ private handleTrainingCommand;
400
+ /**
401
+ * Handle /export command — generates YAML bundle and sends as file attachment
402
+ */
403
+ private handleExportCommand;
404
+ /**
405
+ * Handle /import command — imports YAML bundle from file attachment or URL
406
+ */
407
+ private handleImportCommand;
408
+ /**
409
+ * Handle messages when sender has an active edit session.
410
+ */
411
+ private handlePendingEdit;
412
+ /**
413
+ * Apply a confirmed edit.
414
+ */
415
+ private applyEdit;
416
+ /**
417
+ * Handle messages when sender has an active /quickstart session.
418
+ */
419
+ private handlePendingQuickstart;
420
+ /**
421
+ * Add assistant response to conversation history (public API for manual use)
422
+ */
423
+ addAssistantMessage(customerId: string, text: string, toolCalls?: any[]): Promise<void>;
424
+ private handleInstructionsCommand;
425
+ private handleFieldViewOrEdit;
426
+ private handleConfigCommand;
427
+ private handleModelCommand;
428
+ /**
429
+ * Select agent based on intent.
430
+ * Sorts by priority (higher first), then specificity (fewer triggers = more specific).
431
+ * Agents with triggers: ['*'] are treated as fallback (checked last).
432
+ */
433
+ private selectAgent;
434
+ /**
435
+ * Send message via provider
436
+ */
437
+ private sendMessage;
438
+ /**
439
+ * Get all agents
440
+ */
441
+ getAgents(): Agent[];
442
+ /**
443
+ * Get all skills
444
+ */
445
+ getSkills(): Skill[];
446
+ /**
447
+ * Check if running
448
+ */
449
+ isActive(): boolean;
450
+ /**
451
+ * Get the analytics store (if configured) for querying metrics
452
+ */
453
+ getAnalyticsStore(): any;
454
+ private configSet;
455
+ private configArrayOp;
456
+ private handleWhitelistCommand;
457
+ private handleSkillsCommand;
458
+ private handleCreateSkillCommand;
459
+ private handleUpdateSkillCommand;
460
+ private handleSkillCatalog;
461
+ private handleSkillAdd;
462
+ private handlePendingSkillAdd;
463
+ private installSkillFromCatalog;
464
+ private handleSkillRemove;
465
+ private persistWhitelist;
466
+ /**
467
+ * Format a date string (YYYY-MM-DD) to a day name (e.g. "Monday")
468
+ */
469
+ private formatDayName;
470
+ /**
471
+ * Log helper
472
+ */
473
+ private getFirstAgent;
474
+ private rebuildAgentSystemPrompt;
475
+ private writeAgentFiles;
476
+ private writeAgentFrontmatter;
477
+ private extractSection;
478
+ private replaceSection;
479
+ private parseSections;
480
+ private extractFrontmatter;
481
+ private log;
482
+ }
483
+ //#endregion
484
+ //#region src/InMemoryStore.d.ts
485
+ /**
486
+ * Default in-memory implementation of MemoryStore.
487
+ * Data is lost on restart. Used as the default when no external store is provided.
488
+ */
489
+ declare class InMemoryStore implements MemoryStore {
490
+ private customers;
491
+ private phoneIndex;
492
+ private conversations;
493
+ private settings;
494
+ initialize(): Promise<void>;
495
+ getCustomer(id: string): Promise<Customer | null>;
496
+ getCustomerByPhone(phone: string): Promise<Customer | null>;
497
+ upsertCustomer(customer: Customer): Promise<void>;
498
+ getHistory(customerId: string, limit?: number, agentId?: string): Promise<ConversationMessage[]>;
499
+ addMessage(customerId: string, message: ConversationMessage, agentId?: string): Promise<void>;
500
+ clearHistory(customerId?: string, agentId?: string): Promise<{
501
+ deletedCount: number;
502
+ }>;
503
+ getSetting(key: string): Promise<string | null>;
504
+ setSetting(key: string, value: string | null): Promise<void>;
505
+ close(): Promise<void>;
506
+ }
507
+ //#endregion
508
+ //#region src/AgentLoader.d.ts
509
+ /**
510
+ * Loads agent definitions from a file-based directory structure.
511
+ *
512
+ * Expected layout:
513
+ * agents/
514
+ * _defaults/
515
+ * SOUL.md (optional global soul/personality)
516
+ * <agent-name>/
517
+ * INSTRUCTIONS.md (required — YAML frontmatter + markdown body)
518
+ * IDENTITY.md (optional — identity/persona)
519
+ * SOUL.md (optional — overrides _defaults/SOUL.md)
520
+ * USER.md (optional — workspace-level user context)
521
+ */
522
+ declare class AgentLoader {
523
+ private agentsDir;
524
+ private workspaceRoot;
525
+ constructor(workspaceRoot: string, agentsDir?: string);
526
+ /**
527
+ * Load all agent definitions from the agents directory.
528
+ */
529
+ loadAll(): Promise<AgentDefinition[]>;
530
+ /**
531
+ * Load a single agent definition by directory name.
532
+ */
533
+ loadAgent(name: string): Promise<AgentDefinition | null>;
534
+ }
535
+ /**
536
+ * Read a file and return its contents, or null if it doesn't exist.
537
+ */
538
+ declare function readFileOrNull(filePath: string): Promise<string | null>;
539
+ /**
540
+ * Assemble the system prompt from structured sections.
541
+ */
542
+ declare function buildSystemPrompt(parts: {
543
+ identity: string | null;
544
+ soul: string | null;
545
+ body: string;
546
+ userContext: string | null;
547
+ guardrails?: GuardrailConfig;
548
+ }): string;
549
+ //#endregion
550
+ //#region src/KeywordIntentClassifier.d.ts
551
+ /**
552
+ * Default keyword-based intent classifier.
553
+ * Uses simple keyword matching to classify user messages.
554
+ */
555
+ declare class KeywordIntentClassifier implements IntentClassifier {
556
+ classify(message: string, agents: AgentConfig[], history?: ConversationMessage[]): Promise<Intent>;
557
+ }
558
+ //#endregion
559
+ //#region src/LLMIntentClassifier.d.ts
560
+ /**
561
+ * LLM-based intent classifier.
562
+ * Uses an LLM to classify user messages based on agent configurations.
563
+ * Requires an LLM provider (AIProvider from @operor/llm).
564
+ */
565
+ declare class LLMIntentClassifier implements IntentClassifier {
566
+ private llm;
567
+ constructor(llm: any);
568
+ classify(message: string, agents: AgentConfig[], history?: ConversationMessage[]): Promise<Intent>;
569
+ }
570
+ //#endregion
571
+ //#region src/Guardrails.d.ts
572
+ interface GuardrailCheckResult {
573
+ allowed: boolean;
574
+ reason?: string;
575
+ escalate?: boolean;
576
+ }
577
+ declare class GuardrailEngine {
578
+ /**
579
+ * Check incoming message against guardrail config.
580
+ * Returns whether the message is allowed, and whether it should escalate.
581
+ */
582
+ checkInput(message: string, config: GuardrailConfig): GuardrailCheckResult;
583
+ /**
584
+ * Check outgoing response against guardrail config.
585
+ * Returns whether the response is allowed to be sent.
586
+ */
587
+ checkOutput(response: string, config: GuardrailConfig): GuardrailCheckResult;
588
+ }
589
+ //#endregion
590
+ //#region src/AgentVersionStore.d.ts
591
+ interface VersionSnapshot {
592
+ timestamp: string;
593
+ instructions?: string;
594
+ identity?: string;
595
+ soul?: string;
596
+ frontmatter?: Record<string, any>;
597
+ editedBy?: string;
598
+ changeDescription?: string;
599
+ }
600
+ declare class AgentVersionStore {
601
+ private agentsDir?;
602
+ private memory;
603
+ constructor(agentsDir?: string);
604
+ saveVersion(agentName: string, snapshot: VersionSnapshot): Promise<void>;
605
+ getHistory(agentName: string, limit?: number): Promise<VersionSnapshot[]>;
606
+ getVersion(agentName: string, index: number): Promise<VersionSnapshot | null>;
607
+ private loadHistory;
608
+ }
609
+ //#endregion
610
+ export { Agent, AgentConfig, AgentDefinition, AgentEvent, AgentLoader, AgentResponse, AgentVersionStore, BusinessRule, ConversationContext, ConversationMessage, Customer, type GuardrailCheckResult, GuardrailConfig, GuardrailEngine, InMemoryStore, IncomingMessage, Intent, IntentClassifier, KBDocumentSummary, KBRetrievalHit, KeywordIntentClassifier, KnowledgeBaseRuntime, KnowledgeStoreConfig, LLMConfig, LLMIntentClassifier, LLMResponse, MemoryConfig, MemoryStore, MessageProvider, Operor, OperorConfig, OutgoingMessage, Skill, Tool, ToolCall, TrainingModeConfig, type VersionSnapshot, buildSystemPrompt, readFileOrNull };
611
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/Agent.ts","../src/Operor.ts","../src/InMemoryStore.ts","../src/AgentLoader.ts","../src/KeywordIntentClassifier.ts","../src/LLMIntentClassifier.ts","../src/Guardrails.ts","../src/AgentVersionStore.ts"],"mappings":";;;UAEiB,eAAA;EACf,EAAA;EACA,IAAA;EACA,IAAA;EACA,SAAA;EACA,OAAA;EACA,QAAA;EACA,QAAA,GAAW,MAAA;EALX;EAOA,WAAA,GAAc,MAAA;EALd;EAOA,aAAA;EALA;EAOA,aAAA;AAAA;AAAA,UAGe,eAAA;EACf,EAAA;EACA,IAAA;EACA,QAAA,GAAW,MAAA;EANE;EAQb,WAAA,GAAc,MAAA;EALC;EAOf,aAAA;;EAEA,aAAA;AAAA;AAAA,UAGe,QAAA;EACf,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