@promptbook/node 0.112.0-43 → 0.112.0-45

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.
Files changed (35) hide show
  1. package/esm/index.es.js +144 -57
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/src/avatars/Avatar.d.ts +7 -0
  4. package/esm/src/avatars/avatarRenderingUtils.d.ts +117 -0
  5. package/esm/src/avatars/index.d.ts +6 -0
  6. package/esm/src/avatars/renderAvatarVisual.d.ts +9 -0
  7. package/esm/src/avatars/types/AvatarDefinition.d.ts +20 -0
  8. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +96 -0
  9. package/esm/src/avatars/visuals/avatarVisualRegistry.d.ts +16 -0
  10. package/esm/src/avatars/visuals/minecraftAvatarVisual.d.ts +7 -0
  11. package/esm/src/avatars/visuals/octopusAvatarVisual.d.ts +7 -0
  12. package/esm/src/avatars/visuals/pixelArtAvatarVisual.d.ts +7 -0
  13. package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
  14. package/esm/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +2 -1
  15. package/esm/src/commitments/PERSONA/PERSONA.d.ts +7 -0
  16. package/esm/src/commitments/STYLE/STYLE.d.ts +9 -2
  17. package/esm/src/version.d.ts +1 -1
  18. package/package.json +2 -2
  19. package/umd/index.umd.js +144 -57
  20. package/umd/index.umd.js.map +1 -1
  21. package/umd/src/avatars/Avatar.d.ts +7 -0
  22. package/umd/src/avatars/avatarRenderingUtils.d.ts +117 -0
  23. package/umd/src/avatars/index.d.ts +6 -0
  24. package/umd/src/avatars/renderAvatarVisual.d.ts +9 -0
  25. package/umd/src/avatars/types/AvatarDefinition.d.ts +20 -0
  26. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +96 -0
  27. package/umd/src/avatars/visuals/avatarVisualRegistry.d.ts +16 -0
  28. package/umd/src/avatars/visuals/minecraftAvatarVisual.d.ts +7 -0
  29. package/umd/src/avatars/visuals/octopusAvatarVisual.d.ts +7 -0
  30. package/umd/src/avatars/visuals/pixelArtAvatarVisual.d.ts +7 -0
  31. package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
  32. package/umd/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +2 -1
  33. package/umd/src/commitments/PERSONA/PERSONA.d.ts +7 -0
  34. package/umd/src/commitments/STYLE/STYLE.d.ts +9 -2
  35. package/umd/src/version.d.ts +1 -1
package/umd/index.umd.js CHANGED
@@ -48,7 +48,7 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-43';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-45';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -14790,7 +14790,7 @@
14790
14790
  DELETE Casual conversational style
14791
14791
  REMOVE All emoji usage
14792
14792
  GOAL Provide professional business communications
14793
- STYLE Use formal language and proper business etiquette
14793
+ WRITING RULES Use formal language and proper business etiquette
14794
14794
  \`\`\`
14795
14795
 
14796
14796
  \`\`\`book
@@ -14801,7 +14801,7 @@
14801
14801
  DISCARD Technical jargon explanations
14802
14802
  CANCEL Advanced troubleshooting procedures
14803
14803
  GOAL Help users with simple, easy-to-follow solutions
14804
- STYLE Use plain language that anyone can understand
14804
+ WRITING RULES Use plain language that anyone can understand
14805
14805
  \`\`\`
14806
14806
 
14807
14807
  \`\`\`book
@@ -14818,11 +14818,11 @@
14818
14818
  Concise Information Provider
14819
14819
 
14820
14820
  PERSONA You are a helpful assistant who provides detailed explanations
14821
- STYLE Include examples, analogies, and comprehensive context
14821
+ WRITING RULES Include examples, analogies, and comprehensive context
14822
14822
  CANCEL Detailed explanation style
14823
14823
  DISCARD Examples and analogies
14824
14824
  GOAL Provide brief, direct answers without unnecessary elaboration
14825
- STYLE Be concise and to the point
14825
+ WRITING RULES Be concise and to the point
14826
14826
  \`\`\`
14827
14827
  `);
14828
14828
  }
@@ -15006,7 +15006,7 @@
15006
15006
  PERSONA You are a data analysis expert
15007
15007
  FORMAT Present results in structured tables
15008
15008
  FORMAT Include confidence scores for all predictions
