@promptbook/wizard 0.112.0-31 → 0.112.0-32

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 (59) hide show
  1. package/esm/index.es.js +103 -39
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/src/_packages/components.index.d.ts +6 -0
  4. package/esm/src/_packages/types.index.d.ts +6 -0
  5. package/esm/src/book-2.0/agent-source/AgentReferenceResolver.d.ts +11 -0
  6. package/esm/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +8 -0
  7. package/esm/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +33 -0
  8. package/esm/src/book-2.0/agent-source/createTeamToolName.d.ts +7 -7
  9. package/esm/src/book-components/Chat/Chat/ChatActionsBar.d.ts +5 -0
  10. package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +17 -1
  11. package/esm/src/book-components/Chat/Chat/ChatMessageItem.test.d.ts +1 -1
  12. package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +14 -0
  13. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +290 -0
  14. package/esm/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +16 -0
  15. package/esm/src/book-components/Chat/Chat/renderAdvancedToolCallDetails.d.ts +4 -0
  16. package/esm/src/book-components/Chat/Chat/renderToolCallDetails.d.ts +9 -0
  17. package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -1
  18. package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.test.d.ts +2 -0
  19. package/esm/src/book-components/Chat/hooks/useChatCompleteNotification.d.ts +18 -0
  20. package/esm/src/book-components/Chat/hooks/useChatCompleteNotification.test.d.ts +2 -0
  21. package/esm/src/book-components/Chat/types/ChatMessage.d.ts +77 -1
  22. package/esm/src/book-components/Chat/utils/formatToolCallDateTime.d.ts +37 -0
  23. package/esm/src/book-components/Chat/utils/formatToolCallLocalTime.d.ts +11 -0
  24. package/esm/src/book-components/Chat/utils/formatToolCallTranslationTemplate.d.ts +10 -0
  25. package/esm/src/book-components/Chat/utils/getChatMessageTimingDisplay.d.ts +5 -1
  26. package/esm/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +26 -1
  27. package/esm/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +26 -3
  28. package/esm/src/utils/toolCalls/mergeToolCalls.d.ts +1 -1
  29. package/esm/src/version.d.ts +1 -1
  30. package/package.json +2 -2
  31. package/umd/index.umd.js +103 -39
  32. package/umd/index.umd.js.map +1 -1
  33. package/umd/src/_packages/components.index.d.ts +6 -0
  34. package/umd/src/_packages/types.index.d.ts +6 -0
  35. package/umd/src/book-2.0/agent-source/AgentReferenceResolver.d.ts +11 -0
  36. package/umd/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +8 -0
  37. package/umd/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +33 -0
  38. package/umd/src/book-2.0/agent-source/createTeamToolName.d.ts +7 -7
  39. package/umd/src/book-components/Chat/Chat/ChatActionsBar.d.ts +5 -0
  40. package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +17 -1
  41. package/umd/src/book-components/Chat/Chat/ChatMessageItem.test.d.ts +1 -1
  42. package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +14 -0
  43. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +290 -0
  44. package/umd/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +16 -0
  45. package/umd/src/book-components/Chat/Chat/renderAdvancedToolCallDetails.d.ts +4 -0
  46. package/umd/src/book-components/Chat/Chat/renderToolCallDetails.d.ts +9 -0
  47. package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -1
  48. package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.test.d.ts +2 -0
  49. package/umd/src/book-components/Chat/hooks/useChatCompleteNotification.d.ts +18 -0
  50. package/umd/src/book-components/Chat/hooks/useChatCompleteNotification.test.d.ts +2 -0
  51. package/umd/src/book-components/Chat/types/ChatMessage.d.ts +77 -1
  52. package/umd/src/book-components/Chat/utils/formatToolCallDateTime.d.ts +37 -0
  53. package/umd/src/book-components/Chat/utils/formatToolCallLocalTime.d.ts +11 -0
  54. package/umd/src/book-components/Chat/utils/formatToolCallTranslationTemplate.d.ts +10 -0
  55. package/umd/src/book-components/Chat/utils/getChatMessageTimingDisplay.d.ts +5 -1
  56. package/umd/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +26 -1
  57. package/umd/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +26 -3
  58. package/umd/src/utils/toolCalls/mergeToolCalls.d.ts +1 -1
  59. package/umd/src/version.d.ts +1 -1
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.112.0-31';
41
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-32';
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
@@ -22352,10 +22352,6 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
22352
22352
  * Prefix used for TEAM tool names.
