@promptbook/core 0.101.0-5 → 0.101.0-7

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/esm/index.es.js CHANGED
@@ -25,7 +25,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.101.0-5';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.101.0-7';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -270,6 +270,148 @@ new ActionCommitmentDefinition();
270
270
  * Note: [💞] Ignore a discrepancy between file name and entity name
271
271
  */
272
272
 
273
+ /**
274
+ * DELETE commitment definition
275
+ *
276
+ * The DELETE commitment (and its aliases CANCEL, DISCARD, REMOVE) is used to
277
+ * remove or disregard certain information or context. This can be useful for
278
+ * overriding previous commitments or removing unwanted behaviors.
279
+ *
280
+ * Example usage in agent source:
281
+ *
282
+ * ```book
283
+ * DELETE Previous formatting requirements
284
+ * CANCEL All emotional responses
285
+ * DISCARD Technical jargon explanations
286
+ * REMOVE Casual conversational style
287
+ * ```
288
+ *
289
+ * @private [🪔] Maybe export the commitments through some package
290
+ */
291
+ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
292
+ constructor(type) {
293
+ super(type);
294
+ }
295
+ /**
296
+ * Short one-line description of DELETE/CANCEL/DISCARD/REMOVE.
297
+ */
298
+ get description() {
299
+ return 'Remove or **disregard** certain information, context, or previous commitments.';
300
+ }
301
+ /**
302
+ * Markdown documentation for DELETE commitment.
303
+ */
304
+ get documentation() {
305
+ return spaceTrim(`
306
+ # DELETE (CANCEL, DISCARD, REMOVE)
307
+
308
+ A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
309
+
310
+ ## Aliases
311
+
312
+ - \`DELETE\` - Remove or eliminate something
313
+ - \`CANCEL\` - Cancel or nullify something
314
+ - \`DISCARD\` - Discard or ignore something
315
+ - \`REMOVE\` - Remove or take away something
316
+
317
+ ## Key behaviors
318
+
319
+ - Multiple delete commitments can be used to remove different aspects.
320
+ - Useful for overriding previous commitments in the same agent definition.
321
+ - Can be used to remove inherited behaviors from base personas.
322
+ - Helps fine-tune agent behavior by explicitly removing unwanted elements.
323
+
324
+ ## Use cases
325
+
326
+ - Overriding inherited persona characteristics
327
+ - Removing conflicting or outdated instructions
328
+ - Disabling specific response patterns
329
+ - Canceling previous formatting or style requirements
330
+
331
+ ## Examples
332
+
333
+ \`\`\`book
334
+ Serious Business Assistant
335
+
336
+ PERSONA You are a friendly and casual assistant who uses emojis
337
+ DELETE Casual conversational style
338
+ REMOVE All emoji usage
339
+ GOAL Provide professional business communications
340
+ STYLE Use formal language and proper business etiquette
341
+ \`\`\`
342
+
343
+ \`\`\`book
344
+ Simplified Technical Support
345
+
346
+ PERSONA You are a technical support specialist with deep expertise
347
+ KNOWLEDGE Extensive database of technical specifications
348
+ DISCARD Technical jargon explanations
349
+ CANCEL Advanced troubleshooting procedures
350
+ GOAL Help users with simple, easy-to-follow solutions
351
+ STYLE Use plain language that anyone can understand
352
+ \`\`\`
353
+
354
+ \`\`\`book
355
+ Focused Customer Service
356
+
357
+ PERSONA You are a customer service agent with broad knowledge
358
+ ACTION Can help with billing, technical issues, and product information
359
+ DELETE Billing assistance capabilities
360
+ REMOVE Technical troubleshooting functions
361
+ GOAL Focus exclusively on product information and general inquiries
362
+ \`\`\`
363
+
364
+ \`\`\`book
365
+ Concise Information Provider
366
+
367
+ PERSONA You are a helpful assistant who provides detailed explanations
368
+ STYLE Include examples, analogies, and comprehensive context
369
+ CANCEL Detailed explanation style
370
+ DISCARD Examples and analogies
371
+ GOAL Provide brief, direct answers without unnecessary elaboration
372
+ STYLE Be concise and to the point
373
+ \`\`\`
374
+ `);
375
+ }
376
+ applyToAgentModelRequirements(requirements, content) {
377
+ const trimmedContent = content.trim();
378
+ if (!trimmedContent) {
379
+ return requirements;
380
+ }
381
+ // Create deletion instruction for system message
382
+ const deleteSection = `${this.type}: ${trimmedContent}`;
383
+ // Delete instructions provide important context about what should be removed or ignored
384
+ return this.appendToSystemMessage(requirements, deleteSection, '\n\n');
385
+ }
386
+ }
387
+ /**
388
+ * Singleton instances of the DELETE commitment definitions with aliases
389
+ *
390
+ * @private [🪔] Maybe export the commitments through some package
391
+ */
392
+ new DeleteCommitmentDefinition('DELETE');
393
+ /**
394
+ * Singleton instances of the DELETE commitment definitions with aliases
395
+ *
396
+ * @private [🪔] Maybe export the commitments through some package
397
+ */
398
+ new DeleteCommitmentDefinition('CANCEL');
399
+ /**
400
+ * Singleton instances of the DELETE commitment definitions with aliases
401
+ *
402
+ * @private [🪔] Maybe export the commitments through some package
403
+ */
404
+ new DeleteCommitmentDefinition('DISCARD');
405
+ /**
406
+ * Singleton instances of the DELETE commitment definitions with aliases
407
+ *
408
+ * @private [🪔] Maybe export the commitments through some package
409
+ */
410
+ new DeleteCommitmentDefinition('REMOVE');
411
+ /**
412
+ * Note: [💞] Ignore a discrepancy between file name and entity name
413
+ */
414
+
273
415
  /**
274
416
  * FORMAT commitment definition
275
417
  *
@@ -351,6 +493,106 @@ new FormatCommitmentDefinition();
351
493
  * Note: [💞] Ignore a discrepancy between file name and entity name
352
494
  */