15009
- STYLE Be concise and precise in explanations
15009
+ WRITING RULES Be concise and precise in explanations
15010
15010
  \`\`\`
15011
15011
  `);
15012
15012
  }
@@ -15355,7 +15355,7 @@
15355
15355
  * Short one-line description of GOAL.
15356
15356
  */
15357
15357
  get description() {
15358
- return 'Define main **goals** the AI assistant should achieve, with later goals having higher priority.';
15358
+ return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
15359
15359
  }
15360
15360
  /**
15361
15361
  * Icon for this commitment.
@@ -15370,12 +15370,14 @@
15370
15370
  return _spaceTrim.spaceTrim(`
15371
15371
  # ${this.type}
15372
15372
 
15373
- 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.
15373
+ Defines the main goal which should be achieved by the AI assistant.
15374
+ There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
15374
15375
 
15375
15376
  ## Key aspects
15376
15377
 
15377
15378
  - Both terms work identically and can be used interchangeably.
15378
- - Later goals have higher priority and can override earlier goals.
15379
+ - Later goals overwrite earlier goals.
15380
+ - The public agent profile text is derived from the last goal.
15379
15381
  - Goals provide clear direction and purpose for the agent's responses.
15380
15382
  - Goals influence decision-making and response prioritization.
15381
15383
 
@@ -15388,9 +15390,7 @@
15388
15390
  \`\`\`book
15389
15391
  Customer Support Agent
15390
15392
 
15391
- PERSONA You are a helpful customer support representative
15392
15393
  GOAL Resolve customer issues quickly and efficiently
15393
- GOAL Maintain high customer satisfaction scores
15394
15394
  GOAL Always follow company policies and procedures
15395
15395
  RULE Be polite and professional at all times
15396
15396
  \`\`\`
@@ -15398,19 +15398,15 @@
15398
15398
  \`\`\`book
15399
15399
  Educational Assistant
15400
15400
 
15401
- PERSONA You are an educational assistant specializing in mathematics
15402
15401
  GOAL Help students understand mathematical concepts clearly
15403
- GOAL Encourage critical thinking and problem-solving skills
15404
15402
  GOAL Ensure all explanations are age-appropriate and accessible
15405
- STYLE Use simple language and provide step-by-step explanations
15403
+ WRITING RULES Use simple language and provide step-by-step explanations
15406
15404
  \`\`\`
15407
15405
 
15408
15406
  \`\`\`book
15409
15407
  Safety-First Assistant
15410
15408
 
15411
- PERSONA You are a general-purpose AI assistant
15412
15409
  GOAL Be helpful and informative in all interactions
15413
- GOAL Provide accurate and reliable information
15414
15410
  GOAL Always prioritize user safety and ethical guidelines
15415
15411
  RULE Never provide harmful or dangerous advice
15416
15412
  \`\`\`
@@ -15818,7 +15814,7 @@
15818
15814
  KNOWLEDGE Academic research requires careful citation and verification
15819
15815
  KNOWLEDGE https://example.com/research-guidelines.pdf
15820
15816
  ACTION Can help with literature reviews and data analysis
15821
- STYLE Present information in clear, academic format
15817
+ WRITING RULES Present information in clear, academic format
15822
15818
  \`\`\`
15823
15819
  `);
15824
15820
  }
@@ -17569,7 +17565,7 @@
17569
17565
 
17570
17566
  META IMAGE https://example.com/professional-avatar.jpg
17571
17567
  PERSONA You are a professional business assistant
17572
- STYLE Maintain a formal and courteous tone
17568
+ WRITING RULES Maintain a formal and courteous tone
17573
17569
  \`\`\`
17574
17570
 
17575
17571
  \`\`\`book
@@ -17577,7 +17573,7 @@
17577
17573
 
17578
17574
  META IMAGE /assets/creative-bot-avatar.png
17579
17575
  PERSONA You are a creative and inspiring assistant
17580
- STYLE Be enthusiastic and encouraging
17576
+ WRITING RULES Be enthusiastic and encouraging
17581
17577
  ACTION Can help with brainstorming and ideation
17582
17578
  \`\`\`
17583
17579
  `);
@@ -17736,7 +17732,7 @@
17736
17732
  META LINK https://twitter.com/devhandle
17737
17733
  PERSONA You are an experienced open source developer
17738
17734
  ACTION Can help with code reviews and architecture decisions
17739
- STYLE Be direct and technical in explanations
17735
+ WRITING RULES Be direct and technical in explanations
17740
17736
  \`\`\`
17741
17737
  `);
17742
17738
  }
@@ -17942,7 +17938,7 @@
17942
17938
  MODEL TEMPERATURE 0.8
17943
17939
  MODEL TOP_P 0.9
17944
17940
  MODEL MAX_TOKENS 2048
17945
- STYLE Be imaginative and expressive
17941
+ WRITING RULES Be imaginative and expressive
17946
17942
  ACTION Can help with storytelling and character development
17947
17943
  \`\`\`
17948
17944
 
@@ -18154,7 +18150,7 @@
18154
18150
  NOTE Uses RAG for accessing latest research papers
18155
18151
  PERSONA You are a knowledgeable research assistant
18156
18152
  ACTION Can help with literature reviews and citations
18157
- STYLE Present information in academic format
18153
+ WRITING RULES Present information in academic format
18158
18154
  \`\`\`
18159
18155
  `);
18160
18156
  }
@@ -18269,7 +18265,16 @@
18269
18265
  * Short one-line description of PERSONA.
18270
18266
  */
