@promptbook/node 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 +2 -2
  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/node`
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
@@ -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.110.0-9';
38
+ const PROMPTBOOK_ENGINE_VERSION = '0.110.0';
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
@@ -16955,7 +16955,8 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
16955
16955
  if (!trimmedContent) {
16956
16956
  return requirements;
16957
16957
  }
16958
- const teammates = parseTeamCommitmentContent(trimmedContent, { strict: true });
16958
+ // Keep TEAM resilient: unresolved/malformed teammate entries are skipped, valid ones are still registered.
16959
+ const teammates = parseTeamCommitmentContent(trimmedContent, { strict: false });
16959
16960
  if (teammates.length === 0) {
16960
16961
  return requirements;
16961
16962
  }
@@ -21289,14 +21290,42 @@ function removeCommentsFromSystemMessage(systemMessage) {
21289
21290
  }
21290
21291
 
21291
21292
  /**
21292
- * Creates agent model requirements using the new commitment system
21293
+ * Creates agent model requirements using the new commitment system.
21294
+ *
21293
21295
  * This function uses a reduce-like pattern where each commitment applies its changes
21294
- * to build the final requirements starting from a basic empty model
21296
+ * to build the final requirements starting from a basic empty model.
21295
21297
  *
21296
- * @public exported from `@promptbook/core`
21298
+ * @param agentSource - Agent source book to parse.
21299
+ * @param modelName - Optional override for the agent model name.
21300
+ * @param options - Additional options such as the agent reference resolver.
21301
+ *
21302
+ * @private @@@
21303
+ */
21304
+ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS', 'TEAM']);
21305
+ /**
21306
+ * Returns a safe fallback content when a resolver fails to transform a reference commitment.
21307
+ *
21308
+ * @param commitmentType - Commitment being resolved.
21309
+ * @param originalContent - Original unresolved commitment content.
21310
+ * @returns Fallback content that keeps requirement creation resilient.
21297
21311
  */
21298
- async function createAgentModelRequirementsWithCommitments(agentSource, modelName) {
21312
+ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
21313
+ if (commitmentType === 'FROM') {
21314
+ return 'VOID';
21315
+ }
21316
+ if (commitmentType === 'IMPORT' || commitmentType === 'IMPORTS' || commitmentType === 'TEAM') {
21317
+ return '';
21318
+ }
21319
+ return originalContent;
21320
+ }
21321
+ /**
21322
+ * @@@
21323
+ *
21324
+ * @private @@@
21325
+ */
21326
+ async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
21299
21327
  var _a;
21328
+ const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
21300
21329
  // Parse the agent source to extract commitments
21301
21330
  const parseResult = parseAgentSourceWithCommitments(agentSource);
21302
21331
  // Apply DELETE filtering: remove prior commitments tagged by parameters targeted by DELETE/CANCEL/DISCARD/REMOVE
@@ -21348,6 +21377,17 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
21348
21377
  // Apply each commitment in order using reduce-like pattern
21349
21378
  for (let i = 0; i < filteredCommitments.length; i++) {
21350
21379
  const commitment = filteredCommitments[i];
21380
+ const isReferenceCommitment = Boolean(agentReferenceResolver && COMMITMENTS_WITH_AGENT_REFERENCES.has(commitment.type));
21381
+ let commitmentContent = commitment.content;
21382
+ if (isReferenceCommitment && agentReferenceResolver) {
21383
+ try {
21384
+ commitmentContent = await agentReferenceResolver.resolveCommitmentContent(commitment.type, commitment.content);
21385
+ }
21386
+ catch (error) {
21387
+ console.warn(`Failed to resolve commitment references for ${commitment.type}, falling back to safe defaults:`, error);
21388
+ commitmentContent = getSafeReferenceCommitmentFallback(commitment.type, commitment.content);
21389
+ }
21390
+ }
21351
21391
  // CLOSED commitment should work only if its the last commitment in the book
21352
21392
  if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
21353
21393
  continue;
@@ -21355,7 +21395,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
21355
21395
  const definition = getCommitmentDefinition(commitment.type);
21356
21396
  if (definition) {
21357
21397
  try {
21358
- requirements = definition.applyToAgentModelRequirements(requirements, commitment.content);
21398
+ requirements = definition.applyToAgentModelRequirements(requirements, commitmentContent);
21359
21399
  }
21360
21400
  catch (error) {
21361
21401
  console.warn(`Failed to apply commitment ${commitment.type}:`, error);
@@ -21503,23 +21543,28 @@ function isBinaryMimeType(mimeType) {
21503
21543
  }
21504
21544
 
21505
21545
  /**
21506
- * Creates model requirements for an agent based on its source
21546
+ * Creates model requirements for an agent based on its source.
21507
21547
  *
21508
21548
  * There are 2 similar functions:
21509
21549
  * - `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.
21510
21550
  * - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronous.
21511
21551
  *
21552
+ * @param agentSource - Book describing the agent.
21553
+ * @param modelName - Optional override for the agent's model.
21554
+ * @param availableModels - Models that could fulfill the agent.
21555
+ * @param llmTools - Execution tools used when selecting a best model.
21556
+ * @param options - Optional hooks such as the agent reference resolver.
21512
21557
  * @public exported from `@promptbook/core`
21513
21558
  */
21514
- async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools) {
21559
+ async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools, options) {
21515
21560
  // If availableModels are provided and no specific modelName is given,
21516
21561
  // use preparePersona to select the best model
21517
21562
  if (availableModels && !modelName && llmTools) {
21518
21563
  const selectedModelName = await selectBestModelUsingPersona(agentSource, llmTools);
21519
- return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName);
21564
+ return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName, options);
21520
21565
  }
21521
21566
  // Use the new commitment-based system with provided or default model
21522
- return createAgentModelRequirementsWithCommitments(agentSource, modelName);
21567
+ return createAgentModelRequirementsWithCommitments(agentSource, modelName, options);
21523
21568
  }
21524
21569
  /**
21525
21570
  * Selects the best model using the preparePersona function