@promptbook/browser 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
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
29
29
  * @generated
30
30
  * @see https://github.com/webgptorg/promptbook
31
31
  */
32
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-43';
32
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-44';
33
33
  /**
34
34
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
35
35
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -6481,7 +6481,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
6481
6481
  * Short one-line description of GOAL.
6482
6482
  */
6483
6483
  get description() {
6484
- return 'Define main **goals** the AI assistant should achieve, with later goals having higher priority.';
6484
+ return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
6485
6485
  }
6486
6486
  /**
6487
6487
  * Icon for this commitment.
@@ -6496,12 +6496,14 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
6496
6496
  return spaceTrim$1(`
6497
6497
  # ${this.type}
6498
6498
 
6499
- 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.
6499
+ Defines the main goal which should be achieved by the AI assistant.
6500
+ There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
6500
6501
 
6501
6502
  ## Key aspects
6502
6503
 
6503
6504
  - Both terms work identically and can be used interchangeably.
6504
- - Later goals have higher priority and can override earlier goals.
6505
+ - Later goals overwrite earlier goals.
6506
+ - The public agent profile text is derived from the last goal.
6505
6507
  - Goals provide clear direction and purpose for the agent's responses.
6506
6508
  - Goals influence decision-making and response prioritization.
6507
6509
 
@@ -6514,9 +6516,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
6514
6516
  \`\`\`book
6515
6517
  Customer Support Agent
6516
6518
 
6517
- PERSONA You are a helpful customer support representative
6518
6519
  GOAL Resolve customer issues quickly and efficiently
6519
- GOAL Maintain high customer satisfaction scores
6520
6520
  GOAL Always follow company policies and procedures
6521
6521
  RULE Be polite and professional at all times
6522
6522
  \`\`\`
@@ -6524,9 +6524,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
6524
6524
  \`\`\`book
6525
6525
  Educational Assistant
6526
6526
 
6527
- PERSONA You are an educational assistant specializing in mathematics
6528
6527
  GOAL Help students understand mathematical concepts clearly
6529
- GOAL Encourage critical thinking and problem-solving skills
6530
6528
  GOAL Ensure all explanations are age-appropriate and accessible
6531
6529
  STYLE Use simple language and provide step-by-step explanations
6532
6530
  \`\`\`
@@ -6534,9 +6532,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
6534
6532
  \`\`\`book
6535
6533
  Safety-First Assistant
6536
6534
 
6537
- PERSONA You are a general-purpose AI assistant
6538
6535
  GOAL Be helpful and informative in all interactions
6539
- GOAL Provide accurate and reliable information
6540
6536
  GOAL Always prioritize user safety and ethical guidelines
6541
6537
  RULE Never provide harmful or dangerous advice
6542
6538
  \`\`\`
@@ -9395,7 +9391,16 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
9395
9391
  * Short one-line description of PERSONA.
9396
9392
  */
9397
9393
  get description() {
9398
- return 'Define who the agent is: background, expertise, and personality.';
9394
+ return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
9395
+ }
9396
+ /**
9397
+ * Optional UI/docs-only deprecation metadata.
9398
+ */
9399
+ get deprecation() {
9400
+ return {
9401
+ message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
9402
+ replacedBy: ['GOAL'],
9403
+ };
9399
9404
  }
9400
9405
  /**
9401
9406
  * Icon for this commitment.
@@ -9410,16 +9415,24 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
9410
9415
  return spaceTrim$1(`
9411
9416
  # ${this.type}
9412
9417
 
9413
- Defines who the agent is, their background, expertise, and personality traits.
9418
+ Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
9414
9419
 
9415
- ## Key aspects
9420
+ ## Migration
9416
9421
 
9417
- - Multiple \`PERSONA\` and \`PERSONAE\` commitments are merged together.
9418
- - Both terms work identically and can be used interchangeably.
9419
- - If they are in conflict, the last one takes precedence.
9420
- - You can write persona content in multiple lines.
9422
+ - Existing \`${this.type}\` books still parse and compile.
9423
+ - New books should prefer \`GOAL\`.
9424
+ - Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
9425
+ - Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
9421
9426
 
9422
- ## Examples
9427
+ ## Preferred replacement
9428
+
9429
+ \`\`\`book
9430
+ Programming Assistant
9431
+
9432
+ GOAL Help the user solve programming problems with practical TypeScript and React guidance.
9433
+ \`\`\`
9434
+
9435
+ ## Legacy compatibility example
9423
9436
 
9424
9437
  \`\`\`book
9425
9438
  Programming Assistant
@@ -10184,7 +10197,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
10184
10197
  \`\`\`book
10185
10198
  Legal Assistant
10186
10199
 
10187
- PERSONA An expert software developer
10200
+ GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
10188
10201
  TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
10189
10202
  \`\`\`
10190
10203
  `);
@@ -17530,7 +17543,7 @@ function parseParameters(text) {
17530
17543
  function parseAgentSource(agentSource) {
17531
17544
  const parseResult = parseAgentSourceWithCommitments(agentSource);
17532
17545
  const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
17533
- const personaDescription = extractPersonaDescription(parseResult.commitments);
17546
+ const personaDescription = extractAgentProfileText(parseResult.commitments);
17534
17547
  const initialMessage = extractInitialMessage(parseResult.commitments);
17535
17548
  const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
17536
17549
  ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
@@ -17634,25 +17647,33 @@ const META_COMMITMENT_APPLIERS = {
17634
17647
  */
