@promptbook/node 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
@@ -35,7 +35,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
35
35
  * @generated
36
36
  * @see https://github.com/webgptorg/promptbook
37
37
  */
38
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-43';
38
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-44';
39
39
  /**
40
40
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
41
41
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -15342,7 +15342,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
15342
15342
  * Short one-line description of GOAL.
15343
15343
  */
15344
15344
  get description() {
15345
- return 'Define main **goals** the AI assistant should achieve, with later goals having higher priority.';
15345
+ return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
15346
15346
  }
15347
15347
  /**
15348
15348
  * Icon for this commitment.
@@ -15357,12 +15357,14 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
15357
15357
  return spaceTrim$1(`
15358
15358
  # ${this.type}
15359
15359
 
15360
- 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.
15360
+ Defines the main goal which should be achieved by the AI assistant.
15361
+ There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
15361
15362
 
15362
15363
  ## Key aspects
15363
15364
 
15364
15365
  - Both terms work identically and can be used interchangeably.
15365
- - Later goals have higher priority and can override earlier goals.
15366
+ - Later goals overwrite earlier goals.
15367
+ - The public agent profile text is derived from the last goal.
15366
15368
  - Goals provide clear direction and purpose for the agent's responses.
15367
15369
  - Goals influence decision-making and response prioritization.
15368
15370
 
@@ -15375,9 +15377,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
15375
15377
  \`\`\`book
15376
15378
  Customer Support Agent
15377
15379
 
15378
- PERSONA You are a helpful customer support representative
15379
15380
  GOAL Resolve customer issues quickly and efficiently
15380
- GOAL Maintain high customer satisfaction scores
15381
15381
  GOAL Always follow company policies and procedures
15382
15382
  RULE Be polite and professional at all times
15383
15383
  \`\`\`
@@ -15385,9 +15385,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
15385
15385
  \`\`\`book
15386
15386
  Educational Assistant
15387
15387
 
15388
- PERSONA You are an educational assistant specializing in mathematics
15389
15388
  GOAL Help students understand mathematical concepts clearly
15390
- GOAL Encourage critical thinking and problem-solving skills
15391
15389
  GOAL Ensure all explanations are age-appropriate and accessible
15392
15390
  STYLE Use simple language and provide step-by-step explanations
15393
15391
  \`\`\`
@@ -15395,9 +15393,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
15395
15393
  \`\`\`book
15396
15394
  Safety-First Assistant
15397
15395
 
15398
- PERSONA You are a general-purpose AI assistant
15399
15396
  GOAL Be helpful and informative in all interactions
15400
- GOAL Provide accurate and reliable information
15401
15397
  GOAL Always prioritize user safety and ethical guidelines
15402
15398
  RULE Never provide harmful or dangerous advice
15403
15399
  \`\`\`
@@ -18256,7 +18252,16 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
18256
18252
  * Short one-line description of PERSONA.
18257
18253
  */
18258
18254
  get description() {
18259
- return 'Define who the agent is: background, expertise, and personality.';
18255
+ return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
18256
+ }
18257
+ /**
18258
+ * Optional UI/docs-only deprecation metadata.
18259
+ */
18260
+ get deprecation() {
18261
+ return {
18262
+ message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
18263
+ replacedBy: ['GOAL'],
18264
+ };
18260
18265
  }
18261
18266
  /**
18262
18267
  * Icon for this commitment.
@@ -18271,16 +18276,24 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
18271
18276
  return spaceTrim$1(`
18272
18277
  # ${this.type}
18273
18278
 
18274
- Defines who the agent is, their background, expertise, and personality traits.
18279
+ Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
18275
18280
 
18276
- ## Key aspects
18281
+ ## Migration
18277
18282
 
18278
- - Multiple \`PERSONA\` and \`PERSONAE\` commitments are merged together.
18279
- - Both terms work identically and can be used interchangeably.
18280
- - If they are in conflict, the last one takes precedence.
18281
- - You can write persona content in multiple lines.
18283
+ - Existing \`${this.type}\` books still parse and compile.
18284
+ - New books should prefer \`GOAL\`.
18285
+ - Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
18286
+ - Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
18282
18287
 
18283
- ## Examples
18288
+ ## Preferred replacement
18289
+
18290
+ \`\`\`book
18291
+ Programming Assistant
18292
+
18293
+ GOAL Help the user solve programming problems with practical TypeScript and React guidance.
18294
+ \`\`\`
18295
+
18296
+ ## Legacy compatibility example
18284
18297
 
18285
18298
  \`\`\`book
18286
18299
  Programming Assistant
@@ -19045,7 +19058,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
19045
19058
  \`\`\`book
19046
19059
  Legal Assistant
19047
19060
 
19048
- PERSONA An expert software developer
19061
+ GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
19049
19062
  TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
19050
19063
  \`\`\`
19051
19064
  `);
@@ -28072,7 +28085,7 @@ function parseParameters(text) {
28072
28085
  function parseAgentSource(agentSource) {
28073
28086
  const parseResult = parseAgentSourceWithCommitments(agentSource);
28074
28087
  const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
28075
- const personaDescription = extractPersonaDescription(parseResult.commitments);
28088
+ const personaDescription = extractAgentProfileText(parseResult.commitments);
28076
28089
  const initialMessage = extractInitialMessage(parseResult.commitments);
28077
28090
  const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
28078
28091
  ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
@@ -28176,25 +28189,33 @@ const META_COMMITMENT_APPLIERS = {
28176
28189
  */
