@promptbook/components 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 CHANGED
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
40
40
  * @generated
41
41
  * @see https://github.com/webgptorg/promptbook
42
42
  */
43
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-43';
43
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-44';
44
44
  /**
45
45
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
46
46
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -7254,7 +7254,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
7254
7254
  * Short one-line description of GOAL.
7255
7255
  */
7256
7256
  get description() {
7257
- return 'Define main **goals** the AI assistant should achieve, with later goals having higher priority.';
7257
+ return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
7258
7258
  }
7259
7259
  /**
7260
7260
  * Icon for this commitment.
@@ -7269,12 +7269,14 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
7269
7269
  return spaceTrim$1(`
7270
7270
  # ${this.type}
7271
7271
 
7272
- 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.
7272
+ Defines the main goal which should be achieved by the AI assistant.
7273
+ There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
7273
7274
 
7274
7275
  ## Key aspects
7275
7276
 
7276
7277
  - Both terms work identically and can be used interchangeably.
7277
- - Later goals have higher priority and can override earlier goals.
7278
+ - Later goals overwrite earlier goals.
7279
+ - The public agent profile text is derived from the last goal.
7278
7280
  - Goals provide clear direction and purpose for the agent's responses.
7279
7281
  - Goals influence decision-making and response prioritization.
7280
7282
 
@@ -7287,9 +7289,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
7287
7289
  \`\`\`book
7288
7290
  Customer Support Agent
7289
7291
 
7290
- PERSONA You are a helpful customer support representative
7291
7292
  GOAL Resolve customer issues quickly and efficiently
7292
- GOAL Maintain high customer satisfaction scores
7293
7293
  GOAL Always follow company policies and procedures
7294
7294
  RULE Be polite and professional at all times
7295
7295
  \`\`\`
@@ -7297,9 +7297,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
7297
7297
  \`\`\`book
7298
7298
  Educational Assistant
7299
7299
 
7300
- PERSONA You are an educational assistant specializing in mathematics
7301
7300
  GOAL Help students understand mathematical concepts clearly
7302
- GOAL Encourage critical thinking and problem-solving skills
7303
7301
  GOAL Ensure all explanations are age-appropriate and accessible
7304
7302
  STYLE Use simple language and provide step-by-step explanations
7305
7303
  \`\`\`
@@ -7307,9 +7305,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
7307
7305
  \`\`\`book
7308
7306
  Safety-First Assistant
7309
7307
 
7310
- PERSONA You are a general-purpose AI assistant
7311
7308
  GOAL Be helpful and informative in all interactions
7312
- GOAL Provide accurate and reliable information
7313
7309
  GOAL Always prioritize user safety and ethical guidelines
7314
7310
  RULE Never provide harmful or dangerous advice
7315
7311
  \`\`\`
@@ -10068,7 +10064,16 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
10068
10064
  * Short one-line description of PERSONA.
10069
10065
  */
10070
10066
  get description() {
10071
- return 'Define who the agent is: background, expertise, and personality.';
10067
+ return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
10068
+ }
10069
+ /**
10070
+ * Optional UI/docs-only deprecation metadata.
10071
+ */
10072
+ get deprecation() {
10073
+ return {
10074
+ message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
10075
+ replacedBy: ['GOAL'],
10076
+ };
10072
10077
  }
10073
10078
  /**
10074
10079
  * Icon for this commitment.
@@ -10083,16 +10088,24 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
10083
10088
  return spaceTrim$1(`
10084
10089
  # ${this.type}
10085
10090
 
10086
- Defines who the agent is, their background, expertise, and personality traits.
10091
+ Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
10087
10092
 
10088
- ## Key aspects
10093
+ ## Migration
10089
10094
 
10090
- - Multiple \`PERSONA\` and \`PERSONAE\` commitments are merged together.
10091
- - Both terms work identically and can be used interchangeably.
10092
- - If they are in conflict, the last one takes precedence.
10093
- - You can write persona content in multiple lines.
10095
+ - Existing \`${this.type}\` books still parse and compile.
10096
+ - New books should prefer \`GOAL\`.
10097
+ - Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
10098
+ - Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
10094
10099
 
10095
- ## Examples
10100
+ ## Preferred replacement
10101
+
10102
+ \`\`\`book
10103
+ Programming Assistant
10104
+
10105
+ GOAL Help the user solve programming problems with practical TypeScript and React guidance.
10106
+ \`\`\`
10107
+
10108
+ ## Legacy compatibility example
10096
10109
 
10097
10110
  \`\`\`book
10098
10111
  Programming Assistant
@@ -10857,7 +10870,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
10857
10870
  \`\`\`book
10858
10871
  Legal Assistant
10859
10872
 
10860
- PERSONA An expert software developer
10873
+ GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
10861
10874
  TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
10862
10875
  \`\`\`
10863
10876
  `);
@@ -17446,7 +17459,7 @@ function parseParameters(text) {
17446
17459
  function parseAgentSource(agentSource) {
17447
17460
  const parseResult = parseAgentSourceWithCommitments(agentSource);
17448
17461
  const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
17449
- const personaDescription = extractPersonaDescription(parseResult.commitments);
17462
+ const personaDescription = extractAgentProfileText(parseResult.commitments);
17450
17463
  const initialMessage = extractInitialMessage(parseResult.commitments);
17451
17464
  const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
17452
17465
  ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
@@ -17550,25 +17563,33 @@ const META_COMMITMENT_APPLIERS = {
17550
17563
  */
