@promptbook/remote-server 0.112.0-63 → 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.
- package/esm/index.es.js +45 -190
- package/esm/index.es.js.map +1 -1
- package/esm/src/_packages/components.index.d.ts +0 -2
- package/esm/src/_packages/core.index.d.ts +2 -2
- package/esm/src/_packages/types.index.d.ts +0 -2
- package/esm/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +27 -0
- package/esm/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +25 -0
- package/esm/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +10 -0
- package/esm/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +14 -0
- package/esm/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +43 -0
- package/esm/src/book-components/Chat/types/ChatMessage.d.ts +0 -34
- package/esm/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -11
- package/esm/src/commitments/_common/toolRuntimeContext.d.ts +0 -6
- package/esm/src/formfactors/index.d.ts +2 -2
- package/esm/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +1 -1
- package/esm/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +0 -4
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +0 -9
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +45 -190
- package/umd/index.umd.js.map +1 -1
- package/umd/src/_packages/components.index.d.ts +0 -2
- package/umd/src/_packages/core.index.d.ts +2 -2
- package/umd/src/_packages/types.index.d.ts +0 -2
- package/umd/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +27 -0
- package/umd/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +25 -0
- package/umd/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +10 -0
- package/umd/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +14 -0
- package/umd/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +43 -0
- package/umd/src/book-components/Chat/types/ChatMessage.d.ts +0 -34
- package/umd/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -11
- package/umd/src/commitments/_common/toolRuntimeContext.d.ts +0 -6
- package/umd/src/formfactors/index.d.ts +2 -2
- package/umd/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +1 -1
- package/umd/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +0 -4
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +0 -9
- package/umd/src/version.d.ts +1 -1
- /package/esm/src/{commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts → book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.test.d.ts} +0 -0
- /package/umd/src/{commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts → book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.test.d.ts} +0 -0
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-
|
|
43
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-65';
|
|
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
|
|
@@ -12679,18 +12679,6 @@ function parseDataUrlKnowledgeSource(source) {
|
|
|
12679
12679
|
}
|
|
12680
12680
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
12681
12681
|
|
|
12682
|
-
/**
|
|
12683
|
-
* Name of the tool used by agents to search configured `KNOWLEDGE` sources.
|
|
12684
|
-
*
|
|
12685
|
-
* @public exported from `@promptbook/core`
|
|
12686
|
-
*/
|
|
12687
|
-
const KNOWLEDGE_SEARCH_TOOL_NAME = 'knowledge_search';
|
|
12688
|
-
/**
|
|
12689
|
-
* Title of the system-message section generated for `KNOWLEDGE` commitments.
|
|
12690
|
-
*
|
|
12691
|
-
* @private constant of `KnowledgeCommitmentDefinition`
|
|
12692
|
-
*/
|
|
12693
|
-
const KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE = 'Knowledge Search';
|
|
12694
12682
|
/**
|
|
12695
12683
|
* KNOWLEDGE commitment definition
|
|
12696
12684
|
*
|
|
@@ -12812,17 +12800,9 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
12812
12800
|
knowledgeInfoEntries.push(`Knowledge Source Inline: ${inlineSource.filename} (derived from inline content and processed for retrieval during chat)`);
|
|
12813
12801
|
}
|
|
12814
12802
|
if (knowledgeInfoEntries.length === 0) {
|
|
12815
|
-
return
|
|
12803
|
+
return nextRequirements;
|
|
12816
12804
|
}
|
|
12817
|
-
return
|
|
12818
|
-
}
|
|
12819
|
-
/**
|
|
12820
|
-
* Gets human-readable titles for tool functions provided by this commitment.
|
|
12821
|
-
*/
|
|
12822
|
-
getToolTitles() {
|
|
12823
|
-
return {
|
|
12824
|
-
[KNOWLEDGE_SEARCH_TOOL_NAME]: 'Knowledge search',
|
|
12825
|
-
};
|
|
12805
|
+
return this.appendToSystemMessage(nextRequirements, knowledgeInfoEntries.join('\n'), '\n\n');
|
|
12826
12806
|
}
|
|
12827
12807
|
}
|
|
12828
12808
|
/**
|
|
@@ -12836,128 +12816,6 @@ function hasMeaningfulNonUrlText(content, urls) {
|
|
|
12836
12816
|
const significantText = contentWithoutUrls.replace(/[\s.,!?;:'"`()[\]{}<>/-]+/g, '');
|
|
12837
12817
|
return significantText.length > 0;
|
|
12838
12818
|
}
|
|
12839
|
-
/**
|
|
12840
|
-
* Adds the shared `knowledge_search` tool definition and the consolidated system-message section.
|
|
12841
|
-
*
|
|
12842
|
-
* @param requirements - Requirements after one `KNOWLEDGE` commitment was applied.
|
|
12843
|
-
* @returns Requirements with the knowledge search instructions and tool definition.
|
|
12844
|
-
*
|
|
12845
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12846
|
-
*/
|
|
12847
|
-
function addKnowledgeSearchToolAndSystemSection(requirements) {
|
|
12848
|
-
const nextRequirements = addKnowledgeSearchTool(requirements);
|
|
12849
|
-
const section = createKnowledgeSearchSystemSection(nextRequirements);
|
|
12850
|
-
const sectionHeader = `## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}`;
|
|
12851
|
-
if (nextRequirements.systemMessage.includes(sectionHeader)) {
|
|
12852
|
-
return {
|
|
12853
|
-
...nextRequirements,
|
|
12854
|
-
systemMessage: nextRequirements.systemMessage.replace(new RegExp(`## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), section),
|
|
12855
|
-
};
|
|
12856
|
-
}
|
|
12857
|
-
return {
|
|
12858
|
-
...nextRequirements,
|
|
12859
|
-
systemMessage: nextRequirements.systemMessage.trim()
|
|
12860
|
-
? `${nextRequirements.systemMessage}\n\n${section}`
|
|
12861
|
-
: section,
|
|
12862
|
-
};
|
|
12863
|
-
}
|
|
12864
|
-
/**
|
|
12865
|
-
* Adds the `knowledge_search` model tool when it is not already present.
|
|
12866
|
-
*
|
|
12867
|
-
* @param requirements - Current model requirements.
|
|
12868
|
-
* @returns Requirements with the tool definition available to the model.
|
|
12869
|
-
*
|
|
12870
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12871
|
-
*/
|
|
12872
|
-
function addKnowledgeSearchTool(requirements) {
|
|
12873
|
-
const existingTools = requirements.tools || [];
|
|
12874
|
-
if (existingTools.some((tool) => tool.name === KNOWLEDGE_SEARCH_TOOL_NAME)) {
|
|
12875
|
-
return requirements;
|
|
12876
|
-
}
|
|
12877
|
-
return {
|
|
12878
|
-
...requirements,
|
|
12879
|
-
tools: [
|
|
12880
|
-
...existingTools,
|
|
12881
|
-
{
|
|
12882
|
-
name: KNOWLEDGE_SEARCH_TOOL_NAME,
|
|
12883
|
-
description: spaceTrim$1(`
|
|
12884
|
-
Search the agent's configured knowledge sources and return relevant excerpts with citation ids.
|
|
12885
|
-
Use this before answering questions that may depend on the agent's KNOWLEDGE commitments.
|
|
12886
|
-
`),
|
|
12887
|
-
parameters: {
|
|
12888
|
-
type: 'object',
|
|
12889
|
-
properties: {
|
|
12890
|
-
query: {
|
|
12891
|
-
type: 'string',
|
|
12892
|
-
description: 'The natural-language search query for the knowledge base.',
|
|
12893
|
-
},
|
|
12894
|
-
limit: {
|
|
12895
|
-
type: 'integer',
|
|
12896
|
-
description: 'Maximum number of matching source excerpts to return.',
|
|
12897
|
-
},
|
|
12898
|
-
},
|
|
12899
|
-
required: ['query'],
|
|
12900
|
-
},
|
|
12901
|
-
},
|
|
12902
|
-
],
|
|
12903
|
-
};
|
|
12904
|
-
}
|
|
12905
|
-
/**
|
|
12906
|
-
* Creates the model-facing system-message section for knowledge search.
|
|
12907
|
-
*
|
|
12908
|
-
* @param requirements - Current model requirements.
|
|
12909
|
-
* @returns Markdown system-message section.
|
|
12910
|
-
*
|
|
12911
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12912
|
-
*/
|
|
12913
|
-
function createKnowledgeSearchSystemSection(requirements) {
|
|
12914
|
-
const sourceEntries = createKnowledgeSourceSystemEntries(requirements);
|
|
12915
|
-
const sourceList = sourceEntries.length > 0 ? sourceEntries.map((entry) => `- ${entry}`).join('\n') : '- None';
|
|
12916
|
-
return spaceTrim$1(`
|
|
12917
|
-
## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}
|
|
12918
|
-
|
|
12919
|
-
- Use \`${KNOWLEDGE_SEARCH_TOOL_NAME}\` to search the configured knowledge sources before answering questions that depend on this agent's knowledge base.
|
|
12920
|
-
- Base source-backed factual answers on the returned excerpts.
|
|
12921
|
-
- When you use a returned excerpt, include its citation marker in the answer body, for example \`[0:0]\`.
|
|
12922
|
-
- If the search returns no relevant information, say that the knowledge base did not contain the answer instead of inventing it.
|
|
12923
|
-
|
|
12924
|
-
Configured knowledge sources:
|
|
12925
|
-
${sourceList}
|
|
12926
|
-
`);
|
|
12927
|
-
}
|
|
12928
|
-
/**
|
|
12929
|
-
* Builds a stable list of configured knowledge sources for system-message diagnostics.
|
|
12930
|
-
*
|
|
12931
|
-
* @param requirements - Current model requirements.
|
|
12932
|
-
* @returns Human-readable source entries.
|
|
12933
|
-
*
|
|
12934
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12935
|
-
*/
|
|
12936
|
-
function createKnowledgeSourceSystemEntries(requirements) {
|
|
12937
|
-
var _a;
|
|
12938
|
-
const entries = [];
|
|
12939
|
-
const seenEntries = new Set();
|
|
12940
|
-
for (const source of requirements.knowledgeSources || []) {
|
|
12941
|
-
const entry = `Source URL: ${source} (processed for retrieval during chat)`;
|
|
12942
|
-
if (seenEntries.has(entry)) {
|
|
12943
|
-
continue;
|
|
12944
|
-
}
|
|
12945
|
-
seenEntries.add(entry);
|
|
12946
|
-
entries.push(entry);
|
|
12947
|
-
}
|
|
12948
|
-
const inlineSources = (((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.inlineKnowledgeSources) || [])
|
|
12949
|
-
.map((source) => source.filename)
|
|
12950
|
-
.filter(Boolean);
|
|
12951
|
-
for (const filename of inlineSources) {
|
|
12952
|
-
const entry = `Knowledge Source Inline: ${filename} (Inline source: processed for retrieval during chat)`;
|
|
12953
|
-
if (seenEntries.has(entry)) {
|
|
12954
|
-
continue;
|
|
12955
|
-
}
|
|
12956
|
-
seenEntries.add(entry);
|
|
12957
|
-
entries.push(entry);
|
|
12958
|
-
}
|
|
12959
|
-
return entries;
|
|
12960
|
-
}
|
|
12961
12819
|
|
|
12962
12820
|
/**
|
|
12963
12821
|
* LANGUAGE commitment definition
|
|
@@ -18702,7 +18560,11 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18702
18560
|
// Create new system message with persona at the beginning
|
|
18703
18561
|
// Format: "You are {agentName}\n{personaContent}"
|
|
18704
18562
|
// The # PERSONA comment will be removed later by removeCommentsFromSystemMessage
|
|
18705
|
-
const personaSection =
|
|
18563
|
+
const personaSection = spaceTrim$1((block) => `
|
|
18564
|
+
# PERSONA
|
|
18565
|
+
You are ${agentName}
|
|
18566
|
+
${block(mergedPersonaContent)}
|
|
18567
|
+
`);
|
|
18706
18568
|
const newSystemMessage = cleanedMessage ? `${personaSection}\n\n${cleanedMessage}` : personaSection;
|
|
18707
18569
|
return {
|
|
18708
18570
|
...requirements,
|
|
@@ -31065,11 +30927,11 @@ function formatChatAttachmentContext(attachments) {
|
|
|
31065
30927
|
if (attachments.length === 0) {
|
|
31066
30928
|
return '';
|
|
31067
30929
|
}
|
|
31068
|
-
return
|
|
31069
|
-
|
|
31070
|
-
|
|
31071
|
-
|
|
31072
|
-
|
|
30930
|
+
return spaceTrim$1((block) => `
|
|
30931
|
+
${CHAT_ATTACHMENTS_HEADING}
|
|
30932
|
+
${block(attachments.map((attachment) => formatChatAttachmentLine(attachment)).join('\n'))}
|
|
30933
|
+
${CHAT_ATTACHMENTS_INSTRUCTION}
|
|
30934
|
+
`);
|
|
31073
30935
|
}
|
|
31074
30936
|
|
|
31075
30937
|
/**
|
|
@@ -31310,24 +31172,24 @@ function formatResolvedChatAttachmentContent(contentResolution) {
|
|
|
31310
31172
|
: ''}`
|
|
31311
31173
|
: null;
|
|
31312
31174
|
const warningsLine = contentResolution.warnings.length > 0 ? `Warnings: ${contentResolution.warnings.join(' | ')}` : null;
|
|
31313
|
-
|
|
31175
|
+
const metadataLines = [decodingLine, warningsLine].filter((line) => Boolean(line)).join('\n');
|
|
31176
|
+
const resolvedContent = contentResolution.content;
|
|
31177
|
+
if (!resolvedContent) {
|
|
31314
31178
|
const reason = contentResolution.reason || 'content unavailable';
|
|
31315
|
-
return
|
|
31316
|
-
|
|
31317
|
-
|
|
31179
|
+
return spaceTrim$1((block) => `
|
|
31180
|
+
- ${attachmentLabel}: ${reason}. URL: ${contentResolution.attachment.url}
|
|
31181
|
+
${block(metadataLines)}
|
|
31182
|
+
`);
|
|
31318
31183
|
}
|
|
31319
31184
|
const truncatedLabel = contentResolution.isTruncated ? ' [truncated]' : '';
|
|
31320
|
-
return
|
|
31321
|
-
|
|
31322
|
-
|
|
31323
|
-
|
|
31324
|
-
|
|
31325
|
-
|
|
31326
|
-
|
|
31327
|
-
|
|
31328
|
-
]
|
|
31329
|
-
.filter(Boolean)
|
|
31330
|
-
.join('\n');
|
|
31185
|
+
return spaceTrim$1((block) => `
|
|
31186
|
+
File: ${attachmentLabel}${truncatedLabel}
|
|
31187
|
+
URL: ${contentResolution.attachment.url}
|
|
31188
|
+
${block(metadataLines)}
|
|
31189
|
+
\`\`\`text
|
|
31190
|
+
${block(resolvedContent)}
|
|
31191
|
+
\`\`\`
|
|
31192
|
+
`);
|
|
31331
31193
|
}
|
|
31332
31194
|
/**
|
|
31333
31195
|
* Formats inline attachment-content context section for the model.
|
|
@@ -31341,11 +31203,14 @@ function formatChatAttachmentContentContext(resolvedContents) {
|
|
|
31341
31203
|
if (resolvedContents.length === 0) {
|
|
31342
31204
|
return '';
|
|
31343
31205
|
}
|
|
31344
|
-
return
|
|
31345
|
-
|
|
31346
|
-
|
|
31347
|
-
|
|
31348
|
-
|
|
31206
|
+
return spaceTrim$1((block) => `
|
|
31207
|
+
${CHAT_ATTACHMENT_CONTENT_HEADING}
|
|
31208
|
+
${CHAT_ATTACHMENT_CONTENT_INSTRUCTION}
|
|
31209
|
+
|
|
31210
|
+
${block(resolvedContents
|
|
31211
|
+
.map((resolvedContent) => formatResolvedChatAttachmentContent(resolvedContent))
|
|
31212
|
+
.join('\n\n'))}
|
|
31213
|
+
`);
|
|
31349
31214
|
}
|
|
31350
31215
|
|
|
31351
31216
|
/**
|
|
@@ -32490,9 +32355,11 @@ class OpenAiCompatibleUnsupportedParameterRetrier {
|
|
|
32490
32355
|
* Creates the retry-history error message shared by all OpenAI-compatible model variants.
|
|
32491
32356
|
*/
|
|
32492
32357
|
createAttemptHistoryError(finalErrorMessage) {
|
|
32493
|
-
return new PipelineExecutionError(
|
|
32494
|
-
|
|
32495
|
-
|
|
32358
|
+
return new PipelineExecutionError(spaceTrim$1((block) => `
|
|
32359
|
+
All attempts failed. Attempt history:
|
|
32360
|
+
${block(formatUnsupportedParameterAttemptHistory(this.attemptStack))}
|
|
32361
|
+
Final error: ${finalErrorMessage}
|
|
32362
|
+
`));
|
|
32496
32363
|
}
|
|
32497
32364
|
}
|
|
32498
32365
|
|
|
@@ -35086,7 +34953,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
35086
34953
|
});
|
|
35087
34954
|
}
|
|
35088
34955
|
let vectorStoreId = cachedVectorStoreId;
|
|
35089
|
-
if (
|
|
34956
|
+
if (!vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
|
|
35090
34957
|
const vectorStoreResult = await this.createVectorStoreWithKnowledgeSources({
|
|
35091
34958
|
client: await this.getClient(),
|
|
35092
34959
|
name,
|
|
@@ -35095,19 +34962,13 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
35095
34962
|
});
|
|
35096
34963
|
vectorStoreId = vectorStoreResult.vectorStoreId;
|
|
35097
34964
|
}
|
|
35098
|
-
else if (
|
|
34965
|
+
else if (vectorStoreId && this.options.isVerbose) {
|
|
35099
34966
|
console.info('[🤰]', 'Using cached vector store for AgentKit agent', {
|
|
35100
34967
|
name,
|
|
35101
34968
|
vectorStoreId,
|
|
35102
34969
|
});
|
|
35103
34970
|
}
|
|
35104
|
-
|
|
35105
|
-
vectorStoreId = undefined;
|
|
35106
|
-
}
|
|
35107
|
-
const agentKitTools = this.buildAgentKitTools({
|
|
35108
|
-
tools,
|
|
35109
|
-
vectorStoreId,
|
|
35110
|
-
});
|
|
34971
|
+
const agentKitTools = this.buildAgentKitTools({ tools, vectorStoreId });
|
|
35111
34972
|
const openAiAgentKitAgent = new Agent$1({
|
|
35112
34973
|
name,
|
|
35113
34974
|
model: this.agentKitModelName,
|
|
@@ -35126,7 +34987,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
35126
34987
|
name,
|
|
35127
34988
|
model: this.agentKitModelName,
|
|
35128
34989
|
toolCount: agentKitTools.length,
|
|
35129
|
-
hasVectorStore:
|
|
34990
|
+
hasVectorStore: Boolean(vectorStoreId),
|
|
35130
34991
|
});
|
|
35131
34992
|
}
|
|
35132
34993
|
return preparedAgent;
|
|
@@ -35625,12 +35486,6 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
35625
35486
|
get agentKitOptions() {
|
|
35626
35487
|
return this.options;
|
|
35627
35488
|
}
|
|
35628
|
-
/**
|
|
35629
|
-
* Returns true when hosted OpenAI vector-store search should back `knowledgeSources`.
|
|
35630
|
-
*/
|
|
35631
|
-
get isNativeKnowledgeSearchEnabled() {
|
|
35632
|
-
return this.agentKitOptions.isNativeKnowledgeSearchEnabled !== false;
|
|
35633
|
-
}
|
|
35634
35489
|
/**
|
|
35635
35490
|
* Discriminant for type guards.
|
|
35636
35491
|
*/
|