353
495
 
496
+ /**
497
+ * GOAL commitment definition
498
+ *
499
+ * The GOAL commitment defines the main goal which should be achieved by the AI assistant.
500
+ * There can be multiple goals. Later goals are more important than earlier goals.
501
+ *
502
+ * Example usage in agent source:
503
+ *
504
+ * ```book
505
+ * GOAL Help users understand complex technical concepts
506
+ * GOAL Provide accurate and up-to-date information
507
+ * GOAL Always prioritize user safety and ethical guidelines
508
+ * ```
509
+ *
510
+ * @private [🪔] Maybe export the commitments through some package
511
+ */
512
+ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
513
+ constructor() {
514
+ super('GOAL');
515
+ }
516
+ /**
517
+ * Short one-line description of GOAL.
518
+ */
519
+ get description() {
520
+ return 'Define main **goals** the AI assistant should achieve, with later goals having higher priority.';
521
+ }
522
+ /**
523
+ * Markdown documentation for GOAL commitment.
524
+ */
525
+ get documentation() {
526
+ return spaceTrim(`
527
+ # GOAL
528
+
529
+ Defines the main goal which should be achieved by the AI assistant. There can be multiple goals, and later goals are more important than earlier goals.
530
+
531
+ ## Key behaviors
532
+
533
+ - Multiple \`GOAL\` commitments are applied sequentially.
534
+ - Later goals have higher priority and can override earlier goals.
535
+ - Goals provide clear direction and purpose for the agent's responses.
536
+ - Goals influence decision-making and response prioritization.
537
+
538
+ ## Priority system
539
+
540
+ When multiple goals are defined, they are processed in order, with later goals taking precedence over earlier ones when there are conflicts.
541
+
542
+ ## Examples
543
+
544
+ \`\`\`book
545
+ Customer Support Agent
546
+
547
+ PERSONA You are a helpful customer support representative
548
+ GOAL Resolve customer issues quickly and efficiently
549
+ GOAL Maintain high customer satisfaction scores
550
+ GOAL Always follow company policies and procedures
551
+ RULE Be polite and professional at all times
552
+ \`\`\`
553
+
554
+ \`\`\`book
555
+ Educational Assistant
556
+
557
+ PERSONA You are an educational assistant specializing in mathematics
558
+ GOAL Help students understand mathematical concepts clearly
559
+ GOAL Encourage critical thinking and problem-solving skills
560
+ GOAL Ensure all explanations are age-appropriate and accessible
561
+ STYLE Use simple language and provide step-by-step explanations
562
+ \`\`\`
563
+
564
+ \`\`\`book
565
+ Safety-First Assistant
566
+
567
+ PERSONA You are a general-purpose AI assistant
568
+ GOAL Be helpful and informative in all interactions
569
+ GOAL Provide accurate and reliable information
570
+ GOAL Always prioritize user safety and ethical guidelines
571
+ RULE Never provide harmful or dangerous advice
572
+ \`\`\`
573
+ `);
574
+ }
575
+ applyToAgentModelRequirements(requirements, content) {
576
+ const trimmedContent = content.trim();
577
+ if (!trimmedContent) {
578
+ return requirements;
579
+ }
580
+ // Create goal section for system message
581
+ const goalSection = `Goal: ${trimmedContent}`;
582
+ // Goals are important directives, so we add them prominently to the system message
583
+ return this.appendToSystemMessage(requirements, goalSection, '\n\n');
584
+ }
585
+ }
586
+ /**
587
+ * Singleton instance of the GOAL commitment definition
588
+ *
589
+ * @private [🪔] Maybe export the commitments through some package
590
+ */
591
+ new GoalCommitmentDefinition();
592
+ /**
593
+ * Note: [💞] Ignore a discrepancy between file name and entity name
594
+ */
595
+
354
596
  /**
355
597
  * KNOWLEDGE commitment definition
356
598
  *
@@ -476,180 +718,342 @@ new KnowledgeCommitmentDefinition();
476
718
  */
