@promptbook/core 0.112.0-31 → 0.112.0-32
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 +103 -39
- package/esm/index.es.js.map +1 -1
- package/esm/src/_packages/components.index.d.ts +6 -0
- package/esm/src/_packages/types.index.d.ts +6 -0
- package/esm/src/book-2.0/agent-source/AgentReferenceResolver.d.ts +11 -0
- package/esm/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +8 -0
- package/esm/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +33 -0
- package/esm/src/book-2.0/agent-source/createTeamToolName.d.ts +7 -7
- package/esm/src/book-components/Chat/Chat/ChatActionsBar.d.ts +5 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +17 -1
- package/esm/src/book-components/Chat/Chat/ChatMessageItem.test.d.ts +1 -1
- package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +14 -0
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +290 -0
- package/esm/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +16 -0
- package/esm/src/book-components/Chat/Chat/renderAdvancedToolCallDetails.d.ts +4 -0
- package/esm/src/book-components/Chat/Chat/renderToolCallDetails.d.ts +9 -0
- package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -1
- package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.test.d.ts +2 -0
- package/esm/src/book-components/Chat/hooks/useChatCompleteNotification.d.ts +18 -0
- package/esm/src/book-components/Chat/hooks/useChatCompleteNotification.test.d.ts +2 -0
- package/esm/src/book-components/Chat/types/ChatMessage.d.ts +77 -1
- package/esm/src/book-components/Chat/utils/formatToolCallDateTime.d.ts +37 -0
- package/esm/src/book-components/Chat/utils/formatToolCallLocalTime.d.ts +11 -0
- package/esm/src/book-components/Chat/utils/formatToolCallTranslationTemplate.d.ts +10 -0
- package/esm/src/book-components/Chat/utils/getChatMessageTimingDisplay.d.ts +5 -1
- package/esm/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +26 -1
- package/esm/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +26 -3
- package/esm/src/utils/toolCalls/mergeToolCalls.d.ts +1 -1
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +103 -39
- package/umd/index.umd.js.map +1 -1
- package/umd/src/_packages/components.index.d.ts +6 -0
- package/umd/src/_packages/types.index.d.ts +6 -0
- package/umd/src/book-2.0/agent-source/AgentReferenceResolver.d.ts +11 -0
- package/umd/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +8 -0
- package/umd/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +33 -0
- package/umd/src/book-2.0/agent-source/createTeamToolName.d.ts +7 -7
- package/umd/src/book-components/Chat/Chat/ChatActionsBar.d.ts +5 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +17 -1
- package/umd/src/book-components/Chat/Chat/ChatMessageItem.test.d.ts +1 -1
- package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +14 -0
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +290 -0
- package/umd/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +16 -0
- package/umd/src/book-components/Chat/Chat/renderAdvancedToolCallDetails.d.ts +4 -0
- package/umd/src/book-components/Chat/Chat/renderToolCallDetails.d.ts +9 -0
- package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -1
- package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.test.d.ts +2 -0
- package/umd/src/book-components/Chat/hooks/useChatCompleteNotification.d.ts +18 -0
- package/umd/src/book-components/Chat/hooks/useChatCompleteNotification.test.d.ts +2 -0
- package/umd/src/book-components/Chat/types/ChatMessage.d.ts +77 -1
- package/umd/src/book-components/Chat/utils/formatToolCallDateTime.d.ts +37 -0
- package/umd/src/book-components/Chat/utils/formatToolCallLocalTime.d.ts +11 -0
- package/umd/src/book-components/Chat/utils/formatToolCallTranslationTemplate.d.ts +10 -0
- package/umd/src/book-components/Chat/utils/getChatMessageTimingDisplay.d.ts +5 -1
- package/umd/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +26 -1
- package/umd/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +26 -3
- package/umd/src/utils/toolCalls/mergeToolCalls.d.ts +1 -1
- 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-32';
|
|
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
|
|
@@ -14673,10 +14673,6 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14673
14673
|
* Prefix used for TEAM tool names.
|
|
14674
14674
|
*/
|
|
14675
14675
|
const TEAM_TOOL_PREFIX = 'team_chat_';
|
|
14676
|
-
/**
|
|
14677
|
-
* Length of URL hash suffix appended to TEAM tool names.
|
|
14678
|
-
*/
|
|
14679
|
-
const TEAM_TOOL_HASH_LENGTH = 10;
|
|
14680
14676
|
/**
|
|
14681
14677
|
* Fallback normalized name when teammate label is empty.
|
|
14682
14678
|
*/
|
|
@@ -14693,20 +14689,19 @@ function normalizeTeammateToolNamePart(teammateLabel) {
|
|
|
14693
14689
|
return normalized || TEAM_TOOL_FALLBACK_NAME;
|
|
14694
14690
|
}
|
|
14695
14691
|
/**
|
|
14696
|
-
* Builds a deterministic TEAM tool name from teammate
|
|
14692
|
+
* Builds a deterministic TEAM tool name from the teammate label.
|
|
14697
14693
|
*
|
|
14698
|
-
* The
|
|
14699
|
-
*
|
|
14694
|
+
* The tool name is derived solely from the human-readable label so that it
|
|
14695
|
+
* remains stable and predictable regardless of internal technical identifiers.
|
|
14700
14696
|
*
|
|
14701
|
-
* @param
|
|
14702
|
-
* @param teammateLabel - Human-readable teammate label.
|
|
14703
|
-
* @returns
|
|
14697
|
+
* @param _teammateUrl - Canonical teammate URL (kept for API compatibility, not used).
|
|
14698
|
+
* @param teammateLabel - Human-readable teammate label used as the basis for the name.
|
|
14699
|
+
* @returns TEAM tool name derived from the label.
|
|
14704
14700
|
* @private internal utility of TEAM commitments and chat UI mapping
|
|
14705
14701
|
*/
|
|
14706
|
-
function createTeamToolName(
|
|
14702
|
+
function createTeamToolName(_teammateUrl, teammateLabel) {
|
|
14707
14703
|
const normalizedLabel = normalizeTeammateToolNamePart(teammateLabel);
|
|
14708
|
-
|
|
14709
|
-
return `${TEAM_TOOL_PREFIX}${normalizedLabel}_${hash}`;
|
|
14704
|
+
return `${TEAM_TOOL_PREFIX}${normalizedLabel}`;
|
|
14710
14705
|
}
|
|
14711
14706
|
|
|
14712
14707
|
const urlRegex = /https?:\/\/[^\s]+/gi;
|
|
@@ -14911,7 +14906,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14911
14906
|
`);
|
|
14912
14907
|
}
|
|
14913
14908
|
applyToAgentModelRequirements(requirements, content) {
|
|
14914
|
-
var _a, _b;
|
|
14909
|
+
var _a, _b, _c;
|
|
14915
14910
|
const trimmedContent = content.trim();
|
|
14916
14911
|
if (!trimmedContent) {
|
|
14917
14912
|
return requirements;
|
|
@@ -14923,14 +14918,18 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14923
14918
|
}
|
|
14924
14919
|
const agentName = ((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.agentName) || 'Agent';
|
|
14925
14920
|
const existingTeammates = ((_b = requirements._metadata) === null || _b === void 0 ? void 0 : _b.teammates) || [];
|
|
14921
|
+
const preResolvedProfiles = (((_c = requirements._metadata) === null || _c === void 0 ? void 0 : _c.preResolvedTeammateProfiles) || {});
|
|
14926
14922
|
const resolvedTeammates = resolveTeamTeammateLabels(trimmedContent, teammates);
|
|
14927
14923
|
const teamEntries = resolvedTeammates.map((teammate) => {
|
|
14924
|
+
const profile = preResolvedProfiles[teammate.url];
|
|
14925
|
+
const resolvedLabel = (profile === null || profile === void 0 ? void 0 : profile.agentName) || teammate.label;
|
|
14928
14926
|
const existingTeammate = existingTeammates.find((entry) => entry.url === teammate.url);
|
|
14929
14927
|
return {
|
|
14930
14928
|
toolName: ((existingTeammate === null || existingTeammate === void 0 ? void 0 : existingTeammate.toolName) ||
|
|
14931
|
-
createTeamToolName(teammate.url,
|
|
14932
|
-
teammate,
|
|
14929
|
+
createTeamToolName(teammate.url, resolvedLabel)),
|
|
14930
|
+
teammate: { ...teammate, label: resolvedLabel },
|
|
14933
14931
|
agentName,
|
|
14932
|
+
description: (profile === null || profile === void 0 ? void 0 : profile.personaDescription) || null,
|
|
14934
14933
|
};
|
|
14935
14934
|
});
|
|
14936
14935
|
for (const entry of teamEntries) {
|
|
@@ -14942,9 +14941,12 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14942
14941
|
if (updatedTools.some((tool) => tool.name === entry.toolName)) {
|
|
14943
14942
|
continue;
|
|
14944
14943
|
}
|
|
14944
|
+
const toolDescription = entry.description
|
|
14945
|
+
? `Consult teammate ${entry.teammate.label}\n${entry.description}`
|
|
14946
|
+
: `Consult teammate ${entry.teammate.label}`;
|
|
14945
14947
|
updatedTools.push({
|
|
14946
14948
|
name: entry.toolName,
|
|
14947
|
-
description:
|
|
14949
|
+
description: toolDescription,
|
|
14948
14950
|
parameters: {
|
|
14949
14951
|
type: 'object',
|
|
14950
14952
|
properties: {
|
|
@@ -14973,8 +14975,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14973
14975
|
toolName: entry.toolName,
|
|
14974
14976
|
});
|
|
14975
14977
|
}
|
|
14976
|
-
const
|
|
14977
|
-
const teamSystemMessage = this.createSystemMessageSection('Teammates:', buildTeamSystemMessageBody(teamOverviewText, teamEntries));
|
|
14978
|
+
const teamSystemMessage = this.createSystemMessageSection('Teammates:', buildTeamSystemMessageBody(teamEntries));
|
|
14978
14979
|
return this.appendToSystemMessage({
|
|
14979
14980
|
...requirements,
|
|
14980
14981
|
tools: updatedTools,
|
|
@@ -15011,25 +15012,24 @@ function resolveTeamTeammateLabels(teamContent, teammates) {
|
|
|
15011
15012
|
};
|
|
15012
15013
|
});
|
|
15013
15014
|
}
|
|
15014
|
-
/**
|
|
15015
|
-
* Rewrites TEAM commitment content into a URL-free teammate overview text.
|
|
15016
|
-
*/
|
|
15017
|
-
function createTeamOverviewText(teamContent, teamEntries) {
|
|
15018
|
-
let overviewText = teamContent;
|
|
15019
|
-
for (const entry of teamEntries) {
|
|
15020
|
-
overviewText = overviewText.split(entry.teammate.url).join(entry.teammate.label);
|
|
15021
|
-
}
|
|
15022
|
-
return overviewText.trim();
|
|
15023
|
-
}
|
|
15024
15015
|
/**
|
|
15025
15016
|
* Builds the textual TEAM section body for the final system message.
|
|
15017
|
+
*
|
|
15018
|
+
* Each teammate is listed with its tool name and, when available, a one-line description.
|
|
15019
|
+
* Uses `spaceTrim` to ensure consistent whitespace and indentation.
|
|
15026
15020
|
*/
|
|
15027
|
-
function buildTeamSystemMessageBody(
|
|
15028
|
-
const
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
|
|
15021
|
+
function buildTeamSystemMessageBody(teamEntries) {
|
|
15022
|
+
const lines = teamEntries.map((entry, index) => {
|
|
15023
|
+
const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
|
|
15024
|
+
if (!entry.description) {
|
|
15025
|
+
return toolLine;
|
|
15026
|
+
}
|
|
15027
|
+
return spaceTrim$1(`
|
|
15028
|
+
${toolLine}
|
|
15029
|
+
${entry.description}
|
|
15030
|
+
`);
|
|
15031
|
+
});
|
|
15032
|
+
return lines.join('\n');
|
|
15033
15033
|
}
|
|
15034
15034
|
/**
|
|
15035
15035
|
* Registers tool function and title for a teammate tool.
|
|
@@ -21782,7 +21782,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
|
21782
21782
|
* @private @@@
|
|
21783
21783
|
*/
|
|
21784
21784
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
21785
|
-
var _a;
|
|
21785
|
+
var _a, _b, _c;
|
|
21786
21786
|
const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
|
|
21787
21787
|
// Parse the agent source to extract commitments
|
|
21788
21788
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
@@ -21850,6 +21850,36 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
21850
21850
|
if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
|
|
21851
21851
|
continue;
|
|
21852
21852
|
}
|
|
21853
|
+
// For TEAM commitments, pre-resolve teammate profiles if a resolver is provided
|
|
21854
|
+
// and store them in metadata before the commitment is applied.
|
|
21855
|
+
const profileResolver = (_a = options === null || options === void 0 ? void 0 : options.teammateProfileResolver) !== null && _a !== void 0 ? _a : options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
|
|
21856
|
+
if (commitment.type === 'TEAM' && (profileResolver === null || profileResolver === void 0 ? void 0 : profileResolver.resolveTeammateProfile)) {
|
|
21857
|
+
try {
|
|
21858
|
+
const parsedTeammates = parseTeamCommitmentContent(commitmentContent, { strict: false });
|
|
21859
|
+
const preResolved = {
|
|
21860
|
+
...(_b = requirements._metadata) === null || _b === void 0 ? void 0 : _b.preResolvedTeammateProfiles,
|
|
21861
|
+
};
|
|
21862
|
+
for (const teammate of parsedTeammates) {
|
|
21863
|
+
if (preResolved[teammate.url]) {
|
|
21864
|
+
continue;
|
|
21865
|
+
}
|
|
21866
|
+
const profile = await profileResolver.resolveTeammateProfile(teammate.url);
|
|
21867
|
+
if (profile) {
|
|
21868
|
+
preResolved[teammate.url] = profile;
|
|
21869
|
+
}
|
|
21870
|
+
}
|
|
21871
|
+
requirements = {
|
|
21872
|
+
...requirements,
|
|
21873
|
+
_metadata: {
|
|
21874
|
+
...requirements._metadata,
|
|
21875
|
+
preResolvedTeammateProfiles: preResolved,
|
|
21876
|
+
},
|
|
21877
|
+
};
|
|
21878
|
+
}
|
|
21879
|
+
catch (error) {
|
|
21880
|
+
console.warn('Failed to pre-resolve teammate profiles for TEAM commitment:', error);
|
|
21881
|
+
}
|
|
21882
|
+
}
|
|
21853
21883
|
const definition = getCommitmentDefinition(commitment.type);
|
|
21854
21884
|
if (definition) {
|
|
21855
21885
|
try {
|
|
@@ -21945,7 +21975,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
21945
21975
|
// Add example interactions to the system message
|
|
21946
21976
|
const examples = [];
|
|
21947
21977
|
// 1. Initial message as an example agent response
|
|
21948
|
-
const initialMessage = (
|
|
21978
|
+
const initialMessage = (_c = parseResult.commitments.find((c) => c.type === 'INITIAL MESSAGE')) === null || _c === void 0 ? void 0 : _c.content;
|
|
21949
21979
|
if (initialMessage) {
|
|
21950
21980
|
examples.push(`Agent: ${initialMessage}`);
|
|
21951
21981
|
}
|
|
@@ -34517,13 +34547,23 @@ function getToolCallIdentity(toolCall) {
|
|
|
34517
34547
|
*/
|
|
34518
34548
|
function mergeToolCalls(existingToolCalls, incomingToolCalls) {
|
|
34519
34549
|
if (!existingToolCalls || existingToolCalls.length === 0) {
|
|
34520
|
-
return incomingToolCalls ? [...incomingToolCalls] : [];
|
|
34550
|
+
return incomingToolCalls ? deduplicatePreparationToolCalls([...incomingToolCalls]) : [];
|
|
34521
34551
|
}
|
|
34522
34552
|
if (!incomingToolCalls || incomingToolCalls.length === 0) {
|
|
34523
34553
|
return [...existingToolCalls];
|
|
34524
34554
|
}
|
|
34525
34555
|
const mergedToolCalls = [...existingToolCalls];
|
|
34526
34556
|
for (const incomingToolCall of incomingToolCalls) {
|
|
34557
|
+
if (isAssistantPreparationToolCall(incomingToolCall)) {
|
|
34558
|
+
// A new preparation phase always replaces any previous assistant_preparation tool
|
|
34559
|
+
// call, regardless of phase argument, so only one chip is ever shown at a time.
|
|
34560
|
+
const existingPreparationIndex = mergedToolCalls.findIndex(isAssistantPreparationToolCall);
|
|
34561
|
+
if (existingPreparationIndex !== -1) {
|
|
34562
|
+
mergedToolCalls.splice(existingPreparationIndex, 1);
|
|
34563
|
+
}
|
|
34564
|
+
mergedToolCalls.push(incomingToolCall);
|
|
34565
|
+
continue;
|
|
34566
|
+
}
|
|
34527
34567
|
const incomingIdentity = getToolCallIdentity(incomingToolCall);
|
|
34528
34568
|
const existingIndex = mergedToolCalls.findIndex((existingToolCall) => getToolCallIdentity(existingToolCall) === incomingIdentity);
|
|
34529
34569
|
if (existingIndex === -1) {
|
|
@@ -34635,6 +34675,30 @@ function serializeValueForMerge(value) {
|
|
|
34635
34675
|
return String(value);
|
|
34636
34676
|
}
|
|
34637
34677
|
}
|
|
34678
|
+
/**
|
|
34679
|
+
* Ensures at most one `assistant_preparation` tool call survives in the list,
|
|
34680
|
+
* keeping the last occurrence so the most recent preparation phase is shown.
|
|
34681
|
+
*
|
|
34682
|
+
* @param toolCalls - Mutable list to deduplicate in-place.
|
|
34683
|
+
* @returns The same array after removing redundant preparation entries.
|
|
34684
|
+
* @private helper of `mergeToolCalls`
|
|
34685
|
+
*/
|
|
34686
|
+
function deduplicatePreparationToolCalls(toolCalls) {
|
|
34687
|
+
let lastPreparationIndex = -1;
|
|
34688
|
+
for (let index = toolCalls.length - 1; index >= 0; index--) {
|
|
34689
|
+
if (!isAssistantPreparationToolCall(toolCalls[index])) {
|
|
34690
|
+
continue;
|
|
34691
|
+
}
|
|
34692
|
+
if (lastPreparationIndex === -1) {
|
|
34693
|
+
lastPreparationIndex = index;
|
|
34694
|
+
}
|
|
34695
|
+
else {
|
|
34696
|
+
// Remove earlier duplicate — keep only the last (most recent) one.
|
|
34697
|
+
toolCalls.splice(index, 1);
|
|
34698
|
+
}
|
|
34699
|
+
}
|
|
34700
|
+
return toolCalls;
|
|
34701
|
+
}
|
|
34638
34702
|
|
|
34639
34703
|
/**
|
|
34640
34704
|
* Parses one failed remote agent response into a structured error.
|