@promptbook/remote-server 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
@@ -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.112.0-31';
43
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-32';
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
@@ -15462,10 +15462,6 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
15462
15462
  * Prefix used for TEAM tool names.
15463
15463
  */
15464
15464
  const TEAM_TOOL_PREFIX = 'team_chat_';
15465
- /**
15466
- * Length of URL hash suffix appended to TEAM tool names.
15467
- */
15468
- const TEAM_TOOL_HASH_LENGTH = 10;
15469
15465
  /**
15470
15466
  * Fallback normalized name when teammate label is empty.
15471
15467
  */
@@ -15482,20 +15478,19 @@ function normalizeTeammateToolNamePart(teammateLabel) {
15482
15478
  return normalized || TEAM_TOOL_FALLBACK_NAME;
15483
15479
  }
15484
15480
  /**
15485
- * Builds a deterministic TEAM tool name from teammate identity.
15481
+ * Builds a deterministic TEAM tool name from the teammate label.
15486
15482
  *
15487
- * The readable part is based on teammate label while the hash suffix
15488
- * keeps uniqueness and stable mapping for the underlying teammate URL.
15483
+ * The tool name is derived solely from the human-readable label so that it
15484
+ * remains stable and predictable regardless of internal technical identifiers.
15489
15485
  *
15490
- * @param teammateUrl - Canonical teammate URL used at runtime.
15491
- * @param teammateLabel - Human-readable teammate label.
15492
- * @returns Deterministic TEAM tool name.
15486
+ * @param _teammateUrl - Canonical teammate URL (kept for API compatibility, not used).
15487
+ * @param teammateLabel - Human-readable teammate label used as the basis for the name.
15488
+ * @returns TEAM tool name derived from the label.
15493
15489
  * @private internal utility of TEAM commitments and chat UI mapping
15494
15490
  */