477
719
 
478
720
  /**
479
- * META IMAGE commitment definition
721
+ * MEMORY commitment definition
480
722
  *
481
- * The META IMAGE commitment sets the agent's avatar/profile image URL.
482
- * This commitment is special because it doesn't affect the system message,
483
- * but is handled separately in the parsing logic.
723
+ * The MEMORY commitment is similar to KNOWLEDGE but has a focus on remembering past
724
+ * interactions and user preferences. It helps the agent maintain context about the
725
+ * user's history, preferences, and previous conversations.
484
726
  *
485
727
  * Example usage in agent source:
486
728
  *
487
729
  * ```book
488
- * META IMAGE https://example.com/avatar.jpg
489
- * META IMAGE /assets/agent-avatar.png
730
+ * MEMORY User prefers detailed technical explanations
731
+ * MEMORY Previously worked on React projects
732
+ * MEMORY Timezone: UTC-5 (Eastern Time)
490
733
  * ```
491
734
  *
492
735
  * @private [🪔] Maybe export the commitments through some package
493
736
  */
494
- class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
737
+ class MemoryCommitmentDefinition extends BaseCommitmentDefinition {
495
738
  constructor() {
496
- super('META IMAGE');
739
+ super('MEMORY');
497
740
  }
498
741
  /**
499
- * Short one-line description of META IMAGE.
742
+ * Short one-line description of MEMORY.
500
743
  */
501
744
  get description() {
502
- return "Set the agent's profile image URL.";
745
+ return 'Remember past interactions and user **preferences** for personalized responses.';
503
746
  }
504
747
  /**
505
- * Markdown documentation for META IMAGE commitment.
748
+ * Markdown documentation for MEMORY commitment.
506
749
  */
507
750
  get documentation() {
508
751
  return spaceTrim(`
509
- # META IMAGE
752
+ # MEMORY
510
753
 
511
- Sets the agent's avatar/profile image URL.
754
+ Similar to KNOWLEDGE but focuses on remembering past interactions and user preferences. This commitment helps the agent maintain context about the user's history, preferences, and previous conversations.
512
755
 
513
756
  ## Key behaviors
514
757
 
515
- - Does not modify the agent's behavior or responses.
516
- - Only one \`META IMAGE\` should be used per agent.
517
- - If multiple are specified, the last one takes precedence.
518
- - Used for visual representation in user interfaces.
758
+ - Multiple \`MEMORY\` commitments are applied sequentially.
759
+ - Focuses on user-specific information and interaction history.
760
+ - Helps personalize responses based on past interactions.
761
+ - Maintains continuity across conversations.
762
+
763
+ ## Differences from KNOWLEDGE
764
+
765
+ - \`KNOWLEDGE\` is for domain expertise and factual information
766
+ - \`MEMORY\` is for user-specific context and preferences
767
+ - \`MEMORY\` creates more personalized interactions
768
+ - \`MEMORY\` often includes temporal or preference-based information
519
769
 
520
770
  ## Examples
521
771
 
522
772
  \`\`\`book
523
- Professional Assistant
773
+ Personal Assistant
774
+
775
+ PERSONA You are a personal productivity assistant
776
+ MEMORY User is a software developer working in JavaScript/React
777
+ MEMORY User prefers morning work sessions and afternoon meetings
778
+ MEMORY Previously helped with project planning for mobile apps
779
+ MEMORY User timezone: UTC-8 (Pacific Time)
780
+ GOAL Help optimize daily productivity and workflow
781
+ \`\`\`
524
782
 
525
- META IMAGE https://example.com/professional-avatar.jpg
526
- PERSONA You are a professional business assistant
527
- STYLE Maintain a formal and courteous tone
783
+ \`\`\`book
784
+ Learning Companion
785
+
786
+ PERSONA You are an educational companion for programming students
787
+ MEMORY Student is learning Python as their first programming language
788
+ MEMORY Previous topics covered: variables, loops, functions
789
+ MEMORY Student learns best with practical examples and exercises
790
+ MEMORY Last session: working on list comprehensions
791
+ GOAL Provide progressive learning experiences tailored to student's pace
528
792
  \`\`\`
529
793
 
530
794
  \`\`\`book
531
- Creative Helper
795
+ Customer Support Agent
532
796
 
533
- META IMAGE /assets/creative-bot-avatar.png
534
- PERSONA You are a creative and inspiring assistant
535
- STYLE Be enthusiastic and encouraging
536
- ACTION Can help with brainstorming and ideation
797
+ PERSONA You are a customer support representative
798
+ MEMORY Customer has premium subscription since 2023
799
+ MEMORY Previous issue: billing question resolved last month
800
+ MEMORY Customer prefers email communication over phone calls
801
+ MEMORY Account shows frequent use of advanced features
802
+ GOAL Provide personalized support based on customer history
537
803
  \`\`\`
538
804
  `);
539
805
  }
540
806
  applyToAgentModelRequirements(requirements, content) {
541
- // META IMAGE doesn't modify the system message or model requirements
542
- // It's handled separately in the parsing logic for profile image extraction
543
- // This method exists for consistency with the CommitmentDefinition interface
544
- return requirements;
545
- }
546
- /**
547
- * Extracts the profile image URL from the content
548
- * This is used by the parsing logic
549
- */
550
- extractProfileImageUrl(content) {
551
807
  const trimmedContent = content.trim();
552
- return trimmedContent || null;
808
+ if (!trimmedContent) {
809
+ return requirements;
810
+ }
811
+ // Create memory section for system message
812
+ const memorySection = `Memory: ${trimmedContent}`;
813
+ // Memory information is contextual and should be included in the system message
814
+ return this.appendToSystemMessage(requirements, memorySection, '\n\n');
553
815
  }
554
816
  }
