@promptbook/core 0.103.0-51 → 0.103.0-52
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 +196 -16
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +2 -2
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +6 -0
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +38 -0
- package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +2 -1
- package/esm/typings/src/commitments/index.d.ts +3 -1
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +196 -16
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-52';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -7444,9 +7444,13 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
7444
7444
|
*
|
|
7445
7445
|
* @private - TODO: [🧠] Maybe should be public?
|
|
7446
7446
|
*/
|
|
7447
|
-
function createCommitmentRegex(commitment) {
|
|
7448
|
-
const
|
|
7449
|
-
const
|
|
7447
|
+
function createCommitmentRegex(commitment, aliases = []) {
|
|
7448
|
+
const allCommitments = [commitment, ...aliases];
|
|
7449
|
+
const patterns = allCommitments.map((c) => {
|
|
7450
|
+
const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
7451
|
+
return escapedCommitment.split(/\s+/).join('\\s+');
|
|
7452
|
+
});
|
|
7453
|
+
const keywordPattern = patterns.join('|');
|
|
7450
7454
|
const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
|
|
7451
7455
|
return regex;
|
|
7452
7456
|
}
|
|
@@ -7459,9 +7463,13 @@ function createCommitmentRegex(commitment) {
|
|
|
7459
7463
|
*
|
|
7460
7464
|
* @private
|
|
7461
7465
|
*/
|
|
7462
|
-
function createCommitmentTypeRegex(commitment) {
|
|
7463
|
-
const
|
|
7464
|
-
const
|
|
7466
|
+
function createCommitmentTypeRegex(commitment, aliases = []) {
|
|
7467
|
+
const allCommitments = [commitment, ...aliases];
|
|
7468
|
+
const patterns = allCommitments.map((c) => {
|
|
7469
|
+
const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
7470
|
+
return escapedCommitment.split(/\s+/).join('\\s+');
|
|
7471
|
+
});
|
|
7472
|
+
const keywordPattern = patterns.join('|');
|
|
7465
7473
|
const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b`, 'gim');
|
|
7466
7474
|
return regex;
|
|
7467
7475
|
}
|
|
@@ -7473,22 +7481,23 @@ function createCommitmentTypeRegex(commitment) {
|
|
|
7473
7481
|
* @private
|
|
7474
7482
|
*/
|
|
7475
7483
|
class BaseCommitmentDefinition {
|
|
7476
|
-
constructor(type) {
|
|
7484
|
+
constructor(type, aliases = []) {
|
|
7477
7485
|
this.type = type;
|
|
7486
|
+
this.aliases = aliases;
|
|
7478
7487
|
}
|
|
7479
7488
|
/**
|
|
7480
7489
|
* Creates a regex pattern to match this commitment in agent source
|
|
7481
7490
|
* Uses the existing createCommitmentRegex function as internal helper
|
|
7482
7491
|
*/
|
|
7483
7492
|
createRegex() {
|
|
7484
|
-
return createCommitmentRegex(this.type);
|
|
7493
|
+
return createCommitmentRegex(this.type, this.aliases);
|
|
7485
7494
|
}
|
|
7486
7495
|
/**
|
|
7487
7496
|
* Creates a regex pattern to match just the commitment type
|
|
7488
7497
|
* Uses the existing createCommitmentTypeRegex function as internal helper
|
|
7489
7498
|
*/
|
|
7490
7499
|
createTypeRegex() {
|
|
7491
|
-
return createCommitmentTypeRegex(this.type);
|
|
7500
|
+
return createCommitmentTypeRegex(this.type, this.aliases);
|
|
7492
7501
|
}
|
|
7493
7502
|
/**
|
|
7494
7503
|
* Helper method to create a new requirements object with updated system message
|
|
@@ -8400,6 +8409,165 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8400
8409
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
8401
8410
|
*/
|
|
8402
8411
|
|
|
8412
|
+
/**
|
|
8413
|
+
* META COLOR commitment definition
|
|
8414
|
+
*
|
|
8415
|
+
* The META COLOR commitment sets the agent's accent color.
|
|
8416
|
+
* This commitment is special because it doesn't affect the system message,
|
|
8417
|
+
* but is handled separately in the parsing logic.
|
|
8418
|
+
*
|
|
8419
|
+
* Example usage in agent source:
|
|
8420
|
+
*
|
|
8421
|
+
* ```book
|
|
8422
|
+
* META COLOR #ff0000
|
|
8423
|
+
* META COLOR #00ff00
|
|
8424
|
+
* ```
|
|
8425
|
+
*
|
|
8426
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
8427
|
+
*/
|
|
8428
|
+
class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
8429
|
+
constructor() {
|
|
8430
|
+
super('META COLOR', ['COLOR']);
|
|
8431
|
+
}
|
|
8432
|
+
/**
|
|
8433
|
+
* Short one-line description of META COLOR.
|
|
8434
|
+
*/
|
|
8435
|
+
get description() {
|
|
8436
|
+
return "Set the agent's accent color.";
|
|
8437
|
+
}
|
|
8438
|
+
/**
|
|
8439
|
+
* Markdown documentation for META COLOR commitment.
|
|
8440
|
+
*/
|
|
8441
|
+
get documentation() {
|
|
8442
|
+
return spaceTrim$2(`
|
|
8443
|
+
# META COLOR
|
|
8444
|
+
|
|
8445
|
+
Sets the agent's accent color.
|
|
8446
|
+
|
|
8447
|
+
## Key aspects
|
|
8448
|
+
|
|
8449
|
+
- Does not modify the agent's behavior or responses.
|
|
8450
|
+
- Only one \`META COLOR\` should be used per agent.
|
|
8451
|
+
- If multiple are specified, the last one takes precedence.
|
|
8452
|
+
- Used for visual representation in user interfaces.
|
|
8453
|
+
|
|
8454
|
+
## Examples
|
|
8455
|
+
|
|
8456
|
+
\`\`\`book
|
|
8457
|
+
Professional Assistant
|
|
8458
|
+
|
|
8459
|
+
META COLOR #3498db
|
|
8460
|
+
PERSONA You are a professional business assistant
|
|
8461
|
+
\`\`\`
|
|
8462
|
+
|
|
8463
|
+
\`\`\`book
|
|
8464
|
+
Creative Helper
|
|
8465
|
+
|
|
8466
|
+
META COLOR #e74c3c
|
|
8467
|
+
PERSONA You are a creative and inspiring assistant
|
|
8468
|
+
\`\`\`
|
|
8469
|
+
`);
|
|
8470
|
+
}
|
|
8471
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
8472
|
+
// META COLOR doesn't modify the system message or model requirements
|
|
8473
|
+
// It's handled separately in the parsing logic for profile color extraction
|
|
8474
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
8475
|
+
return requirements;
|
|
8476
|
+
}
|
|
8477
|
+
/**
|
|
8478
|
+
* Extracts the profile color from the content
|
|
8479
|
+
* This is used by the parsing logic
|
|
8480
|
+
*/
|
|
8481
|
+
extractProfileColor(content) {
|
|
8482
|
+
const trimmedContent = content.trim();
|
|
8483
|
+
return trimmedContent || null;
|
|
8484
|
+
}
|
|
8485
|
+
}
|
|
8486
|
+
/**
|
|
8487
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
8488
|
+
*/
|
|
8489
|
+
|
|
8490
|
+
/**
|
|
8491
|
+
* META IMAGE commitment definition
|
|
8492
|
+
*
|
|
8493
|
+
* The META IMAGE commitment sets the agent's avatar/profile image URL.
|
|
8494
|
+
* This commitment is special because it doesn't affect the system message,
|
|
8495
|
+
* but is handled separately in the parsing logic.
|
|
8496
|
+
*
|
|
8497
|
+
* Example usage in agent source:
|
|
8498
|
+
*
|
|
8499
|
+
* ```book
|
|
8500
|
+
* META IMAGE https://example.com/avatar.jpg
|
|
8501
|
+
* META IMAGE /assets/agent-avatar.png
|
|
8502
|
+
* ```
|
|
8503
|
+
*
|
|
8504
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
8505
|
+
*/
|
|
8506
|
+
class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
8507
|
+
constructor() {
|
|
8508
|
+
super('META IMAGE', ['IMAGE']);
|
|
8509
|
+
}
|
|
8510
|
+
/**
|
|
8511
|
+
* Short one-line description of META IMAGE.
|
|
8512
|
+
*/
|
|
8513
|
+
get description() {
|
|
8514
|
+
return "Set the agent's profile image URL.";
|
|
8515
|
+
}
|
|
8516
|
+
/**
|
|
8517
|
+
* Markdown documentation for META IMAGE commitment.
|
|
8518
|
+
*/
|
|
8519
|
+
get documentation() {
|
|
8520
|
+
return spaceTrim$2(`
|
|
8521
|
+
# META IMAGE
|
|
8522
|
+
|
|
8523
|
+
Sets the agent's avatar/profile image URL.
|
|
8524
|
+
|
|
8525
|
+
## Key aspects
|
|
8526
|
+
|
|
8527
|
+
- Does not modify the agent's behavior or responses.
|
|
8528
|
+
- Only one \`META IMAGE\` should be used per agent.
|
|
8529
|
+
- If multiple are specified, the last one takes precedence.
|
|
8530
|
+
- Used for visual representation in user interfaces.
|
|
8531
|
+
|
|
8532
|
+
## Examples
|
|
8533
|
+
|
|
8534
|
+
\`\`\`book
|
|
8535
|
+
Professional Assistant
|
|
8536
|
+
|
|
8537
|
+
META IMAGE https://example.com/professional-avatar.jpg
|
|
8538
|
+
PERSONA You are a professional business assistant
|
|
8539
|
+
STYLE Maintain a formal and courteous tone
|
|
8540
|
+
\`\`\`
|
|
8541
|
+
|
|
8542
|
+
\`\`\`book
|
|
8543
|
+
Creative Helper
|
|
8544
|
+
|
|
8545
|
+
META IMAGE /assets/creative-bot-avatar.png
|
|
8546
|
+
PERSONA You are a creative and inspiring assistant
|
|
8547
|
+
STYLE Be enthusiastic and encouraging
|
|
8548
|
+
ACTION Can help with brainstorming and ideation
|
|
8549
|
+
\`\`\`
|
|
8550
|
+
`);
|
|
8551
|
+
}
|
|
8552
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
8553
|
+
// META IMAGE doesn't modify the system message or model requirements
|
|
8554
|
+
// It's handled separately in the parsing logic for profile image extraction
|
|
8555
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
8556
|
+
return requirements;
|
|
8557
|
+
}
|
|
8558
|
+
/**
|
|
8559
|
+
* Extracts the profile image URL from the content
|
|
8560
|
+
* This is used by the parsing logic
|
|
8561
|
+
*/
|
|
8562
|
+
extractProfileImageUrl(content) {
|
|
8563
|
+
const trimmedContent = content.trim();
|
|
8564
|
+
return trimmedContent || null;
|
|
8565
|
+
}
|
|
8566
|
+
}
|
|
8567
|
+
/**
|
|
8568
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
8569
|
+
*/
|
|
8570
|
+
|
|
8403
8571
|
/**
|
|
8404
8572
|
* MODEL commitment definition
|
|
8405
8573
|
*
|
|
@@ -9307,6 +9475,8 @@ const COMMITMENT_REGISTRY = [
|
|
|
9307
9475
|
new ModelCommitmentDefinition('MODELS'),
|
|
9308
9476
|
new ActionCommitmentDefinition('ACTION'),
|
|
9309
9477
|
new ActionCommitmentDefinition('ACTIONS'),
|
|
9478
|
+
new MetaImageCommitmentDefinition(),
|
|
9479
|
+
new MetaColorCommitmentDefinition(),
|
|
9310
9480
|
new MetaCommitmentDefinition(),
|
|
9311
9481
|
new NoteCommitmentDefinition('NOTE'),
|
|
9312
9482
|
new NoteCommitmentDefinition('NOTES'),
|
|
@@ -10220,6 +10390,14 @@ function parseAgentSource(agentSource) {
|
|
|
10220
10390
|
links.push(spaceTrim$1(commitment.content));
|
|
10221
10391
|
continue;
|
|
10222
10392
|
}
|
|
10393
|
+
if (commitment.type === 'META IMAGE') {
|
|
10394
|
+
meta.image = spaceTrim$1(commitment.content);
|
|
10395
|
+
continue;
|
|
10396
|
+
}
|
|
10397
|
+
if (commitment.type === 'META COLOR') {
|
|
10398
|
+
meta.color = spaceTrim$1(commitment.content);
|
|
10399
|
+
continue;
|
|
10400
|
+
}
|
|
10223
10401
|
if (commitment.type !== 'META') {
|
|
10224
10402
|
continue;
|
|
10225
10403
|
}
|
|
@@ -10235,6 +10413,10 @@ function parseAgentSource(agentSource) {
|
|
|
10235
10413
|
if (!meta.image) {
|
|
10236
10414
|
meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
|
|
10237
10415
|
}
|
|
10416
|
+
// Generate fullname fallback if no meta fullname specified
|
|
10417
|
+
if (!meta.fullname) {
|
|
10418
|
+
meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
10419
|
+
}
|
|
10238
10420
|
// Parse parameters using unified approach - both @Parameter and {parameter} notations
|
|
10239
10421
|
// are treated as the same syntax feature with unified representation
|
|
10240
10422
|
const parameters = parseParameters(agentSource);
|
|
@@ -17264,7 +17446,7 @@ class AgentLlmExecutionTools {
|
|
|
17264
17446
|
}
|
|
17265
17447
|
get title() {
|
|
17266
17448
|
const agentInfo = this.getAgentInfo();
|
|
17267
|
-
return (agentInfo.agentName || 'Agent');
|
|
17449
|
+
return (agentInfo.meta.fullname || agentInfo.agentName || 'Agent');
|
|
17268
17450
|
}
|
|
17269
17451
|
get description() {
|
|
17270
17452
|
const agentInfo = this.getAgentInfo();
|
|
@@ -17277,7 +17459,7 @@ class AgentLlmExecutionTools {
|
|
|
17277
17459
|
}
|
|
17278
17460
|
return {
|
|
17279
17461
|
name: agentInfo.agentName.toUpperCase().replace(/\s+/g, '_'),
|
|
17280
|
-
fullname: agentInfo.agentName,
|
|
17462
|
+
fullname: agentInfo.meta.fullname || agentInfo.agentName,
|
|
17281
17463
|
color: agentInfo.meta.color || '#6366f1',
|
|
17282
17464
|
avatarSrc: agentInfo.meta.image,
|
|
17283
17465
|
};
|
|
@@ -17509,12 +17691,10 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
17509
17691
|
|
|
17510
17692
|
---
|
|
17511
17693
|
|
|
17512
|
-
|
|
17513
|
-
|
|
17514
|
-
User:
|
|
17694
|
+
USER MESSAGE
|
|
17515
17695
|
${block(prompt.content)}
|
|
17516
17696
|
|
|
17517
|
-
|
|
17697
|
+
AGENT MESSAGE
|
|
17518
17698
|
${block(result.content)}
|
|
17519
17699
|
|
|
17520
17700
|
`);
|