@promptbook/core 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.
- package/esm/index.es.js +144 -57
- package/esm/index.es.js.map +1 -1
- package/esm/src/avatars/Avatar.d.ts +7 -0
- package/esm/src/avatars/avatarRenderingUtils.d.ts +117 -0
- package/esm/src/avatars/index.d.ts +6 -0
- package/esm/src/avatars/renderAvatarVisual.d.ts +9 -0
- package/esm/src/avatars/types/AvatarDefinition.d.ts +20 -0
- package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +96 -0
- package/esm/src/avatars/visuals/avatarVisualRegistry.d.ts +16 -0
- package/esm/src/avatars/visuals/minecraftAvatarVisual.d.ts +7 -0
- package/esm/src/avatars/visuals/octopusAvatarVisual.d.ts +7 -0
- package/esm/src/avatars/visuals/pixelArtAvatarVisual.d.ts +7 -0
- 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/commitments/STYLE/STYLE.d.ts +9 -2
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +144 -57
- package/umd/index.umd.js.map +1 -1
- package/umd/src/avatars/Avatar.d.ts +7 -0
- package/umd/src/avatars/avatarRenderingUtils.d.ts +117 -0
- package/umd/src/avatars/index.d.ts +6 -0
- package/umd/src/avatars/renderAvatarVisual.d.ts +9 -0
- package/umd/src/avatars/types/AvatarDefinition.d.ts +20 -0
- package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +96 -0
- package/umd/src/avatars/visuals/avatarVisualRegistry.d.ts +16 -0
- package/umd/src/avatars/visuals/minecraftAvatarVisual.d.ts +7 -0
- package/umd/src/avatars/visuals/octopusAvatarVisual.d.ts +7 -0
- package/umd/src/avatars/visuals/pixelArtAvatarVisual.d.ts +7 -0
- 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/commitments/STYLE/STYLE.d.ts +9 -2
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-45';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -8343,7 +8343,7 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8343
8343
|
DELETE Casual conversational style
|
|
8344
8344
|
REMOVE All emoji usage
|
|
8345
8345
|
GOAL Provide professional business communications
|
|
8346
|
-
|
|
8346
|
+
WRITING RULES Use formal language and proper business etiquette
|
|
8347
8347
|
\`\`\`
|
|
8348
8348
|
|
|
8349
8349
|
\`\`\`book
|
|
@@ -8354,7 +8354,7 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8354
8354
|
DISCARD Technical jargon explanations
|
|
8355
8355
|
CANCEL Advanced troubleshooting procedures
|
|
8356
8356
|
GOAL Help users with simple, easy-to-follow solutions
|
|
8357
|
-
|
|
8357
|
+
WRITING RULES Use plain language that anyone can understand
|
|
8358
8358
|
\`\`\`
|
|
8359
8359
|
|
|
8360
8360
|
\`\`\`book
|
|
@@ -8371,11 +8371,11 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8371
8371
|
Concise Information Provider
|
|
8372
8372
|
|
|
8373
8373
|
PERSONA You are a helpful assistant who provides detailed explanations
|
|
8374
|
-
|
|
8374
|
+
WRITING RULES Include examples, analogies, and comprehensive context
|
|
8375
8375
|
CANCEL Detailed explanation style
|
|
8376
8376
|
DISCARD Examples and analogies
|
|
8377
8377
|
GOAL Provide brief, direct answers without unnecessary elaboration
|
|
8378
|
-
|
|
8378
|
+
WRITING RULES Be concise and to the point
|
|
8379
8379
|
\`\`\`
|
|
8380
8380
|
`);
|
|
8381
8381
|
}
|
|
@@ -8559,7 +8559,7 @@ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8559
8559
|
PERSONA You are a data analysis expert
|
|
8560
8560
|
FORMAT Present results in structured tables
|
|
8561
8561
|
FORMAT Include confidence scores for all predictions
|
|
8562
|
-
|
|
8562
|
+
WRITING RULES Be concise and precise in explanations
|
|
8563
8563
|
\`\`\`
|
|
8564
8564
|
`);
|
|
8565
8565
|
}
|
|
@@ -11410,7 +11410,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11410
11410
|
* Short one-line description of GOAL.
|
|
11411
11411
|
*/
|
|
11412
11412
|
get description() {
|
|
11413
|
-
return 'Define
|
|
11413
|
+
return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
|
|
11414
11414
|
}
|
|
11415
11415
|
/**
|
|
11416
11416
|
* Icon for this commitment.
|
|
@@ -11425,12 +11425,14 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11425
11425
|
return spaceTrim$1(`
|
|
11426
11426
|
# ${this.type}
|
|
11427
11427
|
|
|
11428
|
-
Defines the main goal which should be achieved by the AI assistant.
|
|
11428
|
+
Defines the main goal which should be achieved by the AI assistant.
|
|
11429
|
+
There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
|
|
11429
11430
|
|
|
11430
11431
|
## Key aspects
|
|
11431
11432
|
|
|
11432
11433
|
- Both terms work identically and can be used interchangeably.
|
|
11433
|
-
- Later goals
|
|
11434
|
+
- Later goals overwrite earlier goals.
|
|
11435
|
+
- The public agent profile text is derived from the last goal.
|
|
11434
11436
|
- Goals provide clear direction and purpose for the agent's responses.
|
|
11435
11437
|
- Goals influence decision-making and response prioritization.
|
|
11436
11438
|
|
|
@@ -11443,9 +11445,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11443
11445
|
\`\`\`book
|
|
11444
11446
|
Customer Support Agent
|
|
11445
11447
|
|
|
11446
|
-
PERSONA You are a helpful customer support representative
|
|
11447
11448
|
GOAL Resolve customer issues quickly and efficiently
|
|
11448
|
-
GOAL Maintain high customer satisfaction scores
|
|
11449
11449
|
GOAL Always follow company policies and procedures
|
|
11450
11450
|
RULE Be polite and professional at all times
|
|
11451
11451
|
\`\`\`
|
|
@@ -11453,19 +11453,15 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11453
11453
|
\`\`\`book
|
|
11454
11454
|
Educational Assistant
|
|
11455
11455
|
|
|
11456
|
-
PERSONA You are an educational assistant specializing in mathematics
|
|
11457
11456
|
GOAL Help students understand mathematical concepts clearly
|
|
11458
|
-
GOAL Encourage critical thinking and problem-solving skills
|
|
11459
11457
|
GOAL Ensure all explanations are age-appropriate and accessible
|
|
11460
|
-
|
|
11458
|
+
WRITING RULES Use simple language and provide step-by-step explanations
|
|
11461
11459
|
\`\`\`
|
|
11462
11460
|
|
|
11463
11461
|
\`\`\`book
|
|
11464
11462
|
Safety-First Assistant
|
|
11465
11463
|
|
|
11466
|
-
PERSONA You are a general-purpose AI assistant
|
|
11467
11464
|
GOAL Be helpful and informative in all interactions
|
|
11468
|
-
GOAL Provide accurate and reliable information
|
|
11469
11465
|
GOAL Always prioritize user safety and ethical guidelines
|
|
11470
11466
|
RULE Never provide harmful or dangerous advice
|
|
11471
11467
|
\`\`\`
|
|
@@ -11873,7 +11869,7 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11873
11869
|
KNOWLEDGE Academic research requires careful citation and verification
|
|
11874
11870
|
KNOWLEDGE https://example.com/research-guidelines.pdf
|
|
11875
11871
|
ACTION Can help with literature reviews and data analysis
|
|
11876
|
-
|
|
11872
|
+
WRITING RULES Present information in clear, academic format
|
|
11877
11873
|
\`\`\`
|
|
11878
11874
|
`);
|
|
11879
11875
|
}
|
|
@@ -13624,7 +13620,7 @@ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
13624
13620
|
|
|
13625
13621
|
META IMAGE https://example.com/professional-avatar.jpg
|
|
13626
13622
|
PERSONA You are a professional business assistant
|
|
13627
|
-
|
|
13623
|
+
WRITING RULES Maintain a formal and courteous tone
|
|
13628
13624
|
\`\`\`
|
|
13629
13625
|
|
|
13630
13626
|
\`\`\`book
|
|
@@ -13632,7 +13628,7 @@ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
13632
13628
|
|
|
13633
13629
|
META IMAGE /assets/creative-bot-avatar.png
|
|
13634
13630
|
PERSONA You are a creative and inspiring assistant
|
|
13635
|
-
|
|
13631
|
+
WRITING RULES Be enthusiastic and encouraging
|
|
13636
13632
|
ACTION Can help with brainstorming and ideation
|
|
13637
13633
|
\`\`\`
|
|
13638
13634
|
`);
|
|
@@ -13791,7 +13787,7 @@ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
13791
13787
|
META LINK https://twitter.com/devhandle
|
|
13792
13788
|
PERSONA You are an experienced open source developer
|
|
13793
13789
|
ACTION Can help with code reviews and architecture decisions
|
|
13794
|
-
|
|
13790
|
+
WRITING RULES Be direct and technical in explanations
|
|
13795
13791
|
\`\`\`
|
|
13796
13792
|
`);
|
|
13797
13793
|
}
|
|
@@ -13997,7 +13993,7 @@ class ModelCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
13997
13993
|
MODEL TEMPERATURE 0.8
|
|
13998
13994
|
MODEL TOP_P 0.9
|
|
13999
13995
|
MODEL MAX_TOKENS 2048
|
|
14000
|
-
|
|
13996
|
+
WRITING RULES Be imaginative and expressive
|
|
14001
13997
|
ACTION Can help with storytelling and character development
|
|
14002
13998
|
\`\`\`
|
|
14003
13999
|
|
|
@@ -14209,7 +14205,7 @@ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14209
14205
|
NOTE Uses RAG for accessing latest research papers
|
|
14210
14206
|
PERSONA You are a knowledgeable research assistant
|
|
14211
14207
|
ACTION Can help with literature reviews and citations
|
|
14212
|
-
|
|
14208
|
+
WRITING RULES Present information in academic format
|
|
14213
14209
|
\`\`\`
|
|
14214
14210
|
`);
|
|
14215
14211
|
}
|
|
@@ -14324,7 +14320,16 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14324
14320
|
* Short one-line description of PERSONA.
|
|
14325
14321
|
*/
|
|
14326
14322
|
get description() {
|
|
14327
|
-
return '
|
|
14323
|
+
return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
|
|
14324
|
+
}
|
|
14325
|
+
/**
|
|
14326
|
+
* Optional UI/docs-only deprecation metadata.
|
|
14327
|
+
*/
|
|
14328
|
+
get deprecation() {
|
|
14329
|
+
return {
|
|
14330
|
+
message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
|
|
14331
|
+
replacedBy: ['GOAL'],
|
|
14332
|
+
};
|
|
14328
14333
|
}
|
|
14329
14334
|
/**
|
|
14330
14335
|
* Icon for this commitment.
|
|
@@ -14339,16 +14344,24 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14339
14344
|
return spaceTrim$1(`
|
|
14340
14345
|
# ${this.type}
|
|
14341
14346
|
|
|
14342
|
-
|
|
14347
|
+
Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
|
|
14343
14348
|
|
|
14344
|
-
##
|
|
14349
|
+
## Migration
|
|
14345
14350
|
|
|
14346
|
-
-
|
|
14347
|
-
-
|
|
14348
|
-
-
|
|
14349
|
-
-
|
|
14351
|
+
- Existing \`${this.type}\` books still parse and compile.
|
|
14352
|
+
- New books should prefer \`GOAL\`.
|
|
14353
|
+
- Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
|
|
14354
|
+
- Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
|
|
14350
14355
|
|
|
14351
|
-
##
|
|
14356
|
+
## Preferred replacement
|
|
14357
|
+
|
|
14358
|
+
\`\`\`book
|
|
14359
|
+
Programming Assistant
|
|
14360
|
+
|
|
14361
|
+
GOAL Help the user solve programming problems with practical TypeScript and React guidance.
|
|
14362
|
+
\`\`\`
|
|
14363
|
+
|
|
14364
|
+
## Legacy compatibility example
|
|
14352
14365
|
|
|
14353
14366
|
\`\`\`book
|
|
14354
14367
|
Programming Assistant
|
|
@@ -14486,7 +14499,7 @@ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14486
14499
|
RULE Always ask for clarification if the user's request is ambiguous
|
|
14487
14500
|
RULE Be polite and professional in all interactions
|
|
14488
14501
|
RULES Never provide medical or legal advice
|
|
14489
|
-
|
|
14502
|
+
WRITING RULES Maintain a friendly and helpful tone
|
|
14490
14503
|
\`\`\`
|
|
14491
14504
|
|
|
14492
14505
|
\`\`\`book
|
|
@@ -14755,8 +14768,8 @@ class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14755
14768
|
/**
|
|
14756
14769
|
* STYLE commitment definition
|
|
14757
14770
|
*
|
|
14758
|
-
*
|
|
14759
|
-
*
|
|
14771
|
+
* Deprecated legacy writing-style commitment kept for backward compatibility.
|
|
14772
|
+
* New books should prefer `WRITING RULES` for writing-only constraints.
|
|
14760
14773
|
*
|
|
14761
14774
|
* Example usage in agent source:
|
|
14762
14775
|
*
|
|
@@ -14775,7 +14788,16 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14775
14788
|
* Short one-line description of STYLE.
|
|
14776
14789
|
*/
|
|
14777
14790
|
get description() {
|
|
14778
|
-
return '
|
|
14791
|
+
return 'Deprecated legacy writing-style commitment. Prefer `WRITING RULES` for new books.';
|
|
14792
|
+
}
|
|
14793
|
+
/**
|
|
14794
|
+
* Optional UI/docs-only deprecation metadata.
|
|
14795
|
+
*/
|
|
14796
|
+
get deprecation() {
|
|
14797
|
+
return {
|
|
14798
|
+
message: 'Use `WRITING RULES` for writing-only constraints such as tone, length, formatting, or emoji usage.',
|
|
14799
|
+
replacedBy: ['WRITING RULES'],
|
|
14800
|
+
};
|
|
14779
14801
|
}
|
|
14780
14802
|
/**
|
|
14781
14803
|
* Icon for this commitment.
|
|
@@ -14790,15 +14812,34 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14790
14812
|
return spaceTrim$1(`
|
|
14791
14813
|
# ${this.type}
|
|
14792
14814
|
|
|
14793
|
-
|
|
14815
|
+
Deprecated legacy commitment for writing and presentation instructions.
|
|
14816
|
+
|
|
14817
|
+
## Migration
|
|
14818
|
+
|
|
14819
|
+
- Existing \`${this.type}\` books still parse and compile.
|
|
14820
|
+
- New books should prefer \`WRITING RULES\`.
|
|
14821
|
+
- Use \`WRITING SAMPLE\` when you want to anchor voice by example instead of stating constraints directly.
|
|
14822
|
+
- The plural alias \`STYLES\` is the same legacy commitment family.
|
|
14794
14823
|
|
|
14795
14824
|
## Key aspects
|
|
14796
14825
|
|
|
14797
|
-
-
|
|
14826
|
+
- \`${this.type}\` remains functional for backward compatibility only.
|
|
14798
14827
|
- Later style instructions can override earlier ones.
|
|
14799
14828
|
- Style affects both tone and presentation format.
|
|
14800
14829
|
|
|
14801
|
-
##
|
|
14830
|
+
## Preferred replacement
|
|
14831
|
+
|
|
14832
|
+
\`\`\`book
|
|
14833
|
+
Technical Writer
|
|
14834
|
+
|
|
14835
|
+
GOAL Help the user understand technical topics with practical, accurate guidance.
|
|
14836
|
+
WRITING RULES Write in a professional but friendly tone.
|
|
14837
|
+
WRITING RULES Use bullet points for lists.
|
|
14838
|
+
WRITING RULES Always provide code examples when explaining programming concepts.
|
|
14839
|
+
FORMAT Use markdown formatting with clear headings
|
|
14840
|
+
\`\`\`
|
|
14841
|
+
|
|
14842
|
+
## Legacy compatibility examples
|
|
14802
14843
|
|
|
14803
14844
|
\`\`\`book
|
|
14804
14845
|
Technical Writer
|
|
@@ -15113,7 +15154,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15113
15154
|
\`\`\`book
|
|
15114
15155
|
Legal Assistant
|
|
15115
15156
|
|
|
15116
|
-
|
|
15157
|
+
GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
|
|
15117
15158
|
TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
|
|
15118
15159
|
\`\`\`
|
|
15119
15160
|
`);
|
|
@@ -15539,7 +15580,7 @@ class TemplateCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15539
15580
|
|
|
15540
15581
|
PERSONA You are a helpful customer support representative
|
|
15541
15582
|
TEMPLATE Always structure your response with: 1) Acknowledgment, 2) Solution, 3) Follow-up question
|
|
15542
|
-
|
|
15583
|
+
WRITING RULES Be professional and empathetic
|
|
15543
15584
|
\`\`\`
|
|
15544
15585
|
|
|
15545
15586
|
\`\`\`book
|
|
@@ -15983,7 +16024,7 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15983
16024
|
|
|
15984
16025
|
PERSONA You are a news analyst who stays up-to-date with current events
|
|
15985
16026
|
USE BROWSER
|
|
15986
|
-
|
|
16027
|
+
WRITING RULES Present news in a balanced and objective manner
|
|
15987
16028
|
ACTION Can search for and summarize news articles
|
|
15988
16029
|
\`\`\`
|
|
15989
16030
|
|
|
@@ -21984,6 +22025,15 @@ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS',
|
|
|
21984
22025
|
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
21985
22026
|
*/
|
|
21986
22027
|
const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
|
|
22028
|
+
/**
|
|
22029
|
+
* Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
|
|
22030
|
+
*
|
|
22031
|
+
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
22032
|
+
*/
|
|
22033
|
+
const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
|
|
22034
|
+
['GOAL', 'GOAL'],
|
|
22035
|
+
['GOALS', 'GOAL'],
|
|
22036
|
+
]);
|
|
21987
22037
|
/**
|
|
21988
22038
|
* Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
|
|
21989
22039
|
*
|
|
@@ -22034,7 +22084,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
|
22034
22084
|
*/
|
|
22035
22085
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
22036
22086
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
22037
|
-
const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
|
|
22087
|
+
const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
|
|
22038
22088
|
let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
|
|
22039
22089
|
requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
|
|
22040
22090
|
requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
|
|
@@ -22045,6 +22095,35 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
22045
22095
|
requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
|
|
22046
22096
|
return finalizeRequirements(requirements);
|
|
22047
22097
|
}
|
|
22098
|
+
/**
|
|
22099
|
+
* Removes earlier commitments that are overwritten by later commitments of the same semantic group.
|
|
22100
|
+
*
|
|
22101
|
+
* This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
|
|
22102
|
+
* and multi-goal sources expose one effective goal to the runtime.
|
|
22103
|
+
*
|
|
22104
|
+
* @param commitments - Parsed commitments after DELETE-like filtering.
|
|
22105
|
+
* @returns Commitments with overwritten entries removed while preserving source order.
|
|
22106
|
+
*
|
|
22107
|
+
* @private internal utility of `createAgentModelRequirementsWithCommitments`
|
|
22108
|
+
*/
|
|
22109
|
+
function filterOverwrittenCommitments(commitments) {
|
|
22110
|
+
const seenOverwriteGroups = new Set();
|
|
22111
|
+
const keptCommitments = [];
|
|
22112
|
+
for (let index = commitments.length - 1; index >= 0; index--) {
|
|
22113
|
+
const commitment = commitments[index];
|
|
22114
|
+
const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
|
|
22115
|
+
if (!overwriteGroup) {
|
|
22116
|
+
keptCommitments.push(commitment);
|
|
22117
|
+
continue;
|
|
22118
|
+
}
|
|
22119
|
+
if (seenOverwriteGroups.has(overwriteGroup)) {
|
|
22120
|
+
continue;
|
|
22121
|
+
}
|
|
22122
|
+
seenOverwriteGroups.add(overwriteGroup);
|
|
22123
|
+
keptCommitments.push(commitment);
|
|
22124
|
+
}
|
|
22125
|
+
return keptCommitments.reverse();
|
|
22126
|
+
}
|
|
22048
22127
|
/**
|
|
22049
22128
|
* Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
|
|
22050
22129
|
*
|
|
@@ -22678,7 +22757,7 @@ function createDefaultAgentName(agentSource) {
|
|
|
22678
22757
|
function parseAgentSource(agentSource) {
|
|
22679
22758
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
22680
22759
|
const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
22681
|
-
const personaDescription =
|
|
22760
|
+
const personaDescription = extractAgentProfileText(parseResult.commitments);
|
|
22682
22761
|
const initialMessage = extractInitialMessage(parseResult.commitments);
|
|
22683
22762
|
const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
|
|
22684
22763
|
ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
|
|
@@ -22782,25 +22861,33 @@ const META_COMMITMENT_APPLIERS = {
|
|
|
22782
22861
|
*/
|
|
22783
22862
|
const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
|
|
22784
22863
|
/**
|
|
22785
|
-
*
|
|
22864
|
+
* Resolves the public agent profile text from the last GOAL/GOALS commitment,
|
|
22865
|
+
* falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
|
|
22786
22866
|
*
|
|
22787
22867
|
* @private internal utility of `parseAgentSource`
|
|
22788
22868
|
*/
|
|
22789
|
-
function
|
|
22790
|
-
let
|
|
22869
|
+
function extractAgentProfileText(commitments) {
|
|
22870
|
+
let goalDescription = '';
|
|
22871
|
+
let hasGoalDescription = false;
|
|
22872
|
+
let personaDescription = '';
|
|
22873
|
+
let hasPersonaDescription = false;
|
|
22791
22874
|
for (const commitment of commitments) {
|
|
22792
|
-
if (commitment.type
|
|
22793
|
-
|
|
22794
|
-
|
|
22795
|
-
if (personaDescription === null) {
|
|
22796
|
-
personaDescription = '';
|
|
22875
|
+
if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
|
|
22876
|
+
goalDescription = commitment.content;
|
|
22877
|
+
hasGoalDescription = true;
|
|
22797
22878
|
}
|
|
22798
|
-
|
|
22799
|
-
personaDescription
|
|
22879
|
+
if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
|
|
22880
|
+
personaDescription = commitment.content;
|
|
22881
|
+
hasPersonaDescription = true;
|
|
22800
22882
|
}
|
|
22801
|
-
personaDescription += commitment.content;
|
|
22802
22883
|
}
|
|
22803
|
-
|
|
22884
|
+
if (hasGoalDescription) {
|
|
22885
|
+
return goalDescription;
|
|
22886
|
+
}
|
|
22887
|
+
if (hasPersonaDescription) {
|
|
22888
|
+
return personaDescription;
|
|
22889
|
+
}
|
|
22890
|
+
return null;
|
|
22804
22891
|
}
|
|
22805
22892
|
/**
|
|
22806
22893
|
* Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
|
|
@@ -23287,7 +23374,7 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
23287
23374
|
* Selects the best model using the preparePersona function
|
|
23288
23375
|
* This directly uses preparePersona to ensure DRY principle
|
|
23289
23376
|
*
|
|
23290
|
-
* @param agentSource The agent source to derive
|
|
23377
|
+
* @param agentSource The agent source to derive effective profile text from
|
|
23291
23378
|
* @param llmTools LLM tools for preparing persona
|
|
23292
23379
|
* @returns The name of the best selected model
|
|
23293
23380
|
*
|
|
@@ -23295,9 +23382,9 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
23295
23382
|
*/
|
|
23296
23383
|
async function selectBestModelUsingPersona(agentSource, llmTools) {
|
|
23297
23384
|
var _a;
|
|
23298
|
-
// Parse agent source to get
|
|
23385
|
+
// Parse agent source to get the effective profile description
|
|
23299
23386
|
const { agentName, personaDescription } = parseAgentSource(agentSource);
|
|
23300
|
-
// Use agent name as fallback if no
|
|
23387
|
+
// Use agent name as fallback if no profile description is available
|
|
23301
23388
|
const description = personaDescription || agentName || 'AI Agent';
|
|
23302
23389
|
try {
|
|
23303
23390
|
// Use preparePersona directly
|