@promptbook/components 0.112.0-42 → 0.112.0-43

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.
@@ -745,7 +745,7 @@ export type ChatProps = {
745
745
  * - `BUBBLE_MODE`: keeps the default bubble appearance for all messages.
746
746
  * - `ARTICLE_MODE`: keeps user bubbles while rendering assistant replies as borderless article blocks.
747
747
  *
748
- * @default 'BUBBLE_MODE'
748
+ * @default 'ARTICLE_MODE'
749
749
  */
750
750
  readonly CHAT_VISUAL_MODE?: ChatVisualMode;
751
751
  /**
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Possible runtime shapes returned when importing the `typescript` package.
3
+ */
4
+ type ImportedTypescriptModule = typeof import('typescript') | {
5
+ default: typeof import('typescript');
6
+ };
7
+ /**
8
+ * Loads the TypeScript runtime used for parsing JSONC-style project files.
9
+ *
10
+ * @private internal utility of `coder init`
11
+ */
12
+ export declare function getTypescriptModule(): Promise<typeof import('typescript')>;
13
+ /**
14
+ * Normalizes CommonJS-via-`default` and direct namespace imports of TypeScript.
15
+ *
16
+ * @private internal utility of `getTypescriptModule`
17
+ */
18
+ export declare function normalizeImportedTypescriptModule(importedTypescriptModule: ImportedTypescriptModule): typeof import('typescript');
19
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -44,6 +44,10 @@ export declare class AgentLlmExecutionTools implements LlmExecutionTools {
44
44
  * Cached parsed agent information
45
45
  */
46
46
  private _cachedAgentInfo;
47
+ /**
48
+ * Optional server-precomputed model requirements reused until the source changes.
49
+ */
50
+ private precomputedModelRequirements;
47
51
  /**
48
52
  * Creates new AgentLlmExecutionTools
49
53
  *
@@ -1,4 +1,5 @@
1
1
  import type { string_book } from '../../book-2.0/agent-source/string_book';
2
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
3
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
4
  import type { ExecutionTools } from '../../execution/ExecutionTools';
4
5
  import type { Updatable } from '../../types/Updatable';
@@ -27,6 +28,13 @@ export type AgentOptions = CommonToolsOptions & {
27
28
  * The source of the agent
28
29
  */
29
30
  agentSource: Updatable<string_book>;
31
+ /**
32
+ * Optional precomputed model requirements reused until `agentSource` changes.
33
+ *
34
+ * This keeps the actual runtime prompt aligned with server-prepared requirements
35
+ * such as compact-reference-resolved `TEAM` tools.
36
+ */
37
+ precomputedModelRequirements?: AgentModelRequirements;
30
38
  /**
31
39
  * Teacher agent for self-learning
32
40
  *
@@ -1,4 +1,5 @@
1
1
  import type { string_book } from '../../book-2.0/agent-source/string_book';
2
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
3
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
4
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
5
  import type { OpenAiAgentKitExecutionTools } from '../openai/OpenAiAgentKitExecutionTools';
@@ -25,4 +26,12 @@ export type CreateAgentLlmExecutionToolsOptions = CommonToolsOptions & {
25
26
  * The agent source string that defines the agent's behavior
26
27
  */
27
28
  agentSource: string_book;
29
+ /**
30
+ * Optional precomputed model requirements reused until `agentSource` changes.
31
+ *
32
+ * This is useful for runtimes such as Agents Server that already resolved compact
33
+ * references (for example in `TEAM`) and need the executed prompt to stay aligned
34
+ * with the server-prepared tool list.
35
+ */
36
+ precomputedModelRequirements?: AgentModelRequirements;
28
37
  };
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.112.0-41`).
18
+ * It follows semantic versioning (e.g., `0.112.0-42`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/components",
3
- "version": "0.112.0-42",
3
+ "version": "0.112.0-43",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -30,7 +30,7 @@
30
30
  * @generated
31
31
  * @see https://github.com/webgptorg/promptbook
32
32
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-42';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-43';
34
34
  /**
35
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
36
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -10790,6 +10790,15 @@
10790
10790
  * Map of team tool titles.
10791
10791
  */
10792
10792
  const teamToolTitles = {};
10793
+ /**
10794
+ * Shared TEAM usage rules appended ahead of teammate listings.
10795
+ *
10796
+ * @private
10797
+ */
10798
+ const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
10799
+ '- If a teammate is relevant to the request, consult that teammate using the matching tool.',
10800
+ '- Do not ask the user for information that a listed teammate can provide directly.',
10801
+ ];
10793
10802
  /**
10794
10803
  * Constant for remote agents by Url.
10795
10804
  */
@@ -10879,12 +10888,9 @@
10879
10888
  if (updatedTools.some((tool) => tool.name === entry.toolName)) {
10880
10889
  continue;
10881
10890
  }
10882
- const toolDescription = entry.description
10883
- ? `Consult teammate ${entry.teammate.label}\n${entry.description}`
10884
- : `Consult teammate ${entry.teammate.label}`;
10885
10891
  updatedTools.push({
10886
10892
  name: entry.toolName,
10887
- description: toolDescription,
10893
+ description: buildTeamToolDescription(entry),
10888
10894
  parameters: {
10889
10895
  type: 'object',
10890
10896
  properties: {
@@ -10953,22 +10959,72 @@
10953
10959
  /**
10954
10960
  * Builds the textual TEAM section body for the final system message.
10955
10961
  *
10956
- * Each teammate is listed with its tool name and, when available, a one-line description.
10957
- * Uses `spaceTrim` to ensure consistent whitespace and indentation.
10962
+ * Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
10958
10963
  */
10959
10964
  function buildTeamSystemMessageBody(teamEntries) {
10960
- const lines = teamEntries.map((entry, index) => {
10961
- const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
10962
- if (!entry.description) {
10963
- return toolLine;
10964
- }
10965
- return spacetrim.spaceTrim(`
10966
- ${toolLine}
10967
- ${entry.description}
10968
- `);
10969
- });
10965
+ const lines = [
10966
+ ...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
10967
+ '',
10968
+ ...teamEntries.map((entry, index) => {
10969
+ const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
10970
+ const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
10971
+ return [toolLine, ...detailLines].join('\n');
10972
+ }),
10973
+ ];
10970
10974
  return lines.join('\n');
10971
10975
  }
10976
+ /**
10977
+ * Builds the model-visible description for one teammate tool.
10978
+ *
10979
+ * @private
10980
+ */
10981
+ function buildTeamToolDescription(entry) {
10982
+ const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
10983
+ return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
10984
+ }
10985
+ /**
10986
+ * Collects structured teammate details that should stay visible to the model.
10987
+ *
10988
+ * @private
10989
+ */
10990
+ function collectTeamEntryDetails(entry) {
10991
+ var _a;
10992
+ const details = [];
10993
+ const instructions = entry.teammate.instructions.trim();
10994
+ const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
10995
+ if (instructions) {
10996
+ details.push({
10997
+ label: 'TEAM instructions',
10998
+ content: instructions,
10999
+ });
11000
+ }
11001
+ if (description) {
11002
+ details.push({
11003
+ label: 'Profile',
11004
+ content: description,
11005
+ });
11006
+ }
11007
+ return details;
11008
+ }
11009
+ /**
11010
+ * Formats one teammate detail line for the TEAM system-message section.
11011
+ *
11012
+ * @private
11013
+ */
11014
+ function formatTeamEntryDetailLine(detail) {
11015
+ return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
11016
+ }
11017
+ /**
11018
+ * Indents all lines of one potentially multi-line text block.
11019
+ *
11020
+ * @private
11021
+ */
11022
+ function indentMultilineText(text, prefix) {
11023
+ return text
11024
+ .split('\n')
11025
+ .map((line) => `${prefix}${line}`)
11026
+ .join('\n');
11027
+ }
10972
11028
  /**
10973
11029
  * Registers tool function and title for a teammate tool.
10974
11030
  */
@@ -30906,7 +30962,7 @@
30906
30962
  systemMessage: '',
30907
30963
  promptSuffix: '',
30908
30964
  // modelName: 'gpt-5',
30909
- modelName: 'gemini-2.5-flash-lite',
30965
+ modelName: 'gpt-5.4-mini',
30910
30966
  temperature: 0.7,
30911
30967
  topP: 0.9,
30912
30968
  topK: 50,
@@ -35777,7 +35833,7 @@
35777
35833
  /**
35778
35834
  * Constant for default agent kit model name.
35779
35835
  */
35780
- const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-nano';
35836
+ const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
35781
35837
  /**
35782
35838
  * Creates one structured log entry for streamed tool-call updates.
35783
35839
  *
@@ -37843,6 +37899,7 @@
37843
37899
  * @param agentSource The agent source string that defines the agent's behavior
37844
37900
  */
37845
37901
  constructor(options) {
37902
+ var _a;
37846
37903
  this.options = options;
37847
37904
  /**
37848
37905
  * Cached model requirements to avoid re-parsing the agent source
@@ -37852,6 +37909,7 @@
37852
37909
  * Cached parsed agent information
37853
37910
  */
37854
37911
  this._cachedAgentInfo = null;
37912
+ this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
37855
37913
  }
37856
37914
  /**
37857
37915
  * Updates the agent source and clears the cache
@@ -37859,9 +37917,13 @@
37859
37917
  * @param agentSource The new agent source string
37860
37918
  */
37861
37919
  updateAgentSource(agentSource) {
37920
+ if (this.options.agentSource === agentSource) {
37921
+ return;
37922
+ }
37862
37923
  this.options.agentSource = agentSource;
37863
37924
  this._cachedAgentInfo = null;
37864
37925
  this._cachedModelRequirements = null;
37926
+ this.precomputedModelRequirements = null;
37865
37927
  }
37866
37928
  /**
37867
37929
  * Get cached or parse agent information
@@ -37878,6 +37940,16 @@
37878
37940
  * Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
37879
37941
  */
37880
37942
  async getModelRequirements() {
37943
+ var _a, _b;
37944
+ if (this.precomputedModelRequirements !== null) {
37945
+ if (this.options.isVerbose) {
37946
+ console.info('[🤰]', 'Using precomputed agent model requirements', {
37947
+ agent: this.title,
37948
+ toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
37949
+ });
37950
+ }
37951
+ return this.precomputedModelRequirements;
37952
+ }
37881
37953
  if (this._cachedModelRequirements === null) {
37882
37954
  const preparationStartedAtMs = Date.now();
37883
37955
  if (this.options.isVerbose) {
@@ -37987,6 +38059,7 @@
37987
38059
  * Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
37988
38060
  */
37989
38061
  async prepareChatPrompt(prompt) {
38062
+ var _a;
37990
38063
  const chatPrompt = this.requireChatPrompt(prompt);
37991
38064
  const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
37992
38065
  const attachments = normalizeChatAttachments(chatPrompt.attachments);
@@ -38004,7 +38077,16 @@
38004
38077
  mergedTools,
38005
38078
  knowledgeSourcesForAgent,
38006
38079
  });
38007
- console.log('!!!! promptWithAgentModelRequirements:', forwardedPrompt);
38080
+ if (this.options.isVerbose) {
38081
+ console.info('[🤰]', 'Prepared agent chat prompt', {
38082
+ agent: this.title,
38083
+ usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
38084
+ toolNames: mergedTools.map((tool) => tool.name),
38085
+ knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
38086
+ promptSuffixLength: promptSuffix.length,
38087
+ systemMessageLength: sanitizedRequirements.systemMessage.length,
38088
+ });
38089
+ }
38008
38090
  return {
38009
38091
  forwardedPrompt,
38010
38092
  sanitizedRequirements,
@@ -38191,6 +38273,7 @@
38191
38273
  * Runs one prepared prompt through the deprecated OpenAI Assistant backend.
38192
38274
  */
38193
38275
  async callOpenAiAssistantChatModelStream(options) {
38276
+ var _a, _b, _c, _d;
38194
38277
  const assistant = await this.getOrPrepareOpenAiAssistant({
38195
38278
  llmTools: options.llmTools,
38196
38279
  originalPrompt: options.originalPrompt,
@@ -38198,7 +38281,14 @@
38198
38281
  onProgress: options.onProgress,
38199
38282
  });
38200
38283
  const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
38201
- console.log('!!!! promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools:', promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools);
38284
+ if (this.options.isVerbose) {
38285
+ console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
38286
+ agent: this.title,
38287
+ toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
38288
+ knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
38289
+ .knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
38290
+ });
38291
+ }
38202
38292
  return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
38203
38293
  }
38204
38294
  /**
@@ -38889,7 +38979,8 @@
38889
38979
  isVerbose: options.isVerbose,
38890
38980
  llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
38891
38981
  assistantPreparationMode: options.assistantPreparationMode,
38892
- agentSource: agentSource.value, // <- TODO: [🐱‍🚀] Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
38982
+ agentSource: agentSource.value,
38983
+ precomputedModelRequirements: options.precomputedModelRequirements,
38893
38984
  });
38894
38985
  this._agentName = undefined;
38895
38986
  /**
@@ -43152,7 +43243,7 @@
43152
43243
  // <- TODO: [🧠] Should we wrap more components in `React.memo`
43153
43244
  // Or make normal function from this?
43154
43245
  (props) => {
43155
- const { message, participant, participants, isLastMessage, onMessage, onActionButton, onQuickMessageButton, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, feedbackMode = 'stars', feedbackTranslations, timingTranslations, chatLocale, onCopy, onCreateAgent, toolTitles, teammates, onReplyToMessage, canReplyToMessage, teamAgentProfiles, CHAT_VISUAL_MODE = 'BUBBLE_MODE', onToolCallClick, onCitationClick, soundSystem, isSpeechPlaybackEnabled, elevenLabsVoiceId, chatUiTranslations, } = props;
43246
+ const { message, participant, participants, isLastMessage, onMessage, onActionButton, onQuickMessageButton, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, feedbackMode = 'stars', feedbackTranslations, timingTranslations, chatLocale, onCopy, onCreateAgent, toolTitles, teammates, onReplyToMessage, canReplyToMessage, teamAgentProfiles, CHAT_VISUAL_MODE = 'ARTICLE_MODE', onToolCallClick, onCitationClick, soundSystem, isSpeechPlaybackEnabled, elevenLabsVoiceId, chatUiTranslations, } = props;
43156
43247
  const { isComplete = true,
43157
43248
  // <- TODO: Destruct all `messages` properties like `isComplete`
43158
43249
  } = message;
@@ -46952,7 +47043,7 @@
46952
47043
  * @public exported from `@promptbook/components`
46953
47044
  */
46954
47045
  function Chat(props) {
46955
- const { title = 'Chat', messages, onChange, onMessage, onActionButton, onQuickMessageButton, onReplyToMessage, onCancelReply, onReset, resetRequiresConfirmation = true, newChatButtonHref, onFeedback, feedbackMode = 'stars', feedbackTranslations, timingTranslations, onFileUpload, chatLocale, speechRecognition, placeholderMessageContent, defaultMessage, enterBehavior, resolveEnterBehavior, children, className, style, isAiTextHumanizedAndPromptbookified = true, isVoiceCalling = false, isFocusedOnLoad, participants = [], canReplyToMessage, replyingToMessage, extraActions, actionsContainer, saveFormats, isSaveButtonEnabled = true, isCopyButtonEnabled = true, buttonColor: buttonColorRaw, onUseTemplate, onCreateAgent, toolTitles, teammates, teamAgentProfiles, visual, CHAT_VISUAL_MODE = 'BUBBLE_MODE', effectConfigs, soundSystem, speechRecognitionLanguage, isSpeechPlaybackEnabled = true, elevenLabsVoiceId, chatUiTranslations, } = props;
47046
+ const { title = 'Chat', messages, onChange, onMessage, onActionButton, onQuickMessageButton, onReplyToMessage, onCancelReply, onReset, resetRequiresConfirmation = true, newChatButtonHref, onFeedback, feedbackMode = 'stars', feedbackTranslations, timingTranslations, onFileUpload, chatLocale, speechRecognition, placeholderMessageContent, defaultMessage, enterBehavior, resolveEnterBehavior, children, className, style, isAiTextHumanizedAndPromptbookified = true, isVoiceCalling = false, isFocusedOnLoad, participants = [], canReplyToMessage, replyingToMessage, extraActions, actionsContainer, saveFormats, isSaveButtonEnabled = true, isCopyButtonEnabled = true, buttonColor: buttonColorRaw, onUseTemplate, onCreateAgent, toolTitles, teammates, teamAgentProfiles, visual, CHAT_VISUAL_MODE = 'ARTICLE_MODE', effectConfigs, soundSystem, speechRecognitionLanguage, isSpeechPlaybackEnabled = true, elevenLabsVoiceId, chatUiTranslations, } = props;
46956
47047
  const buttonColor = react.useMemo(() => Color.from(buttonColorRaw || '#0066cc'), [buttonColorRaw]);
46957
47048
  const agentParticipant = react.useMemo(() => participants.find((participant) => participant.name === 'AGENT'), [participants]);
46958
47049
  const postprocessedMessages = useChatPostprocessedMessages({