@promptbook/wizard 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/wizard`
|
|
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
|
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
38
38
|
* @generated
|
|
39
39
|
* @see https://github.com/webgptorg/promptbook
|
|
40
40
|
*/
|
|
41
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.110.0
|
|
41
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0';
|
|
42
42
|
/**
|
|
43
43
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
44
44
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -20654,7 +20654,8 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
20654
20654
|
if (!trimmedContent) {
|
|
20655
20655
|
return requirements;
|
|
20656
20656
|
}
|
|
20657
|
-
|
|
20657
|
+
// Keep TEAM resilient: unresolved/malformed teammate entries are skipped, valid ones are still registered.
|
|
20658
|
+
const teammates = parseTeamCommitmentContent(trimmedContent, { strict: false });
|
|
20658
20659
|
if (teammates.length === 0) {
|
|
20659
20660
|
return requirements;
|
|
20660
20661
|
}
|
|
@@ -22713,14 +22714,42 @@ function removeCommentsFromSystemMessage(systemMessage) {
|
|
|
22713
22714
|
}
|
|
22714
22715
|
|
|
22715
22716
|
/**
|
|
22716
|
-
* Creates agent model requirements using the new commitment system
|
|
22717
|
+
* Creates agent model requirements using the new commitment system.
|
|
22718
|
+
*
|
|
22717
22719
|
* This function uses a reduce-like pattern where each commitment applies its changes
|
|
22718
|
-
* to build the final requirements starting from a basic empty model
|
|
22720
|
+
* to build the final requirements starting from a basic empty model.
|
|
22719
22721
|
*
|
|
22720
|
-
* @
|
|
22722
|
+
* @param agentSource - Agent source book to parse.
|
|
22723
|
+
* @param modelName - Optional override for the agent model name.
|
|
22724
|
+
* @param options - Additional options such as the agent reference resolver.
|
|
22725
|
+
*
|
|
22726
|
+
* @private @@@
|
|
22727
|
+
*/
|
|
22728
|
+
const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS', 'TEAM']);
|
|
22729
|
+
/**
|
|
22730
|
+
* Returns a safe fallback content when a resolver fails to transform a reference commitment.
|
|
22731
|
+
*
|
|
22732
|
+
* @param commitmentType - Commitment being resolved.
|
|
22733
|
+
* @param originalContent - Original unresolved commitment content.
|
|
22734
|
+
* @returns Fallback content that keeps requirement creation resilient.
|
|
22721
22735
|
*/
|
|
22722
|
-
|
|
22736
|
+
function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
22737
|
+
if (commitmentType === 'FROM') {
|
|
22738
|
+
return 'VOID';
|
|
22739
|
+
}
|
|
22740
|
+
if (commitmentType === 'IMPORT' || commitmentType === 'IMPORTS' || commitmentType === 'TEAM') {
|
|
22741
|
+
return '';
|
|
22742
|
+
}
|
|
22743
|
+
return originalContent;
|
|
22744
|
+
}
|
|
22745
|
+
/**
|
|
22746
|
+
* @@@
|
|
22747
|
+
*
|
|
22748
|
+
* @private @@@
|
|
22749
|
+
*/
|
|
22750
|
+
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
22723
22751
|
var _a;
|
|
22752
|
+
const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
|
|
22724
22753
|
// Parse the agent source to extract commitments
|
|
22725
22754
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
22726
22755
|
// Apply DELETE filtering: remove prior commitments tagged by parameters targeted by DELETE/CANCEL/DISCARD/REMOVE
|
|
@@ -22772,6 +22801,17 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
22772
22801
|
// Apply each commitment in order using reduce-like pattern
|
|
22773
22802
|
for (let i = 0; i < filteredCommitments.length; i++) {
|
|
22774
22803
|
const commitment = filteredCommitments[i];
|
|
22804
|
+
const isReferenceCommitment = Boolean(agentReferenceResolver && COMMITMENTS_WITH_AGENT_REFERENCES.has(commitment.type));
|
|
22805
|
+
let commitmentContent = commitment.content;
|
|
22806
|
+
if (isReferenceCommitment && agentReferenceResolver) {
|
|
22807
|
+
try {
|
|
22808
|
+
commitmentContent = await agentReferenceResolver.resolveCommitmentContent(commitment.type, commitment.content);
|
|
22809
|
+
}
|
|
22810
|
+
catch (error) {
|
|
22811
|
+
console.warn(`Failed to resolve commitment references for ${commitment.type}, falling back to safe defaults:`, error);
|
|
22812
|
+
commitmentContent = getSafeReferenceCommitmentFallback(commitment.type, commitment.content);
|
|
22813
|
+
}
|
|
22814
|
+
}
|
|
22775
22815
|
// CLOSED commitment should work only if its the last commitment in the book
|
|
22776
22816
|
if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
|
|
22777
22817
|
continue;
|
|
@@ -22779,7 +22819,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
22779
22819
|
const definition = getCommitmentDefinition(commitment.type);
|
|
22780
22820
|
if (definition) {
|
|
22781
22821
|
try {
|
|
22782
|
-
requirements = definition.applyToAgentModelRequirements(requirements,
|
|
22822
|
+
requirements = definition.applyToAgentModelRequirements(requirements, commitmentContent);
|
|
22783
22823
|
}
|
|
22784
22824
|
catch (error) {
|
|
22785
22825
|
console.warn(`Failed to apply commitment ${commitment.type}:`, error);
|
|
@@ -23238,23 +23278,28 @@ function normalizeSeparator(content) {
|
|
|
23238
23278
|
*/
|
|
23239
23279
|
|
|
23240
23280
|
/**
|
|
23241
|
-
* Creates model requirements for an agent based on its source
|
|
23281
|
+
* Creates model requirements for an agent based on its source.
|
|
23242
23282
|
*
|
|
23243
23283
|
* There are 2 similar functions:
|
|
23244
23284
|
* - `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.
|
|
23245
23285
|
* - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronous.
|
|
23246
23286
|
*
|
|
23287
|
+
* @param agentSource - Book describing the agent.
|
|
23288
|
+
* @param modelName - Optional override for the agent's model.
|
|
23289
|
+
* @param availableModels - Models that could fulfill the agent.
|
|
23290
|
+
* @param llmTools - Execution tools used when selecting a best model.
|
|
23291
|
+
* @param options - Optional hooks such as the agent reference resolver.
|
|
23247
23292
|
* @public exported from `@promptbook/core`
|
|
23248
23293
|
*/
|
|
23249
|
-
async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools) {
|
|
23294
|
+
async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools, options) {
|
|
23250
23295
|
// If availableModels are provided and no specific modelName is given,
|
|
23251
23296
|
// use preparePersona to select the best model
|
|
23252
23297
|
if (availableModels && !modelName && llmTools) {
|
|
23253
23298
|
const selectedModelName = await selectBestModelUsingPersona(agentSource, llmTools);
|
|
23254
|
-
return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName);
|
|
23299
|
+
return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName, options);
|
|
23255
23300
|
}
|
|
23256
23301
|
// Use the new commitment-based system with provided or default model
|
|
23257
|
-
return createAgentModelRequirementsWithCommitments(agentSource, modelName);
|
|
23302
|
+
return createAgentModelRequirementsWithCommitments(agentSource, modelName, options);
|
|
23258
23303
|
}
|
|
23259
23304
|
/**
|
|
23260
23305
|
* Selects the best model using the preparePersona function
|