18271
18267
  get description() {
18272
- return 'Define who the agent is: background, expertise, and personality.';
18268
+ return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
18269
+ }
18270
+ /**
18271
+ * Optional UI/docs-only deprecation metadata.
18272
+ */
18273
+ get deprecation() {
18274
+ return {
18275
+ message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
18276
+ replacedBy: ['GOAL'],
18277
+ };
18273
18278
  }
18274
18279
  /**
18275
18280
  * Icon for this commitment.
@@ -18284,16 +18289,24 @@
18284
18289
  return _spaceTrim.spaceTrim(`
18285
18290
  # ${this.type}
18286
18291
 
18287
- Defines who the agent is, their background, expertise, and personality traits.
18292
+ Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
18288
18293
 
18289
- ## Key aspects
18294
+ ## Migration
18290
18295
 
18291
- - Multiple \`PERSONA\` and \`PERSONAE\` commitments are merged together.
18292
- - Both terms work identically and can be used interchangeably.
18293
- - If they are in conflict, the last one takes precedence.
18294
- - You can write persona content in multiple lines.
18296
+ - Existing \`${this.type}\` books still parse and compile.
18297
+ - New books should prefer \`GOAL\`.
18298
+ - Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
18299
+ - Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
18295
18300
 
18296
- ## Examples
18301
+ ## Preferred replacement
18302
+
18303
+ \`\`\`book
18304
+ Programming Assistant
18305
+
18306
+ GOAL Help the user solve programming problems with practical TypeScript and React guidance.
18307
+ \`\`\`
18308
+
18309
+ ## Legacy compatibility example
18297
18310
 
18298
18311
  \`\`\`book
18299
18312
  Programming Assistant
@@ -18431,7 +18444,7 @@
18431
18444
  RULE Always ask for clarification if the user's request is ambiguous
18432
18445
  RULE Be polite and professional in all interactions
18433
18446
  RULES Never provide medical or legal advice
18434
- STYLE Maintain a friendly and helpful tone
18447
+ WRITING RULES Maintain a friendly and helpful tone
18435
18448
  \`\`\`
18436
18449
 
18437
18450
  \`\`\`book
@@ -18700,8 +18713,8 @@
18700
18713
  /**
18701
18714
  * STYLE commitment definition
18702
18715
  *
18703
- * The STYLE commitment defines how the agent should format and present its responses.
18704
- * This includes tone, writing style, formatting preferences, and communication patterns.
18716
+ * Deprecated legacy writing-style commitment kept for backward compatibility.
18717
+ * New books should prefer `WRITING RULES` for writing-only constraints.
18705
18718
  *
18706
18719
  * Example usage in agent source:
18707
18720
  *
@@ -18720,7 +18733,16 @@
18720
18733
  * Short one-line description of STYLE.
18721
18734
  */
18722
18735
  get description() {
18723
- return 'Control the tone and writing style of responses.';
18736
+ return 'Deprecated legacy writing-style commitment. Prefer `WRITING RULES` for new books.';
18737
+ }
18738
+ /**
18739
+ * Optional UI/docs-only deprecation metadata.
18740
+ */
18741
+ get deprecation() {
18742
+ return {
18743
+ message: 'Use `WRITING RULES` for writing-only constraints such as tone, length, formatting, or emoji usage.',
18744
+ replacedBy: ['WRITING RULES'],
18745
+ };
18724
18746
  }
