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