@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.
- 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 +2 -2
- 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
|
@@ -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-
|
|
38
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-45';
|
|
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
|
|
@@ -14777,7 +14777,7 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14777
14777
|
DELETE Casual conversational style
|
|
14778
14778
|
REMOVE All emoji usage
|
|
14779
14779
|
GOAL Provide professional business communications
|
|
14780
|
-
|
|
14780
|
+
WRITING RULES Use formal language and proper business etiquette
|
|
14781
14781
|
\`\`\`
|
|
14782
14782
|
|
|
14783
14783
|
\`\`\`book
|
|
@@ -14788,7 +14788,7 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14788
14788
|
DISCARD Technical jargon explanations
|
|
14789
14789
|
CANCEL Advanced troubleshooting procedures
|
|
14790
14790
|
GOAL Help users with simple, easy-to-follow solutions
|
|
14791
|
-
|
|
14791
|
+
WRITING RULES Use plain language that anyone can understand
|
|
14792
14792
|
\`\`\`
|
|
14793
14793
|
|
|
14794
14794
|
\`\`\`book
|
|
@@ -14805,11 +14805,11 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14805
14805
|
Concise Information Provider
|
|
14806
14806
|
|
|
14807
14807
|
PERSONA You are a helpful assistant who provides detailed explanations
|
|
14808
|
-
|
|
14808
|
+
WRITING RULES Include examples, analogies, and comprehensive context
|
|
14809
14809
|
CANCEL Detailed explanation style
|
|
14810
14810
|
DISCARD Examples and analogies
|
|
14811
14811
|
GOAL Provide brief, direct answers without unnecessary elaboration
|
|
14812
|
-
|
|
14812
|
+
WRITING RULES Be concise and to the point
|
|
14813
14813
|
\`\`\`
|
|
14814
14814
|
`);
|
|
14815
14815
|
}
|
|
@@ -14993,7 +14993,7 @@ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14993
14993
|
PERSONA You are a data analysis expert
|
|
14994
14994
|
FORMAT Present results in structured tables
|
|
14995
14995
|
FORMAT Include confidence scores for all predictions
|
|
14996
|
-
|
|
14996
|
+
WRITING RULES Be concise and precise in explanations
|
|
14997
14997
|
\`\`\`
|
|
14998
14998
|
`);
|
|
14999
14999
|
}
|
|
@@ -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
|
|
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.
|
|
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
|
|
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,19 +15385,15 @@ 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
|
+
WRITING RULES Use simple language and provide step-by-step explanations
|
|
15393
15391
|
\`\`\`
|
|
15394
15392
|
|
|
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
|
\`\`\`
|
|
@@ -15805,7 +15801,7 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15805
15801
|
KNOWLEDGE Academic research requires careful citation and verification
|
|
15806
15802
|
KNOWLEDGE https://example.com/research-guidelines.pdf
|
|
15807
15803
|
ACTION Can help with literature reviews and data analysis
|
|
15808
|
-
|
|
15804
|
+
WRITING RULES Present information in clear, academic format
|
|
15809
15805
|
\`\`\`
|
|
15810
15806
|
`);
|
|
15811
15807
|
}
|
|
@@ -17556,7 +17552,7 @@ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
17556
17552
|
|
|
17557
17553
|
META IMAGE https://example.com/professional-avatar.jpg
|
|
17558
17554
|
PERSONA You are a professional business assistant
|
|
17559
|
-
|
|
17555
|
+
WRITING RULES Maintain a formal and courteous tone
|
|
17560
17556
|
\`\`\`
|
|
17561
17557
|
|
|
17562
17558
|
\`\`\`book
|
|
@@ -17564,7 +17560,7 @@ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
17564
17560
|
|
|
17565
17561
|
META IMAGE /assets/creative-bot-avatar.png
|
|
17566
17562
|
PERSONA You are a creative and inspiring assistant
|
|
17567
|
-
|
|
17563
|
+
WRITING RULES Be enthusiastic and encouraging
|
|
17568
17564
|
ACTION Can help with brainstorming and ideation
|
|
17569
17565
|
\`\`\`
|
|
17570
17566
|
`);
|
|
@@ -17723,7 +17719,7 @@ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
17723
17719
|
META LINK https://twitter.com/devhandle
|
|
17724
17720
|
PERSONA You are an experienced open source developer
|
|
17725
17721
|
ACTION Can help with code reviews and architecture decisions
|
|
17726
|
-
|
|
17722
|
+
WRITING RULES Be direct and technical in explanations
|
|
17727
17723
|
\`\`\`
|
|
17728
17724
|
`);
|
|
17729
17725
|
}
|
|
@@ -17929,7 +17925,7 @@ class ModelCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
17929
17925
|
MODEL TEMPERATURE 0.8
|
|
17930
17926
|
MODEL TOP_P 0.9
|
|
17931
17927
|
MODEL MAX_TOKENS 2048
|
|
17932
|
-
|
|
17928
|
+
WRITING RULES Be imaginative and expressive
|
|
17933
17929
|
ACTION Can help with storytelling and character development
|
|
17934
17930
|
\`\`\`
|
|
17935
17931
|
|
|
@@ -18141,7 +18137,7 @@ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18141
18137
|
NOTE Uses RAG for accessing latest research papers
|
|
18142
18138
|
PERSONA You are a knowledgeable research assistant
|
|
18143
18139
|
ACTION Can help with literature reviews and citations
|
|
18144
|
-
|
|
18140
|
+
WRITING RULES Present information in academic format
|
|
18145
18141
|
\`\`\`
|
|
18146
18142
|
`);
|
|
18147
18143
|
}
|
|
@@ -18256,7 +18252,16 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18256
18252
|
* Short one-line description of PERSONA.
|
|
18257
18253
|
*/
|
|
18258
18254
|
get description() {
|
|
18259
|
-
return '
|
|
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
|
-
|
|
18279
|
+
Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
|
|
18275
18280
|
|
|
18276
|
-
##
|
|
18281
|
+
## Migration
|
|
18277
18282
|
|
|
18278
|
-
-
|
|
18279
|
-
-
|
|
18280
|
-
-
|
|
18281
|
-
-
|
|
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
|
-
##
|
|
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
|
|
@@ -18418,7 +18431,7 @@ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18418
18431
|
RULE Always ask for clarification if the user's request is ambiguous
|
|
18419
18432
|
RULE Be polite and professional in all interactions
|
|
18420
18433
|
RULES Never provide medical or legal advice
|
|
18421
|
-
|
|
18434
|
+
WRITING RULES Maintain a friendly and helpful tone
|
|
18422
18435
|
\`\`\`
|
|
18423
18436
|
|
|
18424
18437
|
\`\`\`book
|
|
@@ -18687,8 +18700,8 @@ class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18687
18700
|
/**
|
|
18688
18701
|
* STYLE commitment definition
|
|
18689
18702
|
*
|
|
18690
|
-
*
|
|
18691
|
-
*
|
|
18703
|
+
* Deprecated legacy writing-style commitment kept for backward compatibility.
|
|
18704
|
+
* New books should prefer `WRITING RULES` for writing-only constraints.
|
|
18692
18705
|
*
|
|
18693
18706
|
* Example usage in agent source:
|
|
18694
18707
|
*
|
|
@@ -18707,7 +18720,16 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18707
18720
|
* Short one-line description of STYLE.
|
|
18708
18721
|
*/
|
|
18709
18722
|
get description() {
|
|
18710
|
-
return '
|
|
18723
|
+
return 'Deprecated legacy writing-style commitment. Prefer `WRITING RULES` for new books.';
|
|
18724
|
+
}
|
|
18725
|
+
/**
|
|
18726
|
+
* Optional UI/docs-only deprecation metadata.
|
|
18727
|
+
*/
|
|
18728
|
+
get deprecation() {
|
|
18729
|
+
return {
|
|
18730
|
+
message: 'Use `WRITING RULES` for writing-only constraints such as tone, length, formatting, or emoji usage.',
|
|
18731
|
+
replacedBy: ['WRITING RULES'],
|
|
18732
|
+
};
|
|
18711
18733
|
}
|
|
18712
18734
|
/**
|
|
18713
18735
|
* Icon for this commitment.
|
|
@@ -18722,15 +18744,34 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18722
18744
|
return spaceTrim$1(`
|
|
18723
18745
|
# ${this.type}
|
|
18724
18746
|
|
|
18725
|
-
|
|
18747
|
+
Deprecated legacy commitment for writing and presentation instructions.
|
|
18748
|
+
|
|
18749
|
+
## Migration
|
|
18750
|
+
|
|
18751
|
+
- Existing \`${this.type}\` books still parse and compile.
|
|
18752
|
+
- New books should prefer \`WRITING RULES\`.
|
|
18753
|
+
- Use \`WRITING SAMPLE\` when you want to anchor voice by example instead of stating constraints directly.
|
|
18754
|
+
- The plural alias \`STYLES\` is the same legacy commitment family.
|
|
18726
18755
|
|
|
18727
18756
|
## Key aspects
|
|
18728
18757
|
|
|
18729
|
-
-
|
|
18758
|
+
- \`${this.type}\` remains functional for backward compatibility only.
|
|
18730
18759
|
- Later style instructions can override earlier ones.
|
|
18731
18760
|
- Style affects both tone and presentation format.
|
|
18732
18761
|
|
|
18733
|
-
##
|
|
18762
|
+
## Preferred replacement
|
|
18763
|
+
|
|
18764
|
+
\`\`\`book
|
|
18765
|
+
Technical Writer
|
|
18766
|
+
|
|
18767
|
+
GOAL Help the user understand technical topics with practical, accurate guidance.
|
|
18768
|
+
WRITING RULES Write in a professional but friendly tone.
|
|
18769
|
+
WRITING RULES Use bullet points for lists.
|
|
18770
|
+
WRITING RULES Always provide code examples when explaining programming concepts.
|
|
18771
|
+
FORMAT Use markdown formatting with clear headings
|
|
18772
|
+
\`\`\`
|
|
18773
|
+
|
|
18774
|
+
## Legacy compatibility examples
|
|
18734
18775
|
|
|
18735
18776
|
\`\`\`book
|
|
18736
18777
|
Technical Writer
|
|
@@ -19045,7 +19086,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
19045
19086
|
\`\`\`book
|
|
19046
19087
|
Legal Assistant
|
|
19047
19088
|
|
|
19048
|
-
|
|
19089
|
+
GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
|
|
19049
19090
|
TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
|
|
19050
19091
|
\`\`\`
|
|
19051
19092
|
`);
|
|
@@ -19471,7 +19512,7 @@ class TemplateCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
19471
19512
|
|
|
19472
19513
|
PERSONA You are a helpful customer support representative
|
|
19473
19514
|
TEMPLATE Always structure your response with: 1) Acknowledgment, 2) Solution, 3) Follow-up question
|
|
19474
|
-
|
|
19515
|
+
WRITING RULES Be professional and empathetic
|
|
19475
19516
|
\`\`\`
|
|
19476
19517
|
|
|
19477
19518
|
\`\`\`book
|
|
@@ -19915,7 +19956,7 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
19915
19956
|
|
|
19916
19957
|
PERSONA You are a news analyst who stays up-to-date with current events
|
|
19917
19958
|
USE BROWSER
|
|
19918
|
-
|
|
19959
|
+
WRITING RULES Present news in a balanced and objective manner
|
|
19919
19960
|
ACTION Can search for and summarize news articles
|
|
19920
19961
|
\`\`\`
|
|
19921
19962
|
|
|
@@ -28072,7 +28113,7 @@ function parseParameters(text) {
|
|
|
28072
28113
|
function parseAgentSource(agentSource) {
|
|
28073
28114
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
28074
28115
|
const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
28075
|
-
const personaDescription =
|
|
28116
|
+
const personaDescription = extractAgentProfileText(parseResult.commitments);
|
|
28076
28117
|
const initialMessage = extractInitialMessage(parseResult.commitments);
|
|
28077
28118
|
const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
|
|
28078
28119
|
ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
|
|
@@ -28176,25 +28217,33 @@ const META_COMMITMENT_APPLIERS = {
|
|
|
28176
28217
|
*/
|
|
28177
28218
|
const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
|
|
28178
28219
|
/**
|
|
28179
|
-
*
|
|
28220
|
+
* Resolves the public agent profile text from the last GOAL/GOALS commitment,
|
|
28221
|
+
* falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
|
|
28180
28222
|
*
|
|
28181
28223
|
* @private internal utility of `parseAgentSource`
|
|
28182
28224
|
*/
|
|
28183
|
-
function
|
|
28184
|
-
let
|
|
28225
|
+
function extractAgentProfileText(commitments) {
|
|
28226
|
+
let goalDescription = '';
|
|
28227
|
+
let hasGoalDescription = false;
|
|
28228
|
+
let personaDescription = '';
|
|
28229
|
+
let hasPersonaDescription = false;
|
|
28185
28230
|
for (const commitment of commitments) {
|
|
28186
|
-
if (commitment.type
|
|
28187
|
-
|
|
28231
|
+
if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
|
|
28232
|
+
goalDescription = commitment.content;
|
|
28233
|
+
hasGoalDescription = true;
|
|
28188
28234
|
}
|
|
28189
|
-
if (
|
|
28190
|
-
personaDescription =
|
|
28191
|
-
|
|
28192
|
-
else {
|
|
28193
|
-
personaDescription += `\n\n${personaDescription}`;
|
|
28235
|
+
if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
|
|
28236
|
+
personaDescription = commitment.content;
|
|
28237
|
+
hasPersonaDescription = true;
|
|
28194
28238
|
}
|
|
28195
|
-
personaDescription += commitment.content;
|
|
28196
28239
|
}
|
|
28197
|
-
|
|
28240
|
+
if (hasGoalDescription) {
|
|
28241
|
+
return goalDescription;
|
|
28242
|
+
}
|
|
28243
|
+
if (hasPersonaDescription) {
|
|
28244
|
+
return personaDescription;
|
|
28245
|
+
}
|
|
28246
|
+
return null;
|
|
28198
28247
|
}
|
|
28199
28248
|
/**
|
|
28200
28249
|
* Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
|
|
@@ -28876,6 +28925,15 @@ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS',
|
|
|
28876
28925
|
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
28877
28926
|
*/
|
|
28878
28927
|
const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
|
|
28928
|
+
/**
|
|
28929
|
+
* Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
|
|
28930
|
+
*
|
|
28931
|
+
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
28932
|
+
*/
|
|
28933
|
+
const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
|
|
28934
|
+
['GOAL', 'GOAL'],
|
|
28935
|
+
['GOALS', 'GOAL'],
|
|
28936
|
+
]);
|
|
28879
28937
|
/**
|
|
28880
28938
|
* Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
|
|
28881
28939
|
*
|
|
@@ -28926,7 +28984,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
|
28926
28984
|
*/
|
|
28927
28985
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
28928
28986
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
28929
|
-
const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
|
|
28987
|
+
const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
|
|
28930
28988
|
let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
|
|
28931
28989
|
requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
|
|
28932
28990
|
requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
|
|
@@ -28937,6 +28995,35 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
28937
28995
|
requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
|
|
28938
28996
|
return finalizeRequirements(requirements);
|
|
28939
28997
|
}
|
|
28998
|
+
/**
|
|
28999
|
+
* Removes earlier commitments that are overwritten by later commitments of the same semantic group.
|
|
29000
|
+
*
|
|
29001
|
+
* This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
|
|
29002
|
+
* and multi-goal sources expose one effective goal to the runtime.
|
|
29003
|
+
*
|
|
29004
|
+
* @param commitments - Parsed commitments after DELETE-like filtering.
|
|
29005
|
+
* @returns Commitments with overwritten entries removed while preserving source order.
|
|
29006
|
+
*
|
|
29007
|
+
* @private internal utility of `createAgentModelRequirementsWithCommitments`
|
|
29008
|
+
*/
|
|
29009
|
+
function filterOverwrittenCommitments(commitments) {
|
|
29010
|
+
const seenOverwriteGroups = new Set();
|
|
29011
|
+
const keptCommitments = [];
|
|
29012
|
+
for (let index = commitments.length - 1; index >= 0; index--) {
|
|
29013
|
+
const commitment = commitments[index];
|
|
29014
|
+
const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
|
|
29015
|
+
if (!overwriteGroup) {
|
|
29016
|
+
keptCommitments.push(commitment);
|
|
29017
|
+
continue;
|
|
29018
|
+
}
|
|
29019
|
+
if (seenOverwriteGroups.has(overwriteGroup)) {
|
|
29020
|
+
continue;
|
|
29021
|
+
}
|
|
29022
|
+
seenOverwriteGroups.add(overwriteGroup);
|
|
29023
|
+
keptCommitments.push(commitment);
|
|
29024
|
+
}
|
|
29025
|
+
return keptCommitments.reverse();
|
|
29026
|
+
}
|
|
28940
29027
|
/**
|
|
28941
29028
|
* Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
|
|
28942
29029
|
*
|
|
@@ -29528,7 +29615,7 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
29528
29615
|
* Selects the best model using the preparePersona function
|
|
29529
29616
|
* This directly uses preparePersona to ensure DRY principle
|
|
29530
29617
|
*
|
|
29531
|
-
* @param agentSource The agent source to derive
|
|
29618
|
+
* @param agentSource The agent source to derive effective profile text from
|
|
29532
29619
|
* @param llmTools LLM tools for preparing persona
|
|
29533
29620
|
* @returns The name of the best selected model
|
|
29534
29621
|
*
|
|
@@ -29536,9 +29623,9 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
29536
29623
|
*/
|
|
29537
29624
|
async function selectBestModelUsingPersona(agentSource, llmTools) {
|
|
29538
29625
|
var _a;
|
|
29539
|
-
// Parse agent source to get
|
|
29626
|
+
// Parse agent source to get the effective profile description
|
|
29540
29627
|
const { agentName, personaDescription } = parseAgentSource(agentSource);
|
|
29541
|
-
// Use agent name as fallback if no
|
|
29628
|
+
// Use agent name as fallback if no profile description is available
|
|
29542
29629
|
const description = personaDescription || agentName || 'AI Agent';
|
|
29543
29630
|
try {
|
|
29544
29631
|
// Use preparePersona directly
|