@promptbook/core 0.114.0-1 → 0.114.0-3
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/README.md +16 -15
- package/esm/index.es.js +392 -195
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +1 -15
- package/esm/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +1 -1
- package/esm/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +0 -4
- package/esm/src/book-components/Chat/utils/$provideServerDomWindow.d.ts +11 -0
- package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +7 -0
- package/esm/src/cli/cli-commands/coder/agentCodingFile.d.ts +2 -3
- package/esm/src/cli/cli-commands/coder/ping.d.ts +10 -0
- package/esm/src/cli/cli-commands/coder/ping.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/coder.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/coderGitSyncCliOptions.d.ts +34 -0
- package/esm/src/cli/cli-commands/common/coderGitSyncCliOptions.test.d.ts +1 -0
- package/esm/src/cli/common/loadPromptsModule.d.ts +16 -0
- package/esm/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/esm/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiCompatibleRequestManager.d.ts +1 -1
- package/esm/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.d.ts +1 -1
- package/esm/src/llm-providers/openai/utils/loadOpenAiAgentsModule.d.ts +203 -0
- package/esm/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +1 -1
- package/esm/src/utils/misc/createLazyModuleLoader.d.ts +14 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +5 -1
- package/umd/index.umd.js +402 -204
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +1 -15
- package/umd/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +1 -1
- package/umd/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +0 -4
- package/umd/src/book-components/Chat/utils/$provideServerDomWindow.d.ts +11 -0
- package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +7 -0
- package/umd/src/cli/cli-commands/coder/agentCodingFile.d.ts +2 -3
- package/umd/src/cli/cli-commands/coder/ping.d.ts +10 -0
- package/umd/src/cli/cli-commands/coder/ping.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/coder.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/coderGitSyncCliOptions.d.ts +34 -0
- package/umd/src/cli/cli-commands/common/coderGitSyncCliOptions.test.d.ts +1 -0
- package/umd/src/cli/common/loadPromptsModule.d.ts +16 -0
- package/umd/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/umd/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiCompatibleRequestManager.d.ts +1 -1
- package/umd/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.d.ts +1 -1
- package/umd/src/llm-providers/openai/utils/loadOpenAiAgentsModule.d.ts +203 -0
- package/umd/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +1 -1
- package/umd/src/utils/misc/createLazyModuleLoader.d.ts +14 -0
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -10,9 +10,7 @@ import papaparse from 'papaparse';
|
|
|
10
10
|
import moment from 'moment';
|
|
11
11
|
import { randomBytes } from 'crypto';
|
|
12
12
|
import colors from 'colors';
|
|
13
|
-
import { fileSearchTool, tool, Agent as Agent$1, webSearchTool, run, setDefaultOpenAIClient, setDefaultOpenAIKey } from '@openai/agents';
|
|
14
13
|
import Bottleneck from 'bottleneck';
|
|
15
|
-
import OpenAI from 'openai';
|
|
16
14
|
|
|
17
15
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
18
16
|
/**
|
|
@@ -28,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
28
26
|
* @generated
|
|
29
27
|
* @see https://github.com/webgptorg/promptbook
|
|
30
28
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-3';
|
|
32
30
|
/**
|
|
33
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -29676,13 +29674,12 @@ const bookLanguageDocumentationExamples = [
|
|
|
29676
29674
|
`),
|
|
29677
29675
|
},
|
|
29678
29676
|
{
|
|
29679
|
-
id: 'use-project-
|
|
29677
|
+
id: 'use-project-integration-agent',
|
|
29680
29678
|
source: spaceTrim$1(`
|
|
29681
29679
|
Repository Maintainer
|
|
29682
29680
|
|
|
29683
29681
|
GOAL Maintain a GitHub repository and prepare safe pull requests.
|
|
29684
29682
|
USE PROJECT https://github.com/acme/website
|
|
29685
|
-
WALLET Store credentials for repository operations.
|
|
29686
29683
|
RULE Before editing files, explain the planned change and impacted paths.
|
|
29687
29684
|
RULE Never reveal raw credentials in chat output.
|
|
29688
29685
|
INITIAL MESSAGE I can inspect the repository and help you prepare PR-ready changes.
|
|
@@ -29754,24 +29751,6 @@ const DEPRECATED_COMMITMENT_DETAIL_LABEL = 'Deprecated commitment';
|
|
|
29754
29751
|
* Longer label used for unfinished and low-level commitments.
|
|
29755
29752
|
*/
|
|
29756
29753
|
const LOW_LEVEL_COMMITMENT_DETAIL_LABEL = 'Low-level commitment';
|
|
29757
|
-
/**
|
|
29758
|
-
* Prefix used when formatting replacement guidance.
|
|
29759
|
-
*/
|
|
29760
|
-
const PREFERRED_REPLACEMENT_LABEL = 'Preferred replacement';
|
|
29761
|
-
/**
|
|
29762
|
-
* Formats preferred replacement guidance for deprecated commitments.
|
|
29763
|
-
*
|
|
29764
|
-
* @param replacedBy - Preferred replacement commitment keywords.
|
|
29765
|
-
* @returns Optional replacement guidance sentence with leading space.
|
|
29766
|
-
*
|
|
29767
|
-
* @private internal utility of commitment catalog notices
|
|
29768
|
-
*/
|
|
29769
|
-
function formatCommitmentReplacementText(replacedBy) {
|
|
29770
|
-
if (!replacedBy || replacedBy.length === 0) {
|
|
29771
|
-
return '';
|
|
29772
|
-
}
|
|
29773
|
-
return ` ${PREFERRED_REPLACEMENT_LABEL}: ${replacedBy.map((type) => `\`${type}\``).join(', ')}.`;
|
|
29774
|
-
}
|
|
29775
29754
|
/**
|
|
29776
29755
|
* Returns true when one commitment notice should be rendered with low-visibility styling.
|
|
29777
29756
|
*
|
|
@@ -29837,6 +29816,10 @@ function getBookLanguageManualCommitmentGroups() {
|
|
|
29837
29816
|
if ((notice === null || notice === void 0 ? void 0 : notice.kind) === 'deprecated') {
|
|
29838
29817
|
continue;
|
|
29839
29818
|
}
|
|
29819
|
+
if (groupedCommitment.primary instanceof NotYetImplementedCommitmentDefinition ||
|
|
29820
|
+
groupedCommitment.primary.isUnfinished) {
|
|
29821
|
+
continue;
|
|
29822
|
+
}
|
|
29840
29823
|
if (isLowVisibilityCommitmentNotice(notice)) {
|
|
29841
29824
|
lowLevel.push(groupedCommitment);
|
|
29842
29825
|
continue;
|
|
@@ -29864,9 +29847,7 @@ const czechBookLanguageManualDictionary = {
|
|
|
29864
29847
|
metadataLabels: {
|
|
29865
29848
|
bookLanguageVersion: 'Verze jazyka Book',
|
|
29866
29849
|
generatedAt: 'Vygenerováno',
|
|
29867
|
-
|
|
29868
|
-
implementedCommitments: 'Hotových commitmentů',
|
|
29869
|
-
placeholderCommitments: 'Připravovaných commitmentů',
|
|
29850
|
+
commitmentCount: 'Počet commitmentů',
|
|
29870
29851
|
},
|
|
29871
29852
|
tableOfContentsTitle: 'Obsah',
|
|
29872
29853
|
chapters: {
|
|
@@ -29928,15 +29909,7 @@ const czechBookLanguageManualDictionary = {
|
|
|
29928
29909
|
commitmentCatalog: {
|
|
29929
29910
|
title: 'Katalog commitmentů',
|
|
29930
29911
|
body: spaceTrim$1(`
|
|
29931
|
-
|
|
29932
|
-
U každé skupiny commitmentů najdete:
|
|
29933
|
-
|
|
29934
|
-
- shrnutí významu (popis, ikona, stav)
|
|
29935
|
-
- schéma pro parsování (\`createTypeRegex\` a \`createRegex\`)
|
|
29936
|
-
- úplnou dokumentaci
|
|
29937
|
-
|
|
29938
|
-
Klíčová slova commitmentů jsou součástí syntaxe, a proto zůstávají anglicky.
|
|
29939
|
-
Anglicky zůstávají i jejich referenční popisy, které jsou závaznou specifikací jazyka.
|
|
29912
|
+
Každá sekce commitmentu vysvětluje jeho účel, důležité podrobnosti a ukazuje soustředěný příklad.
|
|
29940
29913
|
`),
|
|
29941
29914
|
},
|
|
29942
29915
|
examples: {
|
|
@@ -30023,41 +29996,28 @@ const czechBookLanguageManualDictionary = {
|
|
|
30023
29996
|
První neprázdný řádek, který není klíčovým slovem commitmentu.
|
|
30024
29997
|
2. **Blok commitmentu**:
|
|
30025
29998
|
Začíná klíčovým slovem commitmentu a pokračuje až k dalšímu commitmentu nebo oddělovači.
|
|
30026
|
-
3. **
|
|
30027
|
-
Řádky jako \`---\`
|
|
29999
|
+
3. **Více agentů**:
|
|
30000
|
+
Řádky jako \`---\` oddělují agenty definované ve stejném zdroji Booku.
|
|
30028
30001
|
4. **Bloky kódu**:
|
|
30029
|
-
|
|
30030
|
-
5. **Parametry**:
|
|
30031
|
-
Podporovaný a rozpoznávaný je zápis \`@parametr\` i \`{parametr}\`.
|
|
30002
|
+
Začínají a končí pomocí <code>\`\`\`</code>; jejich obsah zůstává uvnitř commitmentu zachovaný a hodí se pro ukázky a instrukce.
|
|
30032
30003
|
`),
|
|
30033
30004
|
},
|
|
30034
30005
|
references: {
|
|
30035
30006
|
title: 'Odkazy a zástupní agenti',
|
|
30036
30007
|
body: spaceTrim$1(`
|
|
30037
|
-
-
|
|
30008
|
+
- \`@Foo\` a \`{Foo foo}\` odkazují na jiného agenta; nejde o zápis parametrů.
|
|
30009
|
+
- Zkrácené odkazy jako \`@Jméno agenta\` a \`{Jméno agenta}\` vyhodnocuje resolver odkazů v Agents Serveru.
|
|
30038
30010
|
- V příslušných commitmentech lze použít i zástupné agenty (například \`{User}\` nebo \`{Void}\`).
|
|
30039
30011
|
- \`{User}\` je určený pro \`TEAM\`; \`{Void}\` se hodí pro výslovné zrušení dědičnosti.
|
|
30040
30012
|
`),
|
|
30041
30013
|
},
|
|
30042
|
-
keywordsTitle: 'Aktuálně rozpoznávaná klíčová slova commitmentů',
|
|
30043
30014
|
},
|
|
30044
30015
|
commitmentCatalogTitleSuffixes: {
|
|
30045
30016
|
usedFirst: ' (nejdřív používané commitmenty)',
|
|
30046
30017
|
all: ' (všechny commitmenty)',
|
|
30047
30018
|
},
|
|
30048
30019
|
commitmentLabels: {
|
|
30049
|
-
status: 'Stav',
|
|
30050
30020
|
aliases: 'Varianty zápisu',
|
|
30051
|
-
semantics: 'Význam',
|
|
30052
|
-
typeSchema: 'Schéma klíčového slova',
|
|
30053
|
-
blockSchema: 'Schéma bloku',
|
|
30054
|
-
lowLevelNotice: 'Nízkoúrovňový commitment',
|
|
30055
|
-
usage: 'Použití u vybraných agentů',
|
|
30056
|
-
usageOccurrence: 'výskyt',
|
|
30057
|
-
usageOccurrences: 'výskytů',
|
|
30058
|
-
statusImplemented: 'Hotovo',
|
|
30059
|
-
statusPlaceholder: 'Připravuje se (zatím není plně hotové)',
|
|
30060
|
-
noAliases: 'Žádné',
|
|
30061
30021
|
},
|
|
30062
30022
|
exampleLabels: {
|
|
30063
30023
|
commitmentsUsed: 'Použité commitmenty',
|
|
@@ -30107,14 +30067,14 @@ const czechBookLanguageManualDictionary = {
|
|
|
30107
30067
|
'Hodí se pro asistenty, kteří si musí držet kontext v čase.',
|
|
30108
30068
|
],
|
|
30109
30069
|
},
|
|
30110
|
-
'use-project-
|
|
30111
|
-
title: 'Napojení na projekt (USE PROJECT)
|
|
30112
|
-
goal: 'Pracovat s
|
|
30070
|
+
'use-project-integration-agent': {
|
|
30071
|
+
title: 'Napojení na projekt (USE PROJECT)',
|
|
30072
|
+
goal: 'Pracovat s repozitářem na GitHubu přes připojení projektu.',
|
|
30113
30073
|
walkthrough: [
|
|
30114
30074
|
'`USE PROJECT` zapne nástroje pro výpis, čtení a úpravy souborů a pro zakládání pull requestů.',
|
|
30115
30075
|
'Přihlašovací údaje se v Agents Serveru za běhu načtou ze záznamů v peněžence.',
|
|
30116
|
-
'
|
|
30117
|
-
'
|
|
30076
|
+
'Agent má také výslovná pravidla pro bezpečné úpravy a práci s přihlašovacími údaji.',
|
|
30077
|
+
'Tento vzor použijte, když agent potřebuje soustředěný přístup k repozitáři.',
|
|
30118
30078
|
],
|
|
30119
30079
|
},
|
|
30120
30080
|
'use-calendar-integration-agent': {
|
|
@@ -30184,10 +30144,10 @@ const czechBookLanguageManualDictionary = {
|
|
|
30184
30144
|
footer: {
|
|
30185
30145
|
title: 'Vygenerováno z:',
|
|
30186
30146
|
body: spaceTrim$1(`
|
|
30187
|
-
- Registru commitmentů a běhové dokumentace
|
|
30188
|
-
-
|
|
30189
|
-
- Vyhodnocení odkazů a dědičnosti v Agents Serveru
|
|
30190
|
-
- Zdrojových
|
|
30147
|
+
- [Registru commitmentů a běhové dokumentace](https://github.com/webgptorg/promptbook/tree/main/src/commitments)
|
|
30148
|
+
- [Parseru jazyka Book a práce se zdrojem](https://github.com/webgptorg/promptbook/tree/main/src/book-2.0/agent-source)
|
|
30149
|
+
- [Vyhodnocení odkazů a dědičnosti v Agents Serveru](https://github.com/webgptorg/promptbook/tree/main/apps/agents-server/src/utils)
|
|
30150
|
+
- [Zdrojových kódů samostatné příručky](https://github.com/webgptorg/promptbook/tree/main/src/book-2.0/book-language-documentation)
|
|
30191
30151
|
`),
|
|
30192
30152
|
},
|
|
30193
30153
|
};
|
|
@@ -30210,9 +30170,7 @@ const englishBookLanguageManualDictionary = {
|
|
|
30210
30170
|
metadataLabels: {
|
|
30211
30171
|
bookLanguageVersion: 'Book language version',
|
|
30212
30172
|
generatedAt: 'Generated at',
|
|
30213
|
-
|
|
30214
|
-
implementedCommitments: 'Implemented commitments',
|
|
30215
|
-
placeholderCommitments: 'Placeholder commitments',
|
|
30173
|
+
commitmentCount: 'Number of commitments',
|
|
30216
30174
|
},
|
|
30217
30175
|
tableOfContentsTitle: 'Table of Contents',
|
|
30218
30176
|
chapters: {
|
|
@@ -30274,12 +30232,7 @@ const englishBookLanguageManualDictionary = {
|
|
|
30274
30232
|
commitmentCatalog: {
|
|
30275
30233
|
title: 'Commitment catalog',
|
|
30276
30234
|
body: spaceTrim$1(`
|
|
30277
|
-
|
|
30278
|
-
For each commitment group you get:
|
|
30279
|
-
|
|
30280
|
-
- semantics summary (description/icon/status)
|
|
30281
|
-
- parsing schema (\`createTypeRegex\` and \`createRegex\`)
|
|
30282
|
-
- canonical documentation block
|
|
30235
|
+
Each commitment section explains its purpose, important details, and a focused example.
|
|
30283
30236
|
`),
|
|
30284
30237
|
},
|
|
30285
30238
|
examples: {
|
|
@@ -30366,41 +30319,28 @@ const englishBookLanguageManualDictionary = {
|
|
|
30366
30319
|
First non-empty line that is not a commitment keyword.
|
|
30367
30320
|
2. **Commitment block**:
|
|
30368
30321
|
Starts with a commitment keyword and continues until the next commitment block or separator.
|
|
30369
|
-
3. **
|
|
30370
|
-
Lines like \`---\`
|
|
30322
|
+
3. **Multiple agent**:
|
|
30323
|
+
Lines like \`---\` separate agents defined in the same Book source.
|
|
30371
30324
|
4. **Code fences**:
|
|
30372
|
-
|
|
30373
|
-
5. **Parameters**:
|
|
30374
|
-
Both \`@parameter\` and \`{parameter}\` notations are supported and parsed.
|
|
30325
|
+
Start and end with <code>\`\`\`</code>; their content is preserved inside commitments and is useful for examples and instructions.
|
|
30375
30326
|
`),
|
|
30376
30327
|
},
|
|
30377
30328
|
references: {
|
|
30378
30329
|
title: 'Reference tokens and pseudo-agents',
|
|
30379
30330
|
body: spaceTrim$1(`
|
|
30380
|
-
-
|
|
30331
|
+
- \`@Foo\` and \`{Foo foo}\` reference another agent; they are not parameter notation.
|
|
30332
|
+
- Compact references like \`@Agent Name\` and \`{Agent Name}\` are resolved by the Agents Server reference resolver.
|
|
30381
30333
|
- Pseudo-agent forms (for example \`{User}\`, \`{Void}\`) are supported in relevant commitments.
|
|
30382
30334
|
- \`{User}\` is intended for \`TEAM\`; \`{Void}\` is useful for explicit no-parent inheritance.
|
|
30383
30335
|
`),
|
|
30384
30336
|
},
|
|
30385
|
-
keywordsTitle: 'Commitment keywords currently recognized',
|
|
30386
30337
|
},
|
|
30387
30338
|
commitmentCatalogTitleSuffixes: {
|
|
30388
30339
|
usedFirst: ' (used commitments first)',
|
|
30389
30340
|
all: ' (all commitments)',
|
|
30390
30341
|
},
|
|
30391
30342
|
commitmentLabels: {
|
|
30392
|
-
status: 'Status',
|
|
30393
30343
|
aliases: 'Aliases',
|
|
30394
|
-
semantics: 'Semantics',
|
|
30395
|
-
typeSchema: 'Type schema',
|
|
30396
|
-
blockSchema: 'Block schema',
|
|
30397
|
-
lowLevelNotice: 'Low-level commitment',
|
|
30398
|
-
usage: 'Used in selected agents',
|
|
30399
|
-
usageOccurrence: 'occurrence',
|
|
30400
|
-
usageOccurrences: 'occurrences',
|
|
30401
|
-
statusImplemented: 'Implemented',
|
|
30402
|
-
statusPlaceholder: 'Placeholder (not fully implemented)',
|
|
30403
|
-
noAliases: 'None',
|
|
30404
30344
|
},
|
|
30405
30345
|
exampleLabels: {
|
|
30406
30346
|
commitmentsUsed: 'Commitments used',
|
|
@@ -30450,14 +30390,14 @@ const englishBookLanguageManualDictionary = {
|
|
|
30450
30390
|
'Use this for assistants that must preserve context over time.',
|
|
30451
30391
|
],
|
|
30452
30392
|
},
|
|
30453
|
-
'use-project-
|
|
30454
|
-
title: 'USE PROJECT
|
|
30455
|
-
goal: 'Work with GitHub
|
|
30393
|
+
'use-project-integration-agent': {
|
|
30394
|
+
title: 'USE PROJECT external integration',
|
|
30395
|
+
goal: 'Work with a GitHub repository through a connected project integration.',
|
|
30456
30396
|
walkthrough: [
|
|
30457
30397
|
'`USE PROJECT` enables repository tools for listing, reading, editing files, and creating PRs.',
|
|
30458
30398
|
'Credentials are resolved from wallet records at runtime in Agents Server.',
|
|
30459
|
-
'
|
|
30460
|
-
'
|
|
30399
|
+
'The agent also defines explicit rules for safe editing and credential handling.',
|
|
30400
|
+
'Use this pattern when an agent needs focused repository access.',
|
|
30461
30401
|
],
|
|
30462
30402
|
},
|
|
30463
30403
|
'use-calendar-integration-agent': {
|
|
@@ -30527,10 +30467,10 @@ const englishBookLanguageManualDictionary = {
|
|
|
30527
30467
|
footer: {
|
|
30528
30468
|
title: 'Generated from:',
|
|
30529
30469
|
body: spaceTrim$1(`
|
|
30530
|
-
- Commitments registry and runtime
|
|
30531
|
-
-
|
|
30532
|
-
- Agents Server reference
|
|
30533
|
-
- Standalone
|
|
30470
|
+
- [Commitments registry and runtime documentation](https://github.com/webgptorg/promptbook/tree/main/src/commitments)
|
|
30471
|
+
- [Book language parser and source handling](https://github.com/webgptorg/promptbook/tree/main/src/book-2.0/agent-source)
|
|
30472
|
+
- [Agents Server reference and inheritance resolution](https://github.com/webgptorg/promptbook/tree/main/apps/agents-server/src/utils)
|
|
30473
|
+
- [Standalone manual source](https://github.com/webgptorg/promptbook/tree/main/src/book-2.0/book-language-documentation)
|
|
30534
30474
|
`),
|
|
30535
30475
|
},
|
|
30536
30476
|
};
|
|
@@ -30579,6 +30519,28 @@ function getSafeCodeBlock(content, language = 'markdown') {
|
|
|
30579
30519
|
return `${fence}${language}\n${content}\n${fence}`;
|
|
30580
30520
|
}
|
|
30581
30521
|
|
|
30522
|
+
/**
|
|
30523
|
+
* Gets all available commitment definitions
|
|
30524
|
+
*
|
|
30525
|
+
* @returns Array of all commitment definitions
|
|
30526
|
+
*
|
|
30527
|
+
* @public exported from `@promptbook/core`
|
|
30528
|
+
*/
|
|
30529
|
+
function getAllCommitmentDefinitions() {
|
|
30530
|
+
return $deepFreeze(sortCommitmentDefinitions(COMMITMENT_REGISTRY, { isUnfinishedLast: true, isLowLevelLast: true }));
|
|
30531
|
+
}
|
|
30532
|
+
|
|
30533
|
+
/**
|
|
30534
|
+
* Gets all available commitment types
|
|
30535
|
+
*
|
|
30536
|
+
* @returns Array of all commitment types
|
|
30537
|
+
*
|
|
30538
|
+
* @public exported from `@promptbook/core`
|
|
30539
|
+
*/
|
|
30540
|
+
function getAllCommitmentTypes() {
|
|
30541
|
+
return $deepFreeze(getAllCommitmentDefinitions().map((commitmentDefinition) => commitmentDefinition.type));
|
|
30542
|
+
}
|
|
30543
|
+
|
|
30582
30544
|
/**
|
|
30583
30545
|
* Deepest heading level markdown supports.
|
|
30584
30546
|
*
|
|
@@ -30652,6 +30614,19 @@ const CLOSED_COMMITMENT_TYPE = 'CLOSED';
|
|
|
30652
30614
|
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30653
30615
|
*/
|
|
30654
30616
|
const COMMITMENT_DOCUMENTATION_SECTION_HEADING_LEVEL = 2;
|
|
30617
|
+
/**
|
|
30618
|
+
* Markdown code blocks whose Book source is shown as a commitment example.
|
|
30619
|
+
*
|
|
30620
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30621
|
+
*/
|
|
30622
|
+
const BOOK_CODE_BLOCK_PATTERN = /(`{3,})book[^\n]*\n([\s\S]*?)\n\1/gu;
|
|
30623
|
+
/**
|
|
30624
|
+
* Recognized commitment types, ordered so compound keywords take priority over
|
|
30625
|
+
* their shorter prefixes when reducing an example line by line.
|
|
30626
|
+
*
|
|
30627
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30628
|
+
*/
|
|
30629
|
+
const COMMITMENT_TYPES_BY_LENGTH = [...getAllCommitmentTypes()].sort((firstType, secondType) => secondType.length - firstType.length);
|
|
30655
30630
|
/**
|
|
30656
30631
|
* Removes the top-level heading from one commitment documentation block.
|
|
30657
30632
|
*
|
|
@@ -30668,17 +30643,18 @@ function removeLeadingTopLevelHeading(markdown) {
|
|
|
30668
30643
|
*
|
|
30669
30644
|
* @param title - Heading label for the subsection.
|
|
30670
30645
|
* @param documentation - Raw commitment documentation markdown.
|
|
30646
|
+
* @param group - Commitment family represented by the documentation entry.
|
|
30671
30647
|
* @param headingLevelShift - How many levels the whole entry is nested by its host document.
|
|
30672
30648
|
* @returns Markdown subsection introducing one commitment of the family.
|
|
30673
30649
|
*
|
|
30674
30650
|
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30675
30651
|
*/
|
|
30676
|
-
function renderDocumentationSection(title, documentation, headingLevelShift) {
|
|
30652
|
+
function renderDocumentationSection(title, documentation, group, headingLevelShift) {
|
|
30677
30653
|
const headingPrefix = '#'.repeat(COMMITMENT_DOCUMENTATION_SECTION_HEADING_LEVEL + headingLevelShift);
|
|
30678
30654
|
return spaceTrim$1((block) => `
|
|
30679
30655
|
${headingPrefix} ${title}
|
|
30680
30656
|
|
|
30681
|
-
${block(shiftMarkdownHeadingLevels(removeLeadingTopLevelHeading(documentation), headingLevelShift + 1))}
|
|
30657
|
+
${block(shiftMarkdownHeadingLevels(removeLeadingTopLevelHeading(renderFocusedCommitmentExamples(documentation, group)), headingLevelShift + 1))}
|
|
30682
30658
|
`);
|
|
30683
30659
|
}
|
|
30684
30660
|
/**
|
|
@@ -30695,18 +30671,199 @@ function renderDocumentationSection(title, documentation, headingLevelShift) {
|
|
|
30695
30671
|
*/
|
|
30696
30672
|
function renderGroupedCommitmentDocumentationMarkdown(group, headingLevelShift = 0) {
|
|
30697
30673
|
const commitmentTypes = new Set([group.primary.type, ...group.aliases]);
|
|
30698
|
-
|
|
30674
|
+
const isOpenClosedCommitmentFamily = commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE);
|
|
30675
|
+
if (isOpenClosedCommitmentFamily) {
|
|
30699
30676
|
const openCommitmentDefinition = getCommitmentDefinition(OPEN_COMMITMENT_TYPE);
|
|
30700
30677
|
const closedCommitmentDefinition = getCommitmentDefinition(CLOSED_COMMITMENT_TYPE);
|
|
30701
30678
|
if (openCommitmentDefinition && closedCommitmentDefinition) {
|
|
30702
30679
|
return spaceTrim$1((block) => `
|
|
30703
|
-
${block(renderDocumentationSection(OPEN_COMMITMENT_TYPE, openCommitmentDefinition.documentation, headingLevelShift))}
|
|
30680
|
+
${block(renderDocumentationSection(OPEN_COMMITMENT_TYPE, openCommitmentDefinition.documentation, group, headingLevelShift))}
|
|
30704
30681
|
|
|
30705
|
-
${block(renderDocumentationSection(CLOSED_COMMITMENT_TYPE, closedCommitmentDefinition.documentation, headingLevelShift))}
|
|
30682
|
+
${block(renderDocumentationSection(CLOSED_COMMITMENT_TYPE, closedCommitmentDefinition.documentation, group, headingLevelShift))}
|
|
30706
30683
|
`);
|
|
30707
30684
|
}
|
|
30708
30685
|
}
|
|
30709
|
-
return shiftMarkdownHeadingLevels(removeLeadingTopLevelHeading(group.primary.documentation), headingLevelShift);
|
|
30686
|
+
return shiftMarkdownHeadingLevels(removeLeadingTopLevelHeading(renderFocusedCommitmentExamples(group.primary.documentation, group)), headingLevelShift);
|
|
30687
|
+
}
|
|
30688
|
+
/**
|
|
30689
|
+
* Rewrites Book examples in commitment documentation to show one canonical
|
|
30690
|
+
* commitment in isolation, with only `GOAL` and `CLOSED` as supporting syntax.
|
|
30691
|
+
*
|
|
30692
|
+
* @param documentation - Raw commitment documentation markdown.
|
|
30693
|
+
* @param group - Commitment family represented by the documentation entry.
|
|
30694
|
+
* @returns Documentation whose Book examples use focused canonical syntax.
|
|
30695
|
+
*
|
|
30696
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30697
|
+
*/
|
|
30698
|
+
function renderFocusedCommitmentExamples(documentation, group) {
|
|
30699
|
+
return documentation.replace(BOOK_CODE_BLOCK_PATTERN, (codeBlock, _fence, source) => {
|
|
30700
|
+
const focusedSource = createFocusedCommitmentExampleSource(source, group);
|
|
30701
|
+
return focusedSource ? getSafeCodeBlock(focusedSource, 'book') : codeBlock;
|
|
30702
|
+
});
|
|
30703
|
+
}
|
|
30704
|
+
/**
|
|
30705
|
+
* Creates a focused Book source example for one commitment documentation entry.
|
|
30706
|
+
*
|
|
30707
|
+
* @param source - Original Book source from the commitment documentation.
|
|
30708
|
+
* @param group - Commitment family represented by the documentation entry.
|
|
30709
|
+
* @returns Focused source, or `null` when the source cannot be safely reduced.
|
|
30710
|
+
*
|
|
30711
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30712
|
+
*/
|
|
30713
|
+
function createFocusedCommitmentExampleSource(source, group) {
|
|
30714
|
+
const parsedSource = parseAgentSourceWithCommitments(source);
|
|
30715
|
+
const commitmentTypes = new Set([group.primary.type, ...group.aliases]);
|
|
30716
|
+
const isOpenClosedCommitmentFamily = commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE);
|
|
30717
|
+
const allowedCommitmentTypes = new Set([
|
|
30718
|
+
group.primary.type,
|
|
30719
|
+
...group.aliases,
|
|
30720
|
+
'GOAL',
|
|
30721
|
+
CLOSED_COMMITMENT_TYPE,
|
|
30722
|
+
]);
|
|
30723
|
+
const canonicalTypeByCommitmentType = createCanonicalCommitmentTypeByCommitmentType(group, isOpenClosedCommitmentFamily);
|
|
30724
|
+
const focusedCommitments = parsedSource.commitments
|
|
30725
|
+
.filter((commitment) => allowedCommitmentTypes.has(commitment.type))
|
|
30726
|
+
.map((commitment) => {
|
|
30727
|
+
const type = canonicalTypeByCommitmentType.get(commitment.type) || commitment.type;
|
|
30728
|
+
return `${type}${commitment.content ? ` ${commitment.content}` : ''}`;
|
|
30729
|
+
});
|
|
30730
|
+
if (focusedCommitments.length > 0) {
|
|
30731
|
+
return finalizeFocusedCommitmentExampleSource(getFocusedExampleAgentName(parsedSource.agentName), focusedCommitments);
|
|
30732
|
+
}
|
|
30733
|
+
return createLineFocusedCommitmentExampleSource(source, group, isOpenClosedCommitmentFamily);
|
|
30734
|
+
}
|
|
30735
|
+
/**
|
|
30736
|
+
* Creates a focused example when the Book parser cannot recognize the target
|
|
30737
|
+
* commitment because it appears as the first source line or has a shared prefix.
|
|
30738
|
+
*
|
|
30739
|
+
* @param source - Original Book source from the documentation code block.
|
|
30740
|
+
* @param group - Commitment family represented by the documentation entry.
|
|
30741
|
+
* @param isOpenClosedCommitmentFamily - Whether the family contains both switch commitments.
|
|
30742
|
+
* @returns Focused source, or `null` when the source does not use this commitment family.
|
|
30743
|
+
*
|
|
30744
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30745
|
+
*/
|
|
30746
|
+
function createLineFocusedCommitmentExampleSource(source, group, isOpenClosedCommitmentFamily) {
|
|
30747
|
+
const sourceLines = source.split(/\r?\n/u);
|
|
30748
|
+
const allowedCommitmentTypes = new Set([group.primary.type, ...group.aliases, 'GOAL', CLOSED_COMMITMENT_TYPE]);
|
|
30749
|
+
const canonicalTypeByCommitmentType = createCanonicalCommitmentTypeByCommitmentType(group, isOpenClosedCommitmentFamily);
|
|
30750
|
+
const focusedCommitments = [];
|
|
30751
|
+
const firstSourceLine = sourceLines.find((line) => line.trim().length > 0) || null;
|
|
30752
|
+
const firstCommitmentType = firstSourceLine ? getCommitmentTypeAtLine(firstSourceLine) : null;
|
|
30753
|
+
const agentName = firstSourceLine && !firstCommitmentType ? firstSourceLine.trim() : null;
|
|
30754
|
+
let activeFocusedCommitmentIndex = null;
|
|
30755
|
+
let isInsideCodeBlock = false;
|
|
30756
|
+
for (const sourceLine of sourceLines) {
|
|
30757
|
+
const trimmedSourceLine = sourceLine.trim();
|
|
30758
|
+
if (trimmedSourceLine.startsWith('```')) {
|
|
30759
|
+
appendLineToActiveCommitment(focusedCommitments, activeFocusedCommitmentIndex, sourceLine);
|
|
30760
|
+
isInsideCodeBlock = !isInsideCodeBlock;
|
|
30761
|
+
continue;
|
|
30762
|
+
}
|
|
30763
|
+
if (isInsideCodeBlock) {
|
|
30764
|
+
appendLineToActiveCommitment(focusedCommitments, activeFocusedCommitmentIndex, sourceLine);
|
|
30765
|
+
continue;
|
|
30766
|
+
}
|
|
30767
|
+
const commitmentType = getCommitmentTypeAtLine(sourceLine);
|
|
30768
|
+
if (!commitmentType) {
|
|
30769
|
+
appendLineToActiveCommitment(focusedCommitments, activeFocusedCommitmentIndex, sourceLine);
|
|
30770
|
+
continue;
|
|
30771
|
+
}
|
|
30772
|
+
if (!allowedCommitmentTypes.has(commitmentType)) {
|
|
30773
|
+
activeFocusedCommitmentIndex = null;
|
|
30774
|
+
continue;
|
|
30775
|
+
}
|
|
30776
|
+
const canonicalType = canonicalTypeByCommitmentType.get(commitmentType) || commitmentType;
|
|
30777
|
+
const content = trimmedSourceLine.slice(commitmentType.length).trimStart();
|
|
30778
|
+
focusedCommitments.push(`${canonicalType}${content ? ` ${content}` : ''}`);
|
|
30779
|
+
activeFocusedCommitmentIndex = focusedCommitments.length - 1;
|
|
30780
|
+
}
|
|
30781
|
+
return finalizeFocusedCommitmentExampleSource(agentName, focusedCommitments);
|
|
30782
|
+
}
|
|
30783
|
+
/**
|
|
30784
|
+
* Finds the longest supported commitment keyword at the start of a source line.
|
|
30785
|
+
*
|
|
30786
|
+
* @param sourceLine - One Book source line to inspect.
|
|
30787
|
+
* @returns Matching commitment type, or `null` when the line is ordinary content.
|
|
30788
|
+
*
|
|
30789
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30790
|
+
*/
|
|
30791
|
+
function getCommitmentTypeAtLine(sourceLine) {
|
|
30792
|
+
const trimmedSourceLine = sourceLine.trim();
|
|
30793
|
+
return (COMMITMENT_TYPES_BY_LENGTH.find((commitmentType) => trimmedSourceLine === commitmentType || trimmedSourceLine.startsWith(`${commitmentType} `)) || null);
|
|
30794
|
+
}
|
|
30795
|
+
/**
|
|
30796
|
+
* Appends a source line only when a focused commitment currently owns it.
|
|
30797
|
+
*
|
|
30798
|
+
* @param focusedCommitments - Focused commitments assembled from the example.
|
|
30799
|
+
* @param activeFocusedCommitmentIndex - Index of the commitment receiving continuation lines.
|
|
30800
|
+
* @param sourceLine - Source line to append.
|
|
30801
|
+
*
|
|
30802
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30803
|
+
*/
|
|
30804
|
+
function appendLineToActiveCommitment(focusedCommitments, activeFocusedCommitmentIndex, sourceLine) {
|
|
30805
|
+
if (activeFocusedCommitmentIndex === null) {
|
|
30806
|
+
return;
|
|
30807
|
+
}
|
|
30808
|
+
focusedCommitments[activeFocusedCommitmentIndex] += `\n${sourceLine}`;
|
|
30809
|
+
}
|
|
30810
|
+
/**
|
|
30811
|
+
* Adds the standard closing marker and formats one reduced Book example.
|
|
30812
|
+
*
|
|
30813
|
+
* @param agentName - Optional human-readable title retained from the original example.
|
|
30814
|
+
* @param focusedCommitments - Canonical commitment blocks kept in the example.
|
|
30815
|
+
* @returns Focused source, or `null` when no relevant commitment was found.
|
|
30816
|
+
*
|
|
30817
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30818
|
+
*/
|
|
30819
|
+
function finalizeFocusedCommitmentExampleSource(agentName, focusedCommitments) {
|
|
30820
|
+
const normalizedFocusedCommitments = focusedCommitments.map((commitment) => commitment.trim());
|
|
30821
|
+
if (normalizedFocusedCommitments.length === 0) {
|
|
30822
|
+
return null;
|
|
30823
|
+
}
|
|
30824
|
+
const isClosedCommitmentIncluded = normalizedFocusedCommitments.some((commitment) => commitment.startsWith(CLOSED_COMMITMENT_TYPE));
|
|
30825
|
+
const isOpenCommitmentIncluded = normalizedFocusedCommitments.some((commitment) => commitment.startsWith(OPEN_COMMITMENT_TYPE));
|
|
30826
|
+
if (!isClosedCommitmentIncluded && !isOpenCommitmentIncluded) {
|
|
30827
|
+
normalizedFocusedCommitments.push(CLOSED_COMMITMENT_TYPE);
|
|
30828
|
+
}
|
|
30829
|
+
return [agentName, ...normalizedFocusedCommitments]
|
|
30830
|
+
.filter((line) => Boolean(line))
|
|
30831
|
+
.join('\n\n');
|
|
30832
|
+
}
|
|
30833
|
+
/**
|
|
30834
|
+
* Keeps an example title unless the parser interpreted a commitment-only
|
|
30835
|
+
* example's first line as its mandatory agent name.
|
|
30836
|
+
*
|
|
30837
|
+
* @param agentName - Parsed agent name from the original example.
|
|
30838
|
+
* @returns Agent title suitable for a focused example, or `null` when absent.
|
|
30839
|
+
*
|
|
30840
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30841
|
+
*/
|
|
30842
|
+
function getFocusedExampleAgentName(agentName) {
|
|
30843
|
+
if (!agentName || getCommitmentDefinition(agentName)) {
|
|
30844
|
+
return null;
|
|
30845
|
+
}
|
|
30846
|
+
return agentName;
|
|
30847
|
+
}
|
|
30848
|
+
/**
|
|
30849
|
+
* Maps aliases to the canonical keyword shown by a commitment example.
|
|
30850
|
+
*
|
|
30851
|
+
* `OPEN` and `CLOSED` share one documentation entry, but each remains a
|
|
30852
|
+
* distinct keyword and must therefore retain its own spelling.
|
|
30853
|
+
*
|
|
30854
|
+
* @param group - Commitment family represented by the documentation entry.
|
|
30855
|
+
* @param isOpenClosedCommitmentFamily - Whether the family contains both switch commitments.
|
|
30856
|
+
* @returns Canonical keyword by accepted source keyword.
|
|
30857
|
+
*
|
|
30858
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30859
|
+
*/
|
|
30860
|
+
function createCanonicalCommitmentTypeByCommitmentType(group, isOpenClosedCommitmentFamily) {
|
|
30861
|
+
const canonicalTypeByCommitmentType = new Map();
|
|
30862
|
+
canonicalTypeByCommitmentType.set(group.primary.type, group.primary.type);
|
|
30863
|
+
for (const alias of group.aliases) {
|
|
30864
|
+
canonicalTypeByCommitmentType.set(alias, isOpenClosedCommitmentFamily ? alias : group.primary.type);
|
|
30865
|
+
}
|
|
30866
|
+
return canonicalTypeByCommitmentType;
|
|
30710
30867
|
}
|
|
30711
30868
|
|
|
30712
30869
|
/**
|
|
@@ -30746,50 +30903,18 @@ const COMMITMENT_CATALOG_HEADING_LEVEL_SHIFT = 2;
|
|
|
30746
30903
|
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
30747
30904
|
*/
|
|
30748
30905
|
function renderCommitmentCatalogSection(options) {
|
|
30749
|
-
|
|
30750
|
-
const { groupedCommitment, usageCount, dictionary } = options;
|
|
30906
|
+
const { groupedCommitment, dictionary } = options;
|
|
30751
30907
|
const { primary, aliases } = groupedCommitment;
|
|
30752
30908
|
const labels = dictionary.commitmentLabels;
|
|
30753
|
-
const
|
|
30754
|
-
const status = primary instanceof NotYetImplementedCommitmentDefinition
|
|
30755
|
-
? labels.statusPlaceholder
|
|
30756
|
-
: notice
|
|
30757
|
-
? `${labels.statusImplemented} (${notice.detailLabel})`
|
|
30758
|
-
: labels.statusImplemented;
|
|
30759
|
-
const aliasText = aliases.length === 0 ? labels.noAliases : aliases.map((alias) => `\`${alias}\``).join(', ');
|
|
30760
|
-
const noticeText = notice
|
|
30761
|
-
? notice.kind === 'deprecated'
|
|
30762
|
-
? `- **${notice.detailLabel}:** ${notice.message}${formatCommitmentReplacementText((_a = primary.deprecation) === null || _a === void 0 ? void 0 : _a.replacedBy)}`
|
|
30763
|
-
: `- **${labels.lowLevelNotice}:** ${notice.message}`
|
|
30764
|
-
: '';
|
|
30765
|
-
const usageMarkdown = usageCount > 0
|
|
30766
|
-
? `- **${labels.usage}:** ${usageCount} ${usageCount === 1 ? labels.usageOccurrence : labels.usageOccurrences}`
|
|
30767
|
-
: '';
|
|
30909
|
+
const aliasesMarkdown = aliases.length === 0 ? '' : `- **${labels.aliases}:** ${aliases.map((alias) => `\`${alias}\``).join(', ')}`;
|
|
30768
30910
|
return spaceTrim$1((block) => `
|
|
30769
30911
|
### <a id="commitment-${toStableAnchorId(primary.type)}"></a>${primary.icon} ${primary.type}
|
|
30770
30912
|
|
|
30771
|
-
|
|
30772
|
-
- **${labels.aliases}:** ${aliasText}
|
|
30773
|
-
- **${labels.semantics}:** ${primary.description}
|
|
30774
|
-
- **${labels.typeSchema} (\`createTypeRegex\`):** \`${stringifyRegex(primary.createTypeRegex())}\`
|
|
30775
|
-
- **${labels.blockSchema} (\`createRegex\`):** \`${stringifyRegex(primary.createRegex())}\`
|
|
30776
|
-
${noticeText}
|
|
30777
|
-
${usageMarkdown}
|
|
30913
|
+
${aliasesMarkdown}
|
|
30778
30914
|
|
|
30779
30915
|
${block(renderGroupedCommitmentDocumentationMarkdown(groupedCommitment, COMMITMENT_CATALOG_HEADING_LEVEL_SHIFT))}
|
|
30780
30916
|
`);
|
|
30781
30917
|
}
|
|
30782
|
-
/**
|
|
30783
|
-
* Converts a regular expression into a concise literal-like string.
|
|
30784
|
-
*
|
|
30785
|
-
* @param regex - Regex instance.
|
|
30786
|
-
* @returns Printable regex pattern and flags.
|
|
30787
|
-
*
|
|
30788
|
-
* @private internal utility of `renderCommitmentCatalogSection`
|
|
30789
|
-
*/
|
|
30790
|
-
function stringifyRegex(regex) {
|
|
30791
|
-
return `/${regex.source}/${regex.flags}`;
|
|
30792
|
-
}
|
|
30793
30918
|
|
|
30794
30919
|
/**
|
|
30795
30920
|
* Commitment types that primarily model composition of multiple agents.
|
|
@@ -30896,11 +31021,10 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
|
|
|
30896
31021
|
: [];
|
|
30897
31022
|
const manualCommitments = [...catalogCommitments, ...lowLevelCommitments];
|
|
30898
31023
|
const generatedAtIso = new Date().toISOString();
|
|
30899
|
-
const placeholderCommitmentCount = manualCommitments.filter(({ primary }) => primary instanceof NotYetImplementedCommitmentDefinition).length;
|
|
30900
31024
|
const catalogTitleSuffix = isServerSpecificManual
|
|
30901
31025
|
? dictionary.commitmentCatalogTitleSuffixes.usedFirst
|
|
30902
31026
|
: dictionary.commitmentCatalogTitleSuffixes.all;
|
|
30903
|
-
const
|
|
31027
|
+
const commitmentSectionAnchorByType = createCommitmentSectionAnchorByType(manualCommitments);
|
|
30904
31028
|
return spaceTrim$1(
|
|
30905
31029
|
// [✨]
|
|
30906
31030
|
(block) => `
|
|
@@ -30910,9 +31034,7 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
|
|
|
30910
31034
|
|
|
30911
31035
|
- ${dictionary.metadataLabels.bookLanguageVersion}: \`${BOOK_LANGUAGE_VERSION}\`
|
|
30912
31036
|
- ${dictionary.metadataLabels.generatedAt}: \`${generatedAtIso}\`
|
|
30913
|
-
- ${dictionary.metadataLabels.
|
|
30914
|
-
- ${dictionary.metadataLabels.implementedCommitments}: \`${manualCommitments.length - placeholderCommitmentCount}\`
|
|
30915
|
-
- ${dictionary.metadataLabels.placeholderCommitments}: \`${placeholderCommitmentCount}\`
|
|
31037
|
+
- ${dictionary.metadataLabels.commitmentCount}: \`${manualCommitments.length}\`
|
|
30916
31038
|
|
|
30917
31039
|
## <a id="table-of-contents"></a>${dictionary.tableOfContentsTitle}
|
|
30918
31040
|
|
|
@@ -30921,12 +31043,16 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
|
|
|
30921
31043
|
- [${dictionary.chapters.howToStructure.title}](#how-to-structure-good-agents)
|
|
30922
31044
|
- [${dictionary.chapters.primitives.title}](#primitives-and-constructs-reference)
|
|
30923
31045
|
- [${dictionary.chapters.commitmentCatalog.title}${catalogTitleSuffix}](#commitment-catalog)
|
|
31046
|
+
${block(renderCommitmentCatalogTableOfContents(catalogCommitments))}
|
|
30924
31047
|
- [${dictionary.chapters.examples.title}](#end-to-end-examples)
|
|
30925
31048
|
- [${dictionary.chapters.pitfalls.title}](#do-nots-and-common-pitfalls)
|
|
30926
31049
|
- [${dictionary.chapters.tutorial.title}](#build-an-agent-from-scratch-offline-tutorial)
|
|
30927
|
-
${isLowLevelCommitmentsIncluded
|
|
30928
|
-
?
|
|
30929
|
-
|
|
31050
|
+
${block(isLowLevelCommitmentsIncluded
|
|
31051
|
+
? spaceTrim$1(`
|
|
31052
|
+
- [${dictionary.chapters.lowLevelCommitments.title}](#low-level-commitments)
|
|
31053
|
+
${renderCommitmentCatalogTableOfContents(lowLevelCommitments)}
|
|
31054
|
+
`)
|
|
31055
|
+
: '')}
|
|
30930
31056
|
|
|
30931
31057
|
## <a id="what-book-language-is"></a>${dictionary.chapters.whatIs.title}
|
|
30932
31058
|
|
|
@@ -30970,24 +31096,20 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
|
|
|
30970
31096
|
|
|
30971
31097
|
${block(dictionary.primitivesSections.references.body)}
|
|
30972
31098
|
|
|
30973
|
-
### ${dictionary.primitivesSections.keywordsTitle}
|
|
30974
|
-
|
|
30975
|
-
${block(getSafeCodeBlock(allCommitmentKeywords.join(', '), 'text'))}
|
|
30976
|
-
|
|
30977
|
-
<a id="commitment-catalog-all-commitments"></a>
|
|
30978
|
-
|
|
30979
31099
|
## <a id="commitment-catalog"></a>${dictionary.chapters.commitmentCatalog.title}${catalogTitleSuffix}
|
|
30980
31100
|
|
|
30981
31101
|
${block(dictionary.chapters.commitmentCatalog.body)}
|
|
30982
31102
|
|
|
30983
|
-
${block(renderCommitmentCatalogSections(catalogCommitments,
|
|
31103
|
+
${block(renderCommitmentCatalogSections(catalogCommitments, dictionary))}
|
|
30984
31104
|
|
|
30985
31105
|
## <a id="end-to-end-examples"></a>${dictionary.chapters.examples.title}
|
|
30986
31106
|
|
|
30987
31107
|
${block(isServerSpecificManual
|
|
30988
|
-
? selectedAgents
|
|
31108
|
+
? selectedAgents
|
|
31109
|
+
.map((agent) => renderBakedAgentExampleSection(agent, dictionary, commitmentSectionAnchorByType))
|
|
31110
|
+
.join('\n\n')
|
|
30989
31111
|
: bookLanguageDocumentationExamples
|
|
30990
|
-
.map((example) => renderExampleSection(example, dictionary))
|
|
31112
|
+
.map((example) => renderExampleSection(example, dictionary, commitmentSectionAnchorByType))
|
|
30991
31113
|
.join('\n\n'))}
|
|
30992
31114
|
|
|
30993
31115
|
## <a id="do-nots-and-common-pitfalls"></a>${dictionary.chapters.pitfalls.title}
|
|
@@ -31007,7 +31129,7 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
|
|
|
31007
31129
|
${block(dictionary.tutorialSections.checklistBody)}
|
|
31008
31130
|
|
|
31009
31131
|
${block(isLowLevelCommitmentsIncluded
|
|
31010
|
-
? renderLowLevelCommitmentsChapter(lowLevelCommitments,
|
|
31132
|
+
? renderLowLevelCommitmentsChapter(lowLevelCommitments, dictionary)
|
|
31011
31133
|
: '')}
|
|
31012
31134
|
|
|
31013
31135
|
---
|
|
@@ -31047,17 +31169,15 @@ function renderDetectedCommitmentList(commitmentGroups, dictionary) {
|
|
|
31047
31169
|
* Renders every commitment section of one catalog chapter.
|
|
31048
31170
|
*
|
|
31049
31171
|
* @param commitmentGroups - Commitment groups to render, in final order.
|
|
31050
|
-
* @param commitmentUsageByType - Selected-agent occurrence counts by primary type.
|
|
31051
31172
|
* @param dictionary - Translated labels of the manual.
|
|
31052
31173
|
* @returns Markdown sections joined by blank lines.
|
|
31053
31174
|
*
|
|
31054
31175
|
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
31055
31176
|
*/
|
|
31056
|
-
function renderCommitmentCatalogSections(commitmentGroups,
|
|
31177
|
+
function renderCommitmentCatalogSections(commitmentGroups, dictionary) {
|
|
31057
31178
|
return commitmentGroups
|
|
31058
31179
|
.map((groupedCommitment) => renderCommitmentCatalogSection({
|
|
31059
31180
|
groupedCommitment,
|
|
31060
|
-
usageCount: commitmentUsageByType.get(groupedCommitment.primary.type) || 0,
|
|
31061
31181
|
dictionary,
|
|
31062
31182
|
}))
|
|
31063
31183
|
.join('\n\n');
|
|
@@ -31066,21 +31186,52 @@ function renderCommitmentCatalogSections(commitmentGroups, commitmentUsageByType
|
|
|
31066
31186
|
* Renders the closing chapter documenting low-level commitments.
|
|
31067
31187
|
*
|
|
31068
31188
|
* @param commitmentGroups - Low-level commitment groups, in final order.
|
|
31069
|
-
* @param commitmentUsageByType - Selected-agent occurrence counts by primary type.
|
|
31070
31189
|
* @param dictionary - Translated labels of the manual.
|
|
31071
31190
|
* @returns Markdown chapter for low-level commitments.
|
|
31072
31191
|
*
|
|
31073
31192
|
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
31074
31193
|
*/
|
|
31075
|
-
function renderLowLevelCommitmentsChapter(commitmentGroups,
|
|
31194
|
+
function renderLowLevelCommitmentsChapter(commitmentGroups, dictionary) {
|
|
31076
31195
|
return spaceTrim$1((block) => `
|
|
31077
31196
|
## <a id="low-level-commitments"></a>${dictionary.chapters.lowLevelCommitments.title}
|
|
31078
31197
|
|
|
31079
31198
|
${block(dictionary.chapters.lowLevelCommitments.body)}
|
|
31080
31199
|
|
|
31081
|
-
${block(renderCommitmentCatalogSections(commitmentGroups,
|
|
31200
|
+
${block(renderCommitmentCatalogSections(commitmentGroups, dictionary))}
|
|
31082
31201
|
`);
|
|
31083
31202
|
}
|
|
31203
|
+
/**
|
|
31204
|
+
* Renders links from the manual table of contents to the commitment sections.
|
|
31205
|
+
*
|
|
31206
|
+
* @param commitmentGroups - Commitment sections included in the manual.
|
|
31207
|
+
* @returns Indented markdown links ordered like the catalog.
|
|
31208
|
+
*
|
|
31209
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
31210
|
+
*/
|
|
31211
|
+
function renderCommitmentCatalogTableOfContents(commitmentGroups) {
|
|
31212
|
+
return commitmentGroups
|
|
31213
|
+
.map(({ primary }) => ` - [${primary.icon} \`${primary.type}\`](#commitment-${toStableAnchorId(primary.type)})`)
|
|
31214
|
+
.join('\n');
|
|
31215
|
+
}
|
|
31216
|
+
/**
|
|
31217
|
+
* Maps every recognized spelling of a documented commitment to its stable section anchor.
|
|
31218
|
+
*
|
|
31219
|
+
* @param commitmentGroups - Commitment sections included in the manual.
|
|
31220
|
+
* @returns Canonical anchor id by parsed commitment type.
|
|
31221
|
+
*
|
|
31222
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
31223
|
+
*/
|
|
31224
|
+
function createCommitmentSectionAnchorByType(commitmentGroups) {
|
|
31225
|
+
const anchorByType = new Map();
|
|
31226
|
+
for (const { primary, aliases } of commitmentGroups) {
|
|
31227
|
+
const anchorId = `commitment-${toStableAnchorId(primary.type)}`;
|
|
31228
|
+
anchorByType.set(primary.type, anchorId);
|
|
31229
|
+
for (const alias of aliases) {
|
|
31230
|
+
anchorByType.set(alias, anchorId);
|
|
31231
|
+
}
|
|
31232
|
+
}
|
|
31233
|
+
return anchorByType;
|
|
31234
|
+
}
|
|
31084
31235
|
/**
|
|
31085
31236
|
* Renders the "don't vs do" list of common authoring pitfalls.
|
|
31086
31237
|
*
|
|
@@ -31187,9 +31338,9 @@ function prioritizeGroupedCommitments(groupedCommitments, commitmentUsageByType)
|
|
|
31187
31338
|
*
|
|
31188
31339
|
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
31189
31340
|
*/
|
|
31190
|
-
function renderBakedAgentExampleSection(agent, dictionary) {
|
|
31341
|
+
function renderBakedAgentExampleSection(agent, dictionary, commitmentSectionAnchorByType) {
|
|
31191
31342
|
const usedCommitmentTypes = Array.from(new Set(parseAgentSourceWithCommitments(agent.agentSource).commitments.map((commitment) => commitment.type)));
|
|
31192
|
-
const usedCommitmentsMarkdown = usedCommitmentTypes
|
|
31343
|
+
const usedCommitmentsMarkdown = renderCommitmentSectionLinks(usedCommitmentTypes, commitmentSectionAnchorByType);
|
|
31193
31344
|
return spaceTrim$1((block) => `
|
|
31194
31345
|
### <a id="example-${toStableAnchorId(agent.agentName)}"></a>${agent.agentName}
|
|
31195
31346
|
|
|
@@ -31209,7 +31360,7 @@ function renderBakedAgentExampleSection(agent, dictionary) {
|
|
|
31209
31360
|
*
|
|
31210
31361
|
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
31211
31362
|
*/
|
|
31212
|
-
function renderExampleSection(example, dictionary) {
|
|
31363
|
+
function renderExampleSection(example, dictionary, commitmentSectionAnchorByType) {
|
|
31213
31364
|
const exampleText = dictionary.exampleTexts[example.id];
|
|
31214
31365
|
if (exampleText === undefined) {
|
|
31215
31366
|
return '';
|
|
@@ -31219,6 +31370,8 @@ function renderExampleSection(example, dictionary) {
|
|
|
31219
31370
|
|
|
31220
31371
|
**${dictionary.exampleLabels.goal}:** ${exampleText.goal}
|
|
31221
31372
|
|
|
31373
|
+
**${dictionary.exampleLabels.commitmentsUsed}:** ${renderCommitmentSectionLinks(parseAgentSourceWithCommitments(example.source).commitments.map((commitment) => commitment.type), commitmentSectionAnchorByType)}
|
|
31374
|
+
|
|
31222
31375
|
**${dictionary.exampleLabels.fullSource}**
|
|
31223
31376
|
|
|
31224
31377
|
${block(getSafeCodeBlock(example.source, 'book'))}
|
|
@@ -31228,6 +31381,23 @@ function renderExampleSection(example, dictionary) {
|
|
|
31228
31381
|
${block(exampleText.walkthrough.map((step, index) => `${index + 1}. ${step}`).join('\n'))}
|
|
31229
31382
|
`);
|
|
31230
31383
|
}
|
|
31384
|
+
/**
|
|
31385
|
+
* Renders unique commitment links used by an end-to-end example.
|
|
31386
|
+
*
|
|
31387
|
+
* @param commitmentTypes - Commitment types in their source order.
|
|
31388
|
+
* @param commitmentSectionAnchorByType - Documented commitment anchors by parsed type.
|
|
31389
|
+
* @returns Comma-separated markdown links, or an empty string when none are documented.
|
|
31390
|
+
*
|
|
31391
|
+
* @private internal utility of `createStandaloneBookLanguageMarkdown`
|
|
31392
|
+
*/
|
|
31393
|
+
function renderCommitmentSectionLinks(commitmentTypes, commitmentSectionAnchorByType) {
|
|
31394
|
+
return Array.from(new Set(commitmentTypes))
|
|
31395
|
+
.flatMap((type) => {
|
|
31396
|
+
const anchorId = commitmentSectionAnchorByType.get(type);
|
|
31397
|
+
return anchorId ? [`[\`${type}\`](#${anchorId})`] : [];
|
|
31398
|
+
})
|
|
31399
|
+
.join(', ');
|
|
31400
|
+
}
|
|
31231
31401
|
|
|
31232
31402
|
/**
|
|
31233
31403
|
* Generates an image for the agent to use as profile image
|
|
@@ -32207,17 +32377,6 @@ async function pipelineCollectionToJson(collection) {
|
|
|
32207
32377
|
}
|
|
32208
32378
|
// TODO: [🧠] Maybe clear `sourceFile` or clear when exposing through API or remote server
|
|
32209
32379
|
|
|
32210
|
-
/**
|
|
32211
|
-
* Gets all available commitment definitions
|
|
32212
|
-
*
|
|
32213
|
-
* @returns Array of all commitment definitions
|
|
32214
|
-
*
|
|
32215
|
-
* @public exported from `@promptbook/core`
|
|
32216
|
-
*/
|
|
32217
|
-
function getAllCommitmentDefinitions() {
|
|
32218
|
-
return $deepFreeze(sortCommitmentDefinitions(COMMITMENT_REGISTRY, { isUnfinishedLast: true, isLowLevelLast: true }));
|
|
32219
|
-
}
|
|
32220
|
-
|
|
32221
32380
|
/**
|
|
32222
32381
|
* Gets all tool titles provided by all commitments
|
|
32223
32382
|
*
|
|
@@ -32238,17 +32397,6 @@ function getAllCommitmentsToolTitles() {
|
|
|
32238
32397
|
return allToolTitles;
|
|
32239
32398
|
}
|
|
32240
32399
|
|
|
32241
|
-
/**
|
|
32242
|
-
* Gets all available commitment types
|
|
32243
|
-
*
|
|
32244
|
-
* @returns Array of all commitment types
|
|
32245
|
-
*
|
|
32246
|
-
* @public exported from `@promptbook/core`
|
|
32247
|
-
*/
|
|
32248
|
-
function getAllCommitmentTypes() {
|
|
32249
|
-
return $deepFreeze(getAllCommitmentDefinitions().map((commitmentDefinition) => commitmentDefinition.type));
|
|
32250
|
-
}
|
|
32251
|
-
|
|
32252
32400
|
/**
|
|
32253
32401
|
* Checks if a commitment type is supported
|
|
32254
32402
|
*
|
|
@@ -38276,6 +38424,41 @@ function buildToolInvocationScript(options) {
|
|
|
38276
38424
|
`;
|
|
38277
38425
|
}
|
|
38278
38426
|
|
|
38427
|
+
/**
|
|
38428
|
+
* Creates a loader which imports one module on the first call and reuses the very same module afterwards
|
|
38429
|
+
*
|
|
38430
|
+
* Note: [🐌] Heavy third-party dependencies are imported lazily to keep the startup of the Promptbook CLI fast.
|
|
38431
|
+
* A statically imported dependency is loaded every single time the bundle is loaded, even when the running
|
|
38432
|
+
* command never touches it. A lazily imported dependency is loaded only when the feature is really used.
|
|
38433
|
+
*
|
|
38434
|
+
* @example
|
|
38435
|
+
* const loadJsdomModule = createLazyModuleLoader(() => import('jsdom'));
|
|
38436
|
+
* const { JSDOM } = await loadJsdomModule();
|
|
38437
|
+
*
|
|
38438
|
+
* @private internal utility of Promptbook
|
|
38439
|
+
*/
|
|
38440
|
+
function createLazyModuleLoader(importModule) {
|
|
38441
|
+
let importedModulePromise = null;
|
|
38442
|
+
return function loadModule() {
|
|
38443
|
+
if (importedModulePromise === null) {
|
|
38444
|
+
importedModulePromise = importModule();
|
|
38445
|
+
}
|
|
38446
|
+
return importedModulePromise;
|
|
38447
|
+
};
|
|
38448
|
+
}
|
|
38449
|
+
// Note: [🐌] Do not convert the lazy `import(...)` calls back to static `import` statements, it would bring back the
|
|
38450
|
+
// slow startup of the `ptbk` CLI utility
|
|
38451
|
+
|
|
38452
|
+
/**
|
|
38453
|
+
* Loads the OpenAI AgentKit SDK (`@openai/agents`) on demand
|
|
38454
|
+
*
|
|
38455
|
+
* Note: [🐌] The AgentKit SDK is one of the heaviest dependencies of Promptbook, loading it eagerly would slow down
|
|
38456
|
+
* every single run of the `ptbk` CLI utility even when no AgentKit agent is used
|
|
38457
|
+
*
|
|
38458
|
+
* @private internal utility of `@promptbook/openai`
|
|
38459
|
+
*/
|
|
38460
|
+
const loadOpenAiAgentsModule = createLazyModuleLoader(() => import('@openai/agents'));
|
|
38461
|
+
|
|
38279
38462
|
/**
|
|
38280
38463
|
* Constant for default model used for nested DeepSearch tool invocations.
|
|
38281
38464
|
*/
|
|
@@ -38329,8 +38512,9 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
|
|
|
38329
38512
|
/**
|
|
38330
38513
|
* Builds the tool list for AgentKit, including hosted file search when applicable.
|
|
38331
38514
|
*/
|
|
38332
|
-
buildAgentKitTools(options) {
|
|
38515
|
+
async buildAgentKitTools(options) {
|
|
38333
38516
|
const { tools, vectorStoreId } = options;
|
|
38517
|
+
const { fileSearchTool, tool: agentKitTool } = await loadOpenAiAgentsModule();
|
|
38334
38518
|
const agentKitTools = [];
|
|
38335
38519
|
if (vectorStoreId) {
|
|
38336
38520
|
agentKitTools.push(fileSearchTool(vectorStoreId));
|
|
@@ -38341,11 +38525,11 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
|
|
|
38341
38525
|
let scriptTools = null;
|
|
38342
38526
|
for (const toolDefinition of tools) {
|
|
38343
38527
|
if (this.isDeepSearchToolDefinition(toolDefinition)) {
|
|
38344
|
-
agentKitTools.push(this.createDeepSearchAgentKitTool(toolDefinition));
|
|
38528
|
+
agentKitTools.push(await this.createDeepSearchAgentKitTool(toolDefinition));
|
|
38345
38529
|
continue;
|
|
38346
38530
|
}
|
|
38347
38531
|
scriptTools !== null && scriptTools !== void 0 ? scriptTools : (scriptTools = this.resolveScriptTools());
|
|
38348
|
-
agentKitTools.push(
|
|
38532
|
+
agentKitTools.push(agentKitTool({
|
|
38349
38533
|
name: toolDefinition.name,
|
|
38350
38534
|
description: toolDefinition.description,
|
|
38351
38535
|
parameters: this.normalizeAgentKitToolParameters(toolDefinition.parameters),
|
|
@@ -38552,8 +38736,9 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
|
|
|
38552
38736
|
/**
|
|
38553
38737
|
* Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
|
|
38554
38738
|
*/
|
|
38555
|
-
createDeepSearchAgentKitTool(toolDefinition) {
|
|
38556
|
-
const
|
|
38739
|
+
async createDeepSearchAgentKitTool(toolDefinition) {
|
|
38740
|
+
const { Agent: AgentFromKit, webSearchTool } = await loadOpenAiAgentsModule();
|
|
38741
|
+
const deepSearchAgent = new AgentFromKit({
|
|
38557
38742
|
name: 'DeepSearch',
|
|
38558
38743
|
model: DEFAULT_DEEP_SEARCH_MODEL_NAME,
|
|
38559
38744
|
instructions: this.createDeepSearchAgentInstructions(toolDefinition.description),
|
|
@@ -39879,6 +40064,14 @@ class OpenAiCompatibleNonChatPromptCaller {
|
|
|
39879
40064
|
}
|
|
39880
40065
|
}
|
|
39881
40066
|
|
|
40067
|
+
/**
|
|
40068
|
+
* Loads the OpenAI SDK (`openai`) on demand
|
|
40069
|
+
*
|
|
40070
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
40071
|
+
*
|
|
40072
|
+
* @private internal utility of `OpenAiCompatibleRequestManager`
|
|
40073
|
+
*/
|
|
40074
|
+
const loadOpenAiModule = createLazyModuleLoader(() => import('openai'));
|
|
39882
40075
|
/**
|
|
39883
40076
|
* Manages OpenAI-compatible client creation plus shared retry and rate-limit behavior.
|
|
39884
40077
|
*
|
|
@@ -39905,6 +40098,7 @@ class OpenAiCompatibleRequestManager {
|
|
|
39905
40098
|
timeout: API_REQUEST_TIMEOUT,
|
|
39906
40099
|
maxRetries: CONNECTION_RETRIES_LIMIT,
|
|
39907
40100
|
};
|
|
40101
|
+
const { default: OpenAI } = await loadOpenAiModule();
|
|
39908
40102
|
this.client = new OpenAI(enhancedOptions);
|
|
39909
40103
|
}
|
|
39910
40104
|
return this.client;
|
|
@@ -42052,8 +42246,9 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
42052
42246
|
vectorStoreId,
|
|
42053
42247
|
});
|
|
42054
42248
|
}
|
|
42055
|
-
const
|
|
42056
|
-
const
|
|
42249
|
+
const { Agent: AgentFromKit } = await loadOpenAiAgentsModule();
|
|
42250
|
+
const agentKitTools = await this.buildAgentKitTools({ tools, vectorStoreId });
|
|
42251
|
+
const openAiAgentKitAgent = new AgentFromKit({
|
|
42057
42252
|
name,
|
|
42058
42253
|
model: this.agentKitModelName,
|
|
42059
42254
|
instructions: instructions || 'You are a helpful assistant.',
|
|
@@ -42098,6 +42293,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
42098
42293
|
agentName: agentForRun.name,
|
|
42099
42294
|
input: inputItems,
|
|
42100
42295
|
};
|
|
42296
|
+
const { run } = await loadOpenAiAgentsModule();
|
|
42101
42297
|
const streamResult = await run(agentForRun, inputItems, {
|
|
42102
42298
|
stream: true,
|
|
42103
42299
|
maxTurns: 200,
|
|
@@ -42240,6 +42436,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
42240
42436
|
* Ensures the AgentKit SDK is wired to the OpenAI client and API key.
|
|
42241
42437
|
*/
|
|
42242
42438
|
async ensureAgentKitDefaults() {
|
|
42439
|
+
const { setDefaultOpenAIClient, setDefaultOpenAIKey } = await loadOpenAiAgentsModule();
|
|
42243
42440
|
const client = await this.getClient();
|
|
42244
42441
|
setDefaultOpenAIClient(client);
|
|
42245
42442
|
const apiKey = this.agentKitOptions.apiKey;
|