@promptbook/remote-server 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/remote-server`
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
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
40
40
  * @generated
41
41
  * @see https://github.com/webgptorg/promptbook
42
42
  */
43
- const PROMPTBOOK_ENGINE_VERSION = '0.110.0-9';
43
+ const PROMPTBOOK_ENGINE_VERSION = '0.110.0';
44
44
  /**
45
45
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
46
46
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -14046,7 +14046,8 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
14046
14046
  if (!trimmedContent) {
14047
14047
  return requirements;
14048
14048
  }
14049
- const teammates = parseTeamCommitmentContent(trimmedContent, { strict: true });
14049
+ // Keep TEAM resilient: unresolved/malformed teammate entries are skipped, valid ones are still registered.
14050
+ const teammates = parseTeamCommitmentContent(trimmedContent, { strict: false });
14050
14051
  if (teammates.length === 0) {
14051
14052
  return requirements;
14052
14053
  }
@@ -18393,14 +18394,42 @@ function removeCommentsFromSystemMessage(systemMessage) {
18393
18394
  }
18394
18395
 
18395
18396
  /**
18396
- * Creates agent model requirements using the new commitment system
18397
+ * Creates agent model requirements using the new commitment system.
18398
+ *
18397
18399
  * This function uses a reduce-like pattern where each commitment applies its changes
18398
- * to build the final requirements starting from a basic empty model
18400
+ * to build the final requirements starting from a basic empty model.
18399
18401
  *
18400
- * @public exported from `@promptbook/core`
18402
+ * @param agentSource - Agent source book to parse.
18403
+ * @param modelName - Optional override for the agent model name.
18404
+ * @param options - Additional options such as the agent reference resolver.
18405
+ *
18406
+ * @private @@@
18407
+ */
18408
+ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS', 'TEAM']);
18409
+ /**
18410
+ * Returns a safe fallback content when a resolver fails to transform a reference commitment.
18411
+ *
18412
+ * @param commitmentType - Commitment being resolved.
18413
+ * @param originalContent - Original unresolved commitment content.
18414
+ * @returns Fallback content that keeps requirement creation resilient.
18401
18415
  */
18402
- async function createAgentModelRequirementsWithCommitments(agentSource, modelName) {
18416
+ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
18417
+ if (commitmentType === 'FROM') {
18418
+ return 'VOID';
18419
+ }
18420
+ if (commitmentType === 'IMPORT' || commitmentType === 'IMPORTS' || commitmentType === 'TEAM') {
18421
+ return '';
18422
+ }
18423
+ return originalContent;
18424
+ }
18425
+ /**
18426
+ * @@@
18427
+ *
18428
+ * @private @@@
18429
+ */
18430
+ async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
18403
18431
  var _a;
18432
+ const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
18404
18433
  // Parse the agent source to extract commitments
18405
18434
  const parseResult = parseAgentSourceWithCommitments(agentSource);
18406
18435
  // Apply DELETE filtering: remove prior commitments tagged by parameters targeted by DELETE/CANCEL/DISCARD/REMOVE
@@ -18452,6 +18481,17 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
18452
18481
  // Apply each commitment in order using reduce-like pattern
18453
18482
  for (let i = 0; i < filteredCommitments.length; i++) {
18454
18483
  const commitment = filteredCommitments[i];
18484
+ const isReferenceCommitment = Boolean(agentReferenceResolver && COMMITMENTS_WITH_AGENT_REFERENCES.has(commitment.type));
18485
+ let commitmentContent = commitment.content;
18486
+ if (isReferenceCommitment && agentReferenceResolver) {
18487
+ try {
18488
+ commitmentContent = await agentReferenceResolver.resolveCommitmentContent(commitment.type, commitment.content);
18489
+ }
18490
+ catch (error) {
18491
+ console.warn(`Failed to resolve commitment references for ${commitment.type}, falling back to safe defaults:`, error);
18492
+ commitmentContent = getSafeReferenceCommitmentFallback(commitment.type, commitment.content);
18493
+ }
18494
+ }
18455
18495
  // CLOSED commitment should work only if its the last commitment in the book
18456
18496
  if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
18457
18497
  continue;
@@ -18459,7 +18499,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
18459
18499
  const definition = getCommitmentDefinition(commitment.type);
18460
18500
  if (definition) {
18461
18501
  try {
18462
- requirements = definition.applyToAgentModelRequirements(requirements, commitment.content);
18502
+ requirements = definition.applyToAgentModelRequirements(requirements, commitmentContent);
18463
18503
  }
18464
18504
  catch (error) {
18465
18505
  console.warn(`Failed to apply commitment ${commitment.type}:`, error);
@@ -18607,23 +18647,28 @@ function isBinaryMimeType(mimeType) {
18607
18647
  }
18608
18648
 
18609
18649
  /**
18610
- * Creates model requirements for an agent based on its source
18650
+ * Creates model requirements for an agent based on its source.
18611
18651
  *
18612
18652
  * There are 2 similar functions:
18613
18653
  * - `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.
18614
18654
  * - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronous.
18615
18655
  *
18656
+ * @param agentSource - Book describing the agent.
18657
+ * @param modelName - Optional override for the agent's model.
18658
+ * @param availableModels - Models that could fulfill the agent.
18659
+ * @param llmTools - Execution tools used when selecting a best model.
18660
+ * @param options - Optional hooks such as the agent reference resolver.
18616
18661
  * @public exported from `@promptbook/core`
18617
18662
  */
18618
- async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools) {
18663
+ async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools, options) {
18619
18664
  // If availableModels are provided and no specific modelName is given,
18620
18665
  // use preparePersona to select the best model
18621
18666
  if (availableModels && !modelName && llmTools) {
18622
18667
  const selectedModelName = await selectBestModelUsingPersona(agentSource, llmTools);
18623
- return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName);
18668
+ return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName, options);
18624
18669
  }
18625
18670
  // Use the new commitment-based system with provided or default model
18626
- return createAgentModelRequirementsWithCommitments(agentSource, modelName);
18671
+ return createAgentModelRequirementsWithCommitments(agentSource, modelName, options);
18627
18672
  }
18628
18673
  /**
18629
18674
  * Selects the best model using the preparePersona function