@promptbook/browser 0.110.0-9 → 0.110.0
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 +0 -4
- package/esm/index.es.js +56 -11
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +6 -0
- package/esm/typings/src/book-2.0/agent-source/AgentReferenceResolver.d.ts +18 -0
- package/esm/typings/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +12 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +8 -2
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.agentReferenceResolver.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts +4 -5
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +42 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatActionsBar.d.ts +0 -2
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +11 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +12 -0
- package/esm/typings/src/book-components/Chat/hooks/useChatRatings.d.ts +24 -2
- package/esm/typings/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +2 -10
- package/esm/typings/src/book-components/Chat/utils/parseCitationMarker.d.ts +75 -0
- package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +3 -1
- package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.test.d.ts +1 -0
- package/esm/typings/src/book-components/icons/ArrowIcon.d.ts +17 -4
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +56 -11
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -27,10 +27,6 @@ Turn your company's scattered knowledge into AI ready Books
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
<blockquote style="color: #ff8811">
|
|
31
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
32
|
-
</blockquote>
|
|
33
|
-
|
|
34
30
|
## 📦 Package `@promptbook/browser`
|
|
35
31
|
|
|
36
32
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
29
29
|
* @generated
|
|
30
30
|
* @see https://github.com/webgptorg/promptbook
|
|
31
31
|
*/
|
|
32
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.110.0
|
|
32
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0';
|
|
33
33
|
/**
|
|
34
34
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
35
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -8597,7 +8597,8 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8597
8597
|
if (!trimmedContent) {
|
|
8598
8598
|
return requirements;
|
|
8599
8599
|
}
|
|
8600
|
-
|
|
8600
|
+
// Keep TEAM resilient: unresolved/malformed teammate entries are skipped, valid ones are still registered.
|
|
8601
|
+
const teammates = parseTeamCommitmentContent(trimmedContent, { strict: false });
|
|
8601
8602
|
if (teammates.length === 0) {
|
|
8602
8603
|
return requirements;
|
|
8603
8604
|
}
|
|
@@ -15955,14 +15956,42 @@ function removeCommentsFromSystemMessage(systemMessage) {
|
|
|
15955
15956
|
}
|
|
15956
15957
|
|
|
15957
15958
|
/**
|
|
15958
|
-
* Creates agent model requirements using the new commitment system
|
|
15959
|
+
* Creates agent model requirements using the new commitment system.
|
|
15960
|
+
*
|
|
15959
15961
|
* This function uses a reduce-like pattern where each commitment applies its changes
|
|
15960
|
-
* to build the final requirements starting from a basic empty model
|
|
15962
|
+
* to build the final requirements starting from a basic empty model.
|
|
15961
15963
|
*
|
|
15962
|
-
* @
|
|
15964
|
+
* @param agentSource - Agent source book to parse.
|
|
15965
|
+
* @param modelName - Optional override for the agent model name.
|
|
15966
|
+
* @param options - Additional options such as the agent reference resolver.
|
|
15967
|
+
*
|
|
15968
|
+
* @private @@@
|
|
15969
|
+
*/
|
|
15970
|
+
const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS', 'TEAM']);
|
|
15971
|
+
/**
|
|
15972
|
+
* Returns a safe fallback content when a resolver fails to transform a reference commitment.
|
|
15973
|
+
*
|
|
15974
|
+
* @param commitmentType - Commitment being resolved.
|
|
15975
|
+
* @param originalContent - Original unresolved commitment content.
|
|
15976
|
+
* @returns Fallback content that keeps requirement creation resilient.
|
|
15963
15977
|
*/
|
|
15964
|
-
|
|
15978
|
+
function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
15979
|
+
if (commitmentType === 'FROM') {
|
|
15980
|
+
return 'VOID';
|
|
15981
|
+
}
|
|
15982
|
+
if (commitmentType === 'IMPORT' || commitmentType === 'IMPORTS' || commitmentType === 'TEAM') {
|
|
15983
|
+
return '';
|
|
15984
|
+
}
|
|
15985
|
+
return originalContent;
|
|
15986
|
+
}
|
|
15987
|
+
/**
|
|
15988
|
+
* @@@
|
|
15989
|
+
*
|
|
15990
|
+
* @private @@@
|
|
15991
|
+
*/
|
|
15992
|
+
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
15965
15993
|
var _a;
|
|
15994
|
+
const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
|
|
15966
15995
|
// Parse the agent source to extract commitments
|
|
15967
15996
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
15968
15997
|
// Apply DELETE filtering: remove prior commitments tagged by parameters targeted by DELETE/CANCEL/DISCARD/REMOVE
|
|
@@ -16014,6 +16043,17 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
16014
16043
|
// Apply each commitment in order using reduce-like pattern
|
|
16015
16044
|
for (let i = 0; i < filteredCommitments.length; i++) {
|
|
16016
16045
|
const commitment = filteredCommitments[i];
|
|
16046
|
+
const isReferenceCommitment = Boolean(agentReferenceResolver && COMMITMENTS_WITH_AGENT_REFERENCES.has(commitment.type));
|
|
16047
|
+
let commitmentContent = commitment.content;
|
|
16048
|
+
if (isReferenceCommitment && agentReferenceResolver) {
|
|
16049
|
+
try {
|
|
16050
|
+
commitmentContent = await agentReferenceResolver.resolveCommitmentContent(commitment.type, commitment.content);
|
|
16051
|
+
}
|
|
16052
|
+
catch (error) {
|
|
16053
|
+
console.warn(`Failed to resolve commitment references for ${commitment.type}, falling back to safe defaults:`, error);
|
|
16054
|
+
commitmentContent = getSafeReferenceCommitmentFallback(commitment.type, commitment.content);
|
|
16055
|
+
}
|
|
16056
|
+
}
|
|
16017
16057
|
// CLOSED commitment should work only if its the last commitment in the book
|
|
16018
16058
|
if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
|
|
16019
16059
|
continue;
|
|
@@ -16021,7 +16061,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
16021
16061
|
const definition = getCommitmentDefinition(commitment.type);
|
|
16022
16062
|
if (definition) {
|
|
16023
16063
|
try {
|
|
16024
|
-
requirements = definition.applyToAgentModelRequirements(requirements,
|
|
16064
|
+
requirements = definition.applyToAgentModelRequirements(requirements, commitmentContent);
|
|
16025
16065
|
}
|
|
16026
16066
|
catch (error) {
|
|
16027
16067
|
console.warn(`Failed to apply commitment ${commitment.type}:`, error);
|
|
@@ -16169,23 +16209,28 @@ function isBinaryMimeType(mimeType) {
|
|
|
16169
16209
|
}
|
|
16170
16210
|
|
|
16171
16211
|
/**
|
|
16172
|
-
* Creates model requirements for an agent based on its source
|
|
16212
|
+
* Creates model requirements for an agent based on its source.
|
|
16173
16213
|
*
|
|
16174
16214
|
* There are 2 similar functions:
|
|
16175
16215
|
* - `parseAgentSource` which is a lightweight parser for agent source, it parses basic information and its purpose is to be quick and synchronous. The commitments there are hardcoded.
|
|
16176
16216
|
* - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronous.
|
|
16177
16217
|
*
|
|
16218
|
+
* @param agentSource - Book describing the agent.
|
|
16219
|
+
* @param modelName - Optional override for the agent's model.
|
|
16220
|
+
* @param availableModels - Models that could fulfill the agent.
|
|
16221
|
+
* @param llmTools - Execution tools used when selecting a best model.
|
|
16222
|
+
* @param options - Optional hooks such as the agent reference resolver.
|
|
16178
16223
|
* @public exported from `@promptbook/core`
|
|
16179
16224
|
*/
|
|
16180
|
-
async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools) {
|
|
16225
|
+
async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools, options) {
|
|
16181
16226
|
// If availableModels are provided and no specific modelName is given,
|
|
16182
16227
|
// use preparePersona to select the best model
|
|
16183
16228
|
if (availableModels && !modelName && llmTools) {
|
|
16184
16229
|
const selectedModelName = await selectBestModelUsingPersona(agentSource, llmTools);
|
|
16185
|
-
return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName);
|
|
16230
|
+
return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName, options);
|
|
16186
16231
|
}
|
|
16187
16232
|
// Use the new commitment-based system with provided or default model
|
|
16188
|
-
return createAgentModelRequirementsWithCommitments(agentSource, modelName);
|
|
16233
|
+
return createAgentModelRequirementsWithCommitments(agentSource, modelName, options);
|
|
16189
16234
|
}
|
|
16190
16235
|
/**
|
|
16191
16236
|
* Selects the best model using the preparePersona function
|