@promptbook/components 0.112.0-42 → 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/README.md +10 -3
- package/esm/index.es.js +209 -59
- 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/book-components/Chat/Chat/ChatProps.d.ts +1 -1
- package/esm/src/cli/cli-commands/coder/getTypescriptModule.d.ts +19 -0
- package/esm/src/cli/cli-commands/coder/getTypescriptModule.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/coder/mergeStringRecordJsonFile.test.d.ts +1 -0
- package/esm/src/commitments/PERSONA/PERSONA.d.ts +7 -0
- package/esm/src/llm-providers/agent/Agent.test.d.ts +1 -0
- package/esm/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +4 -0
- package/esm/src/llm-providers/agent/AgentOptions.d.ts +8 -0
- package/esm/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +209 -59
- 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/book-components/Chat/Chat/ChatProps.d.ts +1 -1
- package/umd/src/cli/cli-commands/coder/getTypescriptModule.d.ts +19 -0
- package/umd/src/cli/cli-commands/coder/getTypescriptModule.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/coder/mergeStringRecordJsonFile.test.d.ts +1 -0
- package/umd/src/commitments/PERSONA/PERSONA.d.ts +7 -0
- package/umd/src/llm-providers/agent/Agent.test.d.ts +1 -0
- package/umd/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +4 -0
- package/umd/src/llm-providers/agent/AgentOptions.d.ts +8 -0
- package/umd/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
- package/umd/src/version.d.ts +1 -1
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
|
|
@@ -10790,6 +10803,15 @@
|
|
|
10790
10803
|
* Map of team tool titles.
|
|
10791
10804
|
*/
|
|
10792
10805
|
const teamToolTitles = {};
|
|
10806
|
+
/**
|
|
10807
|
+
* Shared TEAM usage rules appended ahead of teammate listings.
|
|
10808
|
+
*
|
|
10809
|
+
* @private
|
|
10810
|
+
*/
|
|
10811
|
+
const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
|
|
10812
|
+
'- If a teammate is relevant to the request, consult that teammate using the matching tool.',
|
|
10813
|
+
'- Do not ask the user for information that a listed teammate can provide directly.',
|
|
10814
|
+
];
|
|
10793
10815
|
/**
|
|
10794
10816
|
* Constant for remote agents by Url.
|
|
10795
10817
|
*/
|
|
@@ -10838,7 +10860,7 @@
|
|
|
10838
10860
|
\`\`\`book
|
|
10839
10861
|
Legal Assistant
|
|
10840
10862
|
|
|
10841
|
-
|
|
10863
|
+
GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
|
|
10842
10864
|
TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
|
|
10843
10865
|
\`\`\`
|
|
10844
10866
|
`);
|
|
@@ -10879,12 +10901,9 @@
|
|
|
10879
10901
|
if (updatedTools.some((tool) => tool.name === entry.toolName)) {
|
|
10880
10902
|
continue;
|
|
10881
10903
|
}
|
|
10882
|
-
const toolDescription = entry.description
|
|
10883
|
-
? `Consult teammate ${entry.teammate.label}\n${entry.description}`
|
|
10884
|
-
: `Consult teammate ${entry.teammate.label}`;
|
|
10885
10904
|
updatedTools.push({
|
|
10886
10905
|
name: entry.toolName,
|
|
10887
|
-
description:
|
|
10906
|
+
description: buildTeamToolDescription(entry),
|
|
10888
10907
|
parameters: {
|
|
10889
10908
|
type: 'object',
|
|
10890
10909
|
properties: {
|
|
@@ -10953,22 +10972,72 @@
|
|
|
10953
10972
|
/**
|
|
10954
10973
|
* Builds the textual TEAM section body for the final system message.
|
|
10955
10974
|
*
|
|
10956
|
-
* Each teammate is listed with its tool name
|
|
10957
|
-
* Uses `spaceTrim` to ensure consistent whitespace and indentation.
|
|
10975
|
+
* Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
|
|
10958
10976
|
*/
|
|
10959
10977
|
function buildTeamSystemMessageBody(teamEntries) {
|
|
10960
|
-
const lines =
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
});
|
|
10978
|
+
const lines = [
|
|
10979
|
+
...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
|
|
10980
|
+
'',
|
|
10981
|
+
...teamEntries.map((entry, index) => {
|
|
10982
|
+
const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
|
|
10983
|
+
const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
|
|
10984
|
+
return [toolLine, ...detailLines].join('\n');
|
|
10985
|
+
}),
|
|
10986
|
+
];
|
|
10970
10987
|
return lines.join('\n');
|
|
10971
10988
|
}
|
|
10989
|
+
/**
|
|
10990
|
+
* Builds the model-visible description for one teammate tool.
|
|
10991
|
+
*
|
|
10992
|
+
* @private
|
|
10993
|
+
*/
|
|
10994
|
+
function buildTeamToolDescription(entry) {
|
|
10995
|
+
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
10996
|
+
return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
|
|
10997
|
+
}
|
|
10998
|
+
/**
|
|
10999
|
+
* Collects structured teammate details that should stay visible to the model.
|
|
11000
|
+
*
|
|
11001
|
+
* @private
|
|
11002
|
+
*/
|
|
11003
|
+
function collectTeamEntryDetails(entry) {
|
|
11004
|
+
var _a;
|
|
11005
|
+
const details = [];
|
|
11006
|
+
const instructions = entry.teammate.instructions.trim();
|
|
11007
|
+
const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
11008
|
+
if (instructions) {
|
|
11009
|
+
details.push({
|
|
11010
|
+
label: 'TEAM instructions',
|
|
11011
|
+
content: instructions,
|
|
11012
|
+
});
|
|
11013
|
+
}
|
|
11014
|
+
if (description) {
|
|
11015
|
+
details.push({
|
|
11016
|
+
label: 'Profile',
|
|
11017
|
+
content: description,
|
|
11018
|
+
});
|
|
11019
|
+
}
|
|
11020
|
+
return details;
|
|
11021
|
+
}
|
|
11022
|
+
/**
|
|
11023
|
+
* Formats one teammate detail line for the TEAM system-message section.
|
|
11024
|
+
*
|
|
11025
|
+
* @private
|
|
11026
|
+
*/
|
|
11027
|
+
function formatTeamEntryDetailLine(detail) {
|
|
11028
|
+
return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
|
|
11029
|
+
}
|
|
11030
|
+
/**
|
|
11031
|
+
* Indents all lines of one potentially multi-line text block.
|
|
11032
|
+
*
|
|
11033
|
+
* @private
|
|
11034
|
+
*/
|
|
11035
|
+
function indentMultilineText(text, prefix) {
|
|
11036
|
+
return text
|
|
11037
|
+
.split('\n')
|
|
11038
|
+
.map((line) => `${prefix}${line}`)
|
|
11039
|
+
.join('\n');
|
|
11040
|
+
}
|
|
10972
11041
|
/**
|
|
10973
11042
|
* Registers tool function and title for a teammate tool.
|
|
10974
11043
|
*/
|
|
@@ -17380,7 +17449,7 @@
|
|
|
17380
17449
|
function parseAgentSource(agentSource) {
|
|
17381
17450
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
17382
17451
|
const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
17383
|
-
const personaDescription =
|
|
17452
|
+
const personaDescription = extractAgentProfileText(parseResult.commitments);
|
|
17384
17453
|
const initialMessage = extractInitialMessage(parseResult.commitments);
|
|
17385
17454
|
const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
|
|
17386
17455
|
ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
|
|
@@ -17484,25 +17553,33 @@
|
|
|
17484
17553
|
*/
|
|
17485
17554
|
const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
|
|
17486
17555
|
/**
|
|
17487
|
-
*
|
|
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.
|
|
17488
17558
|
*
|
|
17489
17559
|
* @private internal utility of `parseAgentSource`
|
|
17490
17560
|
*/
|
|
17491
|
-
function
|
|
17492
|
-
let
|
|
17561
|
+
function extractAgentProfileText(commitments) {
|
|
17562
|
+
let goalDescription = '';
|
|
17563
|
+
let hasGoalDescription = false;
|
|
17564
|
+
let personaDescription = '';
|
|
17565
|
+
let hasPersonaDescription = false;
|
|
17493
17566
|
for (const commitment of commitments) {
|
|
17494
|
-
if (commitment.type
|
|
17495
|
-
|
|
17567
|
+
if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
|
|
17568
|
+
goalDescription = commitment.content;
|
|
17569
|
+
hasGoalDescription = true;
|
|
17496
17570
|
}
|
|
17497
|
-
if (
|
|
17498
|
-
personaDescription =
|
|
17571
|
+
if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
|
|
17572
|
+
personaDescription = commitment.content;
|
|
17573
|
+
hasPersonaDescription = true;
|
|
17499
17574
|
}
|
|
17500
|
-
else {
|
|
17501
|
-
personaDescription += `\n\n${personaDescription}`;
|
|
17502
|
-
}
|
|
17503
|
-
personaDescription += commitment.content;
|
|
17504
17575
|
}
|
|
17505
|
-
|
|
17576
|
+
if (hasGoalDescription) {
|
|
17577
|
+
return goalDescription;
|
|
17578
|
+
}
|
|
17579
|
+
if (hasPersonaDescription) {
|
|
17580
|
+
return personaDescription;
|
|
17581
|
+
}
|
|
17582
|
+
return null;
|
|
17506
17583
|
}
|
|
17507
17584
|
/**
|
|
17508
17585
|
* Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
|
|
@@ -30906,7 +30983,7 @@
|
|
|
30906
30983
|
systemMessage: '',
|
|
30907
30984
|
promptSuffix: '',
|
|
30908
30985
|
// modelName: 'gpt-5',
|
|
30909
|
-
modelName: '
|
|
30986
|
+
modelName: 'gpt-5.4-mini',
|
|
30910
30987
|
temperature: 0.7,
|
|
30911
30988
|
topP: 0.9,
|
|
30912
30989
|
topK: 50,
|
|
@@ -31055,6 +31132,15 @@
|
|
|
31055
31132
|
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
31056
31133
|
*/
|
|
31057
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
|
+
]);
|
|
31058
31144
|
/**
|
|
31059
31145
|
* Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
|
|
31060
31146
|
*
|
|
@@ -31105,7 +31191,7 @@
|
|
|
31105
31191
|
*/
|
|
31106
31192
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
31107
31193
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
31108
|
-
const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
|
|
31194
|
+
const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
|
|
31109
31195
|
let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
|
|
31110
31196
|
requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
|
|
31111
31197
|
requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
|
|
@@ -31116,6 +31202,35 @@
|
|
|
31116
31202
|
requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
|
|
31117
31203
|
return finalizeRequirements(requirements);
|
|
31118
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
|
+
}
|
|
31119
31234
|
/**
|
|
31120
31235
|
* Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
|
|
31121
31236
|
*
|
|
@@ -31707,7 +31822,7 @@
|
|
|
31707
31822
|
* Selects the best model using the preparePersona function
|
|
31708
31823
|
* This directly uses preparePersona to ensure DRY principle
|
|
31709
31824
|
*
|
|
31710
|
-
* @param agentSource The agent source to derive
|
|
31825
|
+
* @param agentSource The agent source to derive effective profile text from
|
|
31711
31826
|
* @param llmTools LLM tools for preparing persona
|
|
31712
31827
|
* @returns The name of the best selected model
|
|
31713
31828
|
*
|
|
@@ -31715,9 +31830,9 @@
|
|
|
31715
31830
|
*/
|
|
31716
31831
|
async function selectBestModelUsingPersona(agentSource, llmTools) {
|
|
31717
31832
|
var _a;
|
|
31718
|
-
// Parse agent source to get
|
|
31833
|
+
// Parse agent source to get the effective profile description
|
|
31719
31834
|
const { agentName, personaDescription } = parseAgentSource(agentSource);
|
|
31720
|
-
// Use agent name as fallback if no
|
|
31835
|
+
// Use agent name as fallback if no profile description is available
|
|
31721
31836
|
const description = personaDescription || agentName || 'AI Agent';
|
|
31722
31837
|
try {
|
|
31723
31838
|
// Use preparePersona directly
|
|
@@ -35777,7 +35892,7 @@
|
|
|
35777
35892
|
/**
|
|
35778
35893
|
* Constant for default agent kit model name.
|
|
35779
35894
|
*/
|
|
35780
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-
|
|
35895
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
|
|
35781
35896
|
/**
|
|
35782
35897
|
* Creates one structured log entry for streamed tool-call updates.
|
|
35783
35898
|
*
|
|
@@ -37843,6 +37958,7 @@
|
|
|
37843
37958
|
* @param agentSource The agent source string that defines the agent's behavior
|
|
37844
37959
|
*/
|
|
37845
37960
|
constructor(options) {
|
|
37961
|
+
var _a;
|
|
37846
37962
|
this.options = options;
|
|
37847
37963
|
/**
|
|
37848
37964
|
* Cached model requirements to avoid re-parsing the agent source
|
|
@@ -37852,6 +37968,7 @@
|
|
|
37852
37968
|
* Cached parsed agent information
|
|
37853
37969
|
*/
|
|
37854
37970
|
this._cachedAgentInfo = null;
|
|
37971
|
+
this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
|
|
37855
37972
|
}
|
|
37856
37973
|
/**
|
|
37857
37974
|
* Updates the agent source and clears the cache
|
|
@@ -37859,9 +37976,13 @@
|
|
|
37859
37976
|
* @param agentSource The new agent source string
|
|
37860
37977
|
*/
|
|
37861
37978
|
updateAgentSource(agentSource) {
|
|
37979
|
+
if (this.options.agentSource === agentSource) {
|
|
37980
|
+
return;
|
|
37981
|
+
}
|
|
37862
37982
|
this.options.agentSource = agentSource;
|
|
37863
37983
|
this._cachedAgentInfo = null;
|
|
37864
37984
|
this._cachedModelRequirements = null;
|
|
37985
|
+
this.precomputedModelRequirements = null;
|
|
37865
37986
|
}
|
|
37866
37987
|
/**
|
|
37867
37988
|
* Get cached or parse agent information
|
|
@@ -37878,6 +37999,16 @@
|
|
|
37878
37999
|
* Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
|
|
37879
38000
|
*/
|
|
37880
38001
|
async getModelRequirements() {
|
|
38002
|
+
var _a, _b;
|
|
38003
|
+
if (this.precomputedModelRequirements !== null) {
|
|
38004
|
+
if (this.options.isVerbose) {
|
|
38005
|
+
console.info('[🤰]', 'Using precomputed agent model requirements', {
|
|
38006
|
+
agent: this.title,
|
|
38007
|
+
toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
38008
|
+
});
|
|
38009
|
+
}
|
|
38010
|
+
return this.precomputedModelRequirements;
|
|
38011
|
+
}
|
|
37881
38012
|
if (this._cachedModelRequirements === null) {
|
|
37882
38013
|
const preparationStartedAtMs = Date.now();
|
|
37883
38014
|
if (this.options.isVerbose) {
|
|
@@ -37987,6 +38118,7 @@
|
|
|
37987
38118
|
* Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
|
|
37988
38119
|
*/
|
|
37989
38120
|
async prepareChatPrompt(prompt) {
|
|
38121
|
+
var _a;
|
|
37990
38122
|
const chatPrompt = this.requireChatPrompt(prompt);
|
|
37991
38123
|
const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
|
|
37992
38124
|
const attachments = normalizeChatAttachments(chatPrompt.attachments);
|
|
@@ -38004,7 +38136,16 @@
|
|
|
38004
38136
|
mergedTools,
|
|
38005
38137
|
knowledgeSourcesForAgent,
|
|
38006
38138
|
});
|
|
38007
|
-
|
|
38139
|
+
if (this.options.isVerbose) {
|
|
38140
|
+
console.info('[🤰]', 'Prepared agent chat prompt', {
|
|
38141
|
+
agent: this.title,
|
|
38142
|
+
usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
|
|
38143
|
+
toolNames: mergedTools.map((tool) => tool.name),
|
|
38144
|
+
knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
|
|
38145
|
+
promptSuffixLength: promptSuffix.length,
|
|
38146
|
+
systemMessageLength: sanitizedRequirements.systemMessage.length,
|
|
38147
|
+
});
|
|
38148
|
+
}
|
|
38008
38149
|
return {
|
|
38009
38150
|
forwardedPrompt,
|
|
38010
38151
|
sanitizedRequirements,
|
|
@@ -38191,6 +38332,7 @@
|
|
|
38191
38332
|
* Runs one prepared prompt through the deprecated OpenAI Assistant backend.
|
|
38192
38333
|
*/
|
|
38193
38334
|
async callOpenAiAssistantChatModelStream(options) {
|
|
38335
|
+
var _a, _b, _c, _d;
|
|
38194
38336
|
const assistant = await this.getOrPrepareOpenAiAssistant({
|
|
38195
38337
|
llmTools: options.llmTools,
|
|
38196
38338
|
originalPrompt: options.originalPrompt,
|
|
@@ -38198,7 +38340,14 @@
|
|
|
38198
38340
|
onProgress: options.onProgress,
|
|
38199
38341
|
});
|
|
38200
38342
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
|
|
38201
|
-
|
|
38343
|
+
if (this.options.isVerbose) {
|
|
38344
|
+
console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
|
|
38345
|
+
agent: this.title,
|
|
38346
|
+
toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
|
|
38347
|
+
knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
|
|
38348
|
+
.knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
38349
|
+
});
|
|
38350
|
+
}
|
|
38202
38351
|
return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
|
|
38203
38352
|
}
|
|
38204
38353
|
/**
|
|
@@ -38889,7 +39038,8 @@
|
|
|
38889
39038
|
isVerbose: options.isVerbose,
|
|
38890
39039
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
38891
39040
|
assistantPreparationMode: options.assistantPreparationMode,
|
|
38892
|
-
agentSource: agentSource.value,
|
|
39041
|
+
agentSource: agentSource.value,
|
|
39042
|
+
precomputedModelRequirements: options.precomputedModelRequirements,
|
|
38893
39043
|
});
|
|
38894
39044
|
this._agentName = undefined;
|
|
38895
39045
|
/**
|
|
@@ -43152,7 +43302,7 @@
|
|
|
43152
43302
|
// <- TODO: [🧠] Should we wrap more components in `React.memo`
|
|
43153
43303
|
// Or make normal function from this?
|
|
43154
43304
|
(props) => {
|
|
43155
|
-
const { message, participant, participants, isLastMessage, onMessage, onActionButton, onQuickMessageButton, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, feedbackMode = 'stars', feedbackTranslations, timingTranslations, chatLocale, onCopy, onCreateAgent, toolTitles, teammates, onReplyToMessage, canReplyToMessage, teamAgentProfiles, CHAT_VISUAL_MODE = '
|
|
43305
|
+
const { message, participant, participants, isLastMessage, onMessage, onActionButton, onQuickMessageButton, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, feedbackMode = 'stars', feedbackTranslations, timingTranslations, chatLocale, onCopy, onCreateAgent, toolTitles, teammates, onReplyToMessage, canReplyToMessage, teamAgentProfiles, CHAT_VISUAL_MODE = 'ARTICLE_MODE', onToolCallClick, onCitationClick, soundSystem, isSpeechPlaybackEnabled, elevenLabsVoiceId, chatUiTranslations, } = props;
|
|
43156
43306
|
const { isComplete = true,
|
|
43157
43307
|
// <- TODO: Destruct all `messages` properties like `isComplete`
|
|
43158
43308
|
} = message;
|
|
@@ -46952,7 +47102,7 @@
|
|
|
46952
47102
|
* @public exported from `@promptbook/components`
|
|
46953
47103
|
*/
|
|
46954
47104
|
function Chat(props) {
|
|
46955
|
-
const { title = 'Chat', messages, onChange, onMessage, onActionButton, onQuickMessageButton, onReplyToMessage, onCancelReply, onReset, resetRequiresConfirmation = true, newChatButtonHref, onFeedback, feedbackMode = 'stars', feedbackTranslations, timingTranslations, onFileUpload, chatLocale, speechRecognition, placeholderMessageContent, defaultMessage, enterBehavior, resolveEnterBehavior, children, className, style, isAiTextHumanizedAndPromptbookified = true, isVoiceCalling = false, isFocusedOnLoad, participants = [], canReplyToMessage, replyingToMessage, extraActions, actionsContainer, saveFormats, isSaveButtonEnabled = true, isCopyButtonEnabled = true, buttonColor: buttonColorRaw, onUseTemplate, onCreateAgent, toolTitles, teammates, teamAgentProfiles, visual, CHAT_VISUAL_MODE = '
|
|
47105
|
+
const { title = 'Chat', messages, onChange, onMessage, onActionButton, onQuickMessageButton, onReplyToMessage, onCancelReply, onReset, resetRequiresConfirmation = true, newChatButtonHref, onFeedback, feedbackMode = 'stars', feedbackTranslations, timingTranslations, onFileUpload, chatLocale, speechRecognition, placeholderMessageContent, defaultMessage, enterBehavior, resolveEnterBehavior, children, className, style, isAiTextHumanizedAndPromptbookified = true, isVoiceCalling = false, isFocusedOnLoad, participants = [], canReplyToMessage, replyingToMessage, extraActions, actionsContainer, saveFormats, isSaveButtonEnabled = true, isCopyButtonEnabled = true, buttonColor: buttonColorRaw, onUseTemplate, onCreateAgent, toolTitles, teammates, teamAgentProfiles, visual, CHAT_VISUAL_MODE = 'ARTICLE_MODE', effectConfigs, soundSystem, speechRecognitionLanguage, isSpeechPlaybackEnabled = true, elevenLabsVoiceId, chatUiTranslations, } = props;
|
|
46956
47106
|
const buttonColor = react.useMemo(() => Color.from(buttonColorRaw || '#0066cc'), [buttonColorRaw]);
|
|
46957
47107
|
const agentParticipant = react.useMemo(() => participants.find((participant) => participant.name === 'AGENT'), [participants]);
|
|
46958
47108
|
const postprocessedMessages = useChatPostprocessedMessages({
|