18725
18747
  /**
18726
18748
  * Icon for this commitment.
@@ -18735,15 +18757,34 @@
18735
18757
  return _spaceTrim.spaceTrim(`
18736
18758
  # ${this.type}
18737
18759
 
18738
- Defines how the agent should format and present its responses (tone, writing style, formatting).
18760
+ Deprecated legacy commitment for writing and presentation instructions.
18761
+
18762
+ ## Migration
18763
+
18764
+ - Existing \`${this.type}\` books still parse and compile.
18765
+ - New books should prefer \`WRITING RULES\`.
18766
+ - Use \`WRITING SAMPLE\` when you want to anchor voice by example instead of stating constraints directly.
18767
+ - The plural alias \`STYLES\` is the same legacy commitment family.
18739
18768
 
18740
18769
  ## Key aspects
18741
18770
 
18742
- - Both terms work identically and can be used interchangeably.
18771
+ - \`${this.type}\` remains functional for backward compatibility only.
18743
18772
  - Later style instructions can override earlier ones.
18744
18773
  - Style affects both tone and presentation format.
18745
18774
 
18746
- ## Examples
18775
+ ## Preferred replacement
18776
+
18777
+ \`\`\`book
18778
+ Technical Writer
18779
+
18780
+ GOAL Help the user understand technical topics with practical, accurate guidance.
18781
+ WRITING RULES Write in a professional but friendly tone.
18782
+ WRITING RULES Use bullet points for lists.
18783
+ WRITING RULES Always provide code examples when explaining programming concepts.
18784
+ FORMAT Use markdown formatting with clear headings
18785
+ \`\`\`
18786
+
18787
+ ## Legacy compatibility examples
18747
18788
 
18748
18789
  \`\`\`book
18749
18790
  Technical Writer
@@ -19058,7 +19099,7 @@
19058
19099
  \`\`\`book
19059
19100
  Legal Assistant
19060
19101
 
19061
- PERSONA An expert software developer
19102
+ GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
19062
19103
  TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
19063
19104
  \`\`\`
19064
19105
  `);
@@ -19484,7 +19525,7 @@
19484
19525
 
19485
19526
  PERSONA You are a helpful customer support representative
19486
19527
  TEMPLATE Always structure your response with: 1) Acknowledgment, 2) Solution, 3) Follow-up question
19487
- STYLE Be professional and empathetic
19528
+ WRITING RULES Be professional and empathetic
19488
19529
  \`\`\`
19489
19530
 
19490
19531
  \`\`\`book
@@ -19928,7 +19969,7 @@
19928
19969
 
19929
19970
  PERSONA You are a news analyst who stays up-to-date with current events
19930
19971
  USE BROWSER
19931
- STYLE Present news in a balanced and objective manner
19972
+ WRITING RULES Present news in a balanced and objective manner
19932
19973
  ACTION Can search for and summarize news articles
19933
19974
  \`\`\`
19934
19975
 
@@ -28085,7 +28126,7 @@
28085
28126
  function parseAgentSource(agentSource) {
28086
28127
  const parseResult = parseAgentSourceWithCommitments(agentSource);
28087
28128
  const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
28088
- const personaDescription = extractPersonaDescription(parseResult.commitments);
28129
+ const personaDescription = extractAgentProfileText(parseResult.commitments);
28089
28130
  const initialMessage = extractInitialMessage(parseResult.commitments);
28090
28131
  const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
28091
28132
  ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
@@ -28189,25 +28230,33 @@
28189
28230
  */
28190
28231
  const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
28191
28232
  /**
28192
- * Builds the combined persona description from PERSONA commitments.
28233
+ * Resolves the public agent profile text from the last GOAL/GOALS commitment,
28234
+ * falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
28193
28235
  *
28194
28236
  * @private internal utility of `parseAgentSource`
28195
28237
  */