17551
17564
  const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
17552
17565
  /**
17553
- * Builds the combined persona description from PERSONA commitments.
17566
+ * Resolves the public agent profile text from the last GOAL/GOALS commitment,
17567
+ * falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
17554
17568
  *
17555
17569
  * @private internal utility of `parseAgentSource`
17556
17570
  */
17557
- function extractPersonaDescription(commitments) {
17558
- let personaDescription = null;
17571
+ function extractAgentProfileText(commitments) {
17572
+ let goalDescription = '';
17573
+ let hasGoalDescription = false;
17574
+ let personaDescription = '';
17575
+ let hasPersonaDescription = false;
17559
17576
  for (const commitment of commitments) {
17560
- if (commitment.type !== 'PERSONA') {
17561
- continue;
17577
+ if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
17578
+ goalDescription = commitment.content;
17579
+ hasGoalDescription = true;
17562
17580
  }
17563
- if (personaDescription === null) {
17564
- personaDescription = '';
17581
+ if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
17582
+ personaDescription = commitment.content;
17583
+ hasPersonaDescription = true;
17565
17584
  }
17566
- else {
17567
- personaDescription += `\n\n${personaDescription}`;
17568
- }
17569
- personaDescription += commitment.content;
17570
17585
  }
17571
- return personaDescription;
17586
+ if (hasGoalDescription) {
17587
+ return goalDescription;
17588
+ }
17589
+ if (hasPersonaDescription) {
17590
+ return personaDescription;
17591
+ }
17592
+ return null;
17572
17593
  }
17573
17594
  /**
17574
17595
  * Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
@@ -31121,6 +31142,15 @@ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS',
31121
31142
  * @private internal constant of `createAgentModelRequirementsWithCommitments`
31122
31143
  */
31123
31144
  const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
31145
+ /**
31146
+ * Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
31147
+ *
31148
+ * @private internal constant of `createAgentModelRequirementsWithCommitments`
31149
+ */
31150
+ const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
31151
+ ['GOAL', 'GOAL'],
31152
+ ['GOALS', 'GOAL'],
31153
+ ]);
31124
31154
  /**
31125
31155
  * Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
31126
31156
  *
@@ -31171,7 +31201,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
31171
31201
  */
31172
31202
  async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
31173
31203
  const parseResult = parseAgentSourceWithCommitments(agentSource);
31174
- const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
31204
+ const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
31175
31205
  let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
31176
31206
  requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
31177
31207
  requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
@@ -31182,6 +31212,35 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
31182
31212
  requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
31183
31213
  return finalizeRequirements(requirements);
31184
31214
  }
31215
+ /**
31216
+ * Removes earlier commitments that are overwritten by later commitments of the same semantic group.
31217
+ *
31218
+ * This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
31219
+ * and multi-goal sources expose one effective goal to the runtime.
31220
+ *
31221
+ * @param commitments - Parsed commitments after DELETE-like filtering.
31222
+ * @returns Commitments with overwritten entries removed while preserving source order.
31223
+ *
31224
+ * @private internal utility of `createAgentModelRequirementsWithCommitments`
31225
+ */
31226
+ function filterOverwrittenCommitments(commitments) {
31227
+ const seenOverwriteGroups = new Set();
31228
+ const keptCommitments = [];
31229
+ for (let index = commitments.length - 1; index >= 0; index--) {
31230
+ const commitment = commitments[index];
31231
+ const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
31232
+ if (!overwriteGroup) {
31233
+ keptCommitments.push(commitment);
31234
+ continue;
31235
+ }
31236
+ if (seenOverwriteGroups.has(overwriteGroup)) {
31237
+ continue;
31238
+ }
31239
+ seenOverwriteGroups.add(overwriteGroup);
31240
+ keptCommitments.push(commitment);
31241
+ }
31242
+ return keptCommitments.reverse();
31243
+ }
31185
31244
  /**
31186
31245
  * Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
31187
31246
  *
@@ -31773,7 +31832,7 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
31773
31832
  * Selects the best model using the preparePersona function
31774
31833
  * This directly uses preparePersona to ensure DRY principle
31775
31834
  *
31776
- * @param agentSource The agent source to derive persona description from
31835
+ * @param agentSource The agent source to derive effective profile text from
31777
31836
  * @param llmTools LLM tools for preparing persona
31778
31837
  * @returns The name of the best selected model
31779
31838
  *
@@ -31781,9 +31840,9 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
31781
31840
  */
31782
31841
  async function selectBestModelUsingPersona(agentSource, llmTools) {
31783
31842
  var _a;
31784
- // Parse agent source to get persona description
31843
+ // Parse agent source to get the effective profile description
31785
31844
  const { agentName, personaDescription } = parseAgentSource(agentSource);
31786
- // Use agent name as fallback if no persona description is available
31845
+ // Use agent name as fallback if no profile description is available
31787
31846
  const description = personaDescription || agentName || 'AI Agent';
31788
31847
  try {
31789
31848
  // Use preparePersona directly