@promptbook/core 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 +873 -236
- 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 +1 -2
- package/umd/index.umd.js +873 -236
- 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/umd/index.umd.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-65';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -12087,18 +12087,6 @@
|
|
|
12087
12087
|
}
|
|
12088
12088
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
12089
12089
|
|
|
12090
|
-
/**
|
|
12091
|
-
* Name of the tool used by agents to search configured `KNOWLEDGE` sources.
|
|
12092
|
-
*
|
|
12093
|
-
* @public exported from `@promptbook/core`
|
|
12094
|
-
*/
|
|
12095
|
-
const KNOWLEDGE_SEARCH_TOOL_NAME = 'knowledge_search';
|
|
12096
|
-
/**
|
|
12097
|
-
* Title of the system-message section generated for `KNOWLEDGE` commitments.
|
|
12098
|
-
*
|
|
12099
|
-
* @private constant of `KnowledgeCommitmentDefinition`
|
|
12100
|
-
*/
|
|
12101
|
-
const KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE = 'Knowledge Search';
|
|
12102
12090
|
/**
|
|
12103
12091
|
* KNOWLEDGE commitment definition
|
|
12104
12092
|
*
|
|
@@ -12220,17 +12208,9 @@
|
|
|
12220
12208
|
knowledgeInfoEntries.push(`Knowledge Source Inline: ${inlineSource.filename} (derived from inline content and processed for retrieval during chat)`);
|
|
12221
12209
|
}
|
|
12222
12210
|
if (knowledgeInfoEntries.length === 0) {
|
|
12223
|
-
return
|
|
12211
|
+
return nextRequirements;
|
|
12224
12212
|
}
|
|
12225
|
-
return
|
|
12226
|
-
}
|
|
12227
|
-
/**
|
|
12228
|
-
* Gets human-readable titles for tool functions provided by this commitment.
|
|
12229
|
-
*/
|
|
12230
|
-
getToolTitles() {
|
|
12231
|
-
return {
|
|
12232
|
-
[KNOWLEDGE_SEARCH_TOOL_NAME]: 'Knowledge search',
|
|
12233
|
-
};
|
|
12213
|
+
return this.appendToSystemMessage(nextRequirements, knowledgeInfoEntries.join('\n'), '\n\n');
|
|
12234
12214
|
}
|
|
12235
12215
|
}
|
|
12236
12216
|
/**
|
|
@@ -12244,128 +12224,6 @@
|
|
|
12244
12224
|
const significantText = contentWithoutUrls.replace(/[\s.,!?;:'"`()[\]{}<>/-]+/g, '');
|
|
12245
12225
|
return significantText.length > 0;
|
|
12246
12226
|
}
|
|
12247
|
-
/**
|
|
12248
|
-
* Adds the shared `knowledge_search` tool definition and the consolidated system-message section.
|
|
12249
|
-
*
|
|
12250
|
-
* @param requirements - Requirements after one `KNOWLEDGE` commitment was applied.
|
|
12251
|
-
* @returns Requirements with the knowledge search instructions and tool definition.
|
|
12252
|
-
*
|
|
12253
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12254
|
-
*/
|
|
12255
|
-
function addKnowledgeSearchToolAndSystemSection(requirements) {
|
|
12256
|
-
const nextRequirements = addKnowledgeSearchTool(requirements);
|
|
12257
|
-
const section = createKnowledgeSearchSystemSection(nextRequirements);
|
|
12258
|
-
const sectionHeader = `## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}`;
|
|
12259
|
-
if (nextRequirements.systemMessage.includes(sectionHeader)) {
|
|
12260
|
-
return {
|
|
12261
|
-
...nextRequirements,
|
|
12262
|
-
systemMessage: nextRequirements.systemMessage.replace(new RegExp(`## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), section),
|
|
12263
|
-
};
|
|
12264
|
-
}
|
|
12265
|
-
return {
|
|
12266
|
-
...nextRequirements,
|
|
12267
|
-
systemMessage: nextRequirements.systemMessage.trim()
|
|
12268
|
-
? `${nextRequirements.systemMessage}\n\n${section}`
|
|
12269
|
-
: section,
|
|
12270
|
-
};
|
|
12271
|
-
}
|
|
12272
|
-
/**
|
|
12273
|
-
* Adds the `knowledge_search` model tool when it is not already present.
|
|
12274
|
-
*
|
|
12275
|
-
* @param requirements - Current model requirements.
|
|
12276
|
-
* @returns Requirements with the tool definition available to the model.
|
|
12277
|
-
*
|
|
12278
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12279
|
-
*/
|
|
12280
|
-
function addKnowledgeSearchTool(requirements) {
|
|
12281
|
-
const existingTools = requirements.tools || [];
|
|
12282
|
-
if (existingTools.some((tool) => tool.name === KNOWLEDGE_SEARCH_TOOL_NAME)) {
|
|
12283
|
-
return requirements;
|
|
12284
|
-
}
|
|
12285
|
-
return {
|
|
12286
|
-
...requirements,
|
|
12287
|
-
tools: [
|
|
12288
|
-
...existingTools,
|
|
12289
|
-
{
|
|
12290
|
-
name: KNOWLEDGE_SEARCH_TOOL_NAME,
|
|
12291
|
-
description: spacetrim.spaceTrim(`
|
|
12292
|
-
Search the agent's configured knowledge sources and return relevant excerpts with citation ids.
|
|
12293
|
-
Use this before answering questions that may depend on the agent's KNOWLEDGE commitments.
|
|
12294
|
-
`),
|
|
12295
|
-
parameters: {
|
|
12296
|
-
type: 'object',
|
|
12297
|
-
properties: {
|
|
12298
|
-
query: {
|
|
12299
|
-
type: 'string',
|
|
12300
|
-
description: 'The natural-language search query for the knowledge base.',
|
|
12301
|
-
},
|
|
12302
|
-
limit: {
|
|
12303
|
-
type: 'integer',
|
|
12304
|
-
description: 'Maximum number of matching source excerpts to return.',
|
|
12305
|
-
},
|
|
12306
|
-
},
|
|
12307
|
-
required: ['query'],
|
|
12308
|
-
},
|
|
12309
|
-
},
|
|
12310
|
-
],
|
|
12311
|
-
};
|
|
12312
|
-
}
|
|
12313
|
-
/**
|
|
12314
|
-
* Creates the model-facing system-message section for knowledge search.
|
|
12315
|
-
*
|
|
12316
|
-
* @param requirements - Current model requirements.
|
|
12317
|
-
* @returns Markdown system-message section.
|
|
12318
|
-
*
|
|
12319
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12320
|
-
*/
|
|
12321
|
-
function createKnowledgeSearchSystemSection(requirements) {
|
|
12322
|
-
const sourceEntries = createKnowledgeSourceSystemEntries(requirements);
|
|
12323
|
-
const sourceList = sourceEntries.length > 0 ? sourceEntries.map((entry) => `- ${entry}`).join('\n') : '- None';
|
|
12324
|
-
return spacetrim.spaceTrim(`
|
|
12325
|
-
## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}
|
|
12326
|
-
|
|
12327
|
-
- Use \`${KNOWLEDGE_SEARCH_TOOL_NAME}\` to search the configured knowledge sources before answering questions that depend on this agent's knowledge base.
|
|
12328
|
-
- Base source-backed factual answers on the returned excerpts.
|
|
12329
|
-
- When you use a returned excerpt, include its citation marker in the answer body, for example \`[0:0]\`.
|
|
12330
|
-
- If the search returns no relevant information, say that the knowledge base did not contain the answer instead of inventing it.
|
|
12331
|
-
|
|
12332
|
-
Configured knowledge sources:
|
|
12333
|
-
${sourceList}
|
|
12334
|
-
`);
|
|
12335
|
-
}
|
|
12336
|
-
/**
|
|
12337
|
-
* Builds a stable list of configured knowledge sources for system-message diagnostics.
|
|
12338
|
-
*
|
|
12339
|
-
* @param requirements - Current model requirements.
|
|
12340
|
-
* @returns Human-readable source entries.
|
|
12341
|
-
*
|
|
12342
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12343
|
-
*/
|
|
12344
|
-
function createKnowledgeSourceSystemEntries(requirements) {
|
|
12345
|
-
var _a;
|
|
12346
|
-
const entries = [];
|
|
12347
|
-
const seenEntries = new Set();
|
|
12348
|
-
for (const source of requirements.knowledgeSources || []) {
|
|
12349
|
-
const entry = `Source URL: ${source} (processed for retrieval during chat)`;
|
|
12350
|
-
if (seenEntries.has(entry)) {
|
|
12351
|
-
continue;
|
|
12352
|
-
}
|
|
12353
|
-
seenEntries.add(entry);
|
|
12354
|
-
entries.push(entry);
|
|
12355
|
-
}
|
|
12356
|
-
const inlineSources = (((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.inlineKnowledgeSources) || [])
|
|
12357
|
-
.map((source) => source.filename)
|
|
12358
|
-
.filter(Boolean);
|
|
12359
|
-
for (const filename of inlineSources) {
|
|
12360
|
-
const entry = `Knowledge Source Inline: ${filename} (Inline source: processed for retrieval during chat)`;
|
|
12361
|
-
if (seenEntries.has(entry)) {
|
|
12362
|
-
continue;
|
|
12363
|
-
}
|
|
12364
|
-
seenEntries.add(entry);
|
|
12365
|
-
entries.push(entry);
|
|
12366
|
-
}
|
|
12367
|
-
return entries;
|
|
12368
|
-
}
|
|
12369
12227
|
|
|
12370
12228
|
/**
|
|
12371
12229
|
* LANGUAGE commitment definition
|
|
@@ -18091,7 +17949,11 @@
|
|
|
18091
17949
|
// Create new system message with persona at the beginning
|
|
18092
17950
|
// Format: "You are {agentName}\n{personaContent}"
|
|
18093
17951
|
// The # PERSONA comment will be removed later by removeCommentsFromSystemMessage
|
|
18094
|
-
const personaSection =
|
|
17952
|
+
const personaSection = spacetrim.spaceTrim((block) => `
|
|
17953
|
+
# PERSONA
|
|
17954
|
+
You are ${agentName}
|
|
17955
|
+
${block(mergedPersonaContent)}
|
|
17956
|
+
`);
|
|
18095
17957
|
const newSystemMessage = cleanedMessage ? `${personaSection}\n\n${cleanedMessage}` : personaSection;
|
|
18096
17958
|
return {
|
|
18097
17959
|
...requirements,
|
|
@@ -27698,6 +27560,791 @@
|
|
|
27698
27560
|
// <- [🐱🚀] Buttons into genesis book
|
|
27699
27561
|
// <- TODO: [🐱🚀] generateBookBoilerplate and deprecate `DEFAULT_BOOK`
|
|
27700
27562
|
|
|
27563
|
+
/**
|
|
27564
|
+
* Warning message used for unfinished commitments.
|
|
27565
|
+
*/
|
|
27566
|
+
const UNFINISHED_COMMITMENT_MESSAGE = 'This commitment is unfinished and not ready to use. Be careful when using it.';
|
|
27567
|
+
/**
|
|
27568
|
+
* Low-level warning message used for low-level commitments.
|
|
27569
|
+
*/
|
|
27570
|
+
const LOW_LEVEL_COMMITMENT_MESSAGE = 'This commitment is low-level and not used by most of the users. Be careful when using it.';
|
|
27571
|
+
/**
|
|
27572
|
+
* Short badge text used for deprecated commitments.
|
|
27573
|
+
*/
|
|
27574
|
+
const DEPRECATED_COMMITMENT_BADGE_LABEL = 'Deprecated';
|
|
27575
|
+
/**
|
|
27576
|
+
* Short badge text used for unfinished and low-level commitments.
|
|
27577
|
+
*/
|
|
27578
|
+
const LOW_LEVEL_COMMITMENT_BADGE_LABEL = 'Low-level';
|
|
27579
|
+
/**
|
|
27580
|
+
* Longer label used for deprecated commitments.
|
|
27581
|
+
*/
|
|
27582
|
+
const DEPRECATED_COMMITMENT_DETAIL_LABEL = 'Deprecated commitment';
|
|
27583
|
+
/**
|
|
27584
|
+
* Longer label used for unfinished and low-level commitments.
|
|
27585
|
+
*/
|
|
27586
|
+
const LOW_LEVEL_COMMITMENT_DETAIL_LABEL = 'Low-level commitment';
|
|
27587
|
+
/**
|
|
27588
|
+
* Prefix used when formatting replacement guidance.
|
|
27589
|
+
*/
|
|
27590
|
+
const PREFERRED_REPLACEMENT_LABEL = 'Preferred replacement';
|
|
27591
|
+
/**
|
|
27592
|
+
* Formats preferred replacement guidance for deprecated commitments.
|
|
27593
|
+
*
|
|
27594
|
+
* @param replacedBy - Preferred replacement commitment keywords.
|
|
27595
|
+
* @returns Optional replacement guidance sentence with leading space.
|
|
27596
|
+
*
|
|
27597
|
+
* @private internal utility of commitment catalog notices
|
|
27598
|
+
*/
|
|
27599
|
+
function formatCommitmentReplacementText(replacedBy) {
|
|
27600
|
+
if (!replacedBy || replacedBy.length === 0) {
|
|
27601
|
+
return '';
|
|
27602
|
+
}
|
|
27603
|
+
return ` ${PREFERRED_REPLACEMENT_LABEL}: ${replacedBy.map((type) => `\`${type}\``).join(', ')}.`;
|
|
27604
|
+
}
|
|
27605
|
+
/**
|
|
27606
|
+
* Resolves the notice metadata for deprecated, unfinished, or low-level commitments.
|
|
27607
|
+
*
|
|
27608
|
+
* @param definition - Commitment definition to inspect.
|
|
27609
|
+
* @returns Notice metadata when the commitment should be surfaced with caution.
|
|
27610
|
+
*
|
|
27611
|
+
* @private internal utility of commitment catalog notices
|
|
27612
|
+
*/
|
|
27613
|
+
function getCommitmentNoticeMetadata(definition) {
|
|
27614
|
+
if (definition.isUnfinished) {
|
|
27615
|
+
return {
|
|
27616
|
+
kind: 'unfinished',
|
|
27617
|
+
badgeLabel: LOW_LEVEL_COMMITMENT_BADGE_LABEL,
|
|
27618
|
+
detailLabel: LOW_LEVEL_COMMITMENT_DETAIL_LABEL,
|
|
27619
|
+
message: UNFINISHED_COMMITMENT_MESSAGE,
|
|
27620
|
+
};
|
|
27621
|
+
}
|
|
27622
|
+
if (definition.isLowLevel) {
|
|
27623
|
+
return {
|
|
27624
|
+
kind: 'lowLevel',
|
|
27625
|
+
badgeLabel: LOW_LEVEL_COMMITMENT_BADGE_LABEL,
|
|
27626
|
+
detailLabel: LOW_LEVEL_COMMITMENT_DETAIL_LABEL,
|
|
27627
|
+
message: LOW_LEVEL_COMMITMENT_MESSAGE,
|
|
27628
|
+
};
|
|
27629
|
+
}
|
|
27630
|
+
if (definition.deprecation) {
|
|
27631
|
+
return {
|
|
27632
|
+
kind: 'deprecated',
|
|
27633
|
+
badgeLabel: DEPRECATED_COMMITMENT_BADGE_LABEL,
|
|
27634
|
+
detailLabel: DEPRECATED_COMMITMENT_DETAIL_LABEL,
|
|
27635
|
+
message: definition.deprecation.message,
|
|
27636
|
+
};
|
|
27637
|
+
}
|
|
27638
|
+
return null;
|
|
27639
|
+
}
|
|
27640
|
+
|
|
27641
|
+
/**
|
|
27642
|
+
* Common anti-patterns with practical fixes.
|
|
27643
|
+
*
|
|
27644
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
27645
|
+
*/
|
|
27646
|
+
const bookLanguageCommonPitfalls = [
|
|
27647
|
+
{
|
|
27648
|
+
title: 'Too broad agent scope',
|
|
27649
|
+
dont: 'One agent tries to be a lawyer, developer, marketer, and researcher at once.',
|
|
27650
|
+
doInstead: 'Split into focused agents and orchestrate with TEAM or IMPORT.',
|
|
27651
|
+
},
|
|
27652
|
+
{
|
|
27653
|
+
title: 'Unverifiable claims',
|
|
27654
|
+
dont: 'The agent answers internet-dependent questions without tools or without citing sources.',
|
|
27655
|
+
doInstead: 'Add `USE SEARCH ENGINE` / `USE BROWSER` and a citation-oriented `RULE`.',
|
|
27656
|
+
},
|
|
27657
|
+
{
|
|
27658
|
+
title: 'Missing guardrails',
|
|
27659
|
+
dont: 'Only persona is defined, with no behavioral constraints.',
|
|
27660
|
+
doInstead: 'Add concrete `RULE` commitments for safety, scope, and tone.',
|
|
27661
|
+
},
|
|
27662
|
+
{
|
|
27663
|
+
title: 'Overloaded inheritance',
|
|
27664
|
+
dont: 'Using deep `FROM` chains without documenting why each parent is needed.',
|
|
27665
|
+
doInstead: 'Keep inheritance shallow and use focused IMPORT/TEAM composition for reuse.',
|
|
27666
|
+
},
|
|
27667
|
+
{
|
|
27668
|
+
title: 'Unsafe memory usage',
|
|
27669
|
+
dont: 'Storing every detail in memory without boundaries.',
|
|
27670
|
+
doInstead: 'Pair `MEMORY` with explicit rules about what is allowed to persist.',
|
|
27671
|
+
},
|
|
27672
|
+
];
|
|
27673
|
+
|
|
27674
|
+
/**
|
|
27675
|
+
* End-to-end examples used by the standalone Book language documentation.
|
|
27676
|
+
*
|
|
27677
|
+
* These are intentionally compact but complete, so they can be copy-pasted and
|
|
27678
|
+
* used as practical starting points.
|
|
27679
|
+
*
|
|
27680
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
27681
|
+
*/
|
|
27682
|
+
const bookLanguageDocumentationExamples = [
|
|
27683
|
+
{
|
|
27684
|
+
id: 'minimal-hello-world-agent',
|
|
27685
|
+
title: 'Minimal hello-world agent',
|
|
27686
|
+
goal: 'Create the smallest useful agent with identity and greeting.',
|
|
27687
|
+
source: spacetrim.spaceTrim(`
|
|
27688
|
+
Hello World Agent
|
|
27689
|
+
|
|
27690
|
+
GOAL Be a concise and friendly assistant.
|
|
27691
|
+
INITIAL MESSAGE Hello! I am ready to help.
|
|
27692
|
+
CLOSED
|
|
27693
|
+
`),
|
|
27694
|
+
walkthrough: [
|
|
27695
|
+
'The first line (`Hello World Agent`) is the agent name.',
|
|
27696
|
+
'`GOAL` defines the effective role and profile text.',
|
|
27697
|
+
'`INITIAL MESSAGE` sets a deterministic first message for a new chat.',
|
|
27698
|
+
'`CLOSED` prevents conversational self-modification.',
|
|
27699
|
+
],
|
|
27700
|
+
},
|
|
27701
|
+
{
|
|
27702
|
+
id: 'tool-using-browser-search-agent',
|
|
27703
|
+
title: 'Tool-using agent (Browser + Search engine)',
|
|
27704
|
+
goal: 'Enable internet research with clear sourcing behavior.',
|
|
27705
|
+
source: spacetrim.spaceTrim(`
|
|
27706
|
+
Web Research Assistant
|
|
27707
|
+
|
|
27708
|
+
GOAL Research topics using fresh and verifiable information.
|
|
27709
|
+
USE SEARCH ENGINE Prefer official sources and recent publications.
|
|
27710
|
+
USE BROWSER
|
|
27711
|
+
RULE Verify important claims across multiple sources when possible.
|
|
27712
|
+
RULE Include source links in your final answer.
|
|
27713
|
+
INITIAL MESSAGE Ask me what topic you want to research and how deep the report should be.
|
|
27714
|
+
`),
|
|
27715
|
+
walkthrough: [
|
|
27716
|
+
'`USE SEARCH ENGINE` provides web search tooling and optional search instructions.',
|
|
27717
|
+
'`USE BROWSER` enables URL fetching and interactive browsing tools.',
|
|
27718
|
+
'`RULE` commitments make reliability behavior explicit and repeatable.',
|
|
27719
|
+
'This pattern is ideal for current-events and fact-checking agents.',
|
|
27720
|
+
],
|
|
27721
|
+
},
|
|
27722
|
+
{
|
|
27723
|
+
id: 'rule-and-knowledge-agent',
|
|
27724
|
+
title: 'Agent with RULE and KNOWLEDGE',
|
|
27725
|
+
goal: 'Ground responses in explicit constraints and curated sources.',
|
|
27726
|
+
source: spacetrim.spaceTrim(`
|
|
27727
|
+
Support Policy Assistant
|
|
27728
|
+
|
|
27729
|
+
GOAL Answer questions about support policy.
|
|
27730
|
+
KNOWLEDGE Refunds are available within 30 days with proof of purchase.
|
|
27731
|
+
KNOWLEDGE https://example.com/support-policy
|
|
27732
|
+
RULE If a policy item is missing in available knowledge, say it explicitly.
|
|
27733
|
+
RULE Never invent legal or policy statements.
|
|
27734
|
+
INITIAL MESSAGE I can explain refund and support rules from provided knowledge.
|
|
27735
|
+
`),
|
|
27736
|
+
walkthrough: [
|
|
27737
|
+
'`KNOWLEDGE` may be inline text or an external URL/document.',
|
|
27738
|
+
'`RULE` commitments define non-negotiable behavior constraints.',
|
|
27739
|
+
'Combining both creates predictable, grounded policy responses.',
|
|
27740
|
+
'Use this pattern for compliance, support, and internal procedures.',
|
|
27741
|
+
],
|
|
27742
|
+
},
|
|
27743
|
+
{
|
|
27744
|
+
id: 'memory-agent-with-long-term-memory',
|
|
27745
|
+
title: 'MEMORY agent with long-term memory',
|
|
27746
|
+
goal: 'Persist user preferences across conversations.',
|
|
27747
|
+
source: spacetrim.spaceTrim(`
|
|
27748
|
+
Customer Success Memory Agent
|
|
27749
|
+
|
|
27750
|
+
GOAL Support SaaS customers while remembering relevant setup and preference context.
|
|
27751
|
+
MEMORY Remember product setup, user goals, and communication preferences.
|
|
27752
|
+
RULE Store only user-approved preferences and project context.
|
|
27753
|
+
RULE Never store secrets or sensitive data unless explicitly requested and allowed.
|
|
27754
|
+
INITIAL MESSAGE I can remember your setup and preferences for future sessions.
|
|
27755
|
+
`),
|
|
27756
|
+
walkthrough: [
|
|
27757
|
+
'`MEMORY` adds runtime memory tools and memory-specific system guidance.',
|
|
27758
|
+
'`RULE` commitments narrow what should be remembered to reduce privacy risks.',
|
|
27759
|
+
'In Agents Server, memory is runtime-backed and user-scoped.',
|
|
27760
|
+
'Use this for assistants that must preserve context over time.',
|
|
27761
|
+
],
|
|
27762
|
+
},
|
|
27763
|
+
{
|
|
27764
|
+
id: 'use-project-and-wallet-integration-agent',
|
|
27765
|
+
title: 'USE PROJECT and WALLET external integration',
|
|
27766
|
+
goal: 'Work with GitHub repositories and wallet-backed credentials.',
|
|
27767
|
+
source: spacetrim.spaceTrim(`
|
|
27768
|
+
Repository Maintainer
|
|
27769
|
+
|
|
27770
|
+
GOAL Maintain a GitHub repository and prepare safe pull requests.
|
|
27771
|
+
USE PROJECT https://github.com/acme/website
|
|
27772
|
+
WALLET Store credentials for repository operations.
|
|
27773
|
+
RULE Before editing files, explain the planned change and impacted paths.
|
|
27774
|
+
RULE Never reveal raw credentials in chat output.
|
|
27775
|
+
INITIAL MESSAGE I can inspect the repository and help you prepare PR-ready changes.
|
|
27776
|
+
`),
|
|
27777
|
+
walkthrough: [
|
|
27778
|
+
'`USE PROJECT` enables repository tools for listing, reading, editing files, and creating PRs.',
|
|
27779
|
+
'Credentials are resolved from wallet records at runtime in Agents Server.',
|
|
27780
|
+
'`WALLET` is kept here as a compatibility marker, but current Book 2.0 parsing treats it as deprecated/ignored.',
|
|
27781
|
+
'In current runtime behavior, wallet-backed integrations are driven by commitments such as `USE PROJECT` and `USE EMAIL`.',
|
|
27782
|
+
],
|
|
27783
|
+
},
|
|
27784
|
+
{
|
|
27785
|
+
id: 'use-calendar-integration-agent',
|
|
27786
|
+
title: 'USE CALENDAR integration',
|
|
27787
|
+
goal: 'Coordinate meetings and schedules through a connected Google Calendar.',
|
|
27788
|
+
source: spacetrim.spaceTrim(`
|
|
27789
|
+
Calendar Assistant
|
|
27790
|
+
|
|
27791
|
+
GOAL Schedule meetings and keep the calendar conflict-free.
|
|
27792
|
+
USE CALENDAR https://calendar.google.com/calendar/u/0/r
|
|
27793
|
+
SCOPES https://www.googleapis.com/auth/calendar
|
|
27794
|
+
RULE Confirm destructive actions before deleting an event.
|
|
27795
|
+
INITIAL MESSAGE Tell me the meeting details and I will schedule it in your calendar.
|
|
27796
|
+
`),
|
|
27797
|
+
walkthrough: [
|
|
27798
|
+
'`USE CALENDAR` enables calendar tools for listing, reading, creating, updating, and deleting events.',
|
|
27799
|
+
'The first calendar URL identifies which calendar integration should be used.',
|
|
27800
|
+
'`SCOPES` can explicitly request required Google Calendar OAuth permissions.',
|
|
27801
|
+
'Credentials are resolved from wallet-backed Google Calendar OAuth records at runtime in Agents Server.',
|
|
27802
|
+
],
|
|
27803
|
+
},
|
|
27804
|
+
{
|
|
27805
|
+
id: 'agents-team-example',
|
|
27806
|
+
title: 'Agents TEAM (with in-book teammates)',
|
|
27807
|
+
goal: 'Delegate sub-tasks to specialized teammates.',
|
|
27808
|
+
source: spacetrim.spaceTrim(`
|
|
27809
|
+
Team Manager
|
|
27810
|
+
|
|
27811
|
+
GOAL Coordinate specialists and deliver one consolidated answer.
|
|
27812
|
+
TEAM Ask {Legal Reviewer} for legal constraints and {Implementation Reviewer} for technical feasibility.
|
|
27813
|
+
RULE Always summarize teammate outputs into one action plan.
|
|
27814
|
+
|
|
27815
|
+
---
|
|
27816
|
+
|
|
27817
|
+
Legal Reviewer
|
|
27818
|
+
|
|
27819
|
+
FROM VOID
|
|
27820
|
+
GOAL Review legal and compliance risk.
|
|
27821
|
+
RULE Flag legal/compliance risk and uncertainty clearly.
|
|
27822
|
+
CLOSED
|
|
27823
|
+
|
|
27824
|
+
---
|
|
27825
|
+
|
|
27826
|
+
Implementation Reviewer
|
|
27827
|
+
|
|
27828
|
+
FROM VOID
|
|
27829
|
+
GOAL Review implementation effort and delivery risk.
|
|
27830
|
+
RULE Estimate complexity and identify blockers.
|
|
27831
|
+
CLOSED
|
|
27832
|
+
`),
|
|
27833
|
+
walkthrough: [
|
|
27834
|
+
'The main agent delegates via `TEAM` commitment.',
|
|
27835
|
+
'References in `{...}` are resolved against embedded agents inside the same book (split by `---`).',
|
|
27836
|
+
'Each teammate can be isolated with `FROM VOID` for deterministic specialization.',
|
|
27837
|
+
'This pattern works well for multi-role review and decision support.',
|
|
27838
|
+
],
|
|
27839
|
+
},
|
|
27840
|
+
];
|
|
27841
|
+
|
|
27842
|
+
/**
|
|
27843
|
+
* Canonical commitment keyword for the open/closed family.
|
|
27844
|
+
*
|
|
27845
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
27846
|
+
*/
|
|
27847
|
+
const OPEN_COMMITMENT_TYPE = 'OPEN';
|
|
27848
|
+
/**
|
|
27849
|
+
* Canonical commitment keyword for the open/closed family.
|
|
27850
|
+
*/
|
|
27851
|
+
const CLOSED_COMMITMENT_TYPE = 'CLOSED';
|
|
27852
|
+
/**
|
|
27853
|
+
* Removes the top-level heading from one commitment documentation block.
|
|
27854
|
+
*
|
|
27855
|
+
* @param markdown - Original markdown source.
|
|
27856
|
+
* @returns Markdown without the first `#` heading.
|
|
27857
|
+
*
|
|
27858
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
27859
|
+
*/
|
|
27860
|
+
function removeLeadingTopLevelHeading(markdown) {
|
|
27861
|
+
return markdown.replace(/^\s*#\s+[^\n]+\n*/u, '').trim();
|
|
27862
|
+
}
|
|
27863
|
+
/**
|
|
27864
|
+
* Renders one subsection for the combined open/closed documentation family.
|
|
27865
|
+
*
|
|
27866
|
+
* @param title - Heading label for the subsection.
|
|
27867
|
+
* @param documentation - Raw commitment documentation markdown.
|
|
27868
|
+
* @returns Markdown subsection with a `####` heading.
|
|
27869
|
+
*
|
|
27870
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
27871
|
+
*/
|
|
27872
|
+
function renderDocumentationSection(title, documentation) {
|
|
27873
|
+
return `#### ${title}\n\n${removeLeadingTopLevelHeading(documentation)}`;
|
|
27874
|
+
}
|
|
27875
|
+
/**
|
|
27876
|
+
* Renders the documentation body for one grouped commitment entry.
|
|
27877
|
+
*
|
|
27878
|
+
* `OPEN` and `CLOSED` are intentionally rendered together so the documentation
|
|
27879
|
+
* surfaces present them as one conceptual switch instead of two isolated pages.
|
|
27880
|
+
*
|
|
27881
|
+
* @param group - Grouped commitment metadata.
|
|
27882
|
+
* @returns Markdown body for the docs page/catalog entry.
|
|
27883
|
+
*
|
|
27884
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
27885
|
+
*/
|
|
27886
|
+
function renderGroupedCommitmentDocumentationMarkdown(group) {
|
|
27887
|
+
const commitmentTypes = new Set([group.primary.type, ...group.aliases]);
|
|
27888
|
+
if (commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE)) {
|
|
27889
|
+
const openCommitmentDefinition = getCommitmentDefinition(OPEN_COMMITMENT_TYPE);
|
|
27890
|
+
const closedCommitmentDefinition = getCommitmentDefinition(CLOSED_COMMITMENT_TYPE);
|
|
27891
|
+
if (openCommitmentDefinition && closedCommitmentDefinition) {
|
|
27892
|
+
return spacetrim.spaceTrim((block) => `
|
|
27893
|
+
${block(renderDocumentationSection(OPEN_COMMITMENT_TYPE, openCommitmentDefinition.documentation))}
|
|
27894
|
+
|
|
27895
|
+
${block(renderDocumentationSection(CLOSED_COMMITMENT_TYPE, closedCommitmentDefinition.documentation))}
|
|
27896
|
+
`);
|
|
27897
|
+
}
|
|
27898
|
+
}
|
|
27899
|
+
return removeLeadingTopLevelHeading(group.primary.documentation);
|
|
27900
|
+
}
|
|
27901
|
+
|
|
27902
|
+
/**
|
|
27903
|
+
* Commitment types that primarily model composition of multiple agents.
|
|
27904
|
+
*
|
|
27905
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
27906
|
+
*/
|
|
27907
|
+
const COMPOSITION_COMMITMENT_TYPES = new Set(['FROM', 'IMPORT', 'IMPORTS', 'TEAM']);
|
|
27908
|
+
/**
|
|
27909
|
+
* Commitment types that expose tools/runtime capabilities.
|
|
27910
|
+
*
|
|
27911
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
27912
|
+
*/
|
|
27913
|
+
const TOOLING_COMMITMENT_TYPES = new Set([
|
|
27914
|
+
'USE BROWSER',
|
|
27915
|
+
'USE DEEPSEARCH',
|
|
27916
|
+
'USE SEARCH ENGINE',
|
|
27917
|
+
'USE SEARCH',
|
|
27918
|
+
'USE SPAWN',
|
|
27919
|
+
'USE EMAIL',
|
|
27920
|
+
'USE POPUP',
|
|
27921
|
+
'USE TIME',
|
|
27922
|
+
'USE USER LOCATION',
|
|
27923
|
+
'USE PROJECT',
|
|
27924
|
+
'USE CALENDAR',
|
|
27925
|
+
'USE IMAGE GENERATOR',
|
|
27926
|
+
'USE MCP',
|
|
27927
|
+
'USE PRIVACY',
|
|
27928
|
+
'MEMORY',
|
|
27929
|
+
'MEMORIES',
|
|
27930
|
+
]);
|
|
27931
|
+
/**
|
|
27932
|
+
* Commitment types that primarily define agent profile metadata.
|
|
27933
|
+
*
|
|
27934
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
27935
|
+
*/
|
|
27936
|
+
const PROFILE_COMMITMENT_TYPES = new Set([
|
|
27937
|
+
'GOAL',
|
|
27938
|
+
'GOALS',
|
|
27939
|
+
'PERSONA',
|
|
27940
|
+
'PERSONAE',
|
|
27941
|
+
'META',
|
|
27942
|
+
'META AVATAR',
|
|
27943
|
+
'META IMAGE',
|
|
27944
|
+
'META LINK',
|
|
27945
|
+
'META DOMAIN',
|
|
27946
|
+
'META DESCRIPTION',
|
|
27947
|
+
'META DISCLAIMER',
|
|
27948
|
+
'META INPUT PLACEHOLDER',
|
|
27949
|
+
'META COLOR',
|
|
27950
|
+
'META FONT',
|
|
27951
|
+
'META VOICE',
|
|
27952
|
+
'INITIAL MESSAGE',
|
|
27953
|
+
'MODEL',
|
|
27954
|
+
'MODELS',
|
|
27955
|
+
]);
|
|
27956
|
+
/**
|
|
27957
|
+
* Commitment types that primarily define behavioral constraints or prompt shaping.
|
|
27958
|
+
*
|
|
27959
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
27960
|
+
*/
|
|
27961
|
+
const BEHAVIOR_COMMITMENT_TYPES = new Set([
|
|
27962
|
+
'RULE',
|
|
27963
|
+
'RULES',
|
|
27964
|
+
'KNOWLEDGE',
|
|
27965
|
+
'GOAL',
|
|
27966
|
+
'GOALS',
|
|
27967
|
+
'STYLE',
|
|
27968
|
+
'STYLES',
|
|
27969
|
+
'LANGUAGE',
|
|
27970
|
+
'LANGUAGES',
|
|
27971
|
+
'FORMAT',
|
|
27972
|
+
'FORMATS',
|
|
27973
|
+
'TEMPLATE',
|
|
27974
|
+
'TEMPLATES',
|
|
27975
|
+
'WRITING SAMPLE',
|
|
27976
|
+
'WRITING RULES',
|
|
27977
|
+
'SAMPLE',
|
|
27978
|
+
'EXAMPLE',
|
|
27979
|
+
'SCENARIO',
|
|
27980
|
+
'SCENARIOS',
|
|
27981
|
+
'MESSAGE',
|
|
27982
|
+
'MESSAGES',
|
|
27983
|
+
'MESSAGE SUFFIX',
|
|
27984
|
+
'USER MESSAGE',
|
|
27985
|
+
'AGENT MESSAGE',
|
|
27986
|
+
'INTERNAL MESSAGE',
|
|
27987
|
+
'OPEN',
|
|
27988
|
+
'CLOSED',
|
|
27989
|
+
]);
|
|
27990
|
+
/**
|
|
27991
|
+
* Creates one standalone markdown guide for Book language (Book 2.0 / agent language).
|
|
27992
|
+
*
|
|
27993
|
+
* The output intentionally combines:
|
|
27994
|
+
* - static conceptual building blocks maintained in this repository
|
|
27995
|
+
* - dynamically generated commitment catalog from runtime commitment definitions
|
|
27996
|
+
* so docs stay up-to-date by design.
|
|
27997
|
+
*
|
|
27998
|
+
* @returns Full standalone markdown document.
|
|
27999
|
+
*
|
|
28000
|
+
* @public exported from `@promptbook/core`
|
|
28001
|
+
*/
|
|
28002
|
+
function createStandaloneBookLanguageMarkdown() {
|
|
28003
|
+
const groupedCommitments = getGroupedCommitmentDefinitions();
|
|
28004
|
+
const generatedAtIso = new Date().toISOString();
|
|
28005
|
+
const placeholderCommitmentCount = groupedCommitments.filter(({ primary }) => primary instanceof NotYetImplementedCommitmentDefinition).length;
|
|
28006
|
+
const implementedCommitmentCount = groupedCommitments.length - placeholderCommitmentCount;
|
|
28007
|
+
const allCommitmentKeywords = groupedCommitments.flatMap(({ primary, aliases }) => [primary.type, ...aliases]);
|
|
28008
|
+
const toolingCommitments = groupedCommitments.filter(({ primary }) => TOOLING_COMMITMENT_TYPES.has(primary.type));
|
|
28009
|
+
const profileCommitments = groupedCommitments.filter(({ primary }) => PROFILE_COMMITMENT_TYPES.has(primary.type));
|
|
28010
|
+
const compositionCommitments = groupedCommitments.filter(({ primary }) => COMPOSITION_COMMITMENT_TYPES.has(primary.type));
|
|
28011
|
+
const behaviorCommitments = groupedCommitments.filter(({ primary }) => BEHAVIOR_COMMITMENT_TYPES.has(primary.type));
|
|
28012
|
+
return spacetrim.spaceTrim(
|
|
28013
|
+
// [✨]
|
|
28014
|
+
(block) => `
|
|
28015
|
+
# Book Language blueprint
|
|
28016
|
+
|
|
28017
|
+
> Canonical standalone guide for Promptbook Book Agent language.
|
|
28018
|
+
> Generated from repository https://github.com/webgptorg/promptbook
|
|
28019
|
+
|
|
28020
|
+
- Book language version: \`${BOOK_LANGUAGE_VERSION}\`
|
|
28021
|
+
- Generated at: \`${generatedAtIso}\`
|
|
28022
|
+
- Commitment groups: \`${groupedCommitments.length}\`
|
|
28023
|
+
- Implemented commitments: \`${implementedCommitmentCount}\`
|
|
28024
|
+
- Placeholder commitments: \`${placeholderCommitmentCount}\`
|
|
28025
|
+
|
|
28026
|
+
## <a id="table-of-contents"></a>Table of Contents
|
|
28027
|
+
|
|
28028
|
+
- [What Book language is](#what-book-language-is)
|
|
28029
|
+
- [Execution and compilation model](#execution-and-compilation-model)
|
|
28030
|
+
- [Mental model of an agent](#mental-model-of-an-agent)
|
|
28031
|
+
- [How to structure good agents](#how-to-structure-good-agents)
|
|
28032
|
+
- [Primitives and constructs reference](#primitives-and-constructs-reference)
|
|
28033
|
+
- [Commitment catalog (all commitments)](#commitment-catalog-all-commitments)
|
|
28034
|
+
- [End-to-end examples](#end-to-end-examples)
|
|
28035
|
+
- [Do nots and common pitfalls](#do-nots-and-common-pitfalls)
|
|
28036
|
+
- [Build an agent from scratch (offline tutorial)](#build-an-agent-from-scratch-offline-tutorial)
|
|
28037
|
+
|
|
28038
|
+
## <a id="what-book-language-is"></a>What Book language is
|
|
28039
|
+
|
|
28040
|
+
Book language is a domain-specific language for defining **AI agents** as plain-text source.
|
|
28041
|
+
It solves these problems:
|
|
28042
|
+
|
|
28043
|
+
- **One editable source of truth** for agent behavior, tools, memory, and profile metadata.
|
|
28044
|
+
- **Composable agent architecture** through commitments like \`FROM\`, \`IMPORT\`, and \`TEAM\`.
|
|
28045
|
+
- **Deterministic runtime preparation** where source is parsed and compiled into model requirements.
|
|
28046
|
+
- **Portable agent definitions** that can be copied, versioned, and reviewed as text.
|
|
28047
|
+
|
|
28048
|
+
In this repository, "Book language" means **Book 2.0 agent language**.
|
|
28049
|
+
|
|
28050
|
+
## <a id="execution-and-compilation-model"></a>Execution and compilation model
|
|
28051
|
+
|
|
28052
|
+
Promptbook and Agents Server use two core passes:
|
|
28053
|
+
|
|
28054
|
+
1. **Fast parse pass** (\`parseAgentSource\`):
|
|
28055
|
+
It synchronously extracts agent profile/basic info (name, last goal/profile text, meta, capabilities, samples, references).
|
|
28056
|
+
2. **Compilation pass** (\`createAgentModelRequirements\`):
|
|
28057
|
+
It applies commitments in sequence and builds executable model requirements (system message, tools, memory/tool metadata, imports, etc.).
|
|
28058
|
+
|
|
28059
|
+
In Agents Server, the runtime flow typically includes:
|
|
28060
|
+
|
|
28061
|
+
1. Resolve scoped references (including in-book references like \`{Some Agent}\`).
|
|
28062
|
+
2. Resolve inheritance/import chains into effective source.
|
|
28063
|
+
3. Compile effective source into model requirements.
|
|
28064
|
+
4. Execute chat turns with resolved tools and runtime adapters.
|
|
28065
|
+
|
|
28066
|
+
## <a id="mental-model-of-an-agent"></a>Mental model of an agent
|
|
28067
|
+
|
|
28068
|
+
Think of one agent source as four layers:
|
|
28069
|
+
|
|
28070
|
+
1. **Identity/Profile layer**:
|
|
28071
|
+
Agent name (first non-commitment line), the last \`GOAL\` (preferred) or deprecated \`PERSONA\`, and \`META*\` commitments.
|
|
28072
|
+
2. **Behavior layer**:
|
|
28073
|
+
\`RULE\`, \`KNOWLEDGE\`, \`WRITING SAMPLE\`, \`WRITING RULES\`, deprecated \`STYLE\`, \`FORMAT\`, \`TEMPLATE\`, \`LANGUAGE\`, \`GOAL\`, and related commitments.
|
|
28074
|
+
3. **Capability layer**:
|
|
28075
|
+
\`USE*\`, \`MEMORY\`, and other tooling commitments exposing runtime abilities.
|
|
28076
|
+
4. **Composition layer**:
|
|
28077
|
+
\`FROM\` inheritance, \`IMPORT\` reuse, and \`TEAM\` delegation.
|
|
28078
|
+
|
|
28079
|
+
Agent composition commitments in current runtime:
|
|
28080
|
+
|
|
28081
|
+
- Profile-centric commitments detected: ${profileCommitments
|
|
28082
|
+
.map(({ primary }) => `\`${primary.type}\``)
|
|
28083
|
+
.join(', ')}
|
|
28084
|
+
- Behavior-centric commitments detected: ${behaviorCommitments
|
|
28085
|
+
.map(({ primary }) => `\`${primary.type}\``)
|
|
28086
|
+
.join(', ')}
|
|
28087
|
+
- Tool/runtime commitments detected: ${toolingCommitments
|
|
28088
|
+
.map(({ primary }) => `\`${primary.type}\``)
|
|
28089
|
+
.join(', ')}
|
|
28090
|
+
- Composition commitments detected: ${compositionCommitments
|
|
28091
|
+
.map(({ primary }) => `\`${primary.type}\``)
|
|
28092
|
+
.join(', ')}
|
|
28093
|
+
|
|
28094
|
+
### META commitments and agent profile
|
|
28095
|
+
|
|
28096
|
+
\`META*\` commitments control profile data shown in UI (for example avatar visual, image, description, disclaimers, domain, input placeholder).
|
|
28097
|
+
They generally shape presentation/metadata rather than tool behavior.
|
|
28098
|
+
|
|
28099
|
+
### FROM inheritance
|
|
28100
|
+
|
|
28101
|
+
\`FROM\` points to a parent agent source. During inheritance resolution:
|
|
28102
|
+
|
|
28103
|
+
- Parent corpus is merged into effective source.
|
|
28104
|
+
- \`FROM {Void}\` / \`FROM VOID\` means explicit "no parent".
|
|
28105
|
+
- Missing references are surfaced as notes in resolved source.
|
|
28106
|
+
|
|
28107
|
+
### TEAM and IMPORT
|
|
28108
|
+
|
|
28109
|
+
- \`TEAM\` registers teammate agents as callable tools.
|
|
28110
|
+
- \`IMPORT\` injects imported agent/file content into current agent context.
|
|
28111
|
+
- In Agents Server, compact references like \`{Legal Reviewer}\` can resolve to embedded in-book agents.
|
|
28112
|
+
|
|
28113
|
+
### USE commitments
|
|
28114
|
+
|
|
28115
|
+
\`USE*\` commitments enable capabilities (search, browser, project integration, email, image generation, etc.).
|
|
28116
|
+
They expose runtime tools and system-message guidance used during execution.
|
|
28117
|
+
|
|
28118
|
+
## <a id="how-to-structure-good-agents"></a>How to structure good agents
|
|
28119
|
+
|
|
28120
|
+
Recommended patterns and tradeoffs:
|
|
28121
|
+
|
|
28122
|
+
1. **Single clear role first**:
|
|
28123
|
+
Start with one narrow \`GOAL\`; use \`PERSONA\` only for backward-compatible legacy books.
|
|
28124
|
+
Tradeoff: less initial flexibility, much higher reliability.
|
|
28125
|
+
2. **Guardrails early**:
|
|
28126
|
+
Add concrete \`RULE\` commitments before adding many tools.
|
|
28127
|
+
Tradeoff: more upfront design, fewer runtime surprises.
|
|
28128
|
+
3. **Grounding over improvisation**:
|
|
28129
|
+
Prefer \`KNOWLEDGE\` + explicit citation rule for high-stakes answers.
|
|
28130
|
+
Tradeoff: extra maintenance for sources, better factual control.
|
|
28131
|
+
4. **Composition over monoliths**:
|
|
28132
|
+
Use \`TEAM\`/\`IMPORT\` for specialized responsibilities.
|
|
28133
|
+
Tradeoff: orchestration overhead, stronger modularity and reuse.
|
|
28134
|
+
5. **Controlled memory**:
|
|
28135
|
+
If using \`MEMORY\`, define what must and must not be remembered.
|
|
28136
|
+
Tradeoff: stricter policy design, better privacy and signal quality.
|
|
28137
|
+
|
|
28138
|
+
## <a id="primitives-and-constructs-reference"></a>Primitives and constructs reference
|
|
28139
|
+
|
|
28140
|
+
### Core syntax primitives
|
|
28141
|
+
|
|
28142
|
+
1. **Agent title**:
|
|
28143
|
+
First non-empty line that is not a commitment keyword.
|
|
28144
|
+
2. **Commitment block**:
|
|
28145
|
+
Starts with a commitment keyword and continues until the next commitment block or separator.
|
|
28146
|
+
3. **Horizontal separator**:
|
|
28147
|
+
Lines like \`---\` split sections; in Agents Server they can delimit embedded in-book agents.
|
|
28148
|
+
4. **Code fences**:
|
|
28149
|
+
Preserved inside commitment content; useful for examples/instructions.
|
|
28150
|
+
5. **Parameters**:
|
|
28151
|
+
Both \`@parameter\` and \`{parameter}\` notations are supported and parsed.
|
|
28152
|
+
|
|
28153
|
+
### Reference tokens and pseudo-agents
|
|
28154
|
+
|
|
28155
|
+
- Compact references like \`{Agent Name}\` are resolved by Agents Server reference resolver.
|
|
28156
|
+
- Pseudo-agent forms (for example \`{User}\`, \`{Void}\`) are supported in relevant commitments.
|
|
28157
|
+
- \`{User}\` is intended for \`TEAM\`; \`{Void}\` is useful for explicit no-parent inheritance.
|
|
28158
|
+
|
|
28159
|
+
### Commitment keywords currently recognized
|
|
28160
|
+
|
|
28161
|
+
${block(getSafeCodeBlock(allCommitmentKeywords.join(', '), 'text'))}
|
|
28162
|
+
|
|
28163
|
+
## <a id="commitment-catalog-all-commitments"></a>Commitment catalog (all commitments)
|
|
28164
|
+
|
|
28165
|
+
This section is generated from commitment definitions in \`src/commitments\`.
|
|
28166
|
+
For each commitment group you get:
|
|
28167
|
+
|
|
28168
|
+
- semantics summary (description/icon/status)
|
|
28169
|
+
- parsing schema (\`createTypeRegex\` and \`createRegex\`)
|
|
28170
|
+
- canonical documentation block
|
|
28171
|
+
|
|
28172
|
+
${block(groupedCommitments.map(renderCommitmentCatalogSection).join('\n\n'))}
|
|
28173
|
+
|
|
28174
|
+
## <a id="end-to-end-examples"></a>End-to-end examples
|
|
28175
|
+
|
|
28176
|
+
${block(bookLanguageDocumentationExamples.map(renderExampleSection).join('\n\n'))}
|
|
28177
|
+
|
|
28178
|
+
## <a id="do-nots-and-common-pitfalls"></a>Do nots and common pitfalls
|
|
28179
|
+
|
|
28180
|
+
${block(bookLanguageCommonPitfalls
|
|
28181
|
+
.map((pitfall, index) => spacetrim.spaceTrim(`
|
|
28182
|
+
${index + 1}. **${pitfall.title}**
|
|
28183
|
+
- Don't: ${pitfall.dont}
|
|
28184
|
+
- Do instead: ${pitfall.doInstead}
|
|
28185
|
+
`))
|
|
28186
|
+
.join('\n'))}
|
|
28187
|
+
|
|
28188
|
+
## <a id="build-an-agent-from-scratch-offline-tutorial"></a>Build an agent from scratch (offline tutorial)
|
|
28189
|
+
|
|
28190
|
+
This tutorial is sufficient without internet access.
|
|
28191
|
+
|
|
28192
|
+
1. **Define role and goal**
|
|
28193
|
+
Create a short name line and one clear \`GOAL\`.
|
|
28194
|
+
2. **Add behavioral constraints**
|
|
28195
|
+
Add 3-6 specific \`RULE\` commitments covering scope, tone, and safety boundaries.
|
|
28196
|
+
3. **Add grounding**
|
|
28197
|
+
Add \`KNOWLEDGE\` commitments (inline text or local/importable sources).
|
|
28198
|
+
4. **Add capabilities**
|
|
28199
|
+
Add only necessary \`USE*\` and/or \`MEMORY\` commitments.
|
|
28200
|
+
5. **Set profile metadata**
|
|
28201
|
+
Add \`META DESCRIPTION\`, \`META AVATAR\` or \`META IMAGE\`, \`META INPUT PLACEHOLDER\`, and disclaimers if needed.
|
|
28202
|
+
6. **Add first interaction**
|
|
28203
|
+
Add \`INITIAL MESSAGE\` and optionally sample \`USER MESSAGE\` / \`AGENT MESSAGE\` pairs.
|
|
28204
|
+
7. **Close for deterministic behavior (optional)**
|
|
28205
|
+
Add \`CLOSED\` when you want stable non-self-modifying behavior.
|
|
28206
|
+
|
|
28207
|
+
Copy-paste template:
|
|
28208
|
+
|
|
28209
|
+
${block(getSafeCodeBlock(spacetrim.spaceTrim(`
|
|
28210
|
+
Project Assistant
|
|
28211
|
+
|
|
28212
|
+
GOAL Help the user turn project ideas into concrete deliverables with focused planning support.
|
|
28213
|
+
|
|
28214
|
+
RULE Ask clarifying questions when requirements are ambiguous.
|
|
28215
|
+
RULE Provide concise, structured outputs with actionable steps.
|
|
28216
|
+
RULE If information is missing, state assumptions explicitly.
|
|
28217
|
+
RULE Do not invent facts.
|
|
28218
|
+
|
|
28219
|
+
KNOWLEDGE Team works in two-week sprints and tracks tasks in Kanban.
|
|
28220
|
+
KNOWLEDGE Preferred output format: summary, plan, risks, next action.
|
|
28221
|
+
|
|
28222
|
+
META DESCRIPTION Practical project-planning assistant.
|
|
28223
|
+
META INPUT PLACEHOLDER Describe your project goal or blocker...
|
|
28224
|
+
|
|
28225
|
+
INITIAL MESSAGE Share your project goal and current blocker, and I will propose a concrete next-step plan.
|
|
28226
|
+
CLOSED
|
|
28227
|
+
`), 'book'))}
|
|
28228
|
+
|
|
28229
|
+
Validation checklist:
|
|
28230
|
+
|
|
28231
|
+
- Does each commitment have a clear purpose?
|
|
28232
|
+
- Are there explicit constraints against hallucination and unsafe behavior?
|
|
28233
|
+
- Are tools only enabled when genuinely needed?
|
|
28234
|
+
- Is memory usage bounded by clear rules?
|
|
28235
|
+
- Is composition (\`FROM\`/\`TEAM\`/\`IMPORT\`) justified and understandable?
|
|
28236
|
+
|
|
28237
|
+
---
|
|
28238
|
+
|
|
28239
|
+
Generated from:
|
|
28240
|
+
|
|
28241
|
+
- Commitments registry and runtime docs in \`src/commitments\`
|
|
28242
|
+
- Parser/compiler behavior in \`src/book-2.0/agent-source\`
|
|
28243
|
+
- Agents Server reference/inheritance resolution in \`apps/agents-server/src/utils\`
|
|
28244
|
+
- Standalone docs source blocks in \`apps/agents-server/src/utils/bookLanguageDocumentation\`
|
|
28245
|
+
`);
|
|
28246
|
+
}
|
|
28247
|
+
/**
|
|
28248
|
+
* Renders one commitment section in the generated catalog.
|
|
28249
|
+
*
|
|
28250
|
+
* @param groupedCommitment - Grouped commitment definition with aliases.
|
|
28251
|
+
* @returns Markdown section for a single commitment.
|
|
28252
|
+
*
|
|
28253
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
28254
|
+
*/
|
|
28255
|
+
function renderCommitmentCatalogSection(groupedCommitment) {
|
|
28256
|
+
var _a;
|
|
28257
|
+
const { primary, aliases } = groupedCommitment;
|
|
28258
|
+
const notice = getCommitmentNoticeMetadata(primary);
|
|
28259
|
+
const status = primary instanceof NotYetImplementedCommitmentDefinition
|
|
28260
|
+
? 'Placeholder (not fully implemented)'
|
|
28261
|
+
: notice
|
|
28262
|
+
? `Implemented (${notice.detailLabel})`
|
|
28263
|
+
: 'Implemented';
|
|
28264
|
+
const aliasText = aliases.length === 0 ? 'None' : aliases.map((alias) => `\`${alias}\``).join(', ');
|
|
28265
|
+
const noticeText = notice
|
|
28266
|
+
? notice.kind === 'deprecated'
|
|
28267
|
+
? `- **Deprecation:** ${notice.message}${formatCommitmentReplacementText((_a = primary.deprecation) === null || _a === void 0 ? void 0 : _a.replacedBy)}`
|
|
28268
|
+
: `- **Low-level commitment:** ${notice.message}`
|
|
28269
|
+
: '';
|
|
28270
|
+
const documentationMarkdown = renderGroupedCommitmentDocumentationMarkdown(groupedCommitment);
|
|
28271
|
+
return spacetrim.spaceTrim((block) => `
|
|
28272
|
+
### <a id="commitment-${toStableAnchorId(primary.type)}"></a>${primary.icon} ${primary.type}
|
|
28273
|
+
|
|
28274
|
+
- **Status:** ${status}
|
|
28275
|
+
- **Aliases:** ${aliasText}
|
|
28276
|
+
- **Semantics:** ${primary.description}
|
|
28277
|
+
- **Type schema (\`createTypeRegex\`):** \`${stringifyRegex(primary.createTypeRegex())}\`
|
|
28278
|
+
- **Block schema (\`createRegex\`):** \`${stringifyRegex(primary.createRegex())}\`
|
|
28279
|
+
${noticeText}
|
|
28280
|
+
|
|
28281
|
+
${block(documentationMarkdown)}
|
|
28282
|
+
`);
|
|
28283
|
+
}
|
|
28284
|
+
/**
|
|
28285
|
+
* Renders one end-to-end example section.
|
|
28286
|
+
*
|
|
28287
|
+
* @param example - Example definition.
|
|
28288
|
+
* @returns Markdown section for one example.
|
|
28289
|
+
*
|
|
28290
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
28291
|
+
*/
|
|
28292
|
+
function renderExampleSection(example) {
|
|
28293
|
+
return spacetrim.spaceTrim((block) => `
|
|
28294
|
+
### <a id="example-${toStableAnchorId(example.id)}"></a>${example.title}
|
|
28295
|
+
|
|
28296
|
+
**Goal:** ${example.goal}
|
|
28297
|
+
|
|
28298
|
+
**Full source**
|
|
28299
|
+
|
|
28300
|
+
${block(getSafeCodeBlock(example.source, 'book'))}
|
|
28301
|
+
|
|
28302
|
+
**Walkthrough**
|
|
28303
|
+
|
|
28304
|
+
${block(example.walkthrough.map((step, index) => `${index + 1}. ${step}`).join('\n'))}
|
|
28305
|
+
`);
|
|
28306
|
+
}
|
|
28307
|
+
/**
|
|
28308
|
+
* Converts a heading label into a stable markdown anchor id.
|
|
28309
|
+
*
|
|
28310
|
+
* @param value - Raw heading/identifier text.
|
|
28311
|
+
* @returns Stable lowercase anchor id.
|
|
28312
|
+
*
|
|
28313
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
28314
|
+
*/
|
|
28315
|
+
function toStableAnchorId(value) {
|
|
28316
|
+
return value
|
|
28317
|
+
.trim()
|
|
28318
|
+
.toLowerCase()
|
|
28319
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
28320
|
+
.replace(/^-+|-+$/g, '');
|
|
28321
|
+
}
|
|
28322
|
+
/**
|
|
28323
|
+
* Converts a regular expression into a concise literal-like string.
|
|
28324
|
+
*
|
|
28325
|
+
* @param regex - Regex instance.
|
|
28326
|
+
* @returns Printable regex pattern and flags.
|
|
28327
|
+
*
|
|
28328
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
28329
|
+
*/
|
|
28330
|
+
function stringifyRegex(regex) {
|
|
28331
|
+
return `/${regex.source}/${regex.flags}`;
|
|
28332
|
+
}
|
|
28333
|
+
/**
|
|
28334
|
+
* Creates a safe markdown fenced code block even when content contains backticks.
|
|
28335
|
+
*
|
|
28336
|
+
* @param content - Raw code content.
|
|
28337
|
+
* @param language - Optional info-string language label.
|
|
28338
|
+
* @returns Fenced code block.
|
|
28339
|
+
*
|
|
28340
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
28341
|
+
*/
|
|
28342
|
+
function getSafeCodeBlock(content, language = 'markdown') {
|
|
28343
|
+
const maxBacktickCount = Math.max(0, ...(content.match(/`+/g) || []).map((match) => match.length));
|
|
28344
|
+
const fence = '`'.repeat(Math.max(3, maxBacktickCount + 1));
|
|
28345
|
+
return `${fence}${language}\n${content}\n${fence}`;
|
|
28346
|
+
}
|
|
28347
|
+
|
|
27701
28348
|
/**
|
|
27702
28349
|
* Generates an image for the agent to use as profile image
|
|
27703
28350
|
*
|
|
@@ -29705,8 +30352,10 @@
|
|
|
29705
30352
|
*/
|
|
29706
30353
|
const MatcherFormfactorDefinition = {
|
|
29707
30354
|
name: 'EXPERIMENTAL_MATCHER',
|
|
29708
|
-
description: `
|
|
29709
|
-
|
|
30355
|
+
description: spacetrim.spaceTrim(`
|
|
30356
|
+
An evaluation system that determines whether content meets specific criteria or patterns.
|
|
30357
|
+
Used for content validation, quality assessment, and intelligent filtering tasks. Currently in experimental phase.
|
|
30358
|
+
`),
|
|
29710
30359
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/177`,
|
|
29711
30360
|
pipelineInterface: {
|
|
29712
30361
|
inputParameters: [
|
|
@@ -29763,9 +30412,11 @@
|
|
|
29763
30412
|
*/
|
|
29764
30413
|
const TranslatorFormfactorDefinition = {
|
|
29765
30414
|
name: 'TRANSLATOR',
|
|
29766
|
-
description: `
|
|
29767
|
-
|
|
29768
|
-
|
|
30415
|
+
description: spacetrim.spaceTrim(`
|
|
30416
|
+
A text transformation system that converts input content into different forms,
|
|
30417
|
+
including language translations, paraphrasing, style conversions, and tone adjustments.
|
|
30418
|
+
This form factor takes one input and produces one transformed output.
|
|
30419
|
+
`),
|
|
29769
30420
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/175`,
|
|
29770
30421
|
pipelineInterface: {
|
|
29771
30422
|
inputParameters: [
|
|
@@ -31125,12 +31776,21 @@
|
|
|
31125
31776
|
// <- TODO: [🧠] Make this dynamic, async, prepare-phase HLAs
|
|
31126
31777
|
],
|
|
31127
31778
|
});
|
|
31128
|
-
// TODO: Use spaceTrim in multiline strings
|
|
31129
31779
|
$pipelineJson.tasks.push({
|
|
31130
31780
|
taskType: 'PROMPT_TASK',
|
|
31131
31781
|
name: 'create-an-answer',
|
|
31132
31782
|
title: 'Create an answer',
|
|
31133
|
-
content:
|
|
31783
|
+
content: spacetrim.spaceTrim(`
|
|
31784
|
+
Write a response to the user message:
|
|
31785
|
+
|
|
31786
|
+
**Question from user**
|
|
31787
|
+
|
|
31788
|
+
> {userMessage}
|
|
31789
|
+
|
|
31790
|
+
**Previous conversation**
|
|
31791
|
+
|
|
31792
|
+
> {previousConversationSummary}
|
|
31793
|
+
`),
|
|
31134
31794
|
resultingParameterName: 'chatbotResponse',
|
|
31135
31795
|
personaName,
|
|
31136
31796
|
dependentParameterNames: [
|
|
@@ -31142,7 +31802,26 @@
|
|
|
31142
31802
|
taskType: 'PROMPT_TASK',
|
|
31143
31803
|
name: 'summarize-the-conversation',
|
|
31144
31804
|
title: 'Summarize the conversation',
|
|
31145
|
-
content:
|
|
31805
|
+
content: spacetrim.spaceTrim(`
|
|
31806
|
+
Summarize the conversation in a few words:
|
|
31807
|
+
|
|
31808
|
+
## Rules
|
|
31809
|
+
|
|
31810
|
+
- Summarise the text of the conversation in a few words
|
|
31811
|
+
- Convert the text to its basic idea
|
|
31812
|
+
- Imagine you are writing the headline or subject line of an email
|
|
31813
|
+
- Respond with a few words of summary only
|
|
31814
|
+
|
|
31815
|
+
## Conversation
|
|
31816
|
+
|
|
31817
|
+
**User:**
|
|
31818
|
+
|
|
31819
|
+
> {userMessage}
|
|
31820
|
+
|
|
31821
|
+
**You:**
|
|
31822
|
+
|
|
31823
|
+
> {chatbotResponse}
|
|
31824
|
+
`),
|
|
31146
31825
|
resultingParameterName: 'conversationSummary',
|
|
31147
31826
|
personaName,
|
|
31148
31827
|
expectations: {
|
|
@@ -33546,11 +34225,11 @@
|
|
|
33546
34225
|
if (attachments.length === 0) {
|
|
33547
34226
|
return '';
|
|
33548
34227
|
}
|
|
33549
|
-
return
|
|
33550
|
-
CHAT_ATTACHMENTS_HEADING
|
|
33551
|
-
|
|
33552
|
-
CHAT_ATTACHMENTS_INSTRUCTION
|
|
33553
|
-
|
|
34228
|
+
return spacetrim.spaceTrim((block) => `
|
|
34229
|
+
${CHAT_ATTACHMENTS_HEADING}
|
|
34230
|
+
${block(attachments.map((attachment) => formatChatAttachmentLine(attachment)).join('\n'))}
|
|
34231
|
+
${CHAT_ATTACHMENTS_INSTRUCTION}
|
|
34232
|
+
`);
|
|
33554
34233
|
}
|
|
33555
34234
|
|
|
33556
34235
|
/**
|
|
@@ -33791,24 +34470,24 @@
|
|
|
33791
34470
|
: ''}`
|
|
33792
34471
|
: null;
|
|
33793
34472
|
const warningsLine = contentResolution.warnings.length > 0 ? `Warnings: ${contentResolution.warnings.join(' | ')}` : null;
|
|
33794
|
-
|
|
34473
|
+
const metadataLines = [decodingLine, warningsLine].filter((line) => Boolean(line)).join('\n');
|
|
34474
|
+
const resolvedContent = contentResolution.content;
|
|
34475
|
+
if (!resolvedContent) {
|
|
33795
34476
|
const reason = contentResolution.reason || 'content unavailable';
|
|
33796
|
-
return
|
|
33797
|
-
.
|
|
33798
|
-
|
|
34477
|
+
return spacetrim.spaceTrim((block) => `
|
|
34478
|
+
- ${attachmentLabel}: ${reason}. URL: ${contentResolution.attachment.url}
|
|
34479
|
+
${block(metadataLines)}
|
|
34480
|
+
`);
|
|
33799
34481
|
}
|
|
33800
34482
|
const truncatedLabel = contentResolution.isTruncated ? ' [truncated]' : '';
|
|
33801
|
-
return
|
|
33802
|
-
|
|
33803
|
-
|
|
33804
|
-
|
|
33805
|
-
|
|
33806
|
-
|
|
33807
|
-
|
|
33808
|
-
|
|
33809
|
-
]
|
|
33810
|
-
.filter(Boolean)
|
|
33811
|
-
.join('\n');
|
|
34483
|
+
return spacetrim.spaceTrim((block) => `
|
|
34484
|
+
File: ${attachmentLabel}${truncatedLabel}
|
|
34485
|
+
URL: ${contentResolution.attachment.url}
|
|
34486
|
+
${block(metadataLines)}
|
|
34487
|
+
\`\`\`text
|
|
34488
|
+
${block(resolvedContent)}
|
|
34489
|
+
\`\`\`
|
|
34490
|
+
`);
|
|
33812
34491
|
}
|
|
33813
34492
|
/**
|
|
33814
34493
|
* Formats inline attachment-content context section for the model.
|
|
@@ -33822,11 +34501,14 @@
|
|
|
33822
34501
|
if (resolvedContents.length === 0) {
|
|
33823
34502
|
return '';
|
|
33824
34503
|
}
|
|
33825
|
-
return
|
|
33826
|
-
CHAT_ATTACHMENT_CONTENT_HEADING
|
|
33827
|
-
CHAT_ATTACHMENT_CONTENT_INSTRUCTION
|
|
33828
|
-
|
|
33829
|
-
|
|
34504
|
+
return spacetrim.spaceTrim((block) => `
|
|
34505
|
+
${CHAT_ATTACHMENT_CONTENT_HEADING}
|
|
34506
|
+
${CHAT_ATTACHMENT_CONTENT_INSTRUCTION}
|
|
34507
|
+
|
|
34508
|
+
${block(resolvedContents
|
|
34509
|
+
.map((resolvedContent) => formatResolvedChatAttachmentContent(resolvedContent))
|
|
34510
|
+
.join('\n\n'))}
|
|
34511
|
+
`);
|
|
33830
34512
|
}
|
|
33831
34513
|
|
|
33832
34514
|
/**
|
|
@@ -34985,9 +35667,11 @@
|
|
|
34985
35667
|
* Creates the retry-history error message shared by all OpenAI-compatible model variants.
|
|
34986
35668
|
*/
|
|
34987
35669
|
createAttemptHistoryError(finalErrorMessage) {
|
|
34988
|
-
return new PipelineExecutionError(
|
|
34989
|
-
|
|
34990
|
-
|
|
35670
|
+
return new PipelineExecutionError(spacetrim.spaceTrim((block) => `
|
|
35671
|
+
All attempts failed. Attempt history:
|
|
35672
|
+
${block(formatUnsupportedParameterAttemptHistory(this.attemptStack))}
|
|
35673
|
+
Final error: ${finalErrorMessage}
|
|
35674
|
+
`));
|
|
34991
35675
|
}
|
|
34992
35676
|
}
|
|
34993
35677
|
|
|
@@ -37581,7 +38265,7 @@
|
|
|
37581
38265
|
});
|
|
37582
38266
|
}
|
|
37583
38267
|
let vectorStoreId = cachedVectorStoreId;
|
|
37584
|
-
if (
|
|
38268
|
+
if (!vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
|
|
37585
38269
|
const vectorStoreResult = await this.createVectorStoreWithKnowledgeSources({
|
|
37586
38270
|
client: await this.getClient(),
|
|
37587
38271
|
name,
|
|
@@ -37590,19 +38274,13 @@
|
|
|
37590
38274
|
});
|
|
37591
38275
|
vectorStoreId = vectorStoreResult.vectorStoreId;
|
|
37592
38276
|
}
|
|
37593
|
-
else if (
|
|
38277
|
+
else if (vectorStoreId && this.options.isVerbose) {
|
|
37594
38278
|
console.info('[🤰]', 'Using cached vector store for AgentKit agent', {
|
|
37595
38279
|
name,
|
|
37596
38280
|
vectorStoreId,
|
|
37597
38281
|
});
|
|
37598
38282
|
}
|
|
37599
|
-
|
|
37600
|
-
vectorStoreId = undefined;
|
|
37601
|
-
}
|
|
37602
|
-
const agentKitTools = this.buildAgentKitTools({
|
|
37603
|
-
tools,
|
|
37604
|
-
vectorStoreId,
|
|
37605
|
-
});
|
|
38283
|
+
const agentKitTools = this.buildAgentKitTools({ tools, vectorStoreId });
|
|
37606
38284
|
const openAiAgentKitAgent = new agents.Agent({
|
|
37607
38285
|
name,
|
|
37608
38286
|
model: this.agentKitModelName,
|
|
@@ -37621,7 +38299,7 @@
|
|
|
37621
38299
|
name,
|
|
37622
38300
|
model: this.agentKitModelName,
|
|
37623
38301
|
toolCount: agentKitTools.length,
|
|
37624
|
-
hasVectorStore:
|
|
38302
|
+
hasVectorStore: Boolean(vectorStoreId),
|
|
37625
38303
|
});
|
|
37626
38304
|
}
|
|
37627
38305
|
return preparedAgent;
|
|
@@ -38120,12 +38798,6 @@
|
|
|
38120
38798
|
get agentKitOptions() {
|
|
38121
38799
|
return this.options;
|
|
38122
38800
|
}
|
|
38123
|
-
/**
|
|
38124
|
-
* Returns true when hosted OpenAI vector-store search should back `knowledgeSources`.
|
|
38125
|
-
*/
|
|
38126
|
-
get isNativeKnowledgeSearchEnabled() {
|
|
38127
|
-
return this.agentKitOptions.isNativeKnowledgeSearchEnabled !== false;
|
|
38128
|
-
}
|
|
38129
38801
|
/**
|
|
38130
38802
|
* Discriminant for type guards.
|
|
38131
38803
|
*/
|
|
@@ -42649,7 +43321,7 @@
|
|
|
42649
43321
|
*/
|
|
42650
43322
|
async function prepareSdkTranspilerContext(book, options) {
|
|
42651
43323
|
const { agentName } = await parseAgentSource(book);
|
|
42652
|
-
const
|
|
43324
|
+
const modelRequirements = await createAgentModelRequirements(book, undefined, undefined, undefined, {
|
|
42653
43325
|
agentReferenceResolver: options === null || options === void 0 ? void 0 : options.agentReferenceResolver,
|
|
42654
43326
|
inlineKnowledgeSourceUploader: options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader,
|
|
42655
43327
|
teammateProfileResolver: options === null || options === void 0 ? void 0 : options.teammateProfileResolver,
|
|
@@ -42659,12 +43331,7 @@
|
|
|
42659
43331
|
const knowledgeContent = knowledgeCommitments.map((commitment) => commitment.content.trim());
|
|
42660
43332
|
const directKnowledge = knowledgeContent.filter((content) => !isKnowledgeSourceUrl(content));
|
|
42661
43333
|
const knowledgeSources = knowledgeContent.filter((content) => isKnowledgeSourceUrl(content));
|
|
42662
|
-
const isKnowledgeHandledWithRetrieval = directKnowledge.join('\n').length > SDK_TRANSPILER_KNOWLEDGE_THRESHOLD ||
|
|
42663
|
-
knowledgeSources.length > 0 ||
|
|
42664
|
-
knowledgeCommitments.length > 0;
|
|
42665
|
-
const modelRequirements = normalizeSdkTranspilerModelRequirements(rawModelRequirements, {
|
|
42666
|
-
isKnowledgeHandledWithRetrieval,
|
|
42667
|
-
});
|
|
43334
|
+
const isKnowledgeHandledWithRetrieval = directKnowledge.join('\n').length > SDK_TRANSPILER_KNOWLEDGE_THRESHOLD || knowledgeSources.length > 0;
|
|
42668
43335
|
const transpiledTeam = createTranspiledTeamExportForContext({
|
|
42669
43336
|
agentName,
|
|
42670
43337
|
agentSource: book,
|
|
@@ -42682,36 +43349,6 @@
|
|
|
42682
43349
|
transpiledTeam,
|
|
42683
43350
|
};
|
|
42684
43351
|
}
|
|
42685
|
-
/**
|
|
42686
|
-
* Removes the runtime-only knowledge-search tool from SDK harnesses that provide
|
|
42687
|
-
* their own generated retrieval scaffold.
|
|
42688
|
-
*
|
|
42689
|
-
* @param modelRequirements - Raw compiled model requirements.
|
|
42690
|
-
* @param options - Knowledge handling mode selected for the generated harness.
|
|
42691
|
-
* @returns Model requirements safe to embed into a standalone SDK export.
|
|
42692
|
-
*/
|
|
42693
|
-
function normalizeSdkTranspilerModelRequirements(modelRequirements, options) {
|
|
42694
|
-
var _a;
|
|
42695
|
-
if (!options.isKnowledgeHandledWithRetrieval) {
|
|
42696
|
-
return modelRequirements;
|
|
42697
|
-
}
|
|
42698
|
-
const tools = (_a = modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.filter((tool) => tool.name !== KNOWLEDGE_SEARCH_TOOL_NAME);
|
|
42699
|
-
return {
|
|
42700
|
-
...modelRequirements,
|
|
42701
|
-
systemMessage: removeKnowledgeSearchSystemSection(modelRequirements.systemMessage),
|
|
42702
|
-
...(tools ? { tools } : {}),
|
|
42703
|
-
};
|
|
42704
|
-
}
|
|
42705
|
-
/**
|
|
42706
|
-
* Removes the generated `## Knowledge Search` instructions from SDK exports
|
|
42707
|
-
* that answer with the transpiler's native retrieval scaffold instead.
|
|
42708
|
-
*
|
|
42709
|
-
* @param systemMessage - Raw system message from compiled model requirements.
|
|
42710
|
-
* @returns System message without the runtime-only knowledge-search section.
|
|
42711
|
-
*/
|
|
42712
|
-
function removeKnowledgeSearchSystemSection(systemMessage) {
|
|
42713
|
-
return systemMessage.replace(/(?:^|\n\n)## Knowledge Search[\s\S]*?(?=\n\n##|$)/, '').trim();
|
|
42714
|
-
}
|
|
42715
43352
|
/**
|
|
42716
43353
|
* Detects whether one knowledge commitment points to a URL instead of inline text.
|
|
42717
43354
|
*
|
|
@@ -45455,7 +46092,6 @@
|
|
|
45455
46092
|
exports.GenericFormfactorDefinition = GenericFormfactorDefinition;
|
|
45456
46093
|
exports.HTTP_STATUS_CODES = HTTP_STATUS_CODES;
|
|
45457
46094
|
exports.ImageGeneratorFormfactorDefinition = ImageGeneratorFormfactorDefinition;
|
|
45458
|
-
exports.KNOWLEDGE_SEARCH_TOOL_NAME = KNOWLEDGE_SEARCH_TOOL_NAME;
|
|
45459
46095
|
exports.KnowledgeScrapeError = KnowledgeScrapeError;
|
|
45460
46096
|
exports.LIMITS = LIMITS;
|
|
45461
46097
|
exports.LimitReachedError = LimitReachedError;
|
|
@@ -45551,6 +46187,7 @@
|
|
|
45551
46187
|
exports.createPipelineCollectionFromUrl = createPipelineCollectionFromUrl;
|
|
45552
46188
|
exports.createPipelineExecutor = createPipelineExecutor;
|
|
45553
46189
|
exports.createPipelineSubcollection = createPipelineSubcollection;
|
|
46190
|
+
exports.createStandaloneBookLanguageMarkdown = createStandaloneBookLanguageMarkdown;
|
|
45554
46191
|
exports.embeddingVectorToString = embeddingVectorToString;
|
|
45555
46192
|
exports.executionReportJsonToString = executionReportJsonToString;
|
|
45556
46193
|
exports.extractParameterNamesFromTask = extractParameterNamesFromTask;
|