17635
17648
  const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
17636
17649
  /**
17637
- * Builds the combined persona description from PERSONA commitments.
17650
+ * Resolves the public agent profile text from the last GOAL/GOALS commitment,
17651
+ * falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
17638
17652
  *
17639
17653
  * @private internal utility of `parseAgentSource`
17640
17654
  */
17641
- function extractPersonaDescription(commitments) {
17642
- let personaDescription = null;
17655
+ function extractAgentProfileText(commitments) {
17656
+ let goalDescription = '';
17657
+ let hasGoalDescription = false;
17658
+ let personaDescription = '';
17659
+ let hasPersonaDescription = false;
17643
17660
  for (const commitment of commitments) {
17644
- if (commitment.type !== 'PERSONA') {
17645
- continue;
17661
+ if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
17662
+ goalDescription = commitment.content;
17663
+ hasGoalDescription = true;
17646
17664
  }
17647
- if (personaDescription === null) {
17648
- personaDescription = '';
17665
+ if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
17666
+ personaDescription = commitment.content;
17667
+ hasPersonaDescription = true;
17649
17668
  }
17650
- else {
17651
- personaDescription += `\n\n${personaDescription}`;
17652
- }
17653
- personaDescription += commitment.content;
17654
17669
  }
17655
- return personaDescription;
17670
+ if (hasGoalDescription) {
17671
+ return goalDescription;
17672
+ }
17673
+ if (hasPersonaDescription) {
17674
+ return personaDescription;
17675
+ }
17676
+ return null;
17656
17677
  }
17657
17678
  /**
17658
17679
  * Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
@@ -23097,6 +23118,15 @@ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS',
23097
23118
  * @private internal constant of `createAgentModelRequirementsWithCommitments`
23098
23119
  */
23099
23120
  const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
23121
+ /**
23122
+ * Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
23123
+ *
23124
+ * @private internal constant of `createAgentModelRequirementsWithCommitments`
23125
+ */
23126
+ const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
23127
+ ['GOAL', 'GOAL'],
23128
+ ['GOALS', 'GOAL'],
23129
+ ]);
23100
23130
  /**
23101
23131
  * Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
23102
23132
  *
@@ -23147,7 +23177,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
23147
23177
  */
23148
23178
  async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
23149
23179
  const parseResult = parseAgentSourceWithCommitments(agentSource);
23150
- const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
23180
+ const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
23151
23181
  let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
23152
23182
  requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
23153
23183
  requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
@@ -23158,6 +23188,35 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
23158
23188
  requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
23159
23189
  return finalizeRequirements(requirements);
23160
23190
  }
23191
+ /**
23192
+ * Removes earlier commitments that are overwritten by later commitments of the same semantic group.
23193
+ *
23194
+ * This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
23195
+ * and multi-goal sources expose one effective goal to the runtime.
23196
+ *
23197
+ * @param commitments - Parsed commitments after DELETE-like filtering.
23198
+ * @returns Commitments with overwritten entries removed while preserving source order.
23199
+ *
23200
+ * @private internal utility of `createAgentModelRequirementsWithCommitments`
23201
+ */
23202
+ function filterOverwrittenCommitments(commitments) {
23203
+ const seenOverwriteGroups = new Set();
23204
+ const keptCommitments = [];
23205
+ for (let index = commitments.length - 1; index >= 0; index--) {
23206
+ const commitment = commitments[index];
23207
+ const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
23208
+ if (!overwriteGroup) {
23209
+ keptCommitments.push(commitment);
23210
+ continue;
23211
+ }
23212
+ if (seenOverwriteGroups.has(overwriteGroup)) {
23213
+ continue;
23214
+ }
23215
+ seenOverwriteGroups.add(overwriteGroup);
23216
+ keptCommitments.push(commitment);
23217
+ }
23218
+ return keptCommitments.reverse();
23219
+ }
23161
23220
  /**
23162
23221
  * Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
23163
23222
  *
@@ -23749,7 +23808,7 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
23749
23808
  * Selects the best model using the preparePersona function
23750
23809
  * This directly uses preparePersona to ensure DRY principle
23751
23810
  *
23752
- * @param agentSource The agent source to derive persona description from
23811
+ * @param agentSource The agent source to derive effective profile text from
23753
23812
  * @param llmTools LLM tools for preparing persona
23754
23813
  * @returns The name of the best selected model
23755
23814
  *
@@ -23757,9 +23816,9 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
23757
23816
  */
23758
23817
  async function selectBestModelUsingPersona(agentSource, llmTools) {
23759
23818
  var _a;
23760
- // Parse agent source to get persona description
23819
+ // Parse agent source to get the effective profile description
23761
23820
  const { agentName, personaDescription } = parseAgentSource(agentSource);
23762
- // Use agent name as fallback if no persona description is available
23821
+ // Use agent name as fallback if no profile description is available
23763
23822
  const description = personaDescription || agentName || 'AI Agent';
23764
23823
  try {
23765
23824
  // Use preparePersona directly