@promptbook/node 0.112.0-58 → 0.112.0-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +281 -248
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-components/BookEditor/useBookEditorMonacoInteractions.d.ts +40 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +34 -0
- package/esm/src/commitments/_base/BaseCommitmentDefinition.d.ts +26 -0
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +2 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +281 -248
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-components/BookEditor/useBookEditorMonacoInteractions.d.ts +40 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +34 -0
- package/umd/src/commitments/_base/BaseCommitmentDefinition.d.ts +26 -0
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +2 -0
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -35,7 +35,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
35
35
|
* @generated
|
|
36
36
|
* @see https://github.com/webgptorg/promptbook
|
|
37
37
|
*/
|
|
38
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
38
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-60';
|
|
39
39
|
/**
|
|
40
40
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
41
41
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -14499,6 +14499,49 @@ class BaseCommitmentDefinition {
|
|
|
14499
14499
|
return this.appendToSystemMessage(requirements, commentSection);
|
|
14500
14500
|
}
|
|
14501
14501
|
}
|
|
14502
|
+
/**
|
|
14503
|
+
* Helper method to append a bullet point to an existing `## SectionTitle` section in the system
|
|
14504
|
+
* message, or to create a new section when it does not yet exist.
|
|
14505
|
+
*
|
|
14506
|
+
* Handles the case where the same commitment type appears multiple times in the book source and
|
|
14507
|
+
* all entries should be grouped under one shared heading rather than emitting a duplicate block.
|
|
14508
|
+
*
|
|
14509
|
+
* @param requirements - Current model requirements.
|
|
14510
|
+
* @param sectionTitle - Section title without the `##` prefix.
|
|
14511
|
+
* @param bulletContent - Bullet content without the leading `- ` prefix.
|
|
14512
|
+
* @returns Requirements with the bullet appended to the section.
|
|
14513
|
+
*/
|
|
14514
|
+
appendBulletPointToSection(requirements, sectionTitle, bulletContent) {
|
|
14515
|
+
const sectionHeader = `## ${sectionTitle}`;
|
|
14516
|
+
const bullet = `- ${bulletContent}`;
|
|
14517
|
+
if (requirements.systemMessage.includes(sectionHeader)) {
|
|
14518
|
+
// Append bullet to end of existing section, before the next h2 heading or end of message
|
|
14519
|
+
const newSystemMessage = requirements.systemMessage.replace(new RegExp(`(## ${sectionTitle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\n\\n)([\\s\\S]*?)(?=\\n\\n##|$)`), `$1$2\n${bullet}`);
|
|
14520
|
+
return { ...requirements, systemMessage: newSystemMessage };
|
|
14521
|
+
}
|
|
14522
|
+
return this.appendToSystemMessage(requirements, `${sectionHeader}\n\n${bullet}`, '\n\n');
|
|
14523
|
+
}
|
|
14524
|
+
/**
|
|
14525
|
+
* Helper method to replace an existing `## SectionTitle` section in the system message, or to
|
|
14526
|
+
* append a new one when the section does not yet exist.
|
|
14527
|
+
*
|
|
14528
|
+
* Use this when a commitment type can appear multiple times and each subsequent occurrence should
|
|
14529
|
+
* update the single shared section rather than appending a duplicate block.
|
|
14530
|
+
*
|
|
14531
|
+
* @param requirements - Current model requirements.
|
|
14532
|
+
* @param sectionTitle - Section title without the `##` prefix.
|
|
14533
|
+
* @param sectionContent - Full section content including the `## Title` header line.
|
|
14534
|
+
* @returns Requirements with the section replaced or appended.
|
|
14535
|
+
*/
|
|
14536
|
+
replaceOrCreateSection(requirements, sectionTitle, sectionContent) {
|
|
14537
|
+
const sectionHeader = `## ${sectionTitle}`;
|
|
14538
|
+
if (requirements.systemMessage.includes(sectionHeader)) {
|
|
14539
|
+
// Replace all text from the heading until the next h2 heading or end of message
|
|
14540
|
+
const newSystemMessage = requirements.systemMessage.replace(new RegExp(`## ${sectionTitle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), sectionContent);
|
|
14541
|
+
return { ...requirements, systemMessage: newSystemMessage };
|
|
14542
|
+
}
|
|
14543
|
+
return this.appendToSystemMessage(requirements, sectionContent, '\n\n');
|
|
14544
|
+
}
|
|
14502
14545
|
/**
|
|
14503
14546
|
* Gets tool function implementations provided by this commitment
|
|
14504
14547
|
*
|
|
@@ -14960,20 +15003,16 @@ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14960
15003
|
if (!trimmedContent) {
|
|
14961
15004
|
return requirements;
|
|
14962
15005
|
}
|
|
14963
|
-
//
|
|
15006
|
+
// Store the entry in metadata for debugging and inspection
|
|
14964
15007
|
const existingDictionary = ((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
|
|
14965
|
-
// Merge the new dictionary entry with existing entries
|
|
14966
15008
|
const mergedDictionary = existingDictionary ? `${existingDictionary}\n${trimmedContent}` : trimmedContent;
|
|
14967
|
-
// Store the merged dictionary in metadata for debugging and inspection
|
|
14968
15009
|
const updatedMetadata = {
|
|
14969
15010
|
...requirements._metadata,
|
|
14970
15011
|
DICTIONARY: mergedDictionary,
|
|
14971
15012
|
};
|
|
14972
|
-
//
|
|
14973
|
-
// Format: "# DICTIONARY\nTerm: definition\nTerm: definition..."
|
|
14974
|
-
const dictionarySection = `# DICTIONARY\n${mergedDictionary}`;
|
|
15013
|
+
// Append each dictionary entry as a bullet point under ## Dictionary
|
|
14975
15014
|
return {
|
|
14976
|
-
...this.
|
|
15015
|
+
...this.appendBulletPointToSection(requirements, 'Dictionary', trimmedContent),
|
|
14977
15016
|
_metadata: updatedMetadata,
|
|
14978
15017
|
};
|
|
14979
15018
|
}
|
|
@@ -15476,10 +15515,10 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15476
15515
|
if (!trimmedContent) {
|
|
15477
15516
|
return requirements;
|
|
15478
15517
|
}
|
|
15479
|
-
// Add goal to the system message
|
|
15480
|
-
const goalSection =
|
|
15518
|
+
// Add goal as a proper h2 section to the system message
|
|
15519
|
+
const goalSection = `## Goal\n\n${trimmedContent}`;
|
|
15481
15520
|
const requirementsWithGoal = this.appendToSystemMessage(requirements, goalSection, '\n\n');
|
|
15482
|
-
return this.appendToPromptSuffix(requirementsWithGoal,
|
|
15521
|
+
return this.appendToPromptSuffix(requirementsWithGoal, trimmedContent);
|
|
15483
15522
|
}
|
|
15484
15523
|
}
|
|
15485
15524
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -15999,11 +16038,8 @@ class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15999
16038
|
if (!trimmedContent) {
|
|
16000
16039
|
return requirements;
|
|
16001
16040
|
}
|
|
16002
|
-
// Add language
|
|
16003
|
-
const languageSection =
|
|
16004
|
-
${block(trimmedContent)}
|
|
16005
|
-
<- You are speaking these languages in your responses to the user.
|
|
16006
|
-
`));
|
|
16041
|
+
// Add language as a bullet under a ## Language section
|
|
16042
|
+
const languageSection = `## Language\n\n- Your language is ${trimmedContent}`;
|
|
16007
16043
|
return this.appendToSystemMessage(requirements, languageSection, '\n\n');
|
|
16008
16044
|
}
|
|
16009
16045
|
}
|
|
@@ -16047,15 +16083,16 @@ const MemoryToolNames = {
|
|
|
16047
16083
|
*/
|
|
16048
16084
|
function createMemorySystemMessage(extraInstructions) {
|
|
16049
16085
|
return spaceTrim$1((block) => `
|
|
16050
|
-
Memory
|
|
16051
|
-
|
|
16052
|
-
-
|
|
16053
|
-
-
|
|
16054
|
-
-
|
|
16055
|
-
-
|
|
16056
|
-
-
|
|
16057
|
-
-
|
|
16058
|
-
-
|
|
16086
|
+
## Memory
|
|
16087
|
+
|
|
16088
|
+
- Prefer storing agent-scoped memories; only make them global when the fact should apply across all your agents.
|
|
16089
|
+
- You can use persistent user memory tools.
|
|
16090
|
+
- Use \`${MemoryToolNames.retrieve}\` to load relevant memory before answering.
|
|
16091
|
+
- Use \`${MemoryToolNames.store}\` to save stable user-specific facts that improve future help.
|
|
16092
|
+
- Use \`${MemoryToolNames.update}\` to refresh an existing memory when the content changes.
|
|
16093
|
+
- Use \`${MemoryToolNames.delete}\` to delete memories that are no longer accurate (deletions are soft and hidden from future queries).
|
|
16094
|
+
- Store concise memory items and avoid duplicates.
|
|
16095
|
+
- Never claim memory was saved or loaded unless the tool confirms it.
|
|
16059
16096
|
${block(extraInstructions)}
|
|
16060
16097
|
`);
|
|
16061
16098
|
}
|
|
@@ -16977,10 +17014,8 @@ class MessageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
16977
17014
|
if (!trimmedContent) {
|
|
16978
17015
|
return requirements;
|
|
16979
17016
|
}
|
|
16980
|
-
// Create message section for system message
|
|
16981
|
-
const messageSection = `Previous Message: ${trimmedContent}`;
|
|
16982
17017
|
// Messages represent conversation history and should be included for context
|
|
16983
|
-
return this.
|
|
17018
|
+
return this.appendBulletPointToSection(requirements, 'Previous messages', trimmedContent);
|
|
16984
17019
|
}
|
|
16985
17020
|
}
|
|
16986
17021
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -21774,10 +21809,9 @@ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21774
21809
|
if (!trimmedContent) {
|
|
21775
21810
|
return requirements;
|
|
21776
21811
|
}
|
|
21777
|
-
//
|
|
21778
|
-
const
|
|
21779
|
-
|
|
21780
|
-
return this.appendToPromptSuffix(requirementsWithRule, ruleSection);
|
|
21812
|
+
// Group all rules under a single ## Rules section as bullet points
|
|
21813
|
+
const requirementsWithRule = this.appendBulletPointToSection(requirements, 'Rules', trimmedContent);
|
|
21814
|
+
return this.appendToPromptSuffix(requirementsWithRule, `- ${trimmedContent}`);
|
|
21781
21815
|
}
|
|
21782
21816
|
}
|
|
21783
21817
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -22013,10 +22047,8 @@ class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
22013
22047
|
if (!trimmedContent) {
|
|
22014
22048
|
return requirements;
|
|
22015
22049
|
}
|
|
22016
|
-
// Create scenario section for system message
|
|
22017
|
-
const scenarioSection = `Scenario: ${trimmedContent}`;
|
|
22018
22050
|
// Scenarios provide important contextual information that affects behavior
|
|
22019
|
-
return this.
|
|
22051
|
+
return this.appendBulletPointToSection(requirements, 'Scenarios', trimmedContent);
|
|
22020
22052
|
}
|
|
22021
22053
|
}
|
|
22022
22054
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -22399,8 +22431,8 @@ const teamToolTitles = {};
|
|
|
22399
22431
|
* @private
|
|
22400
22432
|
*/
|
|
22401
22433
|
const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
|
|
22402
|
-
'-
|
|
22403
|
-
'-
|
|
22434
|
+
'- If a teammate is relevant to the request, consult that teammate using the matching tool.',
|
|
22435
|
+
'- Do not ask the user for information that a listed teammate can provide directly.',
|
|
22404
22436
|
];
|
|
22405
22437
|
/**
|
|
22406
22438
|
* Constant for remote agents by Url.
|
|
@@ -22528,7 +22560,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
22528
22560
|
toolName: entry.toolName,
|
|
22529
22561
|
});
|
|
22530
22562
|
}
|
|
22531
|
-
const teamSystemMessage = this.createSystemMessageSection('Teammates
|
|
22563
|
+
const teamSystemMessage = this.createSystemMessageSection('Teammates', buildTeamSystemMessageBody(teamEntries));
|
|
22532
22564
|
return this.appendToSystemMessage({
|
|
22533
22565
|
...requirements,
|
|
22534
22566
|
tools: updatedTools,
|
|
@@ -23018,36 +23050,38 @@ function createAggregatedUseCommitmentSystemMessage(type, additionalInstructions
|
|
|
23018
23050
|
switch (type) {
|
|
23019
23051
|
case 'USE TIME':
|
|
23020
23052
|
return spaceTrim$1((block) => `
|
|
23021
|
-
Time and date context
|
|
23022
|
-
|
|
23023
|
-
-
|
|
23053
|
+
## Time and date context
|
|
23054
|
+
|
|
23055
|
+
- It is ${moment().format('MMMM YYYY')} now.
|
|
23056
|
+
- If you need more precise current time information, use the tool \`get_current_time\`.
|
|
23024
23057
|
${block(formatOptionalInstructionBlock('Time instructions', combinedAdditionalInstructions))}
|
|
23025
23058
|
`);
|
|
23026
23059
|
case 'USE BROWSER':
|
|
23027
23060
|
return spaceTrim$1((block) => `
|
|
23028
|
-
|
|
23029
|
-
|
|
23030
|
-
-
|
|
23031
|
-
|
|
23061
|
+
## Browser
|
|
23062
|
+
|
|
23063
|
+
- Use \`fetch_url_content\` to retrieve content from specific URLs (webpages or documents) using scrapers.
|
|
23064
|
+
- Use \`run_browser\` for real interactive browser automation (navigation, clicks, typing, waiting, scrolling).
|
|
23065
|
+
- When you need to know information from a specific website or document, use the tools provided.
|
|
23032
23066
|
${block(formatOptionalInstructionBlock('Browser instructions', combinedAdditionalInstructions))}
|
|
23033
23067
|
`);
|
|
23034
23068
|
case 'USE SEARCH ENGINE':
|
|
23035
23069
|
return spaceTrim$1((block) => `
|
|
23036
|
-
|
|
23037
|
-
|
|
23038
|
-
-
|
|
23039
|
-
-
|
|
23040
|
-
-
|
|
23041
|
-
-
|
|
23070
|
+
## Web Search
|
|
23071
|
+
|
|
23072
|
+
- Use \`web_search\` to find up-to-date information or facts.
|
|
23073
|
+
- When you need to know some information from the internet, use the search tool provided.
|
|
23074
|
+
- Do not make up information when you can search for it.
|
|
23075
|
+
- Do not tell the user you cannot search for information, YOU CAN.
|
|
23042
23076
|
${block(formatOptionalInstructionBlock('Search instructions', combinedAdditionalInstructions))}
|
|
23043
23077
|
`);
|
|
23044
23078
|
case 'USE DEEPSEARCH':
|
|
23045
23079
|
return spaceTrim$1((block) => `
|
|
23046
|
-
|
|
23047
|
-
|
|
23048
|
-
-
|
|
23049
|
-
-
|
|
23050
|
-
-
|
|
23080
|
+
## Deep Research
|
|
23081
|
+
|
|
23082
|
+
- Use \`deep_search\` for broader research tasks that need multi-step investigation, comparison, or synthesis across multiple sources.
|
|
23083
|
+
- Prefer it over quick search when the user asks for a well-grounded brief, report, or deeper investigation.
|
|
23084
|
+
- Do not pretend you cannot research current information when this tool is available.
|
|
23051
23085
|
${block(formatOptionalInstructionBlock('DeepSearch instructions', combinedAdditionalInstructions))}
|
|
23052
23086
|
`);
|
|
23053
23087
|
}
|
|
@@ -23377,96 +23411,6 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
23377
23411
|
}
|
|
23378
23412
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23379
23413
|
|
|
23380
|
-
/**
|
|
23381
|
-
* Base Google Calendar API URL.
|
|
23382
|
-
*
|
|
23383
|
-
* @private constant of callGoogleCalendarApi
|
|
23384
|
-
*/
|
|
23385
|
-
const GOOGLE_CALENDAR_API_BASE_URL = 'https://www.googleapis.com/calendar/v3';
|
|
23386
|
-
/**
|
|
23387
|
-
* Runs one Google Calendar API request and parses JSON response payload.
|
|
23388
|
-
*
|
|
23389
|
-
* @private function of UseCalendarCommitmentDefinition
|
|
23390
|
-
*/
|
|
23391
|
-
async function callGoogleCalendarApi(accessToken, options) {
|
|
23392
|
-
const url = new URL(options.path, GOOGLE_CALENDAR_API_BASE_URL);
|
|
23393
|
-
if (options.query) {
|
|
23394
|
-
for (const [key, value] of Object.entries(options.query)) {
|
|
23395
|
-
if (value && value.trim()) {
|
|
23396
|
-
url.searchParams.set(key, value);
|
|
23397
|
-
}
|
|
23398
|
-
}
|
|
23399
|
-
}
|
|
23400
|
-
const response = await fetch(url.toString(), {
|
|
23401
|
-
method: options.method,
|
|
23402
|
-
headers: {
|
|
23403
|
-
Authorization: `Bearer ${accessToken}`,
|
|
23404
|
-
Accept: 'application/json',
|
|
23405
|
-
'Content-Type': 'application/json',
|
|
23406
|
-
},
|
|
23407
|
-
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
23408
|
-
});
|
|
23409
|
-
const textPayload = await response.text();
|
|
23410
|
-
const parsedPayload = tryParseJson$2(textPayload);
|
|
23411
|
-
if (options.allowNotFound && response.status === 404) {
|
|
23412
|
-
return null;
|
|
23413
|
-
}
|
|
23414
|
-
if (!response.ok) {
|
|
23415
|
-
throw new Error(spaceTrim$1(`
|
|
23416
|
-
Google Calendar API request failed (${response.status} ${response.statusText}):
|
|
23417
|
-
${extractGoogleCalendarApiErrorMessage(parsedPayload, textPayload)}
|
|
23418
|
-
`));
|
|
23419
|
-
}
|
|
23420
|
-
return parsedPayload;
|
|
23421
|
-
}
|
|
23422
|
-
/**
|
|
23423
|
-
* Parses raw text into JSON when possible.
|
|
23424
|
-
*
|
|
23425
|
-
* @private function of callGoogleCalendarApi
|
|
23426
|
-
*/
|
|
23427
|
-
function tryParseJson$2(rawText) {
|
|
23428
|
-
if (!rawText.trim()) {
|
|
23429
|
-
return {};
|
|
23430
|
-
}
|
|
23431
|
-
try {
|
|
23432
|
-
return JSON.parse(rawText);
|
|
23433
|
-
}
|
|
23434
|
-
catch (_a) {
|
|
23435
|
-
return rawText;
|
|
23436
|
-
}
|
|
23437
|
-
}
|
|
23438
|
-
/**
|
|
23439
|
-
* Extracts a user-friendly Google Calendar API error message.
|
|
23440
|
-
*
|
|
23441
|
-
* @private function of callGoogleCalendarApi
|
|
23442
|
-
*/
|
|
23443
|
-
function extractGoogleCalendarApiErrorMessage(parsedPayload, fallbackText) {
|
|
23444
|
-
if (parsedPayload && typeof parsedPayload === 'object') {
|
|
23445
|
-
const payload = parsedPayload;
|
|
23446
|
-
const errorPayload = payload.error;
|
|
23447
|
-
if (errorPayload && typeof errorPayload === 'object') {
|
|
23448
|
-
const normalizedErrorPayload = errorPayload;
|
|
23449
|
-
const message = typeof normalizedErrorPayload.message === 'string' ? normalizedErrorPayload.message : '';
|
|
23450
|
-
const errors = Array.isArray(normalizedErrorPayload.errors) ? normalizedErrorPayload.errors : [];
|
|
23451
|
-
const flattenedErrors = errors
|
|
23452
|
-
.map((errorEntry) => {
|
|
23453
|
-
if (!errorEntry || typeof errorEntry !== 'object') {
|
|
23454
|
-
return '';
|
|
23455
|
-
}
|
|
23456
|
-
const normalizedErrorEntry = errorEntry;
|
|
23457
|
-
const detailMessage = typeof normalizedErrorEntry.message === 'string' ? normalizedErrorEntry.message : '';
|
|
23458
|
-
const reason = typeof normalizedErrorEntry.reason === 'string' ? normalizedErrorEntry.reason : '';
|
|
23459
|
-
return [detailMessage, reason].filter(Boolean).join(' | ');
|
|
23460
|
-
})
|
|
23461
|
-
.filter(Boolean);
|
|
23462
|
-
if (message || flattenedErrors.length > 0) {
|
|
23463
|
-
return [message, ...flattenedErrors].filter(Boolean).join(' | ');
|
|
23464
|
-
}
|
|
23465
|
-
}
|
|
23466
|
-
}
|
|
23467
|
-
return fallbackText || 'Unknown Google Calendar API error';
|
|
23468
|
-
}
|
|
23469
|
-
|
|
23470
23414
|
/**
|
|
23471
23415
|
* Hostnames accepted for Google Calendar references.
|
|
23472
23416
|
*
|
|
@@ -23648,6 +23592,96 @@ function removeTokenFromLine(line, token) {
|
|
|
23648
23592
|
}
|
|
23649
23593
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23650
23594
|
|
|
23595
|
+
/**
|
|
23596
|
+
* Base Google Calendar API URL.
|
|
23597
|
+
*
|
|
23598
|
+
* @private constant of callGoogleCalendarApi
|
|
23599
|
+
*/
|
|
23600
|
+
const GOOGLE_CALENDAR_API_BASE_URL = 'https://www.googleapis.com/calendar/v3';
|
|
23601
|
+
/**
|
|
23602
|
+
* Runs one Google Calendar API request and parses JSON response payload.
|
|
23603
|
+
*
|
|
23604
|
+
* @private function of UseCalendarCommitmentDefinition
|
|
23605
|
+
*/
|
|
23606
|
+
async function callGoogleCalendarApi(accessToken, options) {
|
|
23607
|
+
const url = new URL(options.path, GOOGLE_CALENDAR_API_BASE_URL);
|
|
23608
|
+
if (options.query) {
|
|
23609
|
+
for (const [key, value] of Object.entries(options.query)) {
|
|
23610
|
+
if (value && value.trim()) {
|
|
23611
|
+
url.searchParams.set(key, value);
|
|
23612
|
+
}
|
|
23613
|
+
}
|
|
23614
|
+
}
|
|
23615
|
+
const response = await fetch(url.toString(), {
|
|
23616
|
+
method: options.method,
|
|
23617
|
+
headers: {
|
|
23618
|
+
Authorization: `Bearer ${accessToken}`,
|
|
23619
|
+
Accept: 'application/json',
|
|
23620
|
+
'Content-Type': 'application/json',
|
|
23621
|
+
},
|
|
23622
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
23623
|
+
});
|
|
23624
|
+
const textPayload = await response.text();
|
|
23625
|
+
const parsedPayload = tryParseJson$2(textPayload);
|
|
23626
|
+
if (options.allowNotFound && response.status === 404) {
|
|
23627
|
+
return null;
|
|
23628
|
+
}
|
|
23629
|
+
if (!response.ok) {
|
|
23630
|
+
throw new Error(spaceTrim$1(`
|
|
23631
|
+
Google Calendar API request failed (${response.status} ${response.statusText}):
|
|
23632
|
+
${extractGoogleCalendarApiErrorMessage(parsedPayload, textPayload)}
|
|
23633
|
+
`));
|
|
23634
|
+
}
|
|
23635
|
+
return parsedPayload;
|
|
23636
|
+
}
|
|
23637
|
+
/**
|
|
23638
|
+
* Parses raw text into JSON when possible.
|
|
23639
|
+
*
|
|
23640
|
+
* @private function of callGoogleCalendarApi
|
|
23641
|
+
*/
|
|
23642
|
+
function tryParseJson$2(rawText) {
|
|
23643
|
+
if (!rawText.trim()) {
|
|
23644
|
+
return {};
|
|
23645
|
+
}
|
|
23646
|
+
try {
|
|
23647
|
+
return JSON.parse(rawText);
|
|
23648
|
+
}
|
|
23649
|
+
catch (_a) {
|
|
23650
|
+
return rawText;
|
|
23651
|
+
}
|
|
23652
|
+
}
|
|
23653
|
+
/**
|
|
23654
|
+
* Extracts a user-friendly Google Calendar API error message.
|
|
23655
|
+
*
|
|
23656
|
+
* @private function of callGoogleCalendarApi
|
|
23657
|
+
*/
|
|
23658
|
+
function extractGoogleCalendarApiErrorMessage(parsedPayload, fallbackText) {
|
|
23659
|
+
if (parsedPayload && typeof parsedPayload === 'object') {
|
|
23660
|
+
const payload = parsedPayload;
|
|
23661
|
+
const errorPayload = payload.error;
|
|
23662
|
+
if (errorPayload && typeof errorPayload === 'object') {
|
|
23663
|
+
const normalizedErrorPayload = errorPayload;
|
|
23664
|
+
const message = typeof normalizedErrorPayload.message === 'string' ? normalizedErrorPayload.message : '';
|
|
23665
|
+
const errors = Array.isArray(normalizedErrorPayload.errors) ? normalizedErrorPayload.errors : [];
|
|
23666
|
+
const flattenedErrors = errors
|
|
23667
|
+
.map((errorEntry) => {
|
|
23668
|
+
if (!errorEntry || typeof errorEntry !== 'object') {
|
|
23669
|
+
return '';
|
|
23670
|
+
}
|
|
23671
|
+
const normalizedErrorEntry = errorEntry;
|
|
23672
|
+
const detailMessage = typeof normalizedErrorEntry.message === 'string' ? normalizedErrorEntry.message : '';
|
|
23673
|
+
const reason = typeof normalizedErrorEntry.reason === 'string' ? normalizedErrorEntry.reason : '';
|
|
23674
|
+
return [detailMessage, reason].filter(Boolean).join(' | ');
|
|
23675
|
+
})
|
|
23676
|
+
.filter(Boolean);
|
|
23677
|
+
if (message || flattenedErrors.length > 0) {
|
|
23678
|
+
return [message, ...flattenedErrors].filter(Boolean).join(' | ');
|
|
23679
|
+
}
|
|
23680
|
+
}
|
|
23681
|
+
}
|
|
23682
|
+
return fallbackText || 'Unknown Google Calendar API error';
|
|
23683
|
+
}
|
|
23684
|
+
|
|
23651
23685
|
/**
|
|
23652
23686
|
* Wallet metadata used by USE CALENDAR when resolving Google Calendar credentials.
|
|
23653
23687
|
*
|
|
@@ -24548,18 +24582,20 @@ class UseCalendarCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
24548
24582
|
if (parsedCommitment.calendar) {
|
|
24549
24583
|
addConfiguredCalendarIfMissing(existingConfiguredCalendars, parsedCommitment.calendar);
|
|
24550
24584
|
}
|
|
24551
|
-
const
|
|
24552
|
-
? existingConfiguredCalendars
|
|
24553
|
-
|
|
24554
|
-
`- ${calendar.provider}: ${calendar.url}`,
|
|
24555
|
-
calendar.scopes.length > 0 ? ` scopes: ${calendar.scopes.join(', ')}` : '',
|
|
24556
|
-
]
|
|
24557
|
-
.filter(Boolean)
|
|
24558
|
-
.join('\n'))
|
|
24559
|
-
.join('\n')
|
|
24560
|
-
: '- Calendar is resolved from runtime context';
|
|
24585
|
+
const calendarBullets = existingConfiguredCalendars.length > 0
|
|
24586
|
+
? existingConfiguredCalendars.map((calendar) => `- ${calendar.provider}: ${calendar.url}`).join('\n')
|
|
24587
|
+
: '- Calendar is resolved from runtime context';
|
|
24561
24588
|
const extraInstructions = formatOptionalInstructionBlock('Calendar instructions', parsedCommitment.instructions);
|
|
24562
|
-
|
|
24589
|
+
const calendarSectionContent = spaceTrim$1((block) => `
|
|
24590
|
+
## Calendar
|
|
24591
|
+
|
|
24592
|
+
- Use \`calendar_list_events\`, \`calendar_get_event\`, \`calendar_create_event\`, \`calendar_update_event\`, \`calendar_delete_event\`, and \`calendar_invite_guests\` to manage events in configured calendars.
|
|
24593
|
+
- Supported operations include read, create, update, delete, invite guests, and reminders.
|
|
24594
|
+
- Configured calendars:
|
|
24595
|
+
${block(calendarBullets)}
|
|
24596
|
+
${block(extraInstructions)}
|
|
24597
|
+
`);
|
|
24598
|
+
return this.replaceOrCreateSection({
|
|
24563
24599
|
...requirements,
|
|
24564
24600
|
tools: createUseCalendarTools(requirements.tools || []),
|
|
24565
24601
|
_metadata: {
|
|
@@ -24567,16 +24603,7 @@ class UseCalendarCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
24567
24603
|
useCalendar: true,
|
|
24568
24604
|
useCalendars: existingConfiguredCalendars,
|
|
24569
24605
|
},
|
|
24570
|
-
},
|
|
24571
|
-
Calendar tools:
|
|
24572
|
-
- You can inspect and manage events in configured calendars.
|
|
24573
|
-
- Supported operations include read, create, update, delete, invite guests, and reminders.
|
|
24574
|
-
- Configured calendars:
|
|
24575
|
-
${block(calendarsList)}
|
|
24576
|
-
- USE CALENDAR credentials are read from wallet records (ACCESS_TOKEN, service "${UseCalendarWallet.service}", key "${UseCalendarWallet.key}").
|
|
24577
|
-
- If credentials are missing, ask user to connect calendar credentials in host UI and/or add them to wallet.
|
|
24578
|
-
${block(extraInstructions)}
|
|
24579
|
-
`));
|
|
24606
|
+
}, 'Calendar', calendarSectionContent);
|
|
24580
24607
|
}
|
|
24581
24608
|
/**
|
|
24582
24609
|
* Gets human-readable titles for tool functions provided by this commitment.
|
|
@@ -24913,18 +24940,6 @@ async function sendEmailViaBrowser(args, agentsServerUrl) {
|
|
|
24913
24940
|
* @private internal USE EMAIL constant
|
|
24914
24941
|
*/
|
|
24915
24942
|
const SEND_EMAIL_TOOL_NAME = 'send_email';
|
|
24916
|
-
/**
|
|
24917
|
-
* Wallet service used for SMTP credentials required by USE EMAIL.
|
|
24918
|
-
*
|
|
24919
|
-
* @private internal USE EMAIL constant
|
|
24920
|
-
*/
|
|
24921
|
-
const USE_EMAIL_SMTP_WALLET_SERVICE = 'smtp';
|
|
24922
|
-
/**
|
|
24923
|
-
* Wallet key used for SMTP credentials required by USE EMAIL.
|
|
24924
|
-
*
|
|
24925
|
-
* @private internal USE EMAIL constant
|
|
24926
|
-
*/
|
|
24927
|
-
const USE_EMAIL_SMTP_WALLET_KEY = 'use-email-smtp-credentials';
|
|
24928
24943
|
/**
|
|
24929
24944
|
* USE EMAIL commitment definition.
|
|
24930
24945
|
*
|
|
@@ -24983,31 +24998,41 @@ class UseEmailCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
24983
24998
|
`);
|
|
24984
24999
|
}
|
|
24985
25000
|
applyToAgentModelRequirements(requirements, content) {
|
|
25001
|
+
var _a;
|
|
24986
25002
|
const parsedCommitment = parseUseEmailCommitmentContent(content);
|
|
24987
|
-
const extraInstructions = formatOptionalInstructionBlock('Email instructions', parsedCommitment.instructions);
|
|
24988
|
-
const senderInstruction = parsedCommitment.senderEmail
|
|
24989
|
-
? `- Default sender address from commitment: "${parsedCommitment.senderEmail}".`
|
|
24990
|
-
: '';
|
|
24991
25003
|
const updatedTools = addUseEmailTools(requirements.tools || []);
|
|
24992
|
-
|
|
25004
|
+
// Collect all configured sender emails across multiple USE EMAIL commitments
|
|
25005
|
+
const existingSenders = Array.isArray((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.useEmailSenders)
|
|
25006
|
+
? [...requirements._metadata.useEmailSenders]
|
|
25007
|
+
: [];
|
|
25008
|
+
if (parsedCommitment.senderEmail && !existingSenders.includes(parsedCommitment.senderEmail)) {
|
|
25009
|
+
existingSenders.push(parsedCommitment.senderEmail);
|
|
25010
|
+
}
|
|
25011
|
+
const senderBullets = existingSenders.length > 0
|
|
25012
|
+
? existingSenders
|
|
25013
|
+
.map((email, index) => index === 0
|
|
25014
|
+
? `- Default sender address: "${email}".`
|
|
25015
|
+
: `- Additional sender address: "${email}".`)
|
|
25016
|
+
.join('\n')
|
|
25017
|
+
: '';
|
|
25018
|
+
const extraInstructions = formatOptionalInstructionBlock('Email instructions', parsedCommitment.instructions);
|
|
25019
|
+
const emailSectionContent = spaceTrim$1((block) => `
|
|
25020
|
+
## Emails
|
|
25021
|
+
|
|
25022
|
+
- Use \`${SEND_EMAIL_TOOL_NAME}\` to send outbound emails.
|
|
25023
|
+
${block(senderBullets)}
|
|
25024
|
+
${block(extraInstructions)}
|
|
25025
|
+
`);
|
|
25026
|
+
return this.replaceOrCreateSection({
|
|
24993
25027
|
...requirements,
|
|
24994
25028
|
tools: updatedTools,
|
|
24995
25029
|
_metadata: {
|
|
24996
25030
|
...requirements._metadata,
|
|
24997
25031
|
useEmail: true,
|
|
24998
25032
|
...(parsedCommitment.senderEmail ? { useEmailSender: parsedCommitment.senderEmail } : {}),
|
|
25033
|
+
useEmailSenders: existingSenders,
|
|
24999
25034
|
},
|
|
25000
|
-
},
|
|
25001
|
-
Email tool:
|
|
25002
|
-
- Use "${SEND_EMAIL_TOOL_NAME}" to send outbound emails.
|
|
25003
|
-
- Prefer \`message\` argument compatible with Promptbook \`Message\` type.
|
|
25004
|
-
- Include subject in \`message.metadata.subject\` (or use legacy \`subject\` argument).
|
|
25005
|
-
- USE EMAIL credentials are read from wallet records (ACCESS_TOKEN, service "${USE_EMAIL_SMTP_WALLET_SERVICE}", key "${USE_EMAIL_SMTP_WALLET_KEY}").
|
|
25006
|
-
- Wallet secret must contain SMTP credentials in JSON format with fields \`host\`, \`port\`, \`secure\`, \`username\`, \`password\`.
|
|
25007
|
-
- If credentials are missing, ask user to add wallet credentials.
|
|
25008
|
-
${block(senderInstruction)}
|
|
25009
|
-
${block(extraInstructions)}
|
|
25010
|
-
`));
|
|
25035
|
+
}, 'Emails', emailSectionContent);
|
|
25011
25036
|
}
|
|
25012
25037
|
/**
|
|
25013
25038
|
* Gets human-readable titles for tool functions provided by this commitment.
|
|
@@ -25043,13 +25068,13 @@ function addUseEmailTools(existingTools) {
|
|
|
25043
25068
|
...existingTools,
|
|
25044
25069
|
{
|
|
25045
25070
|
name: SEND_EMAIL_TOOL_NAME,
|
|
25046
|
-
description: 'Send an outbound email
|
|
25071
|
+
description: 'Send an outbound email.',
|
|
25047
25072
|
parameters: {
|
|
25048
25073
|
type: 'object',
|
|
25049
25074
|
properties: {
|
|
25050
25075
|
message: {
|
|
25051
25076
|
type: 'object',
|
|
25052
|
-
description: '
|
|
25077
|
+
description: 'Email payload. Use metadata.subject for the subject line.',
|
|
25053
25078
|
},
|
|
25054
25079
|
to: {
|
|
25055
25080
|
type: 'string',
|
|
@@ -25153,13 +25178,14 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
25153
25178
|
useImageGenerator: content || true,
|
|
25154
25179
|
},
|
|
25155
25180
|
}, spaceTrim$1((block) => `
|
|
25156
|
-
Image generation
|
|
25157
|
-
|
|
25158
|
-
-
|
|
25159
|
-
|
|
25160
|
-
|
|
25161
|
-
-
|
|
25162
|
-
-
|
|
25181
|
+
## Image generation
|
|
25182
|
+
|
|
25183
|
+
- You do not generate images directly and you do not call any image tool.
|
|
25184
|
+
- When the user asks for an image, include markdown notation in your message:
|
|
25185
|
+
\`\`
|
|
25186
|
+
- Keep \`<alt text>\` short and descriptive.
|
|
25187
|
+
- Keep \`<prompt>\` detailed so the generated image matches the request.
|
|
25188
|
+
- You can include normal explanatory text before and after the notation.
|
|
25163
25189
|
${block(extraInstructions)}
|
|
25164
25190
|
`));
|
|
25165
25191
|
}
|
|
@@ -25339,11 +25365,12 @@ class UsePopupCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
25339
25365
|
usePopup: content || true,
|
|
25340
25366
|
},
|
|
25341
25367
|
}, spaceTrim$1((block) => `
|
|
25342
|
-
|
|
25343
|
-
|
|
25344
|
-
-
|
|
25368
|
+
## Popup
|
|
25369
|
+
|
|
25370
|
+
- You can open a popup window with a specific URL using the tool \`open_popup\`.
|
|
25371
|
+
- Use this when you want the user to see or interact with a specific website.
|
|
25345
25372
|
${block(extraInstructions)}
|
|
25346
|
-
|
|
25373
|
+
`));
|
|
25347
25374
|
}
|
|
25348
25375
|
/**
|
|
25349
25376
|
* Gets human-readable titles for tool functions provided by this commitment.
|
|
@@ -25517,11 +25544,12 @@ class UsePrivacyCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
25517
25544
|
usePrivacy: content || true,
|
|
25518
25545
|
},
|
|
25519
25546
|
}, spaceTrim$1((block) => `
|
|
25520
|
-
Privacy
|
|
25521
|
-
|
|
25522
|
-
-
|
|
25523
|
-
-
|
|
25524
|
-
-
|
|
25547
|
+
## Privacy
|
|
25548
|
+
|
|
25549
|
+
- Use \`${TURN_PRIVACY_ON_TOOL_NAME}\` when the user asks for a private/sensitive conversation.
|
|
25550
|
+
- This tool requests a UI confirmation dialog. Private mode is enabled only after user confirms.
|
|
25551
|
+
- Current implementation uses the existing chat private mode (no chat persistence, memory persistence, or self-learning while active).
|
|
25552
|
+
- Do not claim that end-to-end encryption is implemented yet.
|
|
25525
25553
|
${block(extraInstructions)}
|
|
25526
25554
|
`));
|
|
25527
25555
|
}
|
|
@@ -27145,9 +27173,16 @@ class UseProjectCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
27145
27173
|
}
|
|
27146
27174
|
const existingConfiguredProjects = normalizeConfiguredProjects((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.useProjects);
|
|
27147
27175
|
addConfiguredProjectIfMissing(existingConfiguredProjects, parsedCommitment.repository);
|
|
27148
|
-
const repositoriesList = existingConfiguredProjects.map((project) => `- ${project.url}`).join('\n');
|
|
27149
27176
|
const extraInstructions = formatOptionalInstructionBlock('Project instructions', parsedCommitment.instructions);
|
|
27150
|
-
|
|
27177
|
+
const sectionContent = spaceTrim$1((block) => `
|
|
27178
|
+
- You can inspect and edit configured GitHub repositories using project tools.
|
|
27179
|
+
- Configured repositories:
|
|
27180
|
+
${block(existingConfiguredProjects.map((project) => `- ${project.url}`).join('\n'))}
|
|
27181
|
+
- When a repository is not obvious from context, pass \`repository\` in tool arguments explicitly.
|
|
27182
|
+
- If credentials are missing, ask the user to connect their GitHub account in the host UI.
|
|
27183
|
+
${block(extraInstructions)}
|
|
27184
|
+
`);
|
|
27185
|
+
return this.replaceOrCreateSection({
|
|
27151
27186
|
...requirements,
|
|
27152
27187
|
tools: createUseProjectTools(requirements.tools || []),
|
|
27153
27188
|
_metadata: {
|
|
@@ -27155,16 +27190,7 @@ class UseProjectCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
27155
27190
|
useProject: true,
|
|
27156
27191
|
useProjects: existingConfiguredProjects,
|
|
27157
27192
|
},
|
|
27158
|
-
},
|
|
27159
|
-
Project tools:
|
|
27160
|
-
- You can inspect and edit configured GitHub repositories using project tools.
|
|
27161
|
-
- Configured repositories:
|
|
27162
|
-
${block(repositoriesList)}
|
|
27163
|
-
- When a repository is not obvious from context, pass "repository" in tool arguments explicitly.
|
|
27164
|
-
- USE PROJECT credentials are read from wallet records (ACCESS_TOKEN, service "${UseProjectWallet.service}", key "${UseProjectWallet.key}").
|
|
27165
|
-
- If credentials are missing, ask the user to connect credentials in host UI and/or add them to wallet.
|
|
27166
|
-
${block(extraInstructions)}
|
|
27167
|
-
`));
|
|
27193
|
+
}, 'GitHub repositories', sectionContent);
|
|
27168
27194
|
}
|
|
27169
27195
|
/**
|
|
27170
27196
|
* Gets human-readable titles for tool functions provided by this commitment.
|
|
@@ -27511,11 +27537,12 @@ class UseSpawnCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
27511
27537
|
useSpawn: content || true,
|
|
27512
27538
|
},
|
|
27513
27539
|
}, spaceTrim$1((block) => `
|
|
27514
|
-
Spawning agents
|
|
27515
|
-
|
|
27516
|
-
-
|
|
27517
|
-
-
|
|
27518
|
-
-
|
|
27540
|
+
## Spawning agents
|
|
27541
|
+
|
|
27542
|
+
- Use \`${SPAWN_AGENT_TOOL_NAME}\` only when user asks to create a persistent new agent.
|
|
27543
|
+
- Pass full agent source in \`source\`.
|
|
27544
|
+
- Keep \`source\` concise; the maximum accepted length is ${CREATE_AGENT_INPUT_SOURCE_MAX_LENGTH} characters.
|
|
27545
|
+
- Do not add unknown fields in tool arguments.
|
|
27519
27546
|
${block(extraInstructions)}
|
|
27520
27547
|
`));
|
|
27521
27548
|
}
|
|
@@ -27549,13 +27576,14 @@ class UseSpawnCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
27549
27576
|
*/
|
|
27550
27577
|
function createTimeoutSystemMessage(extraInstructions) {
|
|
27551
27578
|
return spaceTrim$1((block) => `
|
|
27552
|
-
Timeout scheduling
|
|
27553
|
-
|
|
27554
|
-
-
|
|
27555
|
-
-
|
|
27556
|
-
-
|
|
27557
|
-
-
|
|
27558
|
-
-
|
|
27579
|
+
## Timeout scheduling
|
|
27580
|
+
|
|
27581
|
+
- Use \`set_timeout\` to wake this same chat thread in the future.
|
|
27582
|
+
- Use \`list_timeouts\` to review timeout ids/details across all chats for the same user+agent scope.
|
|
27583
|
+
- \`cancel_timeout\` accepts either one timeout id or \`allActive: true\` to cancel all active timeouts in this same user+agent scope.
|
|
27584
|
+
- Use \`update_timeout\` to pause/resume, edit next run, edit recurrence, or update timeout payload details.
|
|
27585
|
+
- When one timeout elapses, you will receive a new user-like message that explicitly says it is a timeout wake-up and includes the \`timeoutId\`.
|
|
27586
|
+
- Do not claim a timer was set or cancelled unless the tool confirms it.
|
|
27559
27587
|
${block(extraInstructions)}
|
|
27560
27588
|
`);
|
|
27561
27589
|
}
|
|
@@ -28655,10 +28683,11 @@ class UseUserLocationCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
28655
28683
|
useUserLocation: content || true,
|
|
28656
28684
|
},
|
|
28657
28685
|
}, spaceTrim$1((block) => `
|
|
28658
|
-
User location
|
|
28659
|
-
|
|
28660
|
-
-
|
|
28661
|
-
-
|
|
28686
|
+
## User location
|
|
28687
|
+
|
|
28688
|
+
- Use \`${GET_USER_LOCATION_TOOL_NAME}\` only when location is needed for a better answer.
|
|
28689
|
+
- If the tool returns "unavailable" or "permission-denied", ask user to share location or provide city manually.
|
|
28690
|
+
- Do not invent coordinates or local facts when location is unavailable.
|
|
28662
28691
|
${block(extraInstructions)}
|
|
28663
28692
|
`));
|
|
28664
28693
|
}
|
|
@@ -32758,7 +32787,7 @@ function createExampleInteractionsContent(parseResult, samples) {
|
|
|
32758
32787
|
if (examples.length === 0) {
|
|
32759
32788
|
return null;
|
|
32760
32789
|
}
|
|
32761
|
-
return
|
|
32790
|
+
return `## Sample of communication with the agent:\n\n${examples.join('\n\n')}`;
|
|
32762
32791
|
}
|
|
32763
32792
|
/**
|
|
32764
32793
|
* Collects the individual lines used in the example interaction section.
|
|
@@ -32774,11 +32803,11 @@ function collectExampleInteractionLines(parseResult, samples) {
|
|
|
32774
32803
|
const examples = [];
|
|
32775
32804
|
const initialMessage = (_a = parseResult.commitments.find((commitment) => commitment.type === 'INITIAL MESSAGE')) === null || _a === void 0 ? void 0 : _a.content;
|
|
32776
32805
|
if (initialMessage) {
|
|
32777
|
-
examples.push(
|
|
32806
|
+
examples.push(`**Agent:**\n${initialMessage}`);
|
|
32778
32807
|
}
|
|
32779
32808
|
if (samples && samples.length > 0) {
|
|
32780
32809
|
for (const sample of samples) {
|
|
32781
|
-
examples.push(
|
|
32810
|
+
examples.push(`**User:** ${sample.question}\n\n**Agent:**\n${sample.answer}`);
|
|
32782
32811
|
}
|
|
32783
32812
|
}
|
|
32784
32813
|
return examples;
|
|
@@ -37326,8 +37355,8 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
37326
37355
|
* Prepares an AgentKit agent with optional knowledge sources and tool definitions.
|
|
37327
37356
|
*/
|
|
37328
37357
|
async prepareAgentKitAgent(options) {
|
|
37329
|
-
var _a, _b;
|
|
37330
|
-
const { name, instructions, knowledgeSources, tools, vectorStoreId: cachedVectorStoreId, storeAsPrepared, } = options;
|
|
37358
|
+
var _a, _b, _c;
|
|
37359
|
+
const { name, instructions, knowledgeSources, tools, nativeAgentKitTools, vectorStoreId: cachedVectorStoreId, storeAsPrepared, } = options;
|
|
37331
37360
|
await this.ensureAgentKitDefaults();
|
|
37332
37361
|
if (this.options.isVerbose) {
|
|
37333
37362
|
console.info('[🤰]', 'Preparing OpenAI AgentKit agent', {
|
|
@@ -37335,6 +37364,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
37335
37364
|
instructionsLength: instructions.length,
|
|
37336
37365
|
knowledgeSourcesCount: (_a = knowledgeSources === null || knowledgeSources === void 0 ? void 0 : knowledgeSources.length) !== null && _a !== void 0 ? _a : 0,
|
|
37337
37366
|
toolsCount: (_b = tools === null || tools === void 0 ? void 0 : tools.length) !== null && _b !== void 0 ? _b : 0,
|
|
37367
|
+
nativeAgentKitToolsCount: (_c = nativeAgentKitTools === null || nativeAgentKitTools === void 0 ? void 0 : nativeAgentKitTools.length) !== null && _c !== void 0 ? _c : 0,
|
|
37338
37368
|
});
|
|
37339
37369
|
}
|
|
37340
37370
|
let vectorStoreId = cachedVectorStoreId;
|
|
@@ -37353,7 +37383,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
37353
37383
|
vectorStoreId,
|
|
37354
37384
|
});
|
|
37355
37385
|
}
|
|
37356
|
-
const agentKitTools = this.buildAgentKitTools({ tools, vectorStoreId });
|
|
37386
|
+
const agentKitTools = this.buildAgentKitTools({ tools, nativeAgentKitTools, vectorStoreId });
|
|
37357
37387
|
const openAiAgentKitAgent = new Agent$1({
|
|
37358
37388
|
name,
|
|
37359
37389
|
model: this.agentKitModelName,
|
|
@@ -37392,11 +37422,14 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
37392
37422
|
* Builds the tool list for AgentKit, including hosted file search when applicable.
|
|
37393
37423
|
*/
|
|
37394
37424
|
buildAgentKitTools(options) {
|
|
37395
|
-
const { tools, vectorStoreId } = options;
|
|
37425
|
+
const { tools, nativeAgentKitTools, vectorStoreId } = options;
|
|
37396
37426
|
const agentKitTools = [];
|
|
37397
37427
|
if (vectorStoreId) {
|
|
37398
37428
|
agentKitTools.push(fileSearchTool(vectorStoreId));
|
|
37399
37429
|
}
|
|
37430
|
+
if (nativeAgentKitTools && nativeAgentKitTools.length > 0) {
|
|
37431
|
+
agentKitTools.push(...nativeAgentKitTools);
|
|
37432
|
+
}
|
|
37400
37433
|
if (tools && tools.length > 0) {
|
|
37401
37434
|
let scriptTools = null;
|
|
37402
37435
|
for (const toolDefinition of tools) {
|