28196
- function extractPersonaDescription(commitments) {
28197
- let personaDescription = null;
28238
+ function extractAgentProfileText(commitments) {
28239
+ let goalDescription = '';
28240
+ let hasGoalDescription = false;
28241
+ let personaDescription = '';
28242
+ let hasPersonaDescription = false;
28198
28243
  for (const commitment of commitments) {
28199
- if (commitment.type !== 'PERSONA') {
28200
- continue;
28244
+ if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
28245
+ goalDescription = commitment.content;
28246
+ hasGoalDescription = true;
28201
28247
  }
28202
- if (personaDescription === null) {
28203
- personaDescription = '';
28204
- }
28205
- else {
28206
- personaDescription += `\n\n${personaDescription}`;
28248
+ if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
28249
+ personaDescription = commitment.content;
28250
+ hasPersonaDescription = true;
28207
28251
  }
28208
- personaDescription += commitment.content;
28209
28252
  }
28210
- return personaDescription;
28253
+ if (hasGoalDescription) {
28254
+ return goalDescription;
28255
+ }
28256
+ if (hasPersonaDescription) {
28257
+ return personaDescription;
28258
+ }
28259
+ return null;
28211
28260
  }
28212
28261
  /**
28213
28262
  * Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
@@ -28889,6 +28938,15 @@
28889
28938
  * @private internal constant of `createAgentModelRequirementsWithCommitments`
28890
28939
  */
28891
28940
  const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
28941
+ /**
28942
+ * Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
28943
+ *
28944
+ * @private internal constant of `createAgentModelRequirementsWithCommitments`
28945
+ */
28946
+ const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
28947
+ ['GOAL', 'GOAL'],
28948
+ ['GOALS', 'GOAL'],
28949
+ ]);
28892
28950
  /**
28893
28951
  * Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
28894
28952
  *
@@ -28939,7 +28997,7 @@
28939
28997
  */
28940
28998
  async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
28941
28999
  const parseResult = parseAgentSourceWithCommitments(agentSource);
28942
- const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
29000
+ const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
28943
29001
  let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
28944
29002
  requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
28945
29003
  requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
@@ -28950,6 +29008,35 @@
28950
29008
  requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
28951
29009
  return finalizeRequirements(requirements);
28952
29010
  }
29011
+ /**
29012
+ * Removes earlier commitments that are overwritten by later commitments of the same semantic group.
29013
+ *
29014
+ * This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
29015
+ * and multi-goal sources expose one effective goal to the runtime.
29016
+ *
29017
+ * @param commitments - Parsed commitments after DELETE-like filtering.
29018
+ * @returns Commitments with overwritten entries removed while preserving source order.
29019
+ *
29020
+ * @private internal utility of `createAgentModelRequirementsWithCommitments`
29021
+ */
29022
+ function filterOverwrittenCommitments(commitments) {
29023
+ const seenOverwriteGroups = new Set();
29024
+ const keptCommitments = [];
29025
+ for (let index = commitments.length - 1; index >= 0; index--) {
29026
+ const commitment = commitments[index];
29027
+ const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
29028
+ if (!overwriteGroup) {
29029
+ keptCommitments.push(commitment);
29030
+ continue;
29031
+ }
29032
+ if (seenOverwriteGroups.has(overwriteGroup)) {
29033
+ continue;
29034
+ }
29035
+ seenOverwriteGroups.add(overwriteGroup);
29036
+ keptCommitments.push(commitment);
29037
+ }
29038
+ return keptCommitments.reverse();
29039
+ }
28953
29040
  /**
28954
29041
  * Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
28955
29042
  *
@@ -29541,7 +29628,7 @@
29541
29628
  * Selects the best model using the preparePersona function
29542
29629
  * This directly uses preparePersona to ensure DRY principle
29543
29630
  *
29544
- * @param agentSource The agent source to derive persona description from
29631
+ * @param agentSource The agent source to derive effective profile text from
29545
29632
  * @param llmTools LLM tools for preparing persona
29546
29633
  * @returns The name of the best selected model
29547
29634
  *
@@ -29549,9 +29636,9 @@
29549
29636
  */
29550
29637
  async function selectBestModelUsingPersona(agentSource, llmTools) {
29551
29638
  var _a;
29552
- // Parse agent source to get persona description
29639
+ // Parse agent source to get the effective profile description
29553
29640
  const { agentName, personaDescription } = parseAgentSource(agentSource);
29554
- // Use agent name as fallback if no persona description is available
29641
+ // Use agent name as fallback if no profile description is available
29555
29642
  const description = personaDescription || agentName || 'AI Agent';
29556
29643
  try {
29557
29644
  // Use preparePersona directly