22353
22353
  */
22354
22354
  const TEAM_TOOL_PREFIX = 'team_chat_';
22355
- /**
22356
- * Length of URL hash suffix appended to TEAM tool names.
22357
- */
22358
- const TEAM_TOOL_HASH_LENGTH = 10;
22359
22355
  /**
22360
22356
  * Fallback normalized name when teammate label is empty.
22361
22357
  */
@@ -22372,20 +22368,19 @@ function normalizeTeammateToolNamePart(teammateLabel) {
22372
22368
  return normalized || TEAM_TOOL_FALLBACK_NAME;
22373
22369
  }
22374
22370
  /**
22375
- * Builds a deterministic TEAM tool name from teammate identity.
22371
+ * Builds a deterministic TEAM tool name from the teammate label.
22376
22372
  *
22377
- * The readable part is based on teammate label while the hash suffix
22378
- * keeps uniqueness and stable mapping for the underlying teammate URL.
22373
+ * The tool name is derived solely from the human-readable label so that it
22374
+ * remains stable and predictable regardless of internal technical identifiers.
22379
22375
  *
22380
- * @param teammateUrl - Canonical teammate URL used at runtime.
22381
- * @param teammateLabel - Human-readable teammate label.
22382
- * @returns Deterministic TEAM tool name.
22376
+ * @param _teammateUrl - Canonical teammate URL (kept for API compatibility, not used).
22377
+ * @param teammateLabel - Human-readable teammate label used as the basis for the name.
22378
+ * @returns TEAM tool name derived from the label.
22383
22379
  * @private internal utility of TEAM commitments and chat UI mapping
22384
22380
  */