28177
28190
  const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
28178
28191
  /**
28179
- * Builds the combined persona description from PERSONA commitments.
28192
+ * Resolves the public agent profile text from the last GOAL/GOALS commitment,
28193
+ * falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
28180
28194
  *
28181
28195
  * @private internal utility of `parseAgentSource`
28182
28196
  */
28183
- function extractPersonaDescription(commitments) {
28184
- let personaDescription = null;
28197
+ function extractAgentProfileText(commitments) {
28198
+ let goalDescription = '';
28199
+ let hasGoalDescription = false;
28200
+ let personaDescription = '';
28201
+ let hasPersonaDescription = false;
28185
28202
  for (const commitment of commitments) {
28186
- if (commitment.type !== 'PERSONA') {
28187
- continue;
28203
+ if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
28204
+ goalDescription = commitment.content;
28205
+ hasGoalDescription = true;
28188
28206
  }
28189
- if (personaDescription === null) {
28190
- personaDescription = '';
28207
+ if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
28208
+ personaDescription = commitment.content;
28209
+ hasPersonaDescription = true;
28191
28210
  }
28192
- else {
28193
- personaDescription += `\n\n${personaDescription}`;
28194
- }
28195
- personaDescription += commitment.content;
28196
28211
  }
28197
- return personaDescription;
28212
+ if (hasGoalDescription) {
28213
+ return goalDescription;
28214
+ }
28215
+ if (hasPersonaDescription) {
28216
+ return personaDescription;
28217
+ }
28218
+ return null;
28198
28219
  }
28199
28220
  /**
28200
28221
  * Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
@@ -28876,6 +28897,15 @@ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS',
28876
28897
  * @private internal constant of `createAgentModelRequirementsWithCommitments`
28877
28898
  */
28878
28899
  const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
28900
+ /**
28901
+ * Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
28902
+ *
28903
+ * @private internal constant of `createAgentModelRequirementsWithCommitments`
28904
+ */
28905
+ const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
28906
+ ['GOAL', 'GOAL'],
28907
+ ['GOALS', 'GOAL'],
28908
+ ]);
28879
28909
  /**
28880
28910
  * Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
28881
28911
  *
@@ -28926,7 +28956,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
28926
28956
  */
28927
28957
  async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
28928
28958
  const parseResult = parseAgentSourceWithCommitments(agentSource);
28929
- const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
28959
+ const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
28930
28960
  let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
28931
28961
  requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
28932
28962
  requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
@@ -28937,6 +28967,35 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
28937
28967
  requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
28938
28968
  return finalizeRequirements(requirements);
28939
28969
  }
28970
+ /**
28971
+ * Removes earlier commitments that are overwritten by later commitments of the same semantic group.
28972
+ *
28973
+ * This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
28974
+ * and multi-goal sources expose one effective goal to the runtime.
28975
+ *
28976
+ * @param commitments - Parsed commitments after DELETE-like filtering.
28977
+ * @returns Commitments with overwritten entries removed while preserving source order.
28978
+ *
28979
+ * @private internal utility of `createAgentModelRequirementsWithCommitments`
28980
+ */
28981
+ function filterOverwrittenCommitments(commitments) {
28982
+ const seenOverwriteGroups = new Set();
28983
+ const keptCommitments = [];
28984
+ for (let index = commitments.length - 1; index >= 0; index--) {
28985
+ const commitment = commitments[index];
28986
+ const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
28987
+ if (!overwriteGroup) {
28988
+ keptCommitments.push(commitment);
28989
+ continue;
28990
+ }
28991
+ if (seenOverwriteGroups.has(overwriteGroup)) {
28992
+ continue;
28993
+ }
28994
+ seenOverwriteGroups.add(overwriteGroup);
28995
+ keptCommitments.push(commitment);
28996
+ }
28997
+ return keptCommitments.reverse();
28998
+ }
28940
28999
  /**
28941
29000
  * Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
28942
29001
  *
@@ -29528,7 +29587,7 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
29528
29587
  * Selects the best model using the preparePersona function
29529
29588
  * This directly uses preparePersona to ensure DRY principle
29530
29589
  *
29531
- * @param agentSource The agent source to derive persona description from
29590
+ * @param agentSource The agent source to derive effective profile text from
29532
29591
  * @param llmTools LLM tools for preparing persona
29533
29592
  * @returns The name of the best selected model
29534
29593
  *
@@ -29536,9 +29595,9 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
29536
29595
  */
29537
29596
  async function selectBestModelUsingPersona(agentSource, llmTools) {
29538
29597
  var _a;
29539
- // Parse agent source to get persona description
29598
+ // Parse agent source to get the effective profile description
29540
29599
  const { agentName, personaDescription } = parseAgentSource(agentSource);
29541
- // Use agent name as fallback if no persona description is available
29600
+ // Use agent name as fallback if no profile description is available
29542
29601
  const description = personaDescription || agentName || 'AI Agent';
29543
29602
  try {
29544
29603
  // Use preparePersona directly