15495
- function createTeamToolName(teammateUrl, teammateLabel) {
15491
+ function createTeamToolName(_teammateUrl, teammateLabel) {
15496
15492
  const normalizedLabel = normalizeTeammateToolNamePart(teammateLabel);
15497
- const hash = computeHash(teammateUrl).substring(0, TEAM_TOOL_HASH_LENGTH);
15498
- return `${TEAM_TOOL_PREFIX}${normalizedLabel}_${hash}`;
15493
+ return `${TEAM_TOOL_PREFIX}${normalizedLabel}`;
15499
15494
  }
15500
15495
 
15501
15496
  const urlRegex = /https?:\/\/[^\s]+/gi;
@@ -15700,7 +15695,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
15700
15695
  `);
15701
15696
  }
15702
15697
  applyToAgentModelRequirements(requirements, content) {
15703
- var _a, _b;
15698
+ var _a, _b, _c;
15704
15699
  const trimmedContent = content.trim();
15705
15700
  if (!trimmedContent) {
15706
15701
  return requirements;
@@ -15712,14 +15707,18 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
15712
15707
  }
15713
15708
  const agentName = ((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.agentName) || 'Agent';
15714
15709
  const existingTeammates = ((_b = requirements._metadata) === null || _b === void 0 ? void 0 : _b.teammates) || [];
15710
+ const preResolvedProfiles = (((_c = requirements._metadata) === null || _c === void 0 ? void 0 : _c.preResolvedTeammateProfiles) || {});
15715
15711
  const resolvedTeammates = resolveTeamTeammateLabels(trimmedContent, teammates);
15716
15712
  const teamEntries = resolvedTeammates.map((teammate) => {
15713
+ const profile = preResolvedProfiles[teammate.url];
15714
+ const resolvedLabel = (profile === null || profile === void 0 ? void 0 : profile.agentName) || teammate.label;
15717
15715
  const existingTeammate = existingTeammates.find((entry) => entry.url === teammate.url);
15718
15716
  return {
15719
15717
  toolName: ((existingTeammate === null || existingTeammate === void 0 ? void 0 : existingTeammate.toolName) ||
15720
- createTeamToolName(teammate.url, teammate.label)),
15721
- teammate,
15718
+ createTeamToolName(teammate.url, resolvedLabel)),
15719
+ teammate: { ...teammate, label: resolvedLabel },
15722
15720
  agentName,
15721
+ description: (profile === null || profile === void 0 ? void 0 : profile.personaDescription) || null,
15723
15722
  };
15724
15723
  });
15725
15724
  for (const entry of teamEntries) {
@@ -15731,9 +15730,12 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
15731
15730
  if (updatedTools.some((tool) => tool.name === entry.toolName)) {
15732
15731
  continue;
15733
15732
  }
15733
+ const toolDescription = entry.description
15734
+ ? `Consult teammate ${entry.teammate.label}\n${entry.description}`
15735
+ : `Consult teammate ${entry.teammate.label}`;
15734
15736
  updatedTools.push({
15735
15737
  name: entry.toolName,
15736
- description: `Consult teammate ${entry.teammate.label}`,
15738
+ description: toolDescription,
15737
15739
  parameters: {
15738
15740
  type: 'object',
15739
15741
  properties: {
@@ -15762,8 +15764,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
15762
15764
  toolName: entry.toolName,
15763
15765
  });
15764
15766
  }
15765
- const teamOverviewText = createTeamOverviewText(trimmedContent, teamEntries);
15766
- const teamSystemMessage = this.createSystemMessageSection('Teammates:', buildTeamSystemMessageBody(teamOverviewText, teamEntries));
15767
+ const teamSystemMessage = this.createSystemMessageSection('Teammates:', buildTeamSystemMessageBody(teamEntries));
15767
15768
  return this.appendToSystemMessage({
15768
15769
  ...requirements,
15769
15770
  tools: updatedTools,
@@ -15800,25 +15801,24 @@ function resolveTeamTeammateLabels(teamContent, teammates) {
15800
15801
  };
15801
15802
  });
15802
15803
  }
15803
- /**
15804
- * Rewrites TEAM commitment content into a URL-free teammate overview text.
15805
- */
15806
- function createTeamOverviewText(teamContent, teamEntries) {
15807
- let overviewText = teamContent;
15808
- for (const entry of teamEntries) {
15809
- overviewText = overviewText.split(entry.teammate.url).join(entry.teammate.label);
15810
- }
15811
- return overviewText.trim();
15812
- }
15813
15804
  /**
15814
15805
  * Builds the textual TEAM section body for the final system message.
15806
+ *
15807
+ * Each teammate is listed with its tool name and, when available, a one-line description.
15808
+ * Uses `spaceTrim` to ensure consistent whitespace and indentation.
15815
15809
  */
15816
- function buildTeamSystemMessageBody(teamOverviewText, teamEntries) {
15817
- const teammateLines = teamEntries.map((entry, index) => `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``);
15818
- if (!teamOverviewText) {
15819
- return teammateLines.join('\n');
15820
- }
15821
- return `${teamOverviewText}\n\n${teammateLines.join('\n')}`;
15810
+ function buildTeamSystemMessageBody(teamEntries) {
15811
+ const lines = teamEntries.map((entry, index) => {
15812
+ const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
15813
+ if (!entry.description) {
15814
+ return toolLine;
15815
+ }
15816
+ return spaceTrim$1(`
15817
+ ${toolLine}
15818
+ ${entry.description}
15819
+ `);
15820
+ });
15821
+ return lines.join('\n');
15822
15822
  }
15823
15823
  /**
15824
15824
  * Registers tool function and title for a teammate tool.
@@ -24161,13 +24161,23 @@ function getToolCallIdentity(toolCall) {
24161
24161
  */