555
817
  /**
556
- * Singleton instance of the META IMAGE commitment definition
818
+ * Singleton instance of the MEMORY commitment definition
557
819
  *
558
820
  * @private [🪔] Maybe export the commitments through some package
559
821
  */
560
- new MetaImageCommitmentDefinition();
822
+ new MemoryCommitmentDefinition();
561
823
  /**
562
824
  * Note: [💞] Ignore a discrepancy between file name and entity name
563
825
  */
564
826
 
565
827
  /**
566
- * META LINK commitment definition
828
+ * MESSAGE commitment definition
567
829
  *
568
- * The `META LINK` commitment represents the link to the person from whom the agent is created.
569
- * This commitment is special because it doesn't affect the system message,
570
- * but is handled separately in the parsing logic for profile display.
830
+ * The MESSAGE commitment contains 1:1 text of the message which AI assistant already
831
+ * sent during the conversation. Later messages are later in the conversation.
832
+ * It is similar to EXAMPLE but it is not example, it is the real message which
833
+ * AI assistant already sent.
571
834
  *
572
835
  * Example usage in agent source:
573
836
  *
837
+ * ```book
838
+ * MESSAGE Hello! How can I help you today?
839
+ * MESSAGE I understand you're looking for information about our services.
840
+ * MESSAGE Based on your requirements, I'd recommend our premium package.
574
841
  * ```
575
- * META LINK https://twitter.com/username
576
- * META LINK https://linkedin.com/in/profile
577
- * META LINK https://github.com/username
578
- * ```
579
842
  *
580
- * Multiple `META LINK` commitments can be used when there are multiple sources:
843
+ * @private [🪔] Maybe export the commitments through some package
844
+ */
845
+ class MessageCommitmentDefinition extends BaseCommitmentDefinition {
846
+ constructor() {
847
+ super('MESSAGE');
848
+ }
849
+ /**
850
+ * Short one-line description of MESSAGE.
851
+ */
852
+ get description() {
853
+ return 'Include actual **messages** the AI assistant has sent during conversation history.';
854
+ }
855
+ /**
856
+ * Markdown documentation for MESSAGE commitment.
857
+ */
858
+ get documentation() {
859
+ return spaceTrim(`
860
+ # MESSAGE
861
+
862
+ Contains 1:1 text of the message which AI assistant already sent during the conversation. Later messages are later in the conversation. It is similar to EXAMPLE but it is not example, it is the real message which AI assistant already sent.
863
+
864
+ ## Key behaviors
865
+
866
+ - Multiple \`MESSAGE\` commitments represent the conversation timeline.
867
+ - Later messages are later in the conversation chronologically.
868
+ - Contains actual historical messages, not examples or templates.
869
+ - Helps maintain conversation continuity and context.
870
+
871
+ ## Differences from EXAMPLE
872
+
873
+ - \`EXAMPLE\` shows hypothetical or template responses
874
+ - \`MESSAGE\` contains actual historical conversation content
875
+ - \`MESSAGE\` preserves the exact conversation flow
876
+ - \`MESSAGE\` helps with context awareness and consistency
877
+
878
+ ## Use cases
879
+
880
+ - Maintaining conversation history context
881
+ - Ensuring consistent tone and style across messages
882
+ - Referencing previous responses in ongoing conversations
883
+ - Building upon previously established context
884
+
885
+ ## Examples
886
+
887
+ \`\`\`book
888
+ Customer Support Continuation
889
+
890
+ PERSONA You are a helpful customer support agent
891
+ MESSAGE Hello! How can I help you today?
892
+ MESSAGE I understand you're experiencing issues with your account login.
893
+ MESSAGE I've sent you a password reset link to your email address.
894
+ MESSAGE Is there anything else I can help you with regarding your account?
895
+ GOAL Continue providing consistent support based on conversation history
896
+ \`\`\`
897
+
898
+ \`\`\`book
899
+ Technical Discussion
900
+
901
+ PERSONA You are a software development mentor
902
+ MESSAGE Let's start by reviewing the React component structure you shared.
903
+ MESSAGE I notice you're using class components - have you considered hooks?
904
+ MESSAGE Here's how you could refactor that using the useState hook.
905
+ MESSAGE Great question about performance! Let me explain React's rendering cycle.
906
+ KNOWLEDGE React hooks were introduced in version 16.8
907
+ \`\`\`
908
+
909
+ \`\`\`book
910
+ Educational Session
911
+
912
+ PERSONA You are a mathematics tutor
913
+ MESSAGE Today we'll work on solving quadratic equations.
914
+ MESSAGE Let's start with the basic form: ax² + bx + c = 0
915
+ MESSAGE Remember, we can use the quadratic formula or factoring.
916
+ MESSAGE You did great with that first problem! Let's try a more complex one.
917
+ GOAL Build upon previous explanations for deeper understanding
918
+ \`\`\`
919
+ `);
920
+ }
921
+ applyToAgentModelRequirements(requirements, content) {
922
+ const trimmedContent = content.trim();
923
+ if (!trimmedContent) {
924
+ return requirements;
925
+ }
926
+ // Create message section for system message
927
+ const messageSection = `Previous Message: ${trimmedContent}`;
928
+ // Messages represent conversation history and should be included for context
929
+ return this.appendToSystemMessage(requirements, messageSection, '\n\n');
930
+ }
931
+ }
932
+ /**
933
+ * Singleton instance of the MESSAGE commitment definition
934
+ *
935
+ * @private [🪔] Maybe export the commitments through some package
936
+ */
937
+ new MessageCommitmentDefinition();
938
+ /**
939
+ * Note: [💞] Ignore a discrepancy between file name and entity name
940
+ */
941
+
942
+ /**
943
+ * META commitment definition
944
+ *
945
+ * The META commitment handles all meta-information about the agent such as:
946
+ * - META IMAGE: Sets the agent's avatar/profile image URL
947
+ * - META LINK: Provides profile/source links for the person the agent models
948
+ * - META TITLE: Sets the agent's display title
949
+ * - META DESCRIPTION: Sets the agent's description
950
+ * - META [ANYTHING]: Any other meta information in uppercase format
951
+ *
952
+ * These commitments are special because they don't affect the system message,
953
+ * but are handled separately in the parsing logic for profile display.
954
+ *
955
+ * Example usage in agent source:
581
956
  *
582
957
  * ```book
958
+ * META IMAGE https://example.com/avatar.jpg
583
959
  * META LINK https://twitter.com/username
584
- * META LINK https://linkedin.com/in/profile
960
+ * META TITLE Professional Assistant
961
+ * META DESCRIPTION An AI assistant specialized in business tasks
962
+ * META AUTHOR John Doe
963
+ * META VERSION 1.0
585
964
  * ```
586
965
  *
587
966
  * @private [🪔] Maybe export the commitments through some package
588
967
  */
