@baselineos/protocol-core 1.0.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.
@@ -0,0 +1,1322 @@
1
+ import { EventEmitter } from 'events';
2
+
3
+ /**
4
+ * Baseline Protocol™ — Core Type Definitions
5
+ * The foundation for the Baseline prompt engineering language
6
+ *
7
+ * These types define the complete structure of Baseline Language programs
8
+ * across all three layers: Lang, Frame, and Core (Studio).
9
+ *
10
+ * @license Apache-2.0
11
+ */
12
+ interface BaselineProgram {
13
+ blocks: (LangBlock | FrameBlock | CoreBlock)[];
14
+ metadata: ProgramMetadata;
15
+ }
16
+ interface ProgramMetadata {
17
+ version: string;
18
+ created: Date;
19
+ author: string;
20
+ description: string;
21
+ tags: string[];
22
+ }
23
+ interface BlockMetadata {
24
+ id: string;
25
+ name: string;
26
+ description: string;
27
+ version: string;
28
+ created: Date;
29
+ modified: Date;
30
+ tags: string[];
31
+ priority: Priority;
32
+ }
33
+ interface LangBlock {
34
+ type: 'lang';
35
+ content: LexiconBlock | SyntaxBlock | CommandsBlock;
36
+ metadata: BlockMetadata;
37
+ }
38
+ interface LexiconBlock {
39
+ type: 'lexicon';
40
+ domain: Domain;
41
+ vocabulary: VocabularySet;
42
+ templates: Template[];
43
+ patterns: Pattern[];
44
+ }
45
+ interface SyntaxBlock {
46
+ type: 'syntax';
47
+ rules: GrammarRule[];
48
+ operators: Operator[];
49
+ precedence: PrecedenceRule[];
50
+ }
51
+ interface CommandsBlock {
52
+ type: 'commands';
53
+ actions: Action[];
54
+ directives: Directive[];
55
+ operations: Operation[];
56
+ }
57
+ interface FrameBlock {
58
+ type: 'frame';
59
+ content: IntentBlock | ModeBlock | EnvironmentBlock | ScopeBlock | AuthorityBlock | BasisBlock;
60
+ metadata: BlockMetadata;
61
+ }
62
+ interface IntentBlock {
63
+ type: 'intent';
64
+ goals: Goal[];
65
+ deliverables: Deliverable[];
66
+ successCriteria: SuccessCriterion[];
67
+ constraints: Constraint[];
68
+ }
69
+ interface ModeBlock {
70
+ type: 'mode';
71
+ executionPattern: ExecutionPattern;
72
+ reasoning: ReasoningMode;
73
+ checkpoints: Checkpoint[];
74
+ iterations: IterationRule[];
75
+ }
76
+ interface EnvironmentBlock {
77
+ type: 'environment';
78
+ models: Model[];
79
+ tools: Tool[];
80
+ runtime: Runtime;
81
+ policies: Policy[];
82
+ }
83
+ interface ScopeBlock {
84
+ type: 'scope';
85
+ boundaries: Boundary[];
86
+ limits: Limit[];
87
+ exclusions: Exclusion[];
88
+ inclusions: Inclusion[];
89
+ }
90
+ interface AuthorityBlock {
91
+ type: 'authority';
92
+ roles: Role[];
93
+ permissions: Permission[];
94
+ access: AccessControl[];
95
+ delegation: DelegationRule[];
96
+ }
97
+ interface BasisBlock {
98
+ type: 'basis';
99
+ organization: Organization;
100
+ kpis: KPI[];
101
+ metrics: Metric[];
102
+ context: Context[];
103
+ }
104
+ interface CoreBlock {
105
+ type: 'core';
106
+ content: FidelityBlock | SpecBlock | ArtifactBlock | ProductBlock | PlanBlock | PromptBlock;
107
+ metadata: BlockMetadata;
108
+ }
109
+ interface FidelityBlock {
110
+ type: 'fidelity';
111
+ precision: PrecisionLevel;
112
+ verification: VerificationLevel;
113
+ quality: QualityStandard[];
114
+ constraints: Constraint[];
115
+ }
116
+ interface SpecBlock {
117
+ type: 'spec';
118
+ requirements: Requirement[];
119
+ contracts: Contract[];
120
+ interfaces: Interface[];
121
+ validations: Validation[];
122
+ }
123
+ interface ArtifactBlock {
124
+ type: 'artifact';
125
+ outputs: Output[];
126
+ receipts: Receipt[];
127
+ signatures: Signature[];
128
+ retention: RetentionPolicy[];
129
+ }
130
+ interface ProductBlock {
131
+ type: 'product';
132
+ deliverables: Deliverable[];
133
+ documents: Document[];
134
+ results: Result[];
135
+ outcomes: Outcome[];
136
+ }
137
+ interface PlanBlock {
138
+ type: 'plan';
139
+ roadmap: Roadmap;
140
+ timeline: Timeline;
141
+ milestones: Milestone[];
142
+ dependencies: Dependency[];
143
+ }
144
+ interface PromptBlock {
145
+ type: 'prompt';
146
+ ir: IntermediateRepresentation$1;
147
+ instructions: Instruction[];
148
+ context: Context[];
149
+ constraints: Constraint[];
150
+ }
151
+ interface IntermediateRepresentation$1 {
152
+ version: string;
153
+ blocks: (LangBlock | FrameBlock | CoreBlock)[];
154
+ metadata: ProgramMetadata;
155
+ optimizations: Optimization[];
156
+ }
157
+ interface Domain {
158
+ name: string;
159
+ description: string;
160
+ vocabulary: string[];
161
+ patterns: string[];
162
+ examples: string[];
163
+ }
164
+ interface VocabularySet {
165
+ terms: Term[];
166
+ synonyms: Synonym[];
167
+ antonyms: Antonym[];
168
+ definitions: Definition[];
169
+ }
170
+ interface Template {
171
+ name: string;
172
+ description: string;
173
+ pattern: string;
174
+ variables: Variable[];
175
+ examples: string[];
176
+ }
177
+ interface Pattern {
178
+ name: string;
179
+ description: string;
180
+ regex: string;
181
+ examples: string[];
182
+ usage: string[];
183
+ }
184
+ interface Term {
185
+ name: string;
186
+ definition: string;
187
+ synonyms: string[];
188
+ antonyms: string[];
189
+ examples: string[];
190
+ }
191
+ interface Synonym {
192
+ term: string;
193
+ alternatives: string[];
194
+ context: string[];
195
+ }
196
+ interface Antonym {
197
+ term: string;
198
+ opposites: string[];
199
+ context: string[];
200
+ }
201
+ interface Definition {
202
+ term: string;
203
+ meaning: string;
204
+ context: string[];
205
+ examples: string[];
206
+ }
207
+ interface Variable {
208
+ name: string;
209
+ type: string;
210
+ description: string;
211
+ required: boolean;
212
+ default?: unknown;
213
+ }
214
+ interface GrammarRule {
215
+ name: string;
216
+ pattern: string;
217
+ precedence: number;
218
+ associativity: 'left' | 'right' | 'none';
219
+ }
220
+ interface Operator {
221
+ symbol: string;
222
+ precedence: number;
223
+ associativity: 'left' | 'right' | 'none';
224
+ description: string;
225
+ }
226
+ interface PrecedenceRule {
227
+ level: number;
228
+ operators: string[];
229
+ description: string;
230
+ }
231
+ interface Action {
232
+ name: string;
233
+ description: string;
234
+ parameters: Parameter[];
235
+ examples: string[];
236
+ }
237
+ interface Directive {
238
+ name: string;
239
+ description: string;
240
+ parameters: Parameter[];
241
+ examples: string[];
242
+ }
243
+ interface Operation {
244
+ name: string;
245
+ description: string;
246
+ parameters: Parameter[];
247
+ examples: string[];
248
+ }
249
+ interface Parameter {
250
+ name: string;
251
+ type: string;
252
+ description: string;
253
+ required: boolean;
254
+ default?: unknown;
255
+ validation?: Validation[];
256
+ }
257
+ interface Goal {
258
+ name: string;
259
+ description: string;
260
+ priority: Priority;
261
+ deadline: Date;
262
+ successCriteria: string[];
263
+ }
264
+ interface Deliverable {
265
+ name: string;
266
+ description: string;
267
+ type: DeliverableType;
268
+ format: string;
269
+ quality: QualityStandard[];
270
+ }
271
+ interface SuccessCriterion {
272
+ name: string;
273
+ description: string;
274
+ metric: string;
275
+ target: number;
276
+ unit: string;
277
+ }
278
+ interface Constraint {
279
+ name: string;
280
+ description: string;
281
+ type: ConstraintType;
282
+ value: unknown;
283
+ enforcement: EnforcementLevel;
284
+ }
285
+ interface ExecutionPattern {
286
+ name: string;
287
+ description: string;
288
+ steps: Step[];
289
+ checkpoints: Checkpoint[];
290
+ iterations: IterationRule[];
291
+ }
292
+ interface ReasoningMode {
293
+ type: 'chain-of-thought' | 'react' | 'tree-of-thoughts' | 'systematic';
294
+ description: string;
295
+ parameters: Parameter[];
296
+ }
297
+ interface Checkpoint {
298
+ name: string;
299
+ description: string;
300
+ validation: Validation[];
301
+ actions: Action[];
302
+ }
303
+ interface IterationRule {
304
+ name: string;
305
+ condition: string;
306
+ maxIterations: number;
307
+ convergence: ConvergenceCriteria;
308
+ }
309
+ interface Step {
310
+ name: string;
311
+ description: string;
312
+ action: Action;
313
+ validation: Validation[];
314
+ next: string[];
315
+ }
316
+ interface ConvergenceCriteria {
317
+ metric: string;
318
+ threshold: number;
319
+ tolerance: number;
320
+ maxIterations: number;
321
+ }
322
+ interface Model {
323
+ name: string;
324
+ type: ModelType;
325
+ version: string;
326
+ capabilities: Capability[];
327
+ constraints: Constraint[];
328
+ }
329
+ interface Tool {
330
+ name: string;
331
+ description: string;
332
+ type: ToolType;
333
+ parameters: Parameter[];
334
+ examples: string[];
335
+ }
336
+ interface Runtime {
337
+ environment: string;
338
+ version: string;
339
+ resources: Resource[];
340
+ policies: Policy[];
341
+ }
342
+ interface Policy {
343
+ name: string;
344
+ description: string;
345
+ type: PolicyType;
346
+ rules: Rule[];
347
+ enforcement: EnforcementLevel;
348
+ }
349
+ interface Capability {
350
+ name: string;
351
+ description: string;
352
+ parameters: Parameter[];
353
+ examples: string[];
354
+ }
355
+ interface Resource {
356
+ type: string;
357
+ name: string;
358
+ capacity: number;
359
+ unit: string;
360
+ available: number;
361
+ }
362
+ interface Rule {
363
+ name: string;
364
+ description: string;
365
+ condition: string;
366
+ action: string;
367
+ priority: number;
368
+ }
369
+ interface Condition {
370
+ name: string;
371
+ description: string;
372
+ expression: string;
373
+ parameters: Parameter[];
374
+ }
375
+ interface Boundary {
376
+ name: string;
377
+ description: string;
378
+ type: BoundaryType;
379
+ value: unknown;
380
+ enforcement: EnforcementLevel;
381
+ }
382
+ interface Limit {
383
+ name: string;
384
+ description: string;
385
+ type: LimitType;
386
+ value: number;
387
+ unit: string;
388
+ }
389
+ interface Exclusion {
390
+ name: string;
391
+ description: string;
392
+ reason: string;
393
+ alternatives: string[];
394
+ }
395
+ interface Inclusion {
396
+ name: string;
397
+ description: string;
398
+ reason: string;
399
+ requirements: string[];
400
+ }
401
+ interface Role {
402
+ name: string;
403
+ description: string;
404
+ permissions: Permission[];
405
+ responsibilities: string[];
406
+ }
407
+ interface Permission {
408
+ name: string;
409
+ description: string;
410
+ scope: string;
411
+ level: PermissionLevel;
412
+ }
413
+ interface AccessControl {
414
+ resource: string;
415
+ permissions: Permission[];
416
+ roles: string[];
417
+ conditions: Condition[];
418
+ }
419
+ interface DelegationRule {
420
+ name: string;
421
+ description: string;
422
+ fromRole: string;
423
+ toRole: string;
424
+ conditions: Condition[];
425
+ expiration: Date;
426
+ }
427
+ interface Organization {
428
+ name: string;
429
+ description: string;
430
+ structure: Structure;
431
+ culture: Culture;
432
+ values: Value[];
433
+ }
434
+ interface Structure {
435
+ type: string;
436
+ levels: number;
437
+ departments: string[];
438
+ reporting: string[];
439
+ }
440
+ interface Culture {
441
+ values: string[];
442
+ principles: string[];
443
+ practices: string[];
444
+ norms: string[];
445
+ }
446
+ interface Value {
447
+ name: string;
448
+ description: string;
449
+ importance: number;
450
+ examples: string[];
451
+ }
452
+ interface KPI {
453
+ name: string;
454
+ description: string;
455
+ metric: string;
456
+ target: number;
457
+ unit: string;
458
+ frequency: string;
459
+ }
460
+ interface Metric {
461
+ name: string;
462
+ description: string;
463
+ type: MetricType;
464
+ calculation: string;
465
+ unit: string;
466
+ }
467
+ interface Context {
468
+ name: string;
469
+ description: string;
470
+ type: ContextType;
471
+ value: unknown;
472
+ source: string;
473
+ }
474
+ interface PrecisionLevel {
475
+ level: 'low' | 'medium' | 'high' | 'exact';
476
+ description: string;
477
+ requirements: string[];
478
+ }
479
+ interface VerificationLevel {
480
+ level: 'basic' | 'standard' | 'comprehensive' | 'exhaustive';
481
+ description: string;
482
+ methods: string[];
483
+ }
484
+ interface QualityStandard {
485
+ name: string;
486
+ description: string;
487
+ criteria: string[];
488
+ measurement: string;
489
+ }
490
+ interface Validation {
491
+ name: string;
492
+ description: string;
493
+ type: ValidationType;
494
+ rules: Rule[];
495
+ errorHandling: ErrorHandling;
496
+ }
497
+ interface ErrorHandling {
498
+ strategy: string;
499
+ fallback: string;
500
+ logging: string;
501
+ userNotification: string;
502
+ }
503
+ interface AcceptanceCriteria {
504
+ name: string;
505
+ description: string;
506
+ test: string;
507
+ passCondition: string;
508
+ priority: Priority;
509
+ }
510
+ interface Requirement {
511
+ name: string;
512
+ description: string;
513
+ type: RequirementType;
514
+ priority: Priority;
515
+ acceptance: AcceptanceCriteria[];
516
+ }
517
+ interface Contract {
518
+ name: string;
519
+ description: string;
520
+ parties: string[];
521
+ terms: Term[];
522
+ enforcement: EnforcementLevel;
523
+ }
524
+ interface Interface {
525
+ name: string;
526
+ description: string;
527
+ type: InterfaceType;
528
+ methods: Method[];
529
+ properties: Property[];
530
+ }
531
+ interface Method {
532
+ name: string;
533
+ description: string;
534
+ parameters: Parameter[];
535
+ returnType: string;
536
+ examples: string[];
537
+ }
538
+ interface Property {
539
+ name: string;
540
+ description: string;
541
+ type: string;
542
+ required: boolean;
543
+ default?: unknown;
544
+ }
545
+ interface Output {
546
+ name: string;
547
+ description: string;
548
+ type: OutputType;
549
+ format: string;
550
+ quality: QualityStandard[];
551
+ }
552
+ interface Receipt {
553
+ name: string;
554
+ description: string;
555
+ timestamp: Date;
556
+ hash: string;
557
+ signature: Signature;
558
+ }
559
+ interface Signature {
560
+ algorithm: string;
561
+ value: string;
562
+ timestamp: Date;
563
+ key: string;
564
+ }
565
+ interface RetentionPolicy {
566
+ name: string;
567
+ description: string;
568
+ duration: string;
569
+ conditions: Condition[];
570
+ disposal: DisposalMethod;
571
+ }
572
+ interface Document {
573
+ name: string;
574
+ description: string;
575
+ type: DocumentType;
576
+ format: string;
577
+ content: string;
578
+ }
579
+ interface Result {
580
+ name: string;
581
+ description: string;
582
+ type: ResultType;
583
+ value: unknown;
584
+ quality: QualityStandard[];
585
+ }
586
+ interface Outcome {
587
+ name: string;
588
+ description: string;
589
+ type: OutcomeType;
590
+ success: boolean;
591
+ metrics: Metric[];
592
+ }
593
+ interface Roadmap {
594
+ name: string;
595
+ description: string;
596
+ phases: Phase[];
597
+ timeline: Timeline;
598
+ milestones: Milestone[];
599
+ }
600
+ interface Timeline {
601
+ start: Date;
602
+ end: Date;
603
+ phases: Phase[];
604
+ dependencies: Dependency[];
605
+ }
606
+ interface Milestone {
607
+ name: string;
608
+ description: string;
609
+ date: Date;
610
+ deliverables: Deliverable[];
611
+ successCriteria: SuccessCriterion[];
612
+ }
613
+ interface Dependency {
614
+ name: string;
615
+ description: string;
616
+ from: string;
617
+ to: string;
618
+ type: DependencyType;
619
+ critical: boolean;
620
+ }
621
+ interface Phase {
622
+ name: string;
623
+ description: string;
624
+ start: Date;
625
+ end: Date;
626
+ deliverables: Deliverable[];
627
+ milestones: Milestone[];
628
+ }
629
+ interface Optimization {
630
+ name: string;
631
+ description: string;
632
+ type: string;
633
+ impact: string;
634
+ implementation: string[];
635
+ }
636
+ interface Instruction {
637
+ name: string;
638
+ description: string;
639
+ type: InstructionType;
640
+ parameters: Parameter[];
641
+ examples: string[];
642
+ }
643
+ type Priority = 'low' | 'medium' | 'high' | 'critical';
644
+ type DeliverableType = 'document' | 'code' | 'data' | 'model' | 'service';
645
+ type ConstraintType = 'time' | 'cost' | 'quality' | 'security' | 'compliance';
646
+ type EnforcementLevel = 'suggested' | 'recommended' | 'required' | 'mandatory';
647
+ type ModelType = 'llm' | 'ml' | 'nlp' | 'vision' | 'audio';
648
+ type ToolType = 'api' | 'library' | 'service' | 'utility' | 'integration';
649
+ type PolicyType = 'security' | 'privacy' | 'compliance' | 'performance' | 'quality';
650
+ type BoundaryType = 'inclusive' | 'exclusive' | 'range' | 'pattern' | 'custom';
651
+ type LimitType = 'count' | 'size' | 'time' | 'memory' | 'cpu';
652
+ type PermissionLevel = 'read' | 'write' | 'execute' | 'admin' | 'owner';
653
+ type ContextType = 'environment' | 'user' | 'system' | 'business' | 'technical';
654
+ type RequirementType = 'functional' | 'non-functional' | 'business' | 'technical' | 'compliance';
655
+ type InterfaceType = 'api' | 'ui' | 'database' | 'service' | 'protocol';
656
+ type ValidationType = 'format' | 'range' | 'presence' | 'uniqueness' | 'custom';
657
+ type OutputType = 'text' | 'data' | 'file' | 'stream' | 'response';
658
+ type DocumentType = 'specification' | 'manual' | 'report' | 'contract' | 'policy';
659
+ type ResultType = 'success' | 'failure' | 'partial' | 'error' | 'warning';
660
+ type OutcomeType = 'achieved' | 'partially-achieved' | 'failed' | 'cancelled' | 'deferred';
661
+ type DependencyType = 'finish-to-start' | 'start-to-start' | 'finish-to-finish' | 'start-to-finish';
662
+ type InstructionType = 'command' | 'query' | 'action' | 'validation' | 'transformation';
663
+ type MetricType = 'count' | 'percentage' | 'duration' | 'currency' | 'custom';
664
+ type DisposalMethod = 'delete' | 'archive' | 'retain' | 'anonymize' | 'encrypt';
665
+
666
+ /**
667
+ * Baseline Language Parser
668
+ * PEG-based parser for Baseline Language syntax
669
+ *
670
+ * @license Apache-2.0
671
+ */
672
+
673
+ type TokenType = 'IDENTIFIER' | 'STRING' | 'NUMBER' | 'OPERATOR' | 'EOF';
674
+ interface Token {
675
+ type: TokenType;
676
+ value: string;
677
+ position: number;
678
+ }
679
+ interface LangBlockContent {
680
+ type: 'lexicon';
681
+ domain: string;
682
+ vocabulary: unknown[];
683
+ templates: unknown[];
684
+ patterns: unknown[];
685
+ }
686
+ interface FrameBlockContent {
687
+ type: 'intent';
688
+ goals: unknown[];
689
+ deliverables: unknown[];
690
+ successCriteria: unknown[];
691
+ constraints: unknown[];
692
+ }
693
+ interface CoreBlockContent {
694
+ type: 'fidelity';
695
+ precision: string;
696
+ verification: string;
697
+ quality: unknown[];
698
+ constraints: unknown[];
699
+ }
700
+ type ParsedBlock = {
701
+ type: 'lang' | 'frame' | 'core';
702
+ content: LangBlockContent | FrameBlockContent | CoreBlockContent;
703
+ metadata: BlockMetadata;
704
+ };
705
+ declare class BaselineParser {
706
+ private tokens;
707
+ private currentPosition;
708
+ private grammar;
709
+ initialize(): Promise<void>;
710
+ /**
711
+ * Parse Baseline Language source code
712
+ */
713
+ parse(source: string): Promise<BaselineProgram>;
714
+ /**
715
+ * Tokenize source code into tokens
716
+ */
717
+ tokenize(source: string): Token[];
718
+ /**
719
+ * Parse program structure
720
+ */
721
+ private parseProgram;
722
+ /**
723
+ * Parse individual block
724
+ */
725
+ private parseBlock;
726
+ /**
727
+ * Parse language block
728
+ */
729
+ private parseLangBlock;
730
+ /**
731
+ * Parse frame block
732
+ */
733
+ private parseFrameBlock;
734
+ /**
735
+ * Parse core block
736
+ */
737
+ private parseCoreBlock;
738
+ /**
739
+ * Parse language block content
740
+ * TODO: Full implementation should parse lexicon, syntax, and commands
741
+ */
742
+ private parseLangBlockContent;
743
+ /**
744
+ * Parse frame block content
745
+ * TODO: Full implementation should parse intent, mode, environment, etc.
746
+ */
747
+ private parseFrameBlockContent;
748
+ /**
749
+ * Parse core block content
750
+ * TODO: Full implementation should parse fidelity, spec, artifact, etc.
751
+ */
752
+ private parseCoreBlockContent;
753
+ private extractIdentifier;
754
+ private extractString;
755
+ private extractNumber;
756
+ private isOperator;
757
+ private isPunctuation;
758
+ private currentToken;
759
+ private expect;
760
+ private createBlockMetadata;
761
+ private initializeGrammar;
762
+ }
763
+
764
+ /**
765
+ * Baseline Language Lexicon Management
766
+ * Domain-specific vocabulary and template system
767
+ *
768
+ * @license Apache-2.0
769
+ */
770
+ interface LexiconDomain {
771
+ name: string;
772
+ description: string;
773
+ vocabulary: string[];
774
+ patterns: string[];
775
+ examples: string[];
776
+ }
777
+ interface LexiconTerm {
778
+ name: string;
779
+ definition: string;
780
+ synonyms: string[];
781
+ antonyms: string[];
782
+ examples: string[];
783
+ }
784
+ interface LexiconVocabulary {
785
+ terms: LexiconTerm[];
786
+ synonyms: unknown[];
787
+ antonyms: unknown[];
788
+ definitions: LexiconDefinition[];
789
+ }
790
+ interface LexiconDefinition {
791
+ meaning: string;
792
+ context: string;
793
+ examples: string[];
794
+ }
795
+ interface LexiconTemplate {
796
+ name: string;
797
+ description: string;
798
+ pattern: string;
799
+ variables: LexiconVariable[];
800
+ examples: string[];
801
+ }
802
+ interface LexiconVariable {
803
+ name: string;
804
+ type: string;
805
+ description: string;
806
+ required: boolean;
807
+ default?: string;
808
+ }
809
+ interface LexiconPattern {
810
+ name: string;
811
+ description: string;
812
+ regex: string;
813
+ examples: string[];
814
+ usage: string[];
815
+ }
816
+ interface SearchResult {
817
+ type: 'term' | 'definition';
818
+ domain: string;
819
+ item: LexiconTerm | LexiconDefinition;
820
+ relevance: number;
821
+ }
822
+ interface LexiconStats {
823
+ totalDomains: number;
824
+ totalTerms: number;
825
+ totalTemplates: number;
826
+ totalPatterns: number;
827
+ domains: string[];
828
+ vocabularySizes: Record<string, number>;
829
+ }
830
+ declare class BaselineLexicon {
831
+ private domains;
832
+ private vocabulary;
833
+ private templates;
834
+ private patterns;
835
+ initialize(): Promise<void>;
836
+ /**
837
+ * Load default lexicon packs
838
+ */
839
+ loadDefaultPacks(): Promise<void>;
840
+ /**
841
+ * Add a new domain
842
+ */
843
+ addDomain(domain: LexiconDomain): void;
844
+ /**
845
+ * Get domain by name
846
+ */
847
+ getDomain(name: string): LexiconDomain | undefined;
848
+ /**
849
+ * List all domains
850
+ */
851
+ listDomains(): LexiconDomain[];
852
+ /**
853
+ * Add vocabulary set
854
+ */
855
+ addVocabulary(domain: string, vocabulary: LexiconVocabulary): void;
856
+ /**
857
+ * Get vocabulary for domain
858
+ */
859
+ getVocabulary(domain: string): LexiconVocabulary | undefined;
860
+ /**
861
+ * Add template
862
+ */
863
+ addTemplate(template: LexiconTemplate): void;
864
+ /**
865
+ * Get template by name
866
+ */
867
+ getTemplate(name: string): LexiconTemplate | undefined;
868
+ /**
869
+ * List all templates
870
+ */
871
+ listTemplates(): LexiconTemplate[];
872
+ /**
873
+ * Add pattern
874
+ */
875
+ addPattern(pattern: LexiconPattern): void;
876
+ /**
877
+ * Get pattern by name
878
+ */
879
+ getPattern(name: string): LexiconPattern | undefined;
880
+ /**
881
+ * List all patterns
882
+ */
883
+ listPatterns(): LexiconPattern[];
884
+ /**
885
+ * Search vocabulary across domains
886
+ */
887
+ searchVocabulary(query: string, domain?: string): SearchResult[];
888
+ /**
889
+ * Get lexicon statistics
890
+ */
891
+ getLexiconStats(): LexiconStats;
892
+ private initializeDefaultDomains;
893
+ private initializeDefaultVocabulary;
894
+ private initializeDefaultTemplates;
895
+ private initializeDefaultPatterns;
896
+ private loadCoreDomainPack;
897
+ private loadAIMLDomainPack;
898
+ private loadBusinessDomainPack;
899
+ private matchesSearch;
900
+ private calculateRelevance;
901
+ }
902
+
903
+ /**
904
+ * Baseline Lang -- Core Language Implementation
905
+ * The Language & Expression Layer of Baseline Stack
906
+ *
907
+ * @license Apache-2.0
908
+ */
909
+
910
+ interface ValidationResult {
911
+ isValid: boolean;
912
+ errors: string[];
913
+ warnings: string[];
914
+ suggestions: string[];
915
+ }
916
+ interface ExecutionResult {
917
+ success: boolean;
918
+ outputs: unknown[];
919
+ metrics: Record<string, unknown>;
920
+ timestamp: Date;
921
+ }
922
+ interface IntermediateRepresentation {
923
+ version: string;
924
+ blocks: BaselineProgram['blocks'];
925
+ metadata: BaselineProgram['metadata'];
926
+ optimizations: unknown[];
927
+ }
928
+ interface LanguageStats {
929
+ totalBlocks: number;
930
+ blockTypes: Record<string, number>;
931
+ lexiconSize: number;
932
+ patternCount: number;
933
+ templateCount: number;
934
+ complexity: 'low' | 'medium' | 'high' | 'complex';
935
+ }
936
+ declare class BaselineLang {
937
+ private parser;
938
+ private lexicon;
939
+ constructor(parser: BaselineParser, lexicon: BaselineLexicon);
940
+ initialize(): Promise<void>;
941
+ /**
942
+ * Get the lexicon instance
943
+ */
944
+ getLexicon(): BaselineLexicon;
945
+ /**
946
+ * Parse Baseline Language source code
947
+ */
948
+ parseSource(source: string): Promise<BaselineProgram>;
949
+ /**
950
+ * Compile Baseline Language to Intermediate Representation
951
+ */
952
+ compileToIR(program: BaselineProgram): Promise<IntermediateRepresentation>;
953
+ /**
954
+ * Execute Baseline Language program
955
+ */
956
+ execute(program: BaselineProgram): Promise<ExecutionResult>;
957
+ /**
958
+ * Validate Baseline Language program
959
+ */
960
+ validate(program: BaselineProgram): Promise<ValidationResult>;
961
+ /**
962
+ * Generate Baseline Language from template
963
+ */
964
+ generateFromTemplate(template: string, variables: Record<string, unknown>): Promise<string>;
965
+ /**
966
+ * Get language statistics and metrics
967
+ */
968
+ getLanguageStats(): Promise<LanguageStats>;
969
+ private initializeLanguageComponents;
970
+ private initializeDefaultLexicons;
971
+ private initializeLanguagePatterns;
972
+ private initializeLexiconSystem;
973
+ private initializeSyntaxSystem;
974
+ private initializeCommandSystem;
975
+ private initializePatterns;
976
+ private compileProgram;
977
+ private executeIR;
978
+ private validateProgram;
979
+ private validateBlock;
980
+ private generateLanguage;
981
+ private calculateLanguageStats;
982
+ }
983
+
984
+ /**
985
+ * Baseline Language PEG Grammar
986
+ * Parsing Expression Grammar for the Baseline prompt engineering language
987
+ *
988
+ * @license Apache-2.0
989
+ */
990
+ /**
991
+ * PEG Grammar Rules for Baseline Language
992
+ * These rules define how to parse .bl source files into AST nodes
993
+ */
994
+ declare const baselineGrammarRules: Record<string, string>;
995
+ /**
996
+ * Grammar validation utilities
997
+ */
998
+ declare class GrammarValidator {
999
+ static validateRule(rule: string): boolean;
1000
+ static extractReferencedRules(rule: string): string[];
1001
+ static hasRecursion(ruleName: string, grammar: Record<string, string>): boolean;
1002
+ static generateSummary(grammar: Record<string, string>): {
1003
+ totalRules: number;
1004
+ ruleTypes: {
1005
+ structural: string[];
1006
+ lexical: string[];
1007
+ syntactic: string[];
1008
+ semantic: string[];
1009
+ execution: string[];
1010
+ };
1011
+ hasRecursion: boolean;
1012
+ validationStatus: boolean;
1013
+ };
1014
+ }
1015
+ declare const baselineGrammar: {
1016
+ rules: Record<string, string>;
1017
+ validator: typeof GrammarValidator;
1018
+ summary: () => {
1019
+ totalRules: number;
1020
+ ruleTypes: {
1021
+ structural: string[];
1022
+ lexical: string[];
1023
+ syntactic: string[];
1024
+ semantic: string[];
1025
+ execution: string[];
1026
+ };
1027
+ hasRecursion: boolean;
1028
+ validationStatus: boolean;
1029
+ };
1030
+ };
1031
+
1032
+ interface KnowledgeNode {
1033
+ id: string;
1034
+ type: string;
1035
+ name: string;
1036
+ level: number;
1037
+ properties: Record<string, unknown>;
1038
+ metadata: {
1039
+ created: number;
1040
+ lastModified: number;
1041
+ version: number;
1042
+ confidence: number;
1043
+ };
1044
+ embeddings: number[];
1045
+ tags: string[];
1046
+ }
1047
+ interface KnowledgeRelationship {
1048
+ id: string;
1049
+ from: string;
1050
+ to: string;
1051
+ type: string;
1052
+ weight: number;
1053
+ properties: Record<string, unknown>;
1054
+ metadata: {
1055
+ created: number;
1056
+ lastModified: number;
1057
+ confidence: number;
1058
+ };
1059
+ }
1060
+ interface KnowledgeAgent {
1061
+ id: string;
1062
+ type: string;
1063
+ capabilities: string[];
1064
+ state: string;
1065
+ knowledge: Map<string, unknown>;
1066
+ reasoning: ReasoningEngine;
1067
+ tools: string[];
1068
+ }
1069
+ interface ReasoningEngine {
1070
+ type: string;
1071
+ rules: string[];
1072
+ context: Map<string, unknown>;
1073
+ history: unknown[];
1074
+ }
1075
+ interface KnowledgeChain {
1076
+ id: string;
1077
+ type: string;
1078
+ steps: ChainStep[];
1079
+ state: string;
1080
+ executionHistory: ChainExecution[];
1081
+ performance: {
1082
+ totalExecutions: number;
1083
+ averageExecutionTime: number;
1084
+ successRate: number;
1085
+ };
1086
+ }
1087
+ interface ChainStep {
1088
+ tool: string;
1089
+ parameters: Record<string, unknown>;
1090
+ }
1091
+ interface ChainExecution {
1092
+ input: unknown;
1093
+ output: unknown;
1094
+ executionTime: number;
1095
+ timestamp: number;
1096
+ }
1097
+ interface KnowledgeTool {
1098
+ id: string;
1099
+ type: string;
1100
+ capabilities: string[];
1101
+ state: string;
1102
+ usage: {
1103
+ totalUses: number;
1104
+ lastUsed: number | null;
1105
+ successRate: number;
1106
+ };
1107
+ }
1108
+ interface QueryResult {
1109
+ success: boolean;
1110
+ query?: string;
1111
+ results?: unknown[];
1112
+ error?: string;
1113
+ metadata?: Record<string, unknown>;
1114
+ }
1115
+ interface KnowledgeGraphConfig {
1116
+ maxNodes?: number;
1117
+ maxRelationships?: number;
1118
+ knowledgeRetention?: number;
1119
+ reasoningDepth?: number;
1120
+ vectorStore?: Record<string, unknown>;
1121
+ }
1122
+ interface KnowledgeGraphMetrics {
1123
+ totalNodes: number;
1124
+ totalRelationships: number;
1125
+ knowledgeQueries: number;
1126
+ reasoningOperations: number;
1127
+ lastOptimization: number;
1128
+ }
1129
+ interface NodeData {
1130
+ id?: string;
1131
+ type?: string;
1132
+ name?: string;
1133
+ level?: number;
1134
+ properties?: Record<string, unknown>;
1135
+ confidence?: number;
1136
+ embeddings?: number[];
1137
+ tags?: string[];
1138
+ }
1139
+ interface RelationshipData {
1140
+ id?: string;
1141
+ from: string;
1142
+ to: string;
1143
+ type?: string;
1144
+ weight?: number;
1145
+ properties?: Record<string, unknown>;
1146
+ confidence?: number;
1147
+ }
1148
+ interface QueryOptions {
1149
+ type?: string;
1150
+ depth?: number;
1151
+ limit?: number;
1152
+ persona?: string;
1153
+ }
1154
+ declare class KnowledgeGraphEngine extends EventEmitter {
1155
+ private config;
1156
+ private nodes;
1157
+ private relationships;
1158
+ private personaKnowledge;
1159
+ private knowledgePatterns;
1160
+ private agents;
1161
+ private chains;
1162
+ private tools;
1163
+ private metrics;
1164
+ constructor(config?: KnowledgeGraphConfig);
1165
+ initializeEngine(): Promise<void>;
1166
+ private initializeKnowledgeStructures;
1167
+ private initializeAgents;
1168
+ private initializeChains;
1169
+ private initializeTools;
1170
+ createNode(nodeData: NodeData): KnowledgeNode;
1171
+ createRelationship(relData: RelationshipData): KnowledgeRelationship;
1172
+ createAgent(agentType: string): KnowledgeAgent;
1173
+ createChain(chainType: string): KnowledgeChain;
1174
+ createTool(toolType: string): KnowledgeTool;
1175
+ queryKnowledge(query: string, options?: QueryOptions): Promise<QueryResult>;
1176
+ private semanticQuery;
1177
+ private patternQuery;
1178
+ private relationshipQuery;
1179
+ private personaQuery;
1180
+ private applyReasoning;
1181
+ executeChain(chain: KnowledgeChain, input: unknown): Promise<unknown>;
1182
+ private executeStep;
1183
+ private executeTool;
1184
+ private matchesQuery;
1185
+ private calculateRelevance;
1186
+ private calculateStringRelevance;
1187
+ findPathToNode(nodeId: string): string[];
1188
+ getConnectedNodes(nodeId: string): string[];
1189
+ private getAgentCapabilities;
1190
+ private createReasoningEngine;
1191
+ private getReasoningRules;
1192
+ private getAgentTools;
1193
+ private getChainSteps;
1194
+ private getToolCapabilities;
1195
+ private executeKnowledgeQuery;
1196
+ private executePatternMatching;
1197
+ private executeRelationshipBuilding;
1198
+ private executeOptimization;
1199
+ private executeLearningAnalysis;
1200
+ private pruneNodes;
1201
+ private pruneRelationships;
1202
+ getStatus(): Record<string, unknown>;
1203
+ private getNodeCountsByType;
1204
+ private getRelationshipCountsByType;
1205
+ private getAgentCountsByState;
1206
+ private getChainCountsByState;
1207
+ private getToolCountsByState;
1208
+ optimize(): Promise<void>;
1209
+ addPersonaKnowledge(personaId: string, key: string, value: unknown): void;
1210
+ getPersonaKnowledge(personaId: string): Map<string, unknown> | undefined;
1211
+ addKnowledgePattern(patternKey: string, pattern: unknown): void;
1212
+ getKnowledgePatterns(patternKey: string): unknown[] | undefined;
1213
+ getNode(nodeId: string): KnowledgeNode | undefined;
1214
+ getRelationship(relId: string): KnowledgeRelationship | undefined;
1215
+ getAllNodes(): KnowledgeNode[];
1216
+ getAllRelationships(): KnowledgeRelationship[];
1217
+ getNodesByType(type: string): KnowledgeNode[];
1218
+ getRelationshipsByType(type: string): KnowledgeRelationship[];
1219
+ updateNode(nodeId: string, updates: Partial<KnowledgeNode>): KnowledgeNode | undefined;
1220
+ updateRelationship(relId: string, updates: Partial<KnowledgeRelationship>): KnowledgeRelationship | undefined;
1221
+ deleteNode(nodeId: string): boolean;
1222
+ deleteRelationship(relId: string): boolean;
1223
+ getMetrics(): KnowledgeGraphMetrics;
1224
+ }
1225
+
1226
+ interface VectorStoreConfig {
1227
+ host?: string;
1228
+ port?: number;
1229
+ collectionName?: string;
1230
+ embeddingFunction?: string;
1231
+ metadata?: Record<string, string>;
1232
+ }
1233
+ interface VectorStoreMetrics {
1234
+ totalDocuments: number;
1235
+ totalQueries: number;
1236
+ averageQueryTime: number;
1237
+ lastOptimization: number;
1238
+ }
1239
+ interface DocumentInput {
1240
+ ids: string[];
1241
+ embeddings?: number[][];
1242
+ metadatas?: Record<string, unknown>[];
1243
+ documents: string[];
1244
+ }
1245
+ interface VectorQueryResult {
1246
+ success: boolean;
1247
+ query?: string;
1248
+ results?: unknown;
1249
+ error?: string;
1250
+ metadata?: Record<string, unknown>;
1251
+ }
1252
+ interface VectorQueryOptions {
1253
+ nResults?: number;
1254
+ where?: Record<string, unknown>;
1255
+ whereDocument?: Record<string, unknown>;
1256
+ include?: string[];
1257
+ }
1258
+ interface FilterSearchOptions {
1259
+ where?: Record<string, unknown>;
1260
+ whereDocument?: Record<string, unknown>;
1261
+ nResults?: number;
1262
+ include?: string[];
1263
+ }
1264
+ interface BatchOperation {
1265
+ type: 'add' | 'update' | 'delete';
1266
+ data: Record<string, unknown>;
1267
+ }
1268
+ interface CollectionStats {
1269
+ name: string;
1270
+ count: number;
1271
+ metadata: Record<string, unknown>;
1272
+ }
1273
+ declare class ChromaVectorStore {
1274
+ private config;
1275
+ private client;
1276
+ private collection;
1277
+ private isInitialized;
1278
+ private metrics;
1279
+ private queryCache;
1280
+ private cacheMaxAge;
1281
+ constructor(config?: VectorStoreConfig);
1282
+ initializeClient(): Promise<void>;
1283
+ private initializeCollection;
1284
+ addDocuments(input: DocumentInput): Promise<VectorQueryResult>;
1285
+ query(queryText: string, options?: VectorQueryOptions): Promise<VectorQueryResult>;
1286
+ semanticSearch(queryText: string, nResults?: number): Promise<VectorQueryResult>;
1287
+ filterSearch(queryText: string, options?: FilterSearchOptions): Promise<VectorQueryResult>;
1288
+ fullTextSearch(searchText: string, nResults?: number): Promise<VectorQueryResult>;
1289
+ regexSearch(pattern: string, nResults?: number): Promise<VectorQueryResult>;
1290
+ updateDocuments(input: DocumentInput): Promise<VectorQueryResult>;
1291
+ deleteDocuments(ids: string[]): Promise<VectorQueryResult>;
1292
+ getCollectionStats(): Promise<CollectionStats | null>;
1293
+ optimizeCollection(): Promise<VectorQueryResult>;
1294
+ private createEmbeddingFunction;
1295
+ batchOperation(operations: BatchOperation[]): Promise<VectorQueryResult>;
1296
+ getClientStatus(): Record<string, unknown>;
1297
+ close(): Promise<void>;
1298
+ getMetrics(): VectorStoreMetrics;
1299
+ isReady(): boolean;
1300
+ getCollectionName(): string;
1301
+ clearCache(): void;
1302
+ }
1303
+
1304
+ /**
1305
+ * Baseline Lang -- Main Entry Point
1306
+ * The Language & Expression Layer of Baseline Stack
1307
+ *
1308
+ * @license Apache-2.0
1309
+ */
1310
+
1311
+ declare class BaselineLangCore {
1312
+ private lexicon;
1313
+ private parser;
1314
+ private lang;
1315
+ constructor();
1316
+ initialize(): Promise<void>;
1317
+ getLang(): BaselineLang;
1318
+ getParser(): BaselineParser;
1319
+ getLexicon(): BaselineLexicon;
1320
+ }
1321
+
1322
+ export { type AcceptanceCriteria, type AccessControl, type Action, type Antonym, type ArtifactBlock, type AuthorityBlock, BaselineLang, BaselineLangCore, BaselineLexicon, BaselineParser, type BaselineProgram, type BasisBlock, type BatchOperation, type BlockMetadata, type Boundary, type BoundaryType, type Capability, type ChainExecution, type ChainStep, type Checkpoint, ChromaVectorStore, type CollectionStats, type CommandsBlock, type Condition, type Constraint, type ConstraintType, type Context, type ContextType, type Contract, type ConvergenceCriteria, type CoreBlock, type CoreBlockContent, type Culture, type Definition, type DelegationRule, type Deliverable, type DeliverableType, type Dependency, type DependencyType, type Directive, type DisposalMethod, type Document, type DocumentInput, type DocumentType, type Domain, type EnforcementLevel, type EnvironmentBlock, type ErrorHandling, type Exclusion, type ExecutionPattern, type ExecutionResult, type FidelityBlock, type FilterSearchOptions, type FrameBlock, type FrameBlockContent, type Goal, type GrammarRule, GrammarValidator, type Inclusion, type Instruction, type InstructionType, type IntentBlock, type Interface, type InterfaceType, type IntermediateRepresentation, type IterationRule, type KPI, type KnowledgeAgent, type KnowledgeChain, type KnowledgeGraphConfig, KnowledgeGraphEngine, type KnowledgeGraphMetrics, type KnowledgeNode, type KnowledgeRelationship, type KnowledgeTool, type LangBlock, type LangBlockContent, type LanguageStats, type LexiconBlock, type LexiconDefinition, type LexiconDomain, type LexiconPattern, type LexiconStats, type LexiconTemplate, type LexiconTerm, type LexiconVariable, type LexiconVocabulary, type Limit, type LimitType, type Method, type Metric, type MetricType, type Milestone, type ModeBlock, type Model, type ModelType, type Operation, type Operator, type Optimization, type Organization, type Outcome, type OutcomeType, type Output, type OutputType, type Parameter, type ParsedBlock, type Pattern, type Permission, type PermissionLevel, type Phase, type PlanBlock, type Policy, type PolicyType, type PrecedenceRule, type PrecisionLevel, type Priority, type ProductBlock, type ProgramMetadata, type PromptBlock, type Property, type QualityStandard, type QueryResult, type ReasoningEngine, type ReasoningMode, type Receipt, type Requirement, type RequirementType, type Resource, type Result, type ResultType, type RetentionPolicy, type Roadmap, type Role, type Rule, type Runtime, type ScopeBlock, type SearchResult, type Signature, type SpecBlock, type Step, type Structure, type SuccessCriterion, type Synonym, type SyntaxBlock, type Template, type Term, type Timeline, type Token, type TokenType, type Tool, type ToolType, type Validation, type ValidationResult, type ValidationType, type Value, type Variable, type VectorQueryOptions, type VectorQueryResult, type VectorStoreConfig, type VectorStoreMetrics, type VerificationLevel, type VocabularySet, baselineGrammar, baselineGrammarRules };