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