589
- class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
968
+ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
590
969
  constructor() {
591
- super('META LINK');
970
+ super('META');
592
971
  }
593
972
  /**
594
- * Short one-line description of META LINK.
973
+ * Short one-line description of META commitments.
595
974
  */
596
975
  get description() {
597
- return 'Provide profile/source links for the person the agent models.';
976
+ return 'Set meta-information about the agent (IMAGE, LINK, TITLE, DESCRIPTION, etc.).';
598
977
  }
599
978
  /**
600
- * Markdown documentation for META LINK commitment.
979
+ * Markdown documentation for META commitment.
601
980
  */
602
981
  get documentation() {
603
982
  return spaceTrim(`
604
- # META LINK
983
+ # META
984
+
985
+ Sets meta-information about the agent that is used for display and attribution purposes.
605
986
 
606
- Represents a profile or source link for the person the agent is modeled after.
987
+ ## Supported META types
988
+
989
+ - **META IMAGE** - Sets the agent's avatar/profile image URL
990
+ - **META LINK** - Provides profile/source links for the person the agent models
991
+ - **META TITLE** - Sets the agent's display title
992
+ - **META DESCRIPTION** - Sets the agent's description
993
+ - **META [ANYTHING]** - Any other meta information in uppercase format
607
994
 
608
995
  ## Key behaviors
609
996
 
610
- - Does not modify the agent's behavior or responses.
611
- - Multiple \`META LINK\` commitments can be used for different social profiles.
612
- - Used for attribution and crediting the original person.
613
- - Displayed in user interfaces for transparency.
997
+ - Does not modify the agent's behavior or responses
998
+ - Used for visual representation and attribution in user interfaces
999
+ - Multiple META commitments of different types can be used
1000
+ - Multiple META LINK commitments can be used for different social profiles
1001
+ - If multiple META commitments of the same type are specified, the last one takes precedence (except for LINK)
614
1002
 
615
1003
  ## Examples
616
1004
 
1005
+ ### Basic meta information
1006
+
617
1007
  \`\`\`book
618
- Expert Consultant
1008
+ Professional Assistant
619
1009
 
620
- META LINK https://twitter.com/expertname
621
- META LINK https://linkedin.com/in/expertprofile
622
- PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
623
- KNOWLEDGE Extensive background in machine learning and neural networks
1010
+ META IMAGE https://example.com/professional-avatar.jpg
1011
+ META TITLE Senior Business Consultant
1012
+ META DESCRIPTION Specialized in strategic planning and project management
1013
+ META LINK https://linkedin.com/in/professional
624
1014
  \`\`\`
625
1015
 
1016
+ ### Multiple links and custom meta
1017
+
626
1018
  \`\`\`book
627
1019
  Open Source Developer
628
1020
 
1021
+ META IMAGE /assets/dev-avatar.png
629
1022
  META LINK https://github.com/developer
630
1023
  META LINK https://twitter.com/devhandle
631
- PERSONA You are an experienced open source developer
632
- ACTION Can help with code reviews and architecture decisions
633
- STYLE Be direct and technical in explanations
1024
+ META AUTHOR Jane Smith
1025
+ META VERSION 2.1
1026
+ META LICENSE MIT
1027
+ \`\`\`
1028
+
1029
+ ### Creative assistant
1030
+
1031
+ \`\`\`book
1032
+ Creative Helper
1033
+
1034
+ META IMAGE https://example.com/creative-bot.jpg
1035
+ META TITLE Creative Writing Assistant
1036
+ META DESCRIPTION Helps with brainstorming, storytelling, and creative projects
1037
+ META INSPIRATION Books, movies, and real-world experiences
634
1038
  \`\`\`
635
1039
  `);
636
1040
  }