24162
24162
  function mergeToolCalls(existingToolCalls, incomingToolCalls) {
24163
24163
  if (!existingToolCalls || existingToolCalls.length === 0) {
24164
- return incomingToolCalls ? [...incomingToolCalls] : [];
24164
+ return incomingToolCalls ? deduplicatePreparationToolCalls([...incomingToolCalls]) : [];
24165
24165
  }
24166
24166
  if (!incomingToolCalls || incomingToolCalls.length === 0) {
24167
24167
  return [...existingToolCalls];
24168
24168
  }
24169
24169
  const mergedToolCalls = [...existingToolCalls];
24170
24170
  for (const incomingToolCall of incomingToolCalls) {
24171
+ if (isAssistantPreparationToolCall(incomingToolCall)) {
24172
+ // A new preparation phase always replaces any previous assistant_preparation tool
24173
+ // call, regardless of phase argument, so only one chip is ever shown at a time.
24174
+ const existingPreparationIndex = mergedToolCalls.findIndex(isAssistantPreparationToolCall);
24175
+ if (existingPreparationIndex !== -1) {
24176
+ mergedToolCalls.splice(existingPreparationIndex, 1);
24177
+ }
24178
+ mergedToolCalls.push(incomingToolCall);
24179
+ continue;
24180
+ }
24171
24181
  const incomingIdentity = getToolCallIdentity(incomingToolCall);
24172
24182
  const existingIndex = mergedToolCalls.findIndex((existingToolCall) => getToolCallIdentity(existingToolCall) === incomingIdentity);
24173
24183
  if (existingIndex === -1) {
@@ -24279,6 +24289,30 @@ function serializeValueForMerge(value) {
24279
24289
  return String(value);
24280
24290
  }
24281
24291
  }
24292
+ /**
24293
+ * Ensures at most one `assistant_preparation` tool call survives in the list,
24294
+ * keeping the last occurrence so the most recent preparation phase is shown.
24295
+ *
24296
+ * @param toolCalls - Mutable list to deduplicate in-place.
24297
+ * @returns The same array after removing redundant preparation entries.
24298
+ * @private helper of `mergeToolCalls`
24299
+ */
24300
+ function deduplicatePreparationToolCalls(toolCalls) {
24301
+ let lastPreparationIndex = -1;
24302
+ for (let index = toolCalls.length - 1; index >= 0; index--) {
24303
+ if (!isAssistantPreparationToolCall(toolCalls[index])) {
24304
+ continue;
24305
+ }
24306
+ if (lastPreparationIndex === -1) {
24307
+ lastPreparationIndex = index;
24308
+ }
24309
+ else {
24310
+ // Remove earlier duplicate — keep only the last (most recent) one.
24311
+ toolCalls.splice(index, 1);
24312
+ }
24313
+ }
24314
+ return toolCalls;
24315
+ }
24282
24316
 
24283
24317
  /**
24284
24318
  * Computes SHA-256 hash of the agent source
@@ -25211,7 +25245,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
25211
25245
  * @private @@@
25212
25246
  */
25213
25247
  async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
25214
- var _a;
25248
+ var _a, _b, _c;
25215
25249
  const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
25216
25250
  // Parse the agent source to extract commitments
25217
25251
  const parseResult = parseAgentSourceWithCommitments(agentSource);
@@ -25279,6 +25313,36 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
25279
25313
  if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
25280
25314
  continue;
25281
25315
  }
25316
+ // For TEAM commitments, pre-resolve teammate profiles if a resolver is provided
25317
+ // and store them in metadata before the commitment is applied.
25318
+ 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;
25319
+ if (commitment.type === 'TEAM' && (profileResolver === null || profileResolver === void 0 ? void 0 : profileResolver.resolveTeammateProfile)) {
25320
+ try {
25321
+ const parsedTeammates = parseTeamCommitmentContent(commitmentContent, { strict: false });
25322
+ const preResolved = {
25323
+ ...(_b = requirements._metadata) === null || _b === void 0 ? void 0 : _b.preResolvedTeammateProfiles,
25324
+ };
25325
+ for (const teammate of parsedTeammates) {
25326
+ if (preResolved[teammate.url]) {
25327
+ continue;
25328
+ }
25329
+ const profile = await profileResolver.resolveTeammateProfile(teammate.url);
25330
+ if (profile) {
25331
+ preResolved[teammate.url] = profile;
25332
+ }
25333
+ }
25334
+ requirements = {
25335
+ ...requirements,
25336
+ _metadata: {
25337
+ ...requirements._metadata,
25338
+ preResolvedTeammateProfiles: preResolved,
25339
+ },
25340
+ };
25341
+ }
25342
+ catch (error) {
25343
+ console.warn('Failed to pre-resolve teammate profiles for TEAM commitment:', error);
25344
+ }
25345
+ }
25282
25346
  const definition = getCommitmentDefinition(commitment.type);
25283
25347
  if (definition) {
25284
25348
  try {
@@ -25374,7 +25438,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
25374
25438
  // Add example interactions to the system message
25375
25439
  const examples = [];
25376
25440
  // 1. Initial message as an example agent response
25377
- const initialMessage = (_a = parseResult.commitments.find((c) => c.type === 'INITIAL MESSAGE')) === null || _a === void 0 ? void 0 : _a.content;
25441
+ const initialMessage = (_c = parseResult.commitments.find((c) => c.type === 'INITIAL MESSAGE')) === null || _c === void 0 ? void 0 : _c.content;
25378
25442
  if (initialMessage) {
25379
25443
  examples.push(`Agent: ${initialMessage}`);
25380
25444
  }