22385
- function createTeamToolName(teammateUrl, teammateLabel) {
22381
+ function createTeamToolName(_teammateUrl, teammateLabel) {
22386
22382
  const normalizedLabel = normalizeTeammateToolNamePart(teammateLabel);
22387
- const hash = computeHash(teammateUrl).substring(0, TEAM_TOOL_HASH_LENGTH);
22388
- return `${TEAM_TOOL_PREFIX}${normalizedLabel}_${hash}`;
22383
+ return `${TEAM_TOOL_PREFIX}${normalizedLabel}`;
22389
22384
  }
22390
22385
 
22391
22386
  const urlRegex = /https?:\/\/[^\s]+/gi;
@@ -22590,7 +22585,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
22590
22585
  `);
22591
22586
  }
22592
22587
  applyToAgentModelRequirements(requirements, content) {
22593
- var _a, _b;
22588
+ var _a, _b, _c;
22594
22589
  const trimmedContent = content.trim();
22595
22590
  if (!trimmedContent) {
22596
22591
  return requirements;
@@ -22602,14 +22597,18 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
22602
22597
  }
22603
22598
  const agentName = ((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.agentName) || 'Agent';
22604
22599
  const existingTeammates = ((_b = requirements._metadata) === null || _b === void 0 ? void 0 : _b.teammates) || [];
22600
+ const preResolvedProfiles = (((_c = requirements._metadata) === null || _c === void 0 ? void 0 : _c.preResolvedTeammateProfiles) || {});
22605
22601
  const resolvedTeammates = resolveTeamTeammateLabels(trimmedContent, teammates);
22606
22602
  const teamEntries = resolvedTeammates.map((teammate) => {
22603
+ const profile = preResolvedProfiles[teammate.url];
22604
+ const resolvedLabel = (profile === null || profile === void 0 ? void 0 : profile.agentName) || teammate.label;
22607
22605
  const existingTeammate = existingTeammates.find((entry) => entry.url === teammate.url);
22608
22606
  return {
22609
22607
  toolName: ((existingTeammate === null || existingTeammate === void 0 ? void 0 : existingTeammate.toolName) ||
22610
- createTeamToolName(teammate.url, teammate.label)),
22611
- teammate,
22608
+ createTeamToolName(teammate.url, resolvedLabel)),
22609
+ teammate: { ...teammate, label: resolvedLabel },
22612
22610
  agentName,
22611
+ description: (profile === null || profile === void 0 ? void 0 : profile.personaDescription) || null,
22613
22612
  };
22614
22613
  });
22615
22614
  for (const entry of teamEntries) {
@@ -22621,9 +22620,12 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
22621
22620
  if (updatedTools.some((tool) => tool.name === entry.toolName)) {
22622
22621
  continue;
22623
22622
  }
22623
+ const toolDescription = entry.description
22624
+ ? `Consult teammate ${entry.teammate.label}\n${entry.description}`
22625
+ : `Consult teammate ${entry.teammate.label}`;
22624
22626
  updatedTools.push({
22625
22627
  name: entry.toolName,
22626
- description: `Consult teammate ${entry.teammate.label}`,
22628
+ description: toolDescription,
22627
22629
  parameters: {
22628
22630
  type: 'object',
22629
22631
  properties: {
@@ -22652,8 +22654,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
22652
22654
  toolName: entry.toolName,
22653
22655
  });
22654
22656
  }
22655
- const teamOverviewText = createTeamOverviewText(trimmedContent, teamEntries);
22656
- const teamSystemMessage = this.createSystemMessageSection('Teammates:', buildTeamSystemMessageBody(teamOverviewText, teamEntries));
22657
+ const teamSystemMessage = this.createSystemMessageSection('Teammates:', buildTeamSystemMessageBody(teamEntries));
22657
22658
  return this.appendToSystemMessage({
22658
22659
  ...requirements,
22659
22660
  tools: updatedTools,
@@ -22690,25 +22691,24 @@ function resolveTeamTeammateLabels(teamContent, teammates) {
22690
22691
  };
22691
22692
  });
22692
22693
  }
22693
- /**
22694
- * Rewrites TEAM commitment content into a URL-free teammate overview text.
22695
- */
22696
- function createTeamOverviewText(teamContent, teamEntries) {
22697
- let overviewText = teamContent;
22698
- for (const entry of teamEntries) {
22699
- overviewText = overviewText.split(entry.teammate.url).join(entry.teammate.label);
22700
- }
22701
- return overviewText.trim();
22702
- }
22703
22694
  /**
22704
22695
  * Builds the textual TEAM section body for the final system message.
22696
+ *
22697
+ * Each teammate is listed with its tool name and, when available, a one-line description.
22698
+ * Uses `spaceTrim` to ensure consistent whitespace and indentation.
22705
22699
  */
22706
- function buildTeamSystemMessageBody(teamOverviewText, teamEntries) {
22707
- const teammateLines = teamEntries.map((entry, index) => `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``);
22708
- if (!teamOverviewText) {
22709
- return teammateLines.join('\n');
22710
- }
22711
- return `${teamOverviewText}\n\n${teammateLines.join('\n')}`;
22700
+ function buildTeamSystemMessageBody(teamEntries) {
22701
+ const lines = teamEntries.map((entry, index) => {
22702
+ const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
22703
+ if (!entry.description) {
22704
+ return toolLine;
22705
+ }
22706
+ return spaceTrim$1(`
22707
+ ${toolLine}
22708
+ ${entry.description}
22709
+ `);
22710
+ });
22711
+ return lines.join('\n');
22712
22712
  }
22713
22713
  /**
22714
22714
  * Registers tool function and title for a teammate tool.
@@ -29412,7 +29412,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
29412
29412
  * @private @@@
29413
29413
  */
29414
29414
  async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
29415
- var _a;
29415
+ var _a, _b, _c;
29416
29416
  const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
29417
29417
  // Parse the agent source to extract commitments
29418
29418
  const parseResult = parseAgentSourceWithCommitments(agentSource);
@@ -29480,6 +29480,36 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
29480
29480
  if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
29481
29481
  continue;
29482
29482
  }
29483
+ // For TEAM commitments, pre-resolve teammate profiles if a resolver is provided
29484
+ // and store them in metadata before the commitment is applied.
29485
+ const profileResolver = (_a = options === null || options === void 0 ? void 0 : options.teammateProfileResolver) !== null && _a !== void 0 ? _a : options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
29486
+ if (commitment.type === 'TEAM' && (profileResolver === null || profileResolver === void 0 ? void 0 : profileResolver.resolveTeammateProfile)) {
29487
+ try {
29488
+ const parsedTeammates = parseTeamCommitmentContent(commitmentContent, { strict: false });
29489
+ const preResolved = {
29490
+ ...(_b = requirements._metadata) === null || _b === void 0 ? void 0 : _b.preResolvedTeammateProfiles,
29491
+ };
29492
+ for (const teammate of parsedTeammates) {
29493
+ if (preResolved[teammate.url]) {
29494
+ continue;
29495
+ }
29496
+ const profile = await profileResolver.resolveTeammateProfile(teammate.url);
29497
+ if (profile) {
29498
+ preResolved[teammate.url] = profile;
29499
+ }
29500
+ }
29501
+ requirements = {
29502
+ ...requirements,
29503
+ _metadata: {
29504
+ ...requirements._metadata,
29505
+ preResolvedTeammateProfiles: preResolved,
29506
+ },
29507
+ };
29508
+ }
29509
+ catch (error) {
29510
+ console.warn('Failed to pre-resolve teammate profiles for TEAM commitment:', error);
29511
+ }
29512
+ }
29483
29513
  const definition = getCommitmentDefinition(commitment.type);
