@promptbook/core 0.112.0-43 → 0.112.0-44
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 +95 -36
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
- package/esm/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +2 -1
- package/esm/src/commitments/PERSONA/PERSONA.d.ts +7 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +95 -36
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
- package/umd/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +2 -1
- package/umd/src/commitments/PERSONA/PERSONA.d.ts +7 -0
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-44';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -11410,7 +11410,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11410
11410
|
* Short one-line description of GOAL.
|
|
11411
11411
|
*/
|
|
11412
11412
|
get description() {
|
|
11413
|
-
return 'Define
|
|
11413
|
+
return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
|
|
11414
11414
|
}
|
|
11415
11415
|
/**
|
|
11416
11416
|
* Icon for this commitment.
|
|
@@ -11425,12 +11425,14 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11425
11425
|
return spaceTrim$1(`
|
|
11426
11426
|
# ${this.type}
|
|
11427
11427
|
|
|
11428
|
-
Defines the main goal which should be achieved by the AI assistant.
|
|
11428
|
+
Defines the main goal which should be achieved by the AI assistant.
|
|
11429
|
+
There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
|
|
11429
11430
|
|
|
11430
11431
|
## Key aspects
|
|
11431
11432
|
|
|
11432
11433
|
- Both terms work identically and can be used interchangeably.
|
|
11433
|
-
- Later goals
|
|
11434
|
+
- Later goals overwrite earlier goals.
|
|
11435
|
+
- The public agent profile text is derived from the last goal.
|
|
11434
11436
|
- Goals provide clear direction and purpose for the agent's responses.
|
|
11435
11437
|
- Goals influence decision-making and response prioritization.
|
|
11436
11438
|
|
|
@@ -11443,9 +11445,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11443
11445
|
\`\`\`book
|
|
11444
11446
|
Customer Support Agent
|
|
11445
11447
|
|
|
11446
|
-
PERSONA You are a helpful customer support representative
|
|
11447
11448
|
GOAL Resolve customer issues quickly and efficiently
|
|
11448
|
-
GOAL Maintain high customer satisfaction scores
|
|
11449
11449
|
GOAL Always follow company policies and procedures
|
|
11450
11450
|
RULE Be polite and professional at all times
|
|
11451
11451
|
\`\`\`
|
|
@@ -11453,9 +11453,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11453
11453
|
\`\`\`book
|
|
11454
11454
|
Educational Assistant
|
|
11455
11455
|
|
|
11456
|
-
PERSONA You are an educational assistant specializing in mathematics
|
|
11457
11456
|
GOAL Help students understand mathematical concepts clearly
|
|
11458
|
-
GOAL Encourage critical thinking and problem-solving skills
|
|
11459
11457
|
GOAL Ensure all explanations are age-appropriate and accessible
|
|
11460
11458
|
STYLE Use simple language and provide step-by-step explanations
|
|
11461
11459
|
\`\`\`
|
|
@@ -11463,9 +11461,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11463
11461
|
\`\`\`book
|
|
11464
11462
|
Safety-First Assistant
|
|
11465
11463
|
|
|
11466
|
-
PERSONA You are a general-purpose AI assistant
|
|
11467
11464
|
GOAL Be helpful and informative in all interactions
|
|
11468
|
-
GOAL Provide accurate and reliable information
|
|
11469
11465
|
GOAL Always prioritize user safety and ethical guidelines
|
|
11470
11466
|
RULE Never provide harmful or dangerous advice
|
|
11471
11467
|
\`\`\`
|
|
@@ -14324,7 +14320,16 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14324
14320
|
* Short one-line description of PERSONA.
|
|
14325
14321
|
*/
|
|
14326
14322
|
get description() {
|
|
14327
|
-
return '
|
|
14323
|
+
return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
|
|
14324
|
+
}
|
|
14325
|
+
/**
|
|
14326
|
+
* Optional UI/docs-only deprecation metadata.
|
|
14327
|
+
*/
|
|
14328
|
+
get deprecation() {
|
|
14329
|
+
return {
|
|
14330
|
+
message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
|
|
14331
|
+
replacedBy: ['GOAL'],
|
|
14332
|
+
};
|
|
14328
14333
|
}
|
|
14329
14334
|
/**
|
|
14330
14335
|
* Icon for this commitment.
|
|
@@ -14339,16 +14344,24 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14339
14344
|
return spaceTrim$1(`
|
|
14340
14345
|
# ${this.type}
|
|
14341
14346
|
|
|
14342
|
-
|
|
14347
|
+
Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
|
|
14343
14348
|
|
|
14344
|
-
##
|
|
14349
|
+
## Migration
|
|
14345
14350
|
|
|
14346
|
-
-
|
|
14347
|
-
-
|
|
14348
|
-
-
|
|
14349
|
-
-
|
|
14351
|
+
- Existing \`${this.type}\` books still parse and compile.
|
|
14352
|
+
- New books should prefer \`GOAL\`.
|
|
14353
|
+
- Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
|
|
14354
|
+
- Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
|
|
14350
14355
|
|
|
14351
|
-
##
|
|
14356
|
+
## Preferred replacement
|
|
14357
|
+
|
|
14358
|
+
\`\`\`book
|
|
14359
|
+
Programming Assistant
|
|
14360
|
+
|
|
14361
|
+
GOAL Help the user solve programming problems with practical TypeScript and React guidance.
|
|
14362
|
+
\`\`\`
|
|
14363
|
+
|
|
14364
|
+
## Legacy compatibility example
|
|
14352
14365
|
|
|
14353
14366
|
\`\`\`book
|
|
14354
14367
|
Programming Assistant
|
|
@@ -15113,7 +15126,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15113
15126
|
\`\`\`book
|
|
15114
15127
|
Legal Assistant
|
|
15115
15128
|
|
|
15116
|
-
|
|
15129
|
+
GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
|
|
15117
15130
|
TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
|
|
15118
15131
|
\`\`\`
|
|
15119
15132
|
`);
|
|
@@ -21984,6 +21997,15 @@ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS',
|
|
|
21984
21997
|
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
21985
21998
|
*/
|
|
21986
21999
|
const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
|
|
22000
|
+
/**
|
|
22001
|
+
* Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
|
|
22002
|
+
*
|
|
22003
|
+
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
22004
|
+
*/
|
|
22005
|
+
const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
|
|
22006
|
+
['GOAL', 'GOAL'],
|
|
22007
|
+
['GOALS', 'GOAL'],
|
|
22008
|
+
]);
|
|
21987
22009
|
/**
|
|
21988
22010
|
* Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
|
|
21989
22011
|
*
|
|
@@ -22034,7 +22056,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
|
22034
22056
|
*/
|
|
22035
22057
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
22036
22058
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
22037
|
-
const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
|
|
22059
|
+
const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
|
|
22038
22060
|
let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
|
|
22039
22061
|
requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
|
|
22040
22062
|
requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
|
|
@@ -22045,6 +22067,35 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
22045
22067
|
requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
|
|
22046
22068
|
return finalizeRequirements(requirements);
|
|
22047
22069
|
}
|
|
22070
|
+
/**
|
|
22071
|
+
* Removes earlier commitments that are overwritten by later commitments of the same semantic group.
|
|
22072
|
+
*
|
|
22073
|
+
* This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
|
|
22074
|
+
* and multi-goal sources expose one effective goal to the runtime.
|
|
22075
|
+
*
|
|
22076
|
+
* @param commitments - Parsed commitments after DELETE-like filtering.
|
|
22077
|
+
* @returns Commitments with overwritten entries removed while preserving source order.
|
|
22078
|
+
*
|
|
22079
|
+
* @private internal utility of `createAgentModelRequirementsWithCommitments`
|
|
22080
|
+
*/
|
|
22081
|
+
function filterOverwrittenCommitments(commitments) {
|
|
22082
|
+
const seenOverwriteGroups = new Set();
|
|
22083
|
+
const keptCommitments = [];
|
|
22084
|
+
for (let index = commitments.length - 1; index >= 0; index--) {
|
|
22085
|
+
const commitment = commitments[index];
|
|
22086
|
+
const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
|
|
22087
|
+
if (!overwriteGroup) {
|
|
22088
|
+
keptCommitments.push(commitment);
|
|
22089
|
+
continue;
|
|
22090
|
+
}
|
|
22091
|
+
if (seenOverwriteGroups.has(overwriteGroup)) {
|
|
22092
|
+
continue;
|
|
22093
|
+
}
|
|
22094
|
+
seenOverwriteGroups.add(overwriteGroup);
|
|
22095
|
+
keptCommitments.push(commitment);
|
|
22096
|
+
}
|
|
22097
|
+
return keptCommitments.reverse();
|
|
22098
|
+
}
|
|
22048
22099
|
/**
|
|
22049
22100
|
* Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
|
|
22050
22101
|
*
|
|
@@ -22678,7 +22729,7 @@ function createDefaultAgentName(agentSource) {
|
|
|
22678
22729
|
function parseAgentSource(agentSource) {
|
|
22679
22730
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
22680
22731
|
const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
22681
|
-
const personaDescription =
|
|
22732
|
+
const personaDescription = extractAgentProfileText(parseResult.commitments);
|
|
22682
22733
|
const initialMessage = extractInitialMessage(parseResult.commitments);
|
|
22683
22734
|
const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
|
|
22684
22735
|
ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
|
|
@@ -22782,25 +22833,33 @@ const META_COMMITMENT_APPLIERS = {
|
|
|
22782
22833
|
*/
|
|
22783
22834
|
const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
|
|
22784
22835
|
/**
|
|
22785
|
-
*
|
|
22836
|
+
* Resolves the public agent profile text from the last GOAL/GOALS commitment,
|
|
22837
|
+
* falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
|
|
22786
22838
|
*
|
|
22787
22839
|
* @private internal utility of `parseAgentSource`
|
|
22788
22840
|
*/
|
|
22789
|
-
function
|
|
22790
|
-
let
|
|
22841
|
+
function extractAgentProfileText(commitments) {
|
|
22842
|
+
let goalDescription = '';
|
|
22843
|
+
let hasGoalDescription = false;
|
|
22844
|
+
let personaDescription = '';
|
|
22845
|
+
let hasPersonaDescription = false;
|
|
22791
22846
|
for (const commitment of commitments) {
|
|
22792
|
-
if (commitment.type
|
|
22793
|
-
|
|
22847
|
+
if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
|
|
22848
|
+
goalDescription = commitment.content;
|
|
22849
|
+
hasGoalDescription = true;
|
|
22794
22850
|
}
|
|
22795
|
-
if (
|
|
22796
|
-
personaDescription =
|
|
22851
|
+
if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
|
|
22852
|
+
personaDescription = commitment.content;
|
|
22853
|
+
hasPersonaDescription = true;
|
|
22797
22854
|
}
|
|
22798
|
-
else {
|
|
22799
|
-
personaDescription += `\n\n${personaDescription}`;
|
|
22800
|
-
}
|
|
22801
|
-
personaDescription += commitment.content;
|
|
22802
22855
|
}
|
|
22803
|
-
|
|
22856
|
+
if (hasGoalDescription) {
|
|
22857
|
+
return goalDescription;
|
|
22858
|
+
}
|
|
22859
|
+
if (hasPersonaDescription) {
|
|
22860
|
+
return personaDescription;
|
|
22861
|
+
}
|
|
22862
|
+
return null;
|
|
22804
22863
|
}
|
|
22805
22864
|
/**
|
|
22806
22865
|
* Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
|
|
@@ -23287,7 +23346,7 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
23287
23346
|
* Selects the best model using the preparePersona function
|
|
23288
23347
|
* This directly uses preparePersona to ensure DRY principle
|
|
23289
23348
|
*
|
|
23290
|
-
* @param agentSource The agent source to derive
|
|
23349
|
+
* @param agentSource The agent source to derive effective profile text from
|
|
23291
23350
|
* @param llmTools LLM tools for preparing persona
|
|
23292
23351
|
* @returns The name of the best selected model
|
|
23293
23352
|
*
|
|
@@ -23295,9 +23354,9 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
23295
23354
|
*/
|
|
23296
23355
|
async function selectBestModelUsingPersona(agentSource, llmTools) {
|
|
23297
23356
|
var _a;
|
|
23298
|
-
// Parse agent source to get
|
|
23357
|
+
// Parse agent source to get the effective profile description
|
|
23299
23358
|
const { agentName, personaDescription } = parseAgentSource(agentSource);
|
|
23300
|
-
// Use agent name as fallback if no
|
|
23359
|
+
// Use agent name as fallback if no profile description is available
|
|
23301
23360
|
const description = personaDescription || agentName || 'AI Agent';
|
|
23302
23361
|
try {
|
|
23303
23362
|
// Use preparePersona directly
|