@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 +95 -36
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
- package/esm/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +2 -1
- package/esm/src/commitments/PERSONA/PERSONA.d.ts +7 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +95 -36
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
- package/umd/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +2 -1
- package/umd/src/commitments/PERSONA/PERSONA.d.ts +7 -0
- package/umd/src/version.d.ts +1 -1
|
@@ -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
|
|
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
|
|
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
|
*/
|
package/esm/src/version.d.ts
CHANGED
|
@@ -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-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.112.0-43`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* @generated
|
|
31
31
|
* @see https://github.com/webgptorg/promptbook
|
|
32
32
|
*/
|
|
33
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-44';
|
|
34
34
|
/**
|
|
35
35
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
36
36
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -7244,7 +7244,7 @@
|
|
|
7244
7244
|
* Short one-line description of GOAL.
|
|
7245
7245
|
*/
|
|
7246
7246
|
get description() {
|
|
7247
|
-
return 'Define
|
|
7247
|
+
return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
|
|
7248
7248
|
}
|
|
7249
7249
|
/**
|
|
7250
7250
|
* Icon for this commitment.
|
|
@@ -7259,12 +7259,14 @@
|
|
|
7259
7259
|
return spacetrim.spaceTrim(`
|
|
7260
7260
|
# ${this.type}
|
|
7261
7261
|
|
|
7262
|
-
Defines the main goal which should be achieved by the AI assistant.
|
|
7262
|
+
Defines the main goal which should be achieved by the AI assistant.
|
|
7263
|
+
There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
|
|
7263
7264
|
|
|
7264
7265
|
## Key aspects
|
|
7265
7266
|
|
|
7266
7267
|
- Both terms work identically and can be used interchangeably.
|
|
7267
|
-
- Later goals
|
|
7268
|
+
- Later goals overwrite earlier goals.
|
|
7269
|
+
- The public agent profile text is derived from the last goal.
|
|
7268
7270
|
- Goals provide clear direction and purpose for the agent's responses.
|
|
7269
7271
|
- Goals influence decision-making and response prioritization.
|
|
7270
7272
|
|
|
@@ -7277,9 +7279,7 @@
|
|
|
7277
7279
|
\`\`\`book
|
|
7278
7280
|
Customer Support Agent
|
|
7279
7281
|
|
|
7280
|
-
PERSONA You are a helpful customer support representative
|
|
7281
7282
|
GOAL Resolve customer issues quickly and efficiently
|
|
7282
|
-
GOAL Maintain high customer satisfaction scores
|
|
7283
7283
|
GOAL Always follow company policies and procedures
|
|
7284
7284
|
RULE Be polite and professional at all times
|
|
7285
7285
|
\`\`\`
|
|
@@ -7287,9 +7287,7 @@
|
|
|
7287
7287
|
\`\`\`book
|
|
7288
7288
|
Educational Assistant
|
|
7289
7289
|
|
|
7290
|
-
PERSONA You are an educational assistant specializing in mathematics
|
|
7291
7290
|
GOAL Help students understand mathematical concepts clearly
|
|
7292
|
-
GOAL Encourage critical thinking and problem-solving skills
|
|
7293
7291
|
GOAL Ensure all explanations are age-appropriate and accessible
|
|
7294
7292
|
STYLE Use simple language and provide step-by-step explanations
|
|
7295
7293
|
\`\`\`
|
|
@@ -7297,9 +7295,7 @@
|
|
|
7297
7295
|
\`\`\`book
|
|
7298
7296
|
Safety-First Assistant
|
|
7299
7297
|
|
|
7300
|
-
PERSONA You are a general-purpose AI assistant
|
|
7301
7298
|
GOAL Be helpful and informative in all interactions
|
|
7302
|
-
GOAL Provide accurate and reliable information
|
|
7303
7299
|
GOAL Always prioritize user safety and ethical guidelines
|
|
7304
7300
|
RULE Never provide harmful or dangerous advice
|
|
7305
7301
|
\`\`\`
|
|
@@ -10058,7 +10054,16 @@
|
|
|
10058
10054
|
* Short one-line description of PERSONA.
|
|
10059
10055
|
*/
|
|
10060
10056
|
get description() {
|
|
10061
|
-
return '
|
|
10057
|
+
return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
|
|
10058
|
+
}
|
|
10059
|
+
/**
|
|
10060
|
+
* Optional UI/docs-only deprecation metadata.
|
|
10061
|
+
*/
|
|
10062
|
+
get deprecation() {
|
|
10063
|
+
return {
|
|
10064
|
+
message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
|
|
10065
|
+
replacedBy: ['GOAL'],
|
|
10066
|
+
};
|
|
10062
10067
|
}
|
|
10063
10068
|
/**
|
|
10064
10069
|
* Icon for this commitment.
|
|
@@ -10073,16 +10078,24 @@
|
|
|
10073
10078
|
return spacetrim.spaceTrim(`
|
|
10074
10079
|
# ${this.type}
|
|
10075
10080
|
|
|
10076
|
-
|
|
10081
|
+
Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
|
|
10077
10082
|
|
|
10078
|
-
##
|
|
10083
|
+
## Migration
|
|
10079
10084
|
|
|
10080
|
-
-
|
|
10081
|
-
-
|
|
10082
|
-
-
|
|
10083
|
-
-
|
|
10085
|
+
- Existing \`${this.type}\` books still parse and compile.
|
|
10086
|
+
- New books should prefer \`GOAL\`.
|
|
10087
|
+
- Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
|
|
10088
|
+
- Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
|
|
10084
10089
|
|
|
10085
|
-
##
|
|
10090
|
+
## Preferred replacement
|
|
10091
|
+
|
|
10092
|
+
\`\`\`book
|
|
10093
|
+
Programming Assistant
|
|
10094
|
+
|
|
10095
|
+
GOAL Help the user solve programming problems with practical TypeScript and React guidance.
|
|
10096
|
+
\`\`\`
|
|
10097
|
+
|
|
10098
|
+
## Legacy compatibility example
|
|
10086
10099
|
|
|
10087
10100
|
\`\`\`book
|
|
10088
10101
|
Programming Assistant
|
|
@@ -10847,7 +10860,7 @@
|
|
|
10847
10860
|
\`\`\`book
|
|
10848
10861
|
Legal Assistant
|
|
10849
10862
|
|
|
10850
|
-
|
|
10863
|
+
GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
|
|
10851
10864
|
TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
|
|
10852
10865
|
\`\`\`
|
|
10853
10866
|
`);
|
|
@@ -17436,7 +17449,7 @@
|
|
|
17436
17449
|
function parseAgentSource(agentSource) {
|
|
17437
17450
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
17438
17451
|
const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
17439
|
-
const personaDescription =
|
|
17452
|
+
const personaDescription = extractAgentProfileText(parseResult.commitments);
|
|
17440
17453
|
const initialMessage = extractInitialMessage(parseResult.commitments);
|
|
17441
17454
|
const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
|
|
17442
17455
|
ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
|
|
@@ -17540,25 +17553,33 @@
|
|
|
17540
17553
|
*/
|
|
17541
17554
|
const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
|
|
17542
17555
|
/**
|
|
17543
|
-
*
|
|
17556
|
+
* Resolves the public agent profile text from the last GOAL/GOALS commitment,
|
|
17557
|
+
* falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
|
|
17544
17558
|
*
|
|
17545
17559
|
* @private internal utility of `parseAgentSource`
|
|
17546
17560
|
*/
|
|
17547
|
-
function
|
|
17548
|
-
let
|
|
17561
|
+
function extractAgentProfileText(commitments) {
|
|
17562
|
+
let goalDescription = '';
|
|
17563
|
+
let hasGoalDescription = false;
|
|
17564
|
+
let personaDescription = '';
|
|
17565
|
+
let hasPersonaDescription = false;
|
|
17549
17566
|
for (const commitment of commitments) {
|
|
17550
|
-
if (commitment.type
|
|
17551
|
-
|
|
17567
|
+
if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
|
|
17568
|
+
goalDescription = commitment.content;
|
|
17569
|
+
hasGoalDescription = true;
|
|
17552
17570
|
}
|
|
17553
|
-
if (
|
|
17554
|
-
personaDescription =
|
|
17571
|
+
if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
|
|
17572
|
+
personaDescription = commitment.content;
|
|
17573
|
+
hasPersonaDescription = true;
|
|
17555
17574
|
}
|
|
17556
|
-
else {
|
|
17557
|
-
personaDescription += `\n\n${personaDescription}`;
|
|
17558
|
-
}
|
|
17559
|
-
personaDescription += commitment.content;
|
|
17560
17575
|
}
|
|
17561
|
-
|
|
17576
|
+
if (hasGoalDescription) {
|
|
17577
|
+
return goalDescription;
|
|
17578
|
+
}
|
|
17579
|
+
if (hasPersonaDescription) {
|
|
17580
|
+
return personaDescription;
|
|
17581
|
+
}
|
|
17582
|
+
return null;
|
|
17562
17583
|
}
|
|
17563
17584
|
/**
|
|
17564
17585
|
* Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
|
|
@@ -31111,6 +31132,15 @@
|
|
|
31111
31132
|
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
31112
31133
|
*/
|
|
31113
31134
|
const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
|
|
31135
|
+
/**
|
|
31136
|
+
* Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
|
|
31137
|
+
*
|
|
31138
|
+
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
31139
|
+
*/
|
|
31140
|
+
const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
|
|
31141
|
+
['GOAL', 'GOAL'],
|
|
31142
|
+
['GOALS', 'GOAL'],
|
|
31143
|
+
]);
|
|
31114
31144
|
/**
|
|
31115
31145
|
* Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
|
|
31116
31146
|
*
|
|
@@ -31161,7 +31191,7 @@
|
|
|
31161
31191
|
*/
|
|
31162
31192
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
31163
31193
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
31164
|
-
const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
|
|
31194
|
+
const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
|
|
31165
31195
|
let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
|
|
31166
31196
|
requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
|
|
31167
31197
|
requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
|
|
@@ -31172,6 +31202,35 @@
|
|
|
31172
31202
|
requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
|
|
31173
31203
|
return finalizeRequirements(requirements);
|
|
31174
31204
|
}
|
|
31205
|
+
/**
|
|
31206
|
+
* Removes earlier commitments that are overwritten by later commitments of the same semantic group.
|
|
31207
|
+
*
|
|
31208
|
+
* This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
|
|
31209
|
+
* and multi-goal sources expose one effective goal to the runtime.
|
|
31210
|
+
*
|
|
31211
|
+
* @param commitments - Parsed commitments after DELETE-like filtering.
|
|
31212
|
+
* @returns Commitments with overwritten entries removed while preserving source order.
|
|
31213
|
+
*
|
|
31214
|
+
* @private internal utility of `createAgentModelRequirementsWithCommitments`
|
|
31215
|
+
*/
|
|
31216
|
+
function filterOverwrittenCommitments(commitments) {
|
|
31217
|
+
const seenOverwriteGroups = new Set();
|
|
31218
|
+
const keptCommitments = [];
|
|
31219
|
+
for (let index = commitments.length - 1; index >= 0; index--) {
|
|
31220
|
+
const commitment = commitments[index];
|
|
31221
|
+
const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
|
|
31222
|
+
if (!overwriteGroup) {
|
|
31223
|
+
keptCommitments.push(commitment);
|
|
31224
|
+
continue;
|
|
31225
|
+
}
|
|
31226
|
+
if (seenOverwriteGroups.has(overwriteGroup)) {
|
|
31227
|
+
continue;
|
|
31228
|
+
}
|
|
31229
|
+
seenOverwriteGroups.add(overwriteGroup);
|
|
31230
|
+
keptCommitments.push(commitment);
|
|
31231
|
+
}
|
|
31232
|
+
return keptCommitments.reverse();
|
|
31233
|
+
}
|
|
31175
31234
|
/**
|
|
31176
31235
|
* Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
|
|
31177
31236
|
*
|
|
@@ -31763,7 +31822,7 @@
|
|
|
31763
31822
|
* Selects the best model using the preparePersona function
|
|
31764
31823
|
* This directly uses preparePersona to ensure DRY principle
|
|
31765
31824
|
*
|
|
31766
|
-
* @param agentSource The agent source to derive
|
|
31825
|
+
* @param agentSource The agent source to derive effective profile text from
|
|
31767
31826
|
* @param llmTools LLM tools for preparing persona
|
|
31768
31827
|
* @returns The name of the best selected model
|
|
31769
31828
|
*
|
|
@@ -31771,9 +31830,9 @@
|
|
|
31771
31830
|
*/
|
|
31772
31831
|
async function selectBestModelUsingPersona(agentSource, llmTools) {
|
|
31773
31832
|
var _a;
|
|
31774
|
-
// Parse agent source to get
|
|
31833
|
+
// Parse agent source to get the effective profile description
|
|
31775
31834
|
const { agentName, personaDescription } = parseAgentSource(agentSource);
|
|
31776
|
-
// Use agent name as fallback if no
|
|
31835
|
+
// Use agent name as fallback if no profile description is available
|
|
31777
31836
|
const description = personaDescription || agentName || 'AI Agent';
|
|
31778
31837
|
try {
|
|
31779
31838
|
// Use preparePersona directly
|