@promptbook/node 0.112.0-30 → 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 +137 -40
- 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 +2 -2
- package/umd/index.umd.js +137 -40
- 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
|
@@ -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-32';
|
|
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
|
|
@@ -18397,10 +18397,6 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18397
18397
|
* Prefix used for TEAM tool names.
|
|
18398
18398
|
*/
|
|
18399
18399
|
const TEAM_TOOL_PREFIX = 'team_chat_';
|
|
18400
|
-
/**
|
|
18401
|
-
* Length of URL hash suffix appended to TEAM tool names.
|
|
18402
|
-
*/
|
|
18403
|
-
const TEAM_TOOL_HASH_LENGTH = 10;
|
|
18404
18400
|
/**
|
|
18405
18401
|
* Fallback normalized name when teammate label is empty.
|
|
18406
18402
|
*/
|
|
@@ -18417,20 +18413,19 @@ function normalizeTeammateToolNamePart(teammateLabel) {
|
|
|
18417
18413
|
return normalized || TEAM_TOOL_FALLBACK_NAME;
|
|
18418
18414
|
}
|
|
18419
18415
|
/**
|
|
18420
|
-
* Builds a deterministic TEAM tool name from teammate
|
|
18416
|
+
* Builds a deterministic TEAM tool name from the teammate label.
|
|
18421
18417
|
*
|
|
18422
|
-
* The
|
|
18423
|
-
*
|
|
18418
|
+
* The tool name is derived solely from the human-readable label so that it
|
|
18419
|
+
* remains stable and predictable regardless of internal technical identifiers.
|
|
18424
18420
|
*
|
|
18425
|
-
* @param
|
|
18426
|
-
* @param teammateLabel - Human-readable teammate label.
|
|
18427
|
-
* @returns
|
|
18421
|
+
* @param _teammateUrl - Canonical teammate URL (kept for API compatibility, not used).
|
|
18422
|
+
* @param teammateLabel - Human-readable teammate label used as the basis for the name.
|
|
18423
|
+
* @returns TEAM tool name derived from the label.
|
|
18428
18424
|
* @private internal utility of TEAM commitments and chat UI mapping
|
|
18429
18425
|
*/
|
|
18430
|
-
function createTeamToolName(
|
|
18426
|
+
function createTeamToolName(_teammateUrl, teammateLabel) {
|
|
18431
18427
|
const normalizedLabel = normalizeTeammateToolNamePart(teammateLabel);
|
|
18432
|
-
|
|
18433
|
-
return `${TEAM_TOOL_PREFIX}${normalizedLabel}_${hash}`;
|
|
18428
|
+
return `${TEAM_TOOL_PREFIX}${normalizedLabel}`;
|
|
18434
18429
|
}
|
|
18435
18430
|
|
|
18436
18431
|
const urlRegex = /https?:\/\/[^\s]+/gi;
|
|
@@ -18635,7 +18630,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18635
18630
|
`);
|
|
18636
18631
|
}
|
|
18637
18632
|
applyToAgentModelRequirements(requirements, content) {
|
|
18638
|
-
var _a, _b;
|
|
18633
|
+
var _a, _b, _c;
|
|
18639
18634
|
const trimmedContent = content.trim();
|
|
18640
18635
|
if (!trimmedContent) {
|
|
18641
18636
|
return requirements;
|
|
@@ -18647,14 +18642,18 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18647
18642
|
}
|
|
18648
18643
|
const agentName = ((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.agentName) || 'Agent';
|
|
18649
18644
|
const existingTeammates = ((_b = requirements._metadata) === null || _b === void 0 ? void 0 : _b.teammates) || [];
|
|
18645
|
+
const preResolvedProfiles = (((_c = requirements._metadata) === null || _c === void 0 ? void 0 : _c.preResolvedTeammateProfiles) || {});
|
|
18650
18646
|
const resolvedTeammates = resolveTeamTeammateLabels(trimmedContent, teammates);
|
|
18651
18647
|
const teamEntries = resolvedTeammates.map((teammate) => {
|
|
18648
|
+
const profile = preResolvedProfiles[teammate.url];
|
|
18649
|
+
const resolvedLabel = (profile === null || profile === void 0 ? void 0 : profile.agentName) || teammate.label;
|
|
18652
18650
|
const existingTeammate = existingTeammates.find((entry) => entry.url === teammate.url);
|
|
18653
18651
|
return {
|
|
18654
18652
|
toolName: ((existingTeammate === null || existingTeammate === void 0 ? void 0 : existingTeammate.toolName) ||
|
|
18655
|
-
createTeamToolName(teammate.url,
|
|
18656
|
-
teammate,
|
|
18653
|
+
createTeamToolName(teammate.url, resolvedLabel)),
|
|
18654
|
+
teammate: { ...teammate, label: resolvedLabel },
|
|
18657
18655
|
agentName,
|
|
18656
|
+
description: (profile === null || profile === void 0 ? void 0 : profile.personaDescription) || null,
|
|
18658
18657
|
};
|
|
18659
18658
|
});
|
|
18660
18659
|
for (const entry of teamEntries) {
|
|
@@ -18666,9 +18665,12 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18666
18665
|
if (updatedTools.some((tool) => tool.name === entry.toolName)) {
|
|
18667
18666
|
continue;
|
|
18668
18667
|
}
|
|
18668
|
+
const toolDescription = entry.description
|
|
18669
|
+
? `Consult teammate ${entry.teammate.label}\n${entry.description}`
|
|
18670
|
+
: `Consult teammate ${entry.teammate.label}`;
|
|
18669
18671
|
updatedTools.push({
|
|
18670
18672
|
name: entry.toolName,
|
|
18671
|
-
description:
|
|
18673
|
+
description: toolDescription,
|
|
18672
18674
|
parameters: {
|
|
18673
18675
|
type: 'object',
|
|
18674
18676
|
properties: {
|
|
@@ -18697,8 +18699,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18697
18699
|
toolName: entry.toolName,
|
|
18698
18700
|
});
|
|
18699
18701
|
}
|
|
18700
|
-
const
|
|
18701
|
-
const teamSystemMessage = this.createSystemMessageSection('Teammates:', buildTeamSystemMessageBody(teamOverviewText, teamEntries));
|
|
18702
|
+
const teamSystemMessage = this.createSystemMessageSection('Teammates:', buildTeamSystemMessageBody(teamEntries));
|
|
18702
18703
|
return this.appendToSystemMessage({
|
|
18703
18704
|
...requirements,
|
|
18704
18705
|
tools: updatedTools,
|
|
@@ -18735,25 +18736,24 @@ function resolveTeamTeammateLabels(teamContent, teammates) {
|
|
|
18735
18736
|
};
|
|
18736
18737
|
});
|
|
18737
18738
|
}
|
|
18738
|
-
/**
|
|
18739
|
-
* Rewrites TEAM commitment content into a URL-free teammate overview text.
|
|
18740
|
-
*/
|
|
18741
|
-
function createTeamOverviewText(teamContent, teamEntries) {
|
|
18742
|
-
let overviewText = teamContent;
|
|
18743
|
-
for (const entry of teamEntries) {
|
|
18744
|
-
overviewText = overviewText.split(entry.teammate.url).join(entry.teammate.label);
|
|
18745
|
-
}
|
|
18746
|
-
return overviewText.trim();
|
|
18747
|
-
}
|
|
18748
18739
|
/**
|
|
18749
18740
|
* Builds the textual TEAM section body for the final system message.
|
|
18741
|
+
*
|
|
18742
|
+
* Each teammate is listed with its tool name and, when available, a one-line description.
|
|
18743
|
+
* Uses `spaceTrim` to ensure consistent whitespace and indentation.
|
|
18750
18744
|
*/
|
|
18751
|
-
function buildTeamSystemMessageBody(
|
|
18752
|
-
const
|
|
18753
|
-
|
|
18754
|
-
|
|
18755
|
-
|
|
18756
|
-
|
|
18745
|
+
function buildTeamSystemMessageBody(teamEntries) {
|
|
18746
|
+
const lines = teamEntries.map((entry, index) => {
|
|
18747
|
+
const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
|
|
18748
|
+
if (!entry.description) {
|
|
18749
|
+
return toolLine;
|
|
18750
|
+
}
|
|
18751
|
+
return spaceTrim$1(`
|
|
18752
|
+
${toolLine}
|
|
18753
|
+
${entry.description}
|
|
18754
|
+
`);
|
|
18755
|
+
});
|
|
18756
|
+
return lines.join('\n');
|
|
18757
18757
|
}
|
|
18758
18758
|
/**
|
|
18759
18759
|
* Registers tool function and title for a teammate tool.
|
|
@@ -27057,13 +27057,23 @@ function getToolCallIdentity(toolCall) {
|
|
|
27057
27057
|
*/
|
|
27058
27058
|
function mergeToolCalls(existingToolCalls, incomingToolCalls) {
|
|
27059
27059
|
if (!existingToolCalls || existingToolCalls.length === 0) {
|
|
27060
|
-
return incomingToolCalls ? [...incomingToolCalls] : [];
|
|
27060
|
+
return incomingToolCalls ? deduplicatePreparationToolCalls([...incomingToolCalls]) : [];
|
|
27061
27061
|
}
|
|
27062
27062
|
if (!incomingToolCalls || incomingToolCalls.length === 0) {
|
|
27063
27063
|
return [...existingToolCalls];
|
|
27064
27064
|
}
|
|
27065
27065
|
const mergedToolCalls = [...existingToolCalls];
|
|
27066
27066
|
for (const incomingToolCall of incomingToolCalls) {
|
|
27067
|
+
if (isAssistantPreparationToolCall(incomingToolCall)) {
|
|
27068
|
+
// A new preparation phase always replaces any previous assistant_preparation tool
|
|
27069
|
+
// call, regardless of phase argument, so only one chip is ever shown at a time.
|
|
27070
|
+
const existingPreparationIndex = mergedToolCalls.findIndex(isAssistantPreparationToolCall);
|
|
27071
|
+
if (existingPreparationIndex !== -1) {
|
|
27072
|
+
mergedToolCalls.splice(existingPreparationIndex, 1);
|
|
27073
|
+
}
|
|
27074
|
+
mergedToolCalls.push(incomingToolCall);
|
|
27075
|
+
continue;
|
|
27076
|
+
}
|
|
27067
27077
|
const incomingIdentity = getToolCallIdentity(incomingToolCall);
|
|
27068
27078
|
const existingIndex = mergedToolCalls.findIndex((existingToolCall) => getToolCallIdentity(existingToolCall) === incomingIdentity);
|
|
27069
27079
|
if (existingIndex === -1) {
|
|
@@ -27175,6 +27185,30 @@ function serializeValueForMerge(value) {
|
|
|
27175
27185
|
return String(value);
|
|
27176
27186
|
}
|
|
27177
27187
|
}
|
|
27188
|
+
/**
|
|
27189
|
+
* Ensures at most one `assistant_preparation` tool call survives in the list,
|
|
27190
|
+
* keeping the last occurrence so the most recent preparation phase is shown.
|
|
27191
|
+
*
|
|
27192
|
+
* @param toolCalls - Mutable list to deduplicate in-place.
|
|
27193
|
+
* @returns The same array after removing redundant preparation entries.
|
|
27194
|
+
* @private helper of `mergeToolCalls`
|
|
27195
|
+
*/
|
|
27196
|
+
function deduplicatePreparationToolCalls(toolCalls) {
|
|
27197
|
+
let lastPreparationIndex = -1;
|
|
27198
|
+
for (let index = toolCalls.length - 1; index >= 0; index--) {
|
|
27199
|
+
if (!isAssistantPreparationToolCall(toolCalls[index])) {
|
|
27200
|
+
continue;
|
|
27201
|
+
}
|
|
27202
|
+
if (lastPreparationIndex === -1) {
|
|
27203
|
+
lastPreparationIndex = index;
|
|
27204
|
+
}
|
|
27205
|
+
else {
|
|
27206
|
+
// Remove earlier duplicate — keep only the last (most recent) one.
|
|
27207
|
+
toolCalls.splice(index, 1);
|
|
27208
|
+
}
|
|
27209
|
+
}
|
|
27210
|
+
return toolCalls;
|
|
27211
|
+
}
|
|
27178
27212
|
|
|
27179
27213
|
/**
|
|
27180
27214
|
* Computes SHA-256 hash of the agent source
|
|
@@ -28107,7 +28141,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
|
28107
28141
|
* @private @@@
|
|
28108
28142
|
*/
|
|
28109
28143
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
28110
|
-
var _a;
|
|
28144
|
+
var _a, _b, _c;
|
|
28111
28145
|
const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
|
|
28112
28146
|
// Parse the agent source to extract commitments
|
|
28113
28147
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
@@ -28175,6 +28209,36 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
28175
28209
|
if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
|
|
28176
28210
|
continue;
|
|
28177
28211
|
}
|
|
28212
|
+
// For TEAM commitments, pre-resolve teammate profiles if a resolver is provided
|
|
28213
|
+
// and store them in metadata before the commitment is applied.
|
|
28214
|
+
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;
|
|
28215
|
+
if (commitment.type === 'TEAM' && (profileResolver === null || profileResolver === void 0 ? void 0 : profileResolver.resolveTeammateProfile)) {
|
|
28216
|
+
try {
|
|
28217
|
+
const parsedTeammates = parseTeamCommitmentContent(commitmentContent, { strict: false });
|
|
28218
|
+
const preResolved = {
|
|
28219
|
+
...(_b = requirements._metadata) === null || _b === void 0 ? void 0 : _b.preResolvedTeammateProfiles,
|
|
28220
|
+
};
|
|
28221
|
+
for (const teammate of parsedTeammates) {
|
|
28222
|
+
if (preResolved[teammate.url]) {
|
|
28223
|
+
continue;
|
|
28224
|
+
}
|
|
28225
|
+
const profile = await profileResolver.resolveTeammateProfile(teammate.url);
|
|
28226
|
+
if (profile) {
|
|
28227
|
+
preResolved[teammate.url] = profile;
|
|
28228
|
+
}
|
|
28229
|
+
}
|
|
28230
|
+
requirements = {
|
|
28231
|
+
...requirements,
|
|
28232
|
+
_metadata: {
|
|
28233
|
+
...requirements._metadata,
|
|
28234
|
+
preResolvedTeammateProfiles: preResolved,
|
|
28235
|
+
},
|
|
28236
|
+
};
|
|
28237
|
+
}
|
|
28238
|
+
catch (error) {
|
|
28239
|
+
console.warn('Failed to pre-resolve teammate profiles for TEAM commitment:', error);
|
|
28240
|
+
}
|
|
28241
|
+
}
|
|
28178
28242
|
const definition = getCommitmentDefinition(commitment.type);
|
|
28179
28243
|
if (definition) {
|
|
28180
28244
|
try {
|
|
@@ -28270,7 +28334,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
28270
28334
|
// Add example interactions to the system message
|
|
28271
28335
|
const examples = [];
|
|
28272
28336
|
// 1. Initial message as an example agent response
|
|
28273
|
-
const initialMessage = (
|
|
28337
|
+
const initialMessage = (_c = parseResult.commitments.find((c) => c.type === 'INITIAL MESSAGE')) === null || _c === void 0 ? void 0 : _c.content;
|
|
28274
28338
|
if (initialMessage) {
|
|
28275
28339
|
examples.push(`Agent: ${initialMessage}`);
|
|
28276
28340
|
}
|
|
@@ -34115,6 +34179,7 @@ class SelfLearningManager {
|
|
|
34115
34179
|
|
|
34116
34180
|
- Decide what the agent should learn from this interaction.
|
|
34117
34181
|
- Append new commitments at the end of the agent source.
|
|
34182
|
+
- Return only newly learned commitments, never repeat commitments that are already present.
|
|
34118
34183
|
- Do not modify the current agent source, just return new commitments (KNOWLEDGE, RULE, etc.).
|
|
34119
34184
|
- If there is nothing new to learn, return empty book code block
|
|
34120
34185
|
- Wrap the commitments in a book code block.
|
|
@@ -34167,10 +34232,42 @@ class SelfLearningManager {
|
|
|
34167
34232
|
*/
|
|
34168
34233
|
appendToAgentSource(section) {
|
|
34169
34234
|
const currentSource = this.options.getAgentSource();
|
|
34170
|
-
const
|
|
34235
|
+
const normalizedSection = normalizeBookSection(section);
|
|
34236
|
+
if (!normalizedSection) {
|
|
34237
|
+
return;
|
|
34238
|
+
}
|
|
34239
|
+
if (containsNormalizedBookSection(currentSource, normalizedSection)) {
|
|
34240
|
+
return;
|
|
34241
|
+
}
|
|
34242
|
+
const newSource = padBook(validateBook(`${normalizeBookSection(currentSource)}\n\n${normalizedSection}`));
|
|
34171
34243
|
this.options.updateAgentSource(newSource);
|
|
34172
34244
|
}
|
|
34173
34245
|
}
|
|
34246
|
+
/**
|
|
34247
|
+
* Normalizes one book fragment for deduplication and append composition.
|
|
34248
|
+
*
|
|
34249
|
+
* @param section Raw fragment from self-learning workflow.
|
|
34250
|
+
* @returns Trimmed fragment, or empty string when nothing remains.
|
|
34251
|
+
* @private function of Agent
|
|
34252
|
+
*/
|
|
34253
|
+
function normalizeBookSection(section) {
|
|
34254
|
+
return spaceTrim$1(section).replace(/\r\n/g, '\n');
|
|
34255
|
+
}
|
|
34256
|
+
/**
|
|
34257
|
+
* Checks whether one normalized fragment already exists inside the current source.
|
|
34258
|
+
*
|
|
34259
|
+
* @param agentSource Current source.
|
|
34260
|
+
* @param normalizedSection Candidate fragment expected to be normalized first.
|
|
34261
|
+
* @returns True when appending would duplicate an existing fragment.
|
|
34262
|
+
* @private function of Agent
|
|
34263
|
+
*/
|
|
34264
|
+
function containsNormalizedBookSection(agentSource, normalizedSection) {
|
|
34265
|
+
if (!normalizedSection) {
|
|
34266
|
+
return true;
|
|
34267
|
+
}
|
|
34268
|
+
const normalizedSource = normalizeBookSection(agentSource);
|
|
34269
|
+
return normalizedSource.includes(normalizedSection);
|
|
34270
|
+
}
|
|
34174
34271
|
/**
|
|
34175
34272
|
* Determines whether the interaction runs in OpenAI-compatible JSON schema mode.
|
|
34176
34273
|
*
|