29484
29514
  if (definition) {
29485
29515
  try {
@@ -29575,7 +29605,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
29575
29605
  // Add example interactions to the system message
29576
29606
  const examples = [];
29577
29607
  // 1. Initial message as an example agent response
29578
- const initialMessage = (_a = parseResult.commitments.find((c) => c.type === 'INITIAL MESSAGE')) === null || _a === void 0 ? void 0 : _a.content;
29608
+ const initialMessage = (_c = parseResult.commitments.find((c) => c.type === 'INITIAL MESSAGE')) === null || _c === void 0 ? void 0 : _c.content;
29579
29609
  if (initialMessage) {
29580
29610
  examples.push(`Agent: ${initialMessage}`);
29581
29611
  }
@@ -36692,13 +36722,23 @@ function getToolCallIdentity(toolCall) {
36692
36722
  */
36693
36723
  function mergeToolCalls(existingToolCalls, incomingToolCalls) {
36694
36724
  if (!existingToolCalls || existingToolCalls.length === 0) {
36695
- return incomingToolCalls ? [...incomingToolCalls] : [];
36725
+ return incomingToolCalls ? deduplicatePreparationToolCalls([...incomingToolCalls]) : [];
36696
36726
  }
36697
36727
  if (!incomingToolCalls || incomingToolCalls.length === 0) {
36698
36728
  return [...existingToolCalls];
36699
36729
  }
36700
36730
  const mergedToolCalls = [...existingToolCalls];
36701
36731
  for (const incomingToolCall of incomingToolCalls) {
36732
+ if (isAssistantPreparationToolCall(incomingToolCall)) {
36733
+ // A new preparation phase always replaces any previous assistant_preparation tool
36734
+ // call, regardless of phase argument, so only one chip is ever shown at a time.
36735
+ const existingPreparationIndex = mergedToolCalls.findIndex(isAssistantPreparationToolCall);
36736
+ if (existingPreparationIndex !== -1) {
36737
+ mergedToolCalls.splice(existingPreparationIndex, 1);
36738
+ }
36739
+ mergedToolCalls.push(incomingToolCall);
36740
+ continue;
36741
+ }
36702
36742
  const incomingIdentity = getToolCallIdentity(incomingToolCall);
36703
36743
  const existingIndex = mergedToolCalls.findIndex((existingToolCall) => getToolCallIdentity(existingToolCall) === incomingIdentity);
36704
36744
  if (existingIndex === -1) {
@@ -36810,6 +36850,30 @@ function serializeValueForMerge(value) {
36810
36850
  return String(value);
36811
36851
  }
36812
36852
  }
36853
+ /**
36854
+ * Ensures at most one `assistant_preparation` tool call survives in the list,
36855
+ * keeping the last occurrence so the most recent preparation phase is shown.
36856
+ *
36857
+ * @param toolCalls - Mutable list to deduplicate in-place.
36858
+ * @returns The same array after removing redundant preparation entries.
36859
+ * @private helper of `mergeToolCalls`
36860
+ */
36861
+ function deduplicatePreparationToolCalls(toolCalls) {
36862
+ let lastPreparationIndex = -1;
36863
+ for (let index = toolCalls.length - 1; index >= 0; index--) {
36864
+ if (!isAssistantPreparationToolCall(toolCalls[index])) {
36865
+ continue;
36866
+ }
36867
+ if (lastPreparationIndex === -1) {
36868
+ lastPreparationIndex = index;
36869
+ }
36870
+ else {
36871
+ // Remove earlier duplicate — keep only the last (most recent) one.
36872
+ toolCalls.splice(index, 1);
36873
+ }
36874
+ }
36875
+ return toolCalls;
36876
+ }
36813
36877
 
36814
36878
  /**
36815
36879
  * Gets all tool titles provided by all commitments