637
1041
  applyToAgentModelRequirements(requirements, content) {
638
- // META LINK doesn't modify the system message or model requirements
639
- // It's handled separately in the parsing logic for profile link extraction
1042
+ // META commitments don't modify the system message or model requirements
1043
+ // They are handled separately in the parsing logic for meta information extraction
640
1044
  // This method exists for consistency with the CommitmentDefinition interface
641
1045
  return requirements;
642
1046
  }
643
1047
  /**
644
- * Extracts the profile link URL from the content
1048
+ * Extracts meta information from the content based on the meta type
645
1049
  * This is used by the parsing logic
646
1050
  */
647
- extractProfileLinkUrl(content) {
1051
+ extractMetaValue(metaType, content) {
648
1052
  const trimmedContent = content.trim();
649
1053
  return trimmedContent || null;
650
1054
  }
651
1055
  /**
652
- * Validates if the provided content is a valid URL
1056
+ * Validates if the provided content is a valid URL (for IMAGE and LINK types)
653
1057
  */
654
1058
  isValidUrl(content) {
655
1059
  try {
@@ -660,13 +1064,20 @@ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
660
1064
  return false;
661
1065
  }
662
1066
  }
1067
+ /**
1068
+ * Checks if this is a known meta type
1069
+ */
1070
+ isKnownMetaType(metaType) {
1071
+ const knownTypes = ['IMAGE', 'LINK', 'TITLE', 'DESCRIPTION', 'AUTHOR', 'VERSION', 'LICENSE'];
1072
+ return knownTypes.includes(metaType.toUpperCase());
1073
+ }
663
1074
  }
664
1075
  /**
665
- * Singleton instance of the META LINK commitment definition
1076
+ * Singleton instance of the META commitment definition
666
1077
  *
667
1078
  * @private [🪔] Maybe export the commitments through some package
668
1079
  */
669
- new MetaLinkCommitmentDefinition();
1080
+ new MetaCommitmentDefinition();
670
1081
  /**
671
1082
  * Note: [💞] Ignore a discrepancy between file name and entity name
672
1083
  */
@@ -1219,6 +1630,129 @@ new SampleCommitmentDefinition('EXAMPLE');
1219
1630
  * Note: [💞] Ignore a discrepancy between file name and entity name
1220
1631
  */
1221
1632
 
1633
+ /**
1634
+ * SCENARIO commitment definition
1635
+ *
1636
+ * The SCENARIO commitment defines a specific situation or context in which the AI
1637
+ * assistant should operate. It helps to set the scene for the AI's responses.
1638
+ * Later scenarios are more important than earlier scenarios.
1639
+ *
1640
+ * Example usage in agent source:
1641
+ *
1642
+ * ```book
1643
+ * SCENARIO You are in a customer service call center during peak hours
1644
+ * SCENARIO The customer is frustrated and has been on hold for 20 minutes
1645
+ * SCENARIO This is the customer's third call about the same issue
1646
+ * ```
1647
+ *
1648
+ * @private [🪔] Maybe export the commitments through some package
1649
+ */
1650
+ class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
1651
+ constructor() {
1652
+ super('SCENARIO');
1653
+ }
1654
+ /**
1655
+ * Short one-line description of SCENARIO.
1656
+ */
1657
+ get description() {
1658
+ return 'Define specific **situations** or contexts for AI responses, with later scenarios having higher priority.';
1659
+ }
1660
+ /**
1661
+ * Markdown documentation for SCENARIO commitment.
1662
+ */
1663
+ get documentation() {
1664
+ return spaceTrim(`
1665
+ # SCENARIO
1666
+
1667
+ Defines a specific situation or context in which the AI assistant should operate. It helps to set the scene for the AI's responses. Later scenarios are more important than earlier scenarios.
1668
+
1669
+ ## Key behaviors
1670
+
1671
+ - Multiple \`SCENARIO\` commitments build upon each other.
1672
+ - Later scenarios have higher priority and can override earlier scenarios.
1673
+ - Provides situational context that influences response tone and content.
1674
+ - Helps establish the environment and circumstances for interactions.
1675
+
1676
+ ## Priority system
1677
+
1678
+ When multiple scenarios are defined, they are processed in order, with later scenarios taking precedence over earlier ones when there are conflicts.
1679
+
1680
+ ## Use cases
1681
+
1682
+ - Setting the physical or virtual environment
1683
+ - Establishing time constraints or urgency
1684
+ - Defining relationship dynamics or power structures
1685
+ - Creating emotional or situational context
1686
+
1687
+ ## Examples
1688
+
1689
+ \`\`\`book
1690
+ Emergency Response Operator
1691
+
1692
+ PERSONA You are an emergency response operator
1693
+ SCENARIO You are handling a 911 emergency call
1694
+ SCENARIO The caller is panicked and speaking rapidly
1695
+ SCENARIO Time is critical - every second counts
1696
+ GOAL Gather essential information quickly and dispatch appropriate help
1697
+ RULE Stay calm and speak clearly
1698
+ \`\`\`
1699
+
1700
+ \`\`\`book
1701
+ Sales Representative
1702
+
1703
+ PERSONA You are a software sales representative
1704
+ SCENARIO You are in the final meeting of a 6-month sales cycle
1705
+ SCENARIO The client has budget approval and decision-making authority
1706
+ SCENARIO Two competitors have also submitted proposals
1707
+ SCENARIO The client values long-term partnership over lowest price
1708
+ GOAL Close the deal while building trust for future business
1709
+ \`\`\`
1710
+
1711
+ \`\`\`book
1712
+ Medical Assistant
1713
+
1714
+ PERSONA You are a medical assistant in a busy clinic
1715
+ SCENARIO The waiting room is full and the doctor is running behind schedule
1716
+ SCENARIO Patients are becoming impatient and anxious
1717
+ SCENARIO You need to manage expectations while maintaining professionalism
1718
+ SCENARIO Some patients have been waiting over an hour
1719
+ GOAL Keep patients informed and calm while supporting efficient clinic flow
1720
+ RULE Never provide medical advice or diagnosis
1721
+ \`\`\`
1722
+
1723
+ \`\`\`book
1724
+ Technical Support Agent
1725
+
1726
+ PERSONA You are a technical support agent
1727
+ SCENARIO The customer is a small business owner during their busy season
1728
+ SCENARIO Their main business system has been down for 2 hours
1729
+ SCENARIO They are losing money every minute the system is offline
1730
+ SCENARIO This is their first experience with your company
1731
+ GOAL Resolve the issue quickly while creating a positive first impression
1732
+ \`\`\`
1733
+ `);
1734
+ }
1735
+ applyToAgentModelRequirements(requirements, content) {
1736
+ const trimmedContent = content.trim();
1737
+ if (!trimmedContent) {
1738
+ return requirements;
1739
+ }
1740
+ // Create scenario section for system message
1741
+ const scenarioSection = `Scenario: ${trimmedContent}`;
1742
+ // Scenarios provide important contextual information that affects behavior
1743
+ return this.appendToSystemMessage(requirements, scenarioSection, '\n\n');
1744
+ }
1745
+ }
1746
+ /**
1747
+ * Singleton instance of the SCENARIO commitment definition
1748
+ *
1749
+ * @private [🪔] Maybe export the commitments through some package
1750
+ */
1751
+ new ScenarioCommitmentDefinition();
1752
+ /**
1753
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1754
+ */
1755
+
1222
1756
  /**
1223
1757
  * STYLE commitment definition
1224
1758
  *
@@ -1374,6 +1908,7 @@ const COMMITMENT_REGISTRY = [
1374
1908
  // Fully implemented commitments
1375
1909
  new PersonaCommitmentDefinition(),
1376
1910
  new KnowledgeCommitmentDefinition(),
1911
+ new MemoryCommitmentDefinition(),
1377
1912
  new StyleCommitmentDefinition(),
1378
1913
  new RuleCommitmentDefinition('RULE'),
1379
1914
  new RuleCommitmentDefinition('RULES'),
@@ -1382,18 +1917,22 @@ const COMMITMENT_REGISTRY = [
1382
1917
  new FormatCommitmentDefinition(),
1383
1918
  new ModelCommitmentDefinition(),
1384
1919
  new ActionCommitmentDefinition(),
1385
- new MetaImageCommitmentDefinition(),
1386
- new MetaLinkCommitmentDefinition(),
1920
+ new MetaCommitmentDefinition(),
1387
1921
  new NoteCommitmentDefinition(),
1922
+ new GoalCommitmentDefinition(),
1923
+ new MessageCommitmentDefinition(),
1924
+ new ScenarioCommitmentDefinition(),
1925
+ new DeleteCommitmentDefinition('DELETE'),
1926
+ new DeleteCommitmentDefinition('CANCEL'),
1927
+ new DeleteCommitmentDefinition('DISCARD'),
1928
+ new DeleteCommitmentDefinition('REMOVE'),
1388
1929
  // Not yet implemented commitments (using placeholder)
1389
1930
  new NotYetImplementedCommitmentDefinition('EXPECT'),
1390
- new NotYetImplementedCommitmentDefinition('SCENARIO'),
1391
1931
  new NotYetImplementedCommitmentDefinition('SCENARIOS'),
1392
1932
  new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
1393
1933
  new NotYetImplementedCommitmentDefinition('BEHAVIOURS'),
1394
1934
  new NotYetImplementedCommitmentDefinition('AVOID'),
1395
1935
  new NotYetImplementedCommitmentDefinition('AVOIDANCE'),
1396
- new NotYetImplementedCommitmentDefinition('GOAL'),
1397
1936
  new NotYetImplementedCommitmentDefinition('GOALS'),
1398
1937
  new NotYetImplementedCommitmentDefinition('CONTEXT'),
1399
1938
  ];