@promptbook/remote-server 0.112.0-64 → 0.112.0-65

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 (41) hide show
  1. package/esm/index.es.js +45 -190
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/src/_packages/components.index.d.ts +0 -2
  4. package/esm/src/_packages/core.index.d.ts +2 -2
  5. package/esm/src/_packages/types.index.d.ts +0 -2
  6. package/esm/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +27 -0
  7. package/esm/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +25 -0
  8. package/esm/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +10 -0
  9. package/esm/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +14 -0
  10. package/esm/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +43 -0
  11. package/esm/src/book-components/Chat/types/ChatMessage.d.ts +0 -34
  12. package/esm/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -11
  13. package/esm/src/commitments/_common/toolRuntimeContext.d.ts +0 -6
  14. package/esm/src/formfactors/index.d.ts +2 -2
  15. package/esm/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +1 -1
  16. package/esm/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +1 -1
  17. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +0 -4
  18. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +0 -9
  19. package/esm/src/version.d.ts +1 -1
  20. package/package.json +2 -2
  21. package/umd/index.umd.js +45 -190
  22. package/umd/index.umd.js.map +1 -1
  23. package/umd/src/_packages/components.index.d.ts +0 -2
  24. package/umd/src/_packages/core.index.d.ts +2 -2
  25. package/umd/src/_packages/types.index.d.ts +0 -2
  26. package/umd/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +27 -0
  27. package/umd/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +25 -0
  28. package/umd/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +10 -0
  29. package/umd/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +14 -0
  30. package/umd/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +43 -0
  31. package/umd/src/book-components/Chat/types/ChatMessage.d.ts +0 -34
  32. package/umd/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -11
  33. package/umd/src/commitments/_common/toolRuntimeContext.d.ts +0 -6
  34. package/umd/src/formfactors/index.d.ts +2 -2
  35. package/umd/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +1 -1
  36. package/umd/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +1 -1
  37. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +0 -4
  38. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +0 -9
  39. package/umd/src/version.d.ts +1 -1
  40. /package/esm/src/{commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts → book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.test.d.ts} +0 -0
  41. /package/umd/src/{commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts → book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.test.d.ts} +0 -0
package/umd/index.umd.js CHANGED
@@ -50,7 +50,7 @@
50
50
  * @generated
51
51
  * @see https://github.com/webgptorg/promptbook
52
52
  */
53
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-64';
53
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-65';
54
54
  /**
55
55
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
56
56
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -12689,18 +12689,6 @@
12689
12689
  }
12690
12690
  // Note: [💞] Ignore a discrepancy between file name and entity name
12691
12691
 
12692
- /**
12693
- * Name of the tool used by agents to search configured `KNOWLEDGE` sources.
12694
- *
12695
- * @public exported from `@promptbook/core`
12696
- */
12697
- const KNOWLEDGE_SEARCH_TOOL_NAME = 'knowledge_search';
12698
- /**
12699
- * Title of the system-message section generated for `KNOWLEDGE` commitments.
12700
- *
12701
- * @private constant of `KnowledgeCommitmentDefinition`
12702
- */
12703
- const KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE = 'Knowledge Search';
12704
12692
  /**
12705
12693
  * KNOWLEDGE commitment definition
12706
12694
  *
@@ -12822,17 +12810,9 @@
12822
12810
  knowledgeInfoEntries.push(`Knowledge Source Inline: ${inlineSource.filename} (derived from inline content and processed for retrieval during chat)`);
12823
12811
  }
12824
12812
  if (knowledgeInfoEntries.length === 0) {
12825
- return addKnowledgeSearchToolAndSystemSection(nextRequirements);
12813
+ return nextRequirements;
12826
12814
  }
12827
- return addKnowledgeSearchToolAndSystemSection(nextRequirements);
12828
- }
12829
- /**
12830
- * Gets human-readable titles for tool functions provided by this commitment.
12831
- */
12832
- getToolTitles() {
12833
- return {
12834
- [KNOWLEDGE_SEARCH_TOOL_NAME]: 'Knowledge search',
12835
- };
12815
+ return this.appendToSystemMessage(nextRequirements, knowledgeInfoEntries.join('\n'), '\n\n');
12836
12816
  }
12837
12817
  }
12838
12818
  /**
@@ -12846,128 +12826,6 @@
12846
12826
  const significantText = contentWithoutUrls.replace(/[\s.,!?;:'"`()[\]{}<>/-]+/g, '');
12847
12827
  return significantText.length > 0;
12848
12828
  }
12849
- /**
12850
- * Adds the shared `knowledge_search` tool definition and the consolidated system-message section.
12851
- *
12852
- * @param requirements - Requirements after one `KNOWLEDGE` commitment was applied.
12853
- * @returns Requirements with the knowledge search instructions and tool definition.
12854
- *
12855
- * @private internal utility of `KnowledgeCommitmentDefinition`
12856
- */
12857
- function addKnowledgeSearchToolAndSystemSection(requirements) {
12858
- const nextRequirements = addKnowledgeSearchTool(requirements);
12859
- const section = createKnowledgeSearchSystemSection(nextRequirements);
12860
- const sectionHeader = `## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}`;
12861
- if (nextRequirements.systemMessage.includes(sectionHeader)) {
12862
- return {
12863
- ...nextRequirements,
12864
- systemMessage: nextRequirements.systemMessage.replace(new RegExp(`## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), section),
12865
- };
12866
- }
12867
- return {
12868
- ...nextRequirements,
12869
- systemMessage: nextRequirements.systemMessage.trim()
12870
- ? `${nextRequirements.systemMessage}\n\n${section}`
12871
- : section,
12872
- };
12873
- }
12874
- /**
12875
- * Adds the `knowledge_search` model tool when it is not already present.
12876
- *
12877
- * @param requirements - Current model requirements.
12878
- * @returns Requirements with the tool definition available to the model.
12879
- *
12880
- * @private internal utility of `KnowledgeCommitmentDefinition`
12881
- */
12882
- function addKnowledgeSearchTool(requirements) {
12883
- const existingTools = requirements.tools || [];
12884
- if (existingTools.some((tool) => tool.name === KNOWLEDGE_SEARCH_TOOL_NAME)) {
12885
- return requirements;
12886
- }
12887
- return {
12888
- ...requirements,
12889
- tools: [
12890
- ...existingTools,
12891
- {
12892
- name: KNOWLEDGE_SEARCH_TOOL_NAME,
12893
- description: _spaceTrim.spaceTrim(`
12894
- Search the agent's configured knowledge sources and return relevant excerpts with citation ids.
12895
- Use this before answering questions that may depend on the agent's KNOWLEDGE commitments.
12896
- `),
12897
- parameters: {
12898
- type: 'object',
12899
- properties: {
12900
- query: {
12901
- type: 'string',
12902
- description: 'The natural-language search query for the knowledge base.',
12903
- },
12904
- limit: {
12905
- type: 'integer',
12906
- description: 'Maximum number of matching source excerpts to return.',
12907
- },
12908
- },
12909
- required: ['query'],
12910
- },
12911
- },
12912
- ],
12913
- };
12914
- }
12915
- /**
12916
- * Creates the model-facing system-message section for knowledge search.
12917
- *
12918
- * @param requirements - Current model requirements.
12919
- * @returns Markdown system-message section.
12920
- *
12921
- * @private internal utility of `KnowledgeCommitmentDefinition`
12922
- */
12923
- function createKnowledgeSearchSystemSection(requirements) {
12924
- const sourceEntries = createKnowledgeSourceSystemEntries(requirements);
12925
- const sourceList = sourceEntries.length > 0 ? sourceEntries.map((entry) => `- ${entry}`).join('\n') : '- None';
12926
- return _spaceTrim.spaceTrim(`
12927
- ## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}
12928
-
12929
- - Use \`${KNOWLEDGE_SEARCH_TOOL_NAME}\` to search the configured knowledge sources before answering questions that depend on this agent's knowledge base.
12930
- - Base source-backed factual answers on the returned excerpts.
12931
- - When you use a returned excerpt, include its citation marker in the answer body, for example \`[0:0]\`.
12932
- - If the search returns no relevant information, say that the knowledge base did not contain the answer instead of inventing it.
12933
-
12934
- Configured knowledge sources:
12935
- ${sourceList}
12936
- `);
12937
- }
12938
- /**
12939
- * Builds a stable list of configured knowledge sources for system-message diagnostics.
12940
- *
12941
- * @param requirements - Current model requirements.
12942
- * @returns Human-readable source entries.
12943
- *
12944
- * @private internal utility of `KnowledgeCommitmentDefinition`
12945
- */
12946
- function createKnowledgeSourceSystemEntries(requirements) {
12947
- var _a;
12948
- const entries = [];
12949
- const seenEntries = new Set();
12950
- for (const source of requirements.knowledgeSources || []) {
12951
- const entry = `Source URL: ${source} (processed for retrieval during chat)`;
12952
- if (seenEntries.has(entry)) {
12953
- continue;
12954
- }
12955
- seenEntries.add(entry);
12956
- entries.push(entry);
12957
- }
12958
- const inlineSources = (((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.inlineKnowledgeSources) || [])
12959
- .map((source) => source.filename)
12960
- .filter(Boolean);
12961
- for (const filename of inlineSources) {
12962
- const entry = `Knowledge Source Inline: ${filename} (Inline source: processed for retrieval during chat)`;
12963
- if (seenEntries.has(entry)) {
12964
- continue;
12965
- }
12966
- seenEntries.add(entry);
12967
- entries.push(entry);
12968
- }
12969
- return entries;
12970
- }
12971
12829
 
12972
12830
  /**
12973
12831
  * LANGUAGE commitment definition
@@ -18712,7 +18570,11 @@
18712
18570
  // Create new system message with persona at the beginning
18713
18571
  // Format: "You are {agentName}\n{personaContent}"
18714
18572
  // The # PERSONA comment will be removed later by removeCommentsFromSystemMessage
18715
- const personaSection = `# PERSONA\nYou are ${agentName}\n${mergedPersonaContent}`; // <- TODO: Use spaceTrim
18573
+ const personaSection = _spaceTrim.spaceTrim((block) => `
18574
+ # PERSONA
18575
+ You are ${agentName}
18576
+ ${block(mergedPersonaContent)}
18577
+ `);
18716
18578
  const newSystemMessage = cleanedMessage ? `${personaSection}\n\n${cleanedMessage}` : personaSection;
18717
18579
  return {
18718
18580
  ...requirements,
@@ -31075,11 +30937,11 @@
31075
30937
  if (attachments.length === 0) {
31076
30938
  return '';
31077
30939
  }
31078
- return [
31079
- CHAT_ATTACHMENTS_HEADING,
31080
- ...attachments.map((attachment) => formatChatAttachmentLine(attachment)),
31081
- CHAT_ATTACHMENTS_INSTRUCTION,
31082
- ].join('\n');
30940
+ return _spaceTrim.spaceTrim((block) => `
30941
+ ${CHAT_ATTACHMENTS_HEADING}
30942
+ ${block(attachments.map((attachment) => formatChatAttachmentLine(attachment)).join('\n'))}
30943
+ ${CHAT_ATTACHMENTS_INSTRUCTION}
30944
+ `);
31083
30945
  }
31084
30946
 
31085
30947
  /**
@@ -31320,24 +31182,24 @@
31320
31182
  : ''}`
31321
31183
  : null;
31322
31184
  const warningsLine = contentResolution.warnings.length > 0 ? `Warnings: ${contentResolution.warnings.join(' | ')}` : null;
31323
- if (!contentResolution.content) {
31185
+ const metadataLines = [decodingLine, warningsLine].filter((line) => Boolean(line)).join('\n');
31186
+ const resolvedContent = contentResolution.content;
31187
+ if (!resolvedContent) {
31324
31188
  const reason = contentResolution.reason || 'content unavailable';
31325
- return [`- ${attachmentLabel}: ${reason}. URL: ${contentResolution.attachment.url}`, decodingLine, warningsLine]
31326
- .filter(Boolean)
31327
- .join('\n');
31189
+ return _spaceTrim.spaceTrim((block) => `
31190
+ - ${attachmentLabel}: ${reason}. URL: ${contentResolution.attachment.url}
31191
+ ${block(metadataLines)}
31192
+ `);
31328
31193
  }
31329
31194
  const truncatedLabel = contentResolution.isTruncated ? ' [truncated]' : '';
31330
- return [
31331
- `File: ${attachmentLabel}${truncatedLabel}`,
31332
- `URL: ${contentResolution.attachment.url}`,
31333
- decodingLine,
31334
- warningsLine,
31335
- '```text',
31336
- contentResolution.content,
31337
- '```',
31338
- ]
31339
- .filter(Boolean)
31340
- .join('\n');
31195
+ return _spaceTrim.spaceTrim((block) => `
31196
+ File: ${attachmentLabel}${truncatedLabel}
31197
+ URL: ${contentResolution.attachment.url}
31198
+ ${block(metadataLines)}
31199
+ \`\`\`text
31200
+ ${block(resolvedContent)}
31201
+ \`\`\`
31202
+ `);
31341
31203
  }
31342
31204
  /**
31343
31205
  * Formats inline attachment-content context section for the model.
@@ -31351,11 +31213,14 @@
31351
31213
  if (resolvedContents.length === 0) {
31352
31214
  return '';
31353
31215
  }
31354
- return [
31355
- CHAT_ATTACHMENT_CONTENT_HEADING,
31356
- CHAT_ATTACHMENT_CONTENT_INSTRUCTION,
31357
- ...resolvedContents.map((resolvedContent) => formatResolvedChatAttachmentContent(resolvedContent)),
31358
- ].join('\n\n');
31216
+ return _spaceTrim.spaceTrim((block) => `
31217
+ ${CHAT_ATTACHMENT_CONTENT_HEADING}
31218
+ ${CHAT_ATTACHMENT_CONTENT_INSTRUCTION}
31219
+
31220
+ ${block(resolvedContents
31221
+ .map((resolvedContent) => formatResolvedChatAttachmentContent(resolvedContent))
31222
+ .join('\n\n'))}
31223
+ `);
31359
31224
  }
31360
31225
 
31361
31226
  /**
@@ -32500,9 +32365,11 @@
32500
32365
  * Creates the retry-history error message shared by all OpenAI-compatible model variants.
32501
32366
  */
32502
32367
  createAttemptHistoryError(finalErrorMessage) {
32503
- return new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
32504
- formatUnsupportedParameterAttemptHistory(this.attemptStack) +
32505
- `\nFinal error: ${finalErrorMessage}`);
32368
+ return new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
32369
+ All attempts failed. Attempt history:
32370
+ ${block(formatUnsupportedParameterAttemptHistory(this.attemptStack))}
32371
+ Final error: ${finalErrorMessage}
32372
+ `));
32506
32373
  }
32507
32374
  }
32508
32375
 
@@ -35096,7 +34963,7 @@
35096
34963
  });
35097
34964
  }
35098
34965
  let vectorStoreId = cachedVectorStoreId;
35099
- if (this.isNativeKnowledgeSearchEnabled && !vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
34966
+ if (!vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
35100
34967
  const vectorStoreResult = await this.createVectorStoreWithKnowledgeSources({
35101
34968
  client: await this.getClient(),
35102
34969
  name,
@@ -35105,19 +34972,13 @@
35105
34972
  });
35106
34973
  vectorStoreId = vectorStoreResult.vectorStoreId;
35107
34974
  }
35108
- else if (this.isNativeKnowledgeSearchEnabled && vectorStoreId && this.options.isVerbose) {
34975
+ else if (vectorStoreId && this.options.isVerbose) {
35109
34976
  console.info('[🤰]', 'Using cached vector store for AgentKit agent', {
35110
34977
  name,
35111
34978
  vectorStoreId,
35112
34979
  });
35113
34980
  }
35114
- if (!this.isNativeKnowledgeSearchEnabled) {
35115
- vectorStoreId = undefined;
35116
- }
35117
- const agentKitTools = this.buildAgentKitTools({
35118
- tools,
35119
- vectorStoreId,
35120
- });
34981
+ const agentKitTools = this.buildAgentKitTools({ tools, vectorStoreId });
35121
34982
  const openAiAgentKitAgent = new agents.Agent({
35122
34983
  name,
35123
34984
  model: this.agentKitModelName,
@@ -35136,7 +34997,7 @@
35136
34997
  name,
35137
34998
  model: this.agentKitModelName,
35138
34999
  toolCount: agentKitTools.length,
35139
- hasVectorStore: this.isNativeKnowledgeSearchEnabled && Boolean(vectorStoreId),
35000
+ hasVectorStore: Boolean(vectorStoreId),
35140
35001
  });
35141
35002
  }
35142
35003
  return preparedAgent;
@@ -35635,12 +35496,6 @@
35635
35496
  get agentKitOptions() {
35636
35497
  return this.options;
35637
35498
  }
35638
- /**
35639
- * Returns true when hosted OpenAI vector-store search should back `knowledgeSources`.
35640
- */
35641
- get isNativeKnowledgeSearchEnabled() {
35642
- return this.agentKitOptions.isNativeKnowledgeSearchEnabled !== false;
35643
- }
35644
35499
  /**
35645
35500
  * Discriminant for type guards.
35646
35501
  */