@promptbook/browser 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.
- 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
|
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
29
29
|
* @generated
|
|
30
30
|
* @see https://github.com/webgptorg/promptbook
|
|
31
31
|
*/
|
|
32
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
32
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-65';
|
|
33
33
|
/**
|
|
34
34
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
35
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6977,18 +6977,6 @@ function parseDataUrlKnowledgeSource(source) {
|
|
|
6977
6977
|
}
|
|
6978
6978
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
6979
6979
|
|
|
6980
|
-
/**
|
|
6981
|
-
* Name of the tool used by agents to search configured `KNOWLEDGE` sources.
|
|
6982
|
-
*
|
|
6983
|
-
* @public exported from `@promptbook/core`
|
|
6984
|
-
*/
|
|
6985
|
-
const KNOWLEDGE_SEARCH_TOOL_NAME = 'knowledge_search';
|
|
6986
|
-
/**
|
|
6987
|
-
* Title of the system-message section generated for `KNOWLEDGE` commitments.
|
|
6988
|
-
*
|
|
6989
|
-
* @private constant of `KnowledgeCommitmentDefinition`
|
|
6990
|
-
*/
|
|
6991
|
-
const KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE = 'Knowledge Search';
|
|
6992
6980
|
/**
|
|
6993
6981
|
* KNOWLEDGE commitment definition
|
|
6994
6982
|
*
|
|
@@ -7110,17 +7098,9 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7110
7098
|
knowledgeInfoEntries.push(`Knowledge Source Inline: ${inlineSource.filename} (derived from inline content and processed for retrieval during chat)`);
|
|
7111
7099
|
}
|
|
7112
7100
|
if (knowledgeInfoEntries.length === 0) {
|
|
7113
|
-
return
|
|
7101
|
+
return nextRequirements;
|
|
7114
7102
|
}
|
|
7115
|
-
return
|
|
7116
|
-
}
|
|
7117
|
-
/**
|
|
7118
|
-
* Gets human-readable titles for tool functions provided by this commitment.
|
|
7119
|
-
*/
|
|
7120
|
-
getToolTitles() {
|
|
7121
|
-
return {
|
|
7122
|
-
[KNOWLEDGE_SEARCH_TOOL_NAME]: 'Knowledge search',
|
|
7123
|
-
};
|
|
7103
|
+
return this.appendToSystemMessage(nextRequirements, knowledgeInfoEntries.join('\n'), '\n\n');
|
|
7124
7104
|
}
|
|
7125
7105
|
}
|
|
7126
7106
|
/**
|
|
@@ -7134,128 +7114,6 @@ function hasMeaningfulNonUrlText(content, urls) {
|
|
|
7134
7114
|
const significantText = contentWithoutUrls.replace(/[\s.,!?;:'"`()[\]{}<>/-]+/g, '');
|
|
7135
7115
|
return significantText.length > 0;
|
|
7136
7116
|
}
|
|
7137
|
-
/**
|
|
7138
|
-
* Adds the shared `knowledge_search` tool definition and the consolidated system-message section.
|
|
7139
|
-
*
|
|
7140
|
-
* @param requirements - Requirements after one `KNOWLEDGE` commitment was applied.
|
|
7141
|
-
* @returns Requirements with the knowledge search instructions and tool definition.
|
|
7142
|
-
*
|
|
7143
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
7144
|
-
*/
|
|
7145
|
-
function addKnowledgeSearchToolAndSystemSection(requirements) {
|
|
7146
|
-
const nextRequirements = addKnowledgeSearchTool(requirements);
|
|
7147
|
-
const section = createKnowledgeSearchSystemSection(nextRequirements);
|
|
7148
|
-
const sectionHeader = `## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}`;
|
|
7149
|
-
if (nextRequirements.systemMessage.includes(sectionHeader)) {
|
|
7150
|
-
return {
|
|
7151
|
-
...nextRequirements,
|
|
7152
|
-
systemMessage: nextRequirements.systemMessage.replace(new RegExp(`## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), section),
|
|
7153
|
-
};
|
|
7154
|
-
}
|
|
7155
|
-
return {
|
|
7156
|
-
...nextRequirements,
|
|
7157
|
-
systemMessage: nextRequirements.systemMessage.trim()
|
|
7158
|
-
? `${nextRequirements.systemMessage}\n\n${section}`
|
|
7159
|
-
: section,
|
|
7160
|
-
};
|
|
7161
|
-
}
|
|
7162
|
-
/**
|
|
7163
|
-
* Adds the `knowledge_search` model tool when it is not already present.
|
|
7164
|
-
*
|
|
7165
|
-
* @param requirements - Current model requirements.
|
|
7166
|
-
* @returns Requirements with the tool definition available to the model.
|
|
7167
|
-
*
|
|
7168
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
7169
|
-
*/
|
|
7170
|
-
function addKnowledgeSearchTool(requirements) {
|
|
7171
|
-
const existingTools = requirements.tools || [];
|
|
7172
|
-
if (existingTools.some((tool) => tool.name === KNOWLEDGE_SEARCH_TOOL_NAME)) {
|
|
7173
|
-
return requirements;
|
|
7174
|
-
}
|
|
7175
|
-
return {
|
|
7176
|
-
...requirements,
|
|
7177
|
-
tools: [
|
|
7178
|
-
...existingTools,
|
|
7179
|
-
{
|
|
7180
|
-
name: KNOWLEDGE_SEARCH_TOOL_NAME,
|
|
7181
|
-
description: spaceTrim$1(`
|
|
7182
|
-
Search the agent's configured knowledge sources and return relevant excerpts with citation ids.
|
|
7183
|
-
Use this before answering questions that may depend on the agent's KNOWLEDGE commitments.
|
|
7184
|
-
`),
|
|
7185
|
-
parameters: {
|
|
7186
|
-
type: 'object',
|
|
7187
|
-
properties: {
|
|
7188
|
-
query: {
|
|
7189
|
-
type: 'string',
|
|
7190
|
-
description: 'The natural-language search query for the knowledge base.',
|
|
7191
|
-
},
|
|
7192
|
-
limit: {
|
|
7193
|
-
type: 'integer',
|
|
7194
|
-
description: 'Maximum number of matching source excerpts to return.',
|
|
7195
|
-
},
|
|
7196
|
-
},
|
|
7197
|
-
required: ['query'],
|
|
7198
|
-
},
|
|
7199
|
-
},
|
|
7200
|
-
],
|
|
7201
|
-
};
|
|
7202
|
-
}
|
|
7203
|
-
/**
|
|
7204
|
-
* Creates the model-facing system-message section for knowledge search.
|
|
7205
|
-
*
|
|
7206
|
-
* @param requirements - Current model requirements.
|
|
7207
|
-
* @returns Markdown system-message section.
|
|
7208
|
-
*
|
|
7209
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
7210
|
-
*/
|
|
7211
|
-
function createKnowledgeSearchSystemSection(requirements) {
|
|
7212
|
-
const sourceEntries = createKnowledgeSourceSystemEntries(requirements);
|
|
7213
|
-
const sourceList = sourceEntries.length > 0 ? sourceEntries.map((entry) => `- ${entry}`).join('\n') : '- None';
|
|
7214
|
-
return spaceTrim$1(`
|
|
7215
|
-
## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}
|
|
7216
|
-
|
|
7217
|
-
- Use \`${KNOWLEDGE_SEARCH_TOOL_NAME}\` to search the configured knowledge sources before answering questions that depend on this agent's knowledge base.
|
|
7218
|
-
- Base source-backed factual answers on the returned excerpts.
|
|
7219
|
-
- When you use a returned excerpt, include its citation marker in the answer body, for example \`[0:0]\`.
|
|
7220
|
-
- If the search returns no relevant information, say that the knowledge base did not contain the answer instead of inventing it.
|
|
7221
|
-
|
|
7222
|
-
Configured knowledge sources:
|
|
7223
|
-
${sourceList}
|
|
7224
|
-
`);
|
|
7225
|
-
}
|
|
7226
|
-
/**
|
|
7227
|
-
* Builds a stable list of configured knowledge sources for system-message diagnostics.
|
|
7228
|
-
*
|
|
7229
|
-
* @param requirements - Current model requirements.
|
|
7230
|
-
* @returns Human-readable source entries.
|
|
7231
|
-
*
|
|
7232
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
7233
|
-
*/
|
|
7234
|
-
function createKnowledgeSourceSystemEntries(requirements) {
|
|
7235
|
-
var _a;
|
|
7236
|
-
const entries = [];
|
|
7237
|
-
const seenEntries = new Set();
|
|
7238
|
-
for (const source of requirements.knowledgeSources || []) {
|
|
7239
|
-
const entry = `Source URL: ${source} (processed for retrieval during chat)`;
|
|
7240
|
-
if (seenEntries.has(entry)) {
|
|
7241
|
-
continue;
|
|
7242
|
-
}
|
|
7243
|
-
seenEntries.add(entry);
|
|
7244
|
-
entries.push(entry);
|
|
7245
|
-
}
|
|
7246
|
-
const inlineSources = (((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.inlineKnowledgeSources) || [])
|
|
7247
|
-
.map((source) => source.filename)
|
|
7248
|
-
.filter(Boolean);
|
|
7249
|
-
for (const filename of inlineSources) {
|
|
7250
|
-
const entry = `Knowledge Source Inline: ${filename} (Inline source: processed for retrieval during chat)`;
|
|
7251
|
-
if (seenEntries.has(entry)) {
|
|
7252
|
-
continue;
|
|
7253
|
-
}
|
|
7254
|
-
seenEntries.add(entry);
|
|
7255
|
-
entries.push(entry);
|
|
7256
|
-
}
|
|
7257
|
-
return entries;
|
|
7258
|
-
}
|
|
7259
7117
|
|
|
7260
7118
|
/**
|
|
7261
7119
|
* LANGUAGE commitment definition
|
|
@@ -13000,7 +12858,11 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
13000
12858
|
// Create new system message with persona at the beginning
|
|
13001
12859
|
// Format: "You are {agentName}\n{personaContent}"
|
|
13002
12860
|
// The # PERSONA comment will be removed later by removeCommentsFromSystemMessage
|
|
13003
|
-
const personaSection =
|
|
12861
|
+
const personaSection = spaceTrim$1((block) => `
|
|
12862
|
+
# PERSONA
|
|
12863
|
+
You are ${agentName}
|
|
12864
|
+
${block(mergedPersonaContent)}
|
|
12865
|
+
`);
|
|
13004
12866
|
const newSystemMessage = cleanedMessage ? `${personaSection}\n\n${cleanedMessage}` : personaSection;
|
|
13005
12867
|
return {
|
|
13006
12868
|
...requirements,
|
|
@@ -28304,11 +28166,11 @@ function formatChatAttachmentContext(attachments) {
|
|
|
28304
28166
|
if (attachments.length === 0) {
|
|
28305
28167
|
return '';
|
|
28306
28168
|
}
|
|
28307
|
-
return
|
|
28308
|
-
|
|
28309
|
-
|
|
28310
|
-
|
|
28311
|
-
|
|
28169
|
+
return spaceTrim$1((block) => `
|
|
28170
|
+
${CHAT_ATTACHMENTS_HEADING}
|
|
28171
|
+
${block(attachments.map((attachment) => formatChatAttachmentLine(attachment)).join('\n'))}
|
|
28172
|
+
${CHAT_ATTACHMENTS_INSTRUCTION}
|
|
28173
|
+
`);
|
|
28312
28174
|
}
|
|
28313
28175
|
|
|
28314
28176
|
/**
|
|
@@ -28549,24 +28411,24 @@ function formatResolvedChatAttachmentContent(contentResolution) {
|
|
|
28549
28411
|
: ''}`
|
|
28550
28412
|
: null;
|
|
28551
28413
|
const warningsLine = contentResolution.warnings.length > 0 ? `Warnings: ${contentResolution.warnings.join(' | ')}` : null;
|
|
28552
|
-
|
|
28414
|
+
const metadataLines = [decodingLine, warningsLine].filter((line) => Boolean(line)).join('\n');
|
|
28415
|
+
const resolvedContent = contentResolution.content;
|
|
28416
|
+
if (!resolvedContent) {
|
|
28553
28417
|
const reason = contentResolution.reason || 'content unavailable';
|
|
28554
|
-
return
|
|
28555
|
-
|
|
28556
|
-
|
|
28418
|
+
return spaceTrim$1((block) => `
|
|
28419
|
+
- ${attachmentLabel}: ${reason}. URL: ${contentResolution.attachment.url}
|
|
28420
|
+
${block(metadataLines)}
|
|
28421
|
+
`);
|
|
28557
28422
|
}
|
|
28558
28423
|
const truncatedLabel = contentResolution.isTruncated ? ' [truncated]' : '';
|
|
28559
|
-
return
|
|
28560
|
-
|
|
28561
|
-
|
|
28562
|
-
|
|
28563
|
-
|
|
28564
|
-
|
|
28565
|
-
|
|
28566
|
-
|
|
28567
|
-
]
|
|
28568
|
-
.filter(Boolean)
|
|
28569
|
-
.join('\n');
|
|
28424
|
+
return spaceTrim$1((block) => `
|
|
28425
|
+
File: ${attachmentLabel}${truncatedLabel}
|
|
28426
|
+
URL: ${contentResolution.attachment.url}
|
|
28427
|
+
${block(metadataLines)}
|
|
28428
|
+
\`\`\`text
|
|
28429
|
+
${block(resolvedContent)}
|
|
28430
|
+
\`\`\`
|
|
28431
|
+
`);
|
|
28570
28432
|
}
|
|
28571
28433
|
/**
|
|
28572
28434
|
* Formats inline attachment-content context section for the model.
|
|
@@ -28580,11 +28442,14 @@ function formatChatAttachmentContentContext(resolvedContents) {
|
|
|
28580
28442
|
if (resolvedContents.length === 0) {
|
|
28581
28443
|
return '';
|
|
28582
28444
|
}
|
|
28583
|
-
return
|
|
28584
|
-
|
|
28585
|
-
|
|
28586
|
-
|
|
28587
|
-
|
|
28445
|
+
return spaceTrim$1((block) => `
|
|
28446
|
+
${CHAT_ATTACHMENT_CONTENT_HEADING}
|
|
28447
|
+
${CHAT_ATTACHMENT_CONTENT_INSTRUCTION}
|
|
28448
|
+
|
|
28449
|
+
${block(resolvedContents
|
|
28450
|
+
.map((resolvedContent) => formatResolvedChatAttachmentContent(resolvedContent))
|
|
28451
|
+
.join('\n\n'))}
|
|
28452
|
+
`);
|
|
28588
28453
|
}
|
|
28589
28454
|
|
|
28590
28455
|
/**
|
|
@@ -29729,9 +29594,11 @@ class OpenAiCompatibleUnsupportedParameterRetrier {
|
|
|
29729
29594
|
* Creates the retry-history error message shared by all OpenAI-compatible model variants.
|
|
29730
29595
|
*/
|
|
29731
29596
|
createAttemptHistoryError(finalErrorMessage) {
|
|
29732
|
-
return new PipelineExecutionError(
|
|
29733
|
-
|
|
29734
|
-
|
|
29597
|
+
return new PipelineExecutionError(spaceTrim$1((block) => `
|
|
29598
|
+
All attempts failed. Attempt history:
|
|
29599
|
+
${block(formatUnsupportedParameterAttemptHistory(this.attemptStack))}
|
|
29600
|
+
Final error: ${finalErrorMessage}
|
|
29601
|
+
`));
|
|
29735
29602
|
}
|
|
29736
29603
|
}
|
|
29737
29604
|
|
|
@@ -32325,7 +32192,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
32325
32192
|
});
|
|
32326
32193
|
}
|
|
32327
32194
|
let vectorStoreId = cachedVectorStoreId;
|
|
32328
|
-
if (
|
|
32195
|
+
if (!vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
|
|
32329
32196
|
const vectorStoreResult = await this.createVectorStoreWithKnowledgeSources({
|
|
32330
32197
|
client: await this.getClient(),
|
|
32331
32198
|
name,
|
|
@@ -32334,19 +32201,13 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
32334
32201
|
});
|
|
32335
32202
|
vectorStoreId = vectorStoreResult.vectorStoreId;
|
|
32336
32203
|
}
|
|
32337
|
-
else if (
|
|
32204
|
+
else if (vectorStoreId && this.options.isVerbose) {
|
|
32338
32205
|
console.info('[🤰]', 'Using cached vector store for AgentKit agent', {
|
|
32339
32206
|
name,
|
|
32340
32207
|
vectorStoreId,
|
|
32341
32208
|
});
|
|
32342
32209
|
}
|
|
32343
|
-
|
|
32344
|
-
vectorStoreId = undefined;
|
|
32345
|
-
}
|
|
32346
|
-
const agentKitTools = this.buildAgentKitTools({
|
|
32347
|
-
tools,
|
|
32348
|
-
vectorStoreId,
|
|
32349
|
-
});
|
|
32210
|
+
const agentKitTools = this.buildAgentKitTools({ tools, vectorStoreId });
|
|
32350
32211
|
const openAiAgentKitAgent = new Agent$1({
|
|
32351
32212
|
name,
|
|
32352
32213
|
model: this.agentKitModelName,
|
|
@@ -32365,7 +32226,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
32365
32226
|
name,
|
|
32366
32227
|
model: this.agentKitModelName,
|
|
32367
32228
|
toolCount: agentKitTools.length,
|
|
32368
|
-
hasVectorStore:
|
|
32229
|
+
hasVectorStore: Boolean(vectorStoreId),
|
|
32369
32230
|
});
|
|
32370
32231
|
}
|
|
32371
32232
|
return preparedAgent;
|
|
@@ -32864,12 +32725,6 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
32864
32725
|
get agentKitOptions() {
|
|
32865
32726
|
return this.options;
|
|
32866
32727
|
}
|
|
32867
|
-
/**
|
|
32868
|
-
* Returns true when hosted OpenAI vector-store search should back `knowledgeSources`.
|
|
32869
|
-
*/
|
|
32870
|
-
get isNativeKnowledgeSearchEnabled() {
|
|
32871
|
-
return this.agentKitOptions.isNativeKnowledgeSearchEnabled !== false;
|
|
32872
|
-
}
|
|
32873
32728
|
/**
|
|
32874
32729
|
* Discriminant for type guards.
|
|
32875
32730
|
*/
|