@promptbook/cli 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.
Files changed (25) hide show
  1. package/README.md +0 -4
  2. package/esm/index.es.js +56 -11
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/components.index.d.ts +4 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  7. package/esm/typings/src/book-2.0/agent-source/AgentReferenceResolver.d.ts +18 -0
  8. package/esm/typings/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +12 -0
  9. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +8 -2
  10. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.agentReferenceResolver.test.d.ts +1 -0
  11. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts +4 -5
  12. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +42 -0
  13. package/esm/typings/src/book-components/Chat/Chat/ChatActionsBar.d.ts +0 -2
  14. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +11 -0
  15. package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +12 -0
  16. package/esm/typings/src/book-components/Chat/hooks/useChatRatings.d.ts +24 -2
  17. package/esm/typings/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +2 -10
  18. package/esm/typings/src/book-components/Chat/utils/parseCitationMarker.d.ts +75 -0
  19. package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +3 -1
  20. package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.test.d.ts +1 -0
  21. package/esm/typings/src/book-components/icons/ArrowIcon.d.ts +17 -4
  22. package/esm/typings/src/version.d.ts +1 -1
  23. package/package.json +1 -1
  24. package/umd/index.umd.js +56 -11
  25. 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/cli`
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
@@ -48,7 +48,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.110.0-9';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.110.0';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -19073,7 +19073,8 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
19073
19073
  if (!trimmedContent) {
19074
19074
  return requirements;
19075
19075
  }
19076
- const teammates = parseTeamCommitmentContent(trimmedContent, { strict: true });
19076
+ // Keep TEAM resilient: unresolved/malformed teammate entries are skipped, valid ones are still registered.
19077
+ const teammates = parseTeamCommitmentContent(trimmedContent, { strict: false });
19077
19078
  if (teammates.length === 0) {
19078
19079
  return requirements;
19079
19080
  }
@@ -31646,14 +31647,42 @@ function removeCommentsFromSystemMessage(systemMessage) {
31646
31647
  }
31647
31648
 
31648
31649
  /**
31649
- * Creates agent model requirements using the new commitment system
31650
+ * Creates agent model requirements using the new commitment system.
31651
+ *
31650
31652
  * This function uses a reduce-like pattern where each commitment applies its changes
31651
- * to build the final requirements starting from a basic empty model
31653
+ * to build the final requirements starting from a basic empty model.
31652
31654
  *
31653
- * @public exported from `@promptbook/core`
31655
+ * @param agentSource - Agent source book to parse.
31656
+ * @param modelName - Optional override for the agent model name.
31657
+ * @param options - Additional options such as the agent reference resolver.
31658
+ *
31659
+ * @private @@@
31660
+ */
31661
+ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS', 'TEAM']);
31662
+ /**
31663
+ * Returns a safe fallback content when a resolver fails to transform a reference commitment.
31664
+ *
31665
+ * @param commitmentType - Commitment being resolved.
31666
+ * @param originalContent - Original unresolved commitment content.
31667
+ * @returns Fallback content that keeps requirement creation resilient.
31654
31668
  */
31655
- async function createAgentModelRequirementsWithCommitments(agentSource, modelName) {
31669
+ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
31670
+ if (commitmentType === 'FROM') {
31671
+ return 'VOID';
31672
+ }
31673
+ if (commitmentType === 'IMPORT' || commitmentType === 'IMPORTS' || commitmentType === 'TEAM') {
31674
+ return '';
31675
+ }
31676
+ return originalContent;
31677
+ }
31678
+ /**
31679
+ * @@@
31680
+ *
31681
+ * @private @@@
31682
+ */
31683
+ async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
31656
31684
  var _a;
31685
+ const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
31657
31686
  // Parse the agent source to extract commitments
31658
31687
  const parseResult = parseAgentSourceWithCommitments(agentSource);
31659
31688
  // Apply DELETE filtering: remove prior commitments tagged by parameters targeted by DELETE/CANCEL/DISCARD/REMOVE
@@ -31705,6 +31734,17 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
31705
31734
  // Apply each commitment in order using reduce-like pattern
31706
31735
  for (let i = 0; i < filteredCommitments.length; i++) {
31707
31736
  const commitment = filteredCommitments[i];
31737
+ const isReferenceCommitment = Boolean(agentReferenceResolver && COMMITMENTS_WITH_AGENT_REFERENCES.has(commitment.type));
31738
+ let commitmentContent = commitment.content;
31739
+ if (isReferenceCommitment && agentReferenceResolver) {
31740
+ try {
31741
+ commitmentContent = await agentReferenceResolver.resolveCommitmentContent(commitment.type, commitment.content);
31742
+ }
31743
+ catch (error) {
31744
+ console.warn(`Failed to resolve commitment references for ${commitment.type}, falling back to safe defaults:`, error);
31745
+ commitmentContent = getSafeReferenceCommitmentFallback(commitment.type, commitment.content);
31746
+ }
31747
+ }
31708
31748
  // CLOSED commitment should work only if its the last commitment in the book
31709
31749
  if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
31710
31750
  continue;
@@ -31712,7 +31752,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
31712
31752
  const definition = getCommitmentDefinition(commitment.type);
31713
31753
  if (definition) {
31714
31754
  try {
31715
- requirements = definition.applyToAgentModelRequirements(requirements, commitment.content);
31755
+ requirements = definition.applyToAgentModelRequirements(requirements, commitmentContent);
31716
31756
  }
31717
31757
  catch (error) {
31718
31758
  console.warn(`Failed to apply commitment ${commitment.type}:`, error);
@@ -32171,23 +32211,28 @@ function normalizeSeparator(content) {
32171
32211
  */
32172
32212
 
32173
32213
  /**
32174
- * Creates model requirements for an agent based on its source
32214
+ * Creates model requirements for an agent based on its source.
32175
32215
  *
32176
32216
  * There are 2 similar functions:
32177
32217
  * - `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.
32178
32218
  * - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronous.
32179
32219
  *
32220
+ * @param agentSource - Book describing the agent.
32221
+ * @param modelName - Optional override for the agent's model.
32222
+ * @param availableModels - Models that could fulfill the agent.
32223
+ * @param llmTools - Execution tools used when selecting a best model.
32224
+ * @param options - Optional hooks such as the agent reference resolver.
32180
32225
  * @public exported from `@promptbook/core`
32181
32226
  */
32182
- async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools) {
32227
+ async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools, options) {
32183
32228
  // If availableModels are provided and no specific modelName is given,
32184
32229
  // use preparePersona to select the best model
32185
32230
  if (availableModels && !modelName && llmTools) {
32186
32231
  const selectedModelName = await selectBestModelUsingPersona(agentSource, llmTools);
32187
- return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName);
32232
+ return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName, options);
32188
32233
  }
32189
32234
  // Use the new commitment-based system with provided or default model
32190
- return createAgentModelRequirementsWithCommitments(agentSource, modelName);
32235
+ return createAgentModelRequirementsWithCommitments(agentSource, modelName, options);
32191
32236
  }
32192
32237
  /**
32193
32238
  * Selects the best model using the preparePersona function