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