@promptbook/remote-server 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
|
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
40
40
|
* @generated
|
|
41
41
|
* @see https://github.com/webgptorg/promptbook
|
|
42
42
|
*/
|
|
43
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
43
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-60';
|
|
44
44
|
/**
|
|
45
45
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
46
46
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -11340,6 +11340,49 @@ class BaseCommitmentDefinition {
|
|
|
11340
11340
|
return this.appendToSystemMessage(requirements, commentSection);
|
|
11341
11341
|
}
|
|
11342
11342
|
}
|
|
11343
|
+
/**
|
|
11344
|
+
* Helper method to append a bullet point to an existing `## SectionTitle` section in the system
|
|
11345
|
+
* message, or to create a new section when it does not yet exist.
|
|
11346
|
+
*
|
|
11347
|
+
* Handles the case where the same commitment type appears multiple times in the book source and
|
|
11348
|
+
* all entries should be grouped under one shared heading rather than emitting a duplicate block.
|
|
11349
|
+
*
|
|
11350
|
+
* @param requirements - Current model requirements.
|
|
11351
|
+
* @param sectionTitle - Section title without the `##` prefix.
|
|
11352
|
+
* @param bulletContent - Bullet content without the leading `- ` prefix.
|
|
11353
|
+
* @returns Requirements with the bullet appended to the section.
|
|
11354
|
+
*/
|
|
11355
|
+
appendBulletPointToSection(requirements, sectionTitle, bulletContent) {
|
|
11356
|
+
const sectionHeader = `## ${sectionTitle}`;
|
|
11357
|
+
const bullet = `- ${bulletContent}`;
|
|
11358
|
+
if (requirements.systemMessage.includes(sectionHeader)) {
|
|
11359
|
+
// Append bullet to end of existing section, before the next h2 heading or end of message
|
|
11360
|
+
const newSystemMessage = requirements.systemMessage.replace(new RegExp(`(## ${sectionTitle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\n\\n)([\\s\\S]*?)(?=\\n\\n##|$)`), `$1$2\n${bullet}`);
|
|
11361
|
+
return { ...requirements, systemMessage: newSystemMessage };
|
|
11362
|
+
}
|
|
11363
|
+
return this.appendToSystemMessage(requirements, `${sectionHeader}\n\n${bullet}`, '\n\n');
|
|
11364
|
+
}
|
|
11365
|
+
/**
|
|
11366
|
+
* Helper method to replace an existing `## SectionTitle` section in the system message, or to
|
|
11367
|
+
* append a new one when the section does not yet exist.
|
|
11368
|
+
*
|
|
11369
|
+
* Use this when a commitment type can appear multiple times and each subsequent occurrence should
|
|
11370
|
+
* update the single shared section rather than appending a duplicate block.
|
|
11371
|
+
*
|
|
11372
|
+
* @param requirements - Current model requirements.
|
|
11373
|
+
* @param sectionTitle - Section title without the `##` prefix.
|
|
11374
|
+
* @param sectionContent - Full section content including the `## Title` header line.
|
|
11375
|
+
* @returns Requirements with the section replaced or appended.
|
|
11376
|
+
*/
|
|
11377
|
+
replaceOrCreateSection(requirements, sectionTitle, sectionContent) {
|
|
11378
|
+
const sectionHeader = `## ${sectionTitle}`;
|
|
11379
|
+
if (requirements.systemMessage.includes(sectionHeader)) {
|
|
11380
|
+
// Replace all text from the heading until the next h2 heading or end of message
|
|
11381
|
+
const newSystemMessage = requirements.systemMessage.replace(new RegExp(`## ${sectionTitle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), sectionContent);
|
|
11382
|
+
return { ...requirements, systemMessage: newSystemMessage };
|
|
11383
|
+
}
|
|
11384
|
+
return this.appendToSystemMessage(requirements, sectionContent, '\n\n');
|
|
11385
|
+
}
|
|
11343
11386
|
/**
|
|
11344
11387
|
* Gets tool function implementations provided by this commitment
|
|
11345
11388
|
*
|
|
@@ -11801,20 +11844,16 @@ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11801
11844
|
if (!trimmedContent) {
|
|
11802
11845
|
return requirements;
|
|
11803
11846
|
}
|
|
11804
|
-
//
|
|
11847
|
+
// Store the entry in metadata for debugging and inspection
|
|
11805
11848
|
const existingDictionary = ((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
|
|
11806
|
-
// Merge the new dictionary entry with existing entries
|
|
11807
11849
|
const mergedDictionary = existingDictionary ? `${existingDictionary}\n${trimmedContent}` : trimmedContent;
|
|
11808
|
-
// Store the merged dictionary in metadata for debugging and inspection
|
|
11809
11850
|
const updatedMetadata = {
|
|
11810
11851
|
...requirements._metadata,
|
|
11811
11852
|
DICTIONARY: mergedDictionary,
|
|
11812
11853
|
};
|
|
11813
|
-
//
|
|
11814
|
-
// Format: "# DICTIONARY\nTerm: definition\nTerm: definition..."
|
|
11815
|
-
const dictionarySection = `# DICTIONARY\n${mergedDictionary}`;
|
|
11854
|
+
// Append each dictionary entry as a bullet point under ## Dictionary
|
|
11816
11855
|
return {
|
|
11817
|
-
...this.
|
|
11856
|
+
...this.appendBulletPointToSection(requirements, 'Dictionary', trimmedContent),
|
|
11818
11857
|
_metadata: updatedMetadata,
|
|
11819
11858
|
};
|
|
11820
11859
|
}
|
|
@@ -12317,10 +12356,10 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
12317
12356
|
if (!trimmedContent) {
|
|
12318
12357
|
return requirements;
|
|
12319
12358
|
}
|
|
12320
|
-
// Add goal to the system message
|
|
12321
|
-
const goalSection =
|
|
12359
|
+
// Add goal as a proper h2 section to the system message
|
|
12360
|
+
const goalSection = `## Goal\n\n${trimmedContent}`;
|
|
12322
12361
|
const requirementsWithGoal = this.appendToSystemMessage(requirements, goalSection, '\n\n');
|
|
12323
|
-
return this.appendToPromptSuffix(requirementsWithGoal,
|
|
12362
|
+
return this.appendToPromptSuffix(requirementsWithGoal, trimmedContent);
|
|
12324
12363
|
}
|
|
12325
12364
|
}
|
|
12326
12365
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -12840,11 +12879,8 @@ class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
12840
12879
|
if (!trimmedContent) {
|
|
12841
12880
|
return requirements;
|
|
12842
12881
|
}
|
|
12843
|
-
// Add language
|
|
12844
|
-
const languageSection =
|
|
12845
|
-
${block(trimmedContent)}
|
|
12846
|
-
<- You are speaking these languages in your responses to the user.
|
|
12847
|
-
`));
|
|
12882
|
+
// Add language as a bullet under a ## Language section
|
|
12883
|
+
const languageSection = `## Language\n\n- Your language is ${trimmedContent}`;
|
|
12848
12884
|
return this.appendToSystemMessage(requirements, languageSection, '\n\n');
|
|
12849
12885
|
}
|
|
12850
12886
|
}
|
|
@@ -12888,15 +12924,16 @@ const MemoryToolNames = {
|
|
|
12888
12924
|
*/
|
|
12889
12925
|
function createMemorySystemMessage(extraInstructions) {
|
|
12890
12926
|
return spaceTrim$1((block) => `
|
|
12891
|
-
Memory
|
|
12892
|
-
|
|
12893
|
-
-
|
|
12894
|
-
-
|
|
12895
|
-
-
|
|
12896
|
-
-
|
|
12897
|
-
-
|
|
12898
|
-
-
|
|
12899
|
-
-
|
|
12927
|
+
## Memory
|
|
12928
|
+
|
|
12929
|
+
- Prefer storing agent-scoped memories; only make them global when the fact should apply across all your agents.
|
|
12930
|
+
- You can use persistent user memory tools.
|
|
12931
|
+
- Use \`${MemoryToolNames.retrieve}\` to load relevant memory before answering.
|
|
12932
|
+
- Use \`${MemoryToolNames.store}\` to save stable user-specific facts that improve future help.
|
|
12933
|
+
- Use \`${MemoryToolNames.update}\` to refresh an existing memory when the content changes.
|
|
12934
|
+
- Use \`${MemoryToolNames.delete}\` to delete memories that are no longer accurate (deletions are soft and hidden from future queries).
|
|
12935
|
+
- Store concise memory items and avoid duplicates.
|
|
12936
|
+
- Never claim memory was saved or loaded unless the tool confirms it.
|
|
12900
12937
|
${block(extraInstructions)}
|
|
12901
12938
|
`);
|
|
12902
12939
|
}
|
|
@@ -13818,10 +13855,8 @@ class MessageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
13818
13855
|
if (!trimmedContent) {
|
|
13819
13856
|
return requirements;
|
|
13820
13857
|
}
|
|
13821
|
-
// Create message section for system message
|
|
13822
|
-
const messageSection = `Previous Message: ${trimmedContent}`;
|
|
13823
13858
|
// Messages represent conversation history and should be included for context
|
|
13824
|
-
return this.
|
|
13859
|
+
return this.appendBulletPointToSection(requirements, 'Previous messages', trimmedContent);
|
|
13825
13860
|
}
|
|
13826
13861
|
}
|
|
13827
13862
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -18615,10 +18650,9 @@ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18615
18650
|
if (!trimmedContent) {
|
|
18616
18651
|
return requirements;
|
|
18617
18652
|
}
|
|
18618
|
-
//
|
|
18619
|
-
const
|
|
18620
|
-
|
|
18621
|
-
return this.appendToPromptSuffix(requirementsWithRule, ruleSection);
|
|
18653
|
+
// Group all rules under a single ## Rules section as bullet points
|
|
18654
|
+
const requirementsWithRule = this.appendBulletPointToSection(requirements, 'Rules', trimmedContent);
|
|
18655
|
+
return this.appendToPromptSuffix(requirementsWithRule, `- ${trimmedContent}`);
|
|
18622
18656
|
}
|
|
18623
18657
|
}
|
|
18624
18658
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -18854,10 +18888,8 @@ class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
18854
18888
|
if (!trimmedContent) {
|
|
18855
18889
|
return requirements;
|
|
18856
18890
|
}
|
|
18857
|
-
// Create scenario section for system message
|
|
18858
|
-
const scenarioSection = `Scenario: ${trimmedContent}`;
|
|
18859
18891
|
// Scenarios provide important contextual information that affects behavior
|
|
18860
|
-
return this.
|
|
18892
|
+
return this.appendBulletPointToSection(requirements, 'Scenarios', trimmedContent);
|
|
18861
18893
|
}
|
|
18862
18894
|
}
|
|
18863
18895
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -19240,8 +19272,8 @@ const teamToolTitles = {};
|
|
|
19240
19272
|
* @private
|
|
19241
19273
|
*/
|
|
19242
19274
|
const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
|
|
19243
|
-
'-
|
|
19244
|
-
'-
|
|
19275
|
+
'- If a teammate is relevant to the request, consult that teammate using the matching tool.',
|
|
19276
|
+
'- Do not ask the user for information that a listed teammate can provide directly.',
|
|
19245
19277
|
];
|
|
19246
19278
|
/**
|
|
19247
19279
|
* Constant for remote agents by Url.
|
|
@@ -19369,7 +19401,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
19369
19401
|
toolName: entry.toolName,
|
|
19370
19402
|
});
|
|
19371
19403
|
}
|
|
19372
|
-
const teamSystemMessage = this.createSystemMessageSection('Teammates
|
|
19404
|
+
const teamSystemMessage = this.createSystemMessageSection('Teammates', buildTeamSystemMessageBody(teamEntries));
|
|
19373
19405
|
return this.appendToSystemMessage({
|
|
19374
19406
|
...requirements,
|
|
19375
19407
|
tools: updatedTools,
|
|
@@ -19859,36 +19891,38 @@ function createAggregatedUseCommitmentSystemMessage(type, additionalInstructions
|
|
|
19859
19891
|
switch (type) {
|
|
19860
19892
|
case 'USE TIME':
|
|
19861
19893
|
return spaceTrim$1((block) => `
|
|
19862
|
-
Time and date context
|
|
19863
|
-
|
|
19864
|
-
-
|
|
19894
|
+
## Time and date context
|
|
19895
|
+
|
|
19896
|
+
- It is ${moment().format('MMMM YYYY')} now.
|
|
19897
|
+
- If you need more precise current time information, use the tool \`get_current_time\`.
|
|
19865
19898
|
${block(formatOptionalInstructionBlock('Time instructions', combinedAdditionalInstructions))}
|
|
19866
19899
|
`);
|
|
19867
19900
|
case 'USE BROWSER':
|
|
19868
19901
|
return spaceTrim$1((block) => `
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
-
|
|
19872
|
-
|
|
19902
|
+
## Browser
|
|
19903
|
+
|
|
19904
|
+
- Use \`fetch_url_content\` to retrieve content from specific URLs (webpages or documents) using scrapers.
|
|
19905
|
+
- Use \`run_browser\` for real interactive browser automation (navigation, clicks, typing, waiting, scrolling).
|
|
19906
|
+
- When you need to know information from a specific website or document, use the tools provided.
|
|
19873
19907
|
${block(formatOptionalInstructionBlock('Browser instructions', combinedAdditionalInstructions))}
|
|
19874
19908
|
`);
|
|
19875
19909
|
case 'USE SEARCH ENGINE':
|
|
19876
19910
|
return spaceTrim$1((block) => `
|
|
19877
|
-
|
|
19878
|
-
|
|
19879
|
-
-
|
|
19880
|
-
-
|
|
19881
|
-
-
|
|
19882
|
-
-
|
|
19911
|
+
## Web Search
|
|
19912
|
+
|
|
19913
|
+
- Use \`web_search\` to find up-to-date information or facts.
|
|
19914
|
+
- When you need to know some information from the internet, use the search tool provided.
|
|
19915
|
+
- Do not make up information when you can search for it.
|
|
19916
|
+
- Do not tell the user you cannot search for information, YOU CAN.
|
|
19883
19917
|
${block(formatOptionalInstructionBlock('Search instructions', combinedAdditionalInstructions))}
|
|
19884
19918
|
`);
|
|
19885
19919
|
case 'USE DEEPSEARCH':
|
|
19886
19920
|
return spaceTrim$1((block) => `
|
|
19887
|
-
|
|
19888
|
-
|
|
19889
|
-
-
|
|
19890
|
-
-
|
|
19891
|
-
-
|
|
19921
|
+
## Deep Research
|
|
19922
|
+
|
|
19923
|
+
- Use \`deep_search\` for broader research tasks that need multi-step investigation, comparison, or synthesis across multiple sources.
|
|
19924
|
+
- Prefer it over quick search when the user asks for a well-grounded brief, report, or deeper investigation.
|
|
19925
|
+
- Do not pretend you cannot research current information when this tool is available.
|
|
19892
19926
|
${block(formatOptionalInstructionBlock('DeepSearch instructions', combinedAdditionalInstructions))}
|
|
19893
19927
|
`);
|
|
19894
19928
|
}
|
|
@@ -20218,96 +20252,6 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
20218
20252
|
}
|
|
20219
20253
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
20220
20254
|
|
|
20221
|
-
/**
|
|
20222
|
-
* Base Google Calendar API URL.
|
|
20223
|
-
*
|
|
20224
|
-
* @private constant of callGoogleCalendarApi
|
|
20225
|
-
*/
|
|
20226
|
-
const GOOGLE_CALENDAR_API_BASE_URL = 'https://www.googleapis.com/calendar/v3';
|
|
20227
|
-
/**
|
|
20228
|
-
* Runs one Google Calendar API request and parses JSON response payload.
|
|
20229
|
-
*
|
|
20230
|
-
* @private function of UseCalendarCommitmentDefinition
|
|
20231
|
-
*/
|
|
20232
|
-
async function callGoogleCalendarApi(accessToken, options) {
|
|
20233
|
-
const url = new URL(options.path, GOOGLE_CALENDAR_API_BASE_URL);
|
|
20234
|
-
if (options.query) {
|
|
20235
|
-
for (const [key, value] of Object.entries(options.query)) {
|
|
20236
|
-
if (value && value.trim()) {
|
|
20237
|
-
url.searchParams.set(key, value);
|
|
20238
|
-
}
|
|
20239
|
-
}
|
|
20240
|
-
}
|
|
20241
|
-
const response = await fetch(url.toString(), {
|
|
20242
|
-
method: options.method,
|
|
20243
|
-
headers: {
|
|
20244
|
-
Authorization: `Bearer ${accessToken}`,
|
|
20245
|
-
Accept: 'application/json',
|
|
20246
|
-
'Content-Type': 'application/json',
|
|
20247
|
-
},
|
|
20248
|
-
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
20249
|
-
});
|
|
20250
|
-
const textPayload = await response.text();
|
|
20251
|
-
const parsedPayload = tryParseJson$2(textPayload);
|
|
20252
|
-
if (options.allowNotFound && response.status === 404) {
|
|
20253
|
-
return null;
|
|
20254
|
-
}
|
|
20255
|
-
if (!response.ok) {
|
|
20256
|
-
throw new Error(spaceTrim$1(`
|
|
20257
|
-
Google Calendar API request failed (${response.status} ${response.statusText}):
|
|
20258
|
-
${extractGoogleCalendarApiErrorMessage(parsedPayload, textPayload)}
|
|
20259
|
-
`));
|
|
20260
|
-
}
|
|
20261
|
-
return parsedPayload;
|
|
20262
|
-
}
|
|
20263
|
-
/**
|
|
20264
|
-
* Parses raw text into JSON when possible.
|
|
20265
|
-
*
|
|
20266
|
-
* @private function of callGoogleCalendarApi
|
|
20267
|
-
*/
|
|
20268
|
-
function tryParseJson$2(rawText) {
|
|
20269
|
-
if (!rawText.trim()) {
|
|
20270
|
-
return {};
|
|
20271
|
-
}
|
|
20272
|
-
try {
|
|
20273
|
-
return JSON.parse(rawText);
|
|
20274
|
-
}
|
|
20275
|
-
catch (_a) {
|
|
20276
|
-
return rawText;
|
|
20277
|
-
}
|
|
20278
|
-
}
|
|
20279
|
-
/**
|
|
20280
|
-
* Extracts a user-friendly Google Calendar API error message.
|
|
20281
|
-
*
|
|
20282
|
-
* @private function of callGoogleCalendarApi
|
|
20283
|
-
*/
|
|
20284
|
-
function extractGoogleCalendarApiErrorMessage(parsedPayload, fallbackText) {
|
|
20285
|
-
if (parsedPayload && typeof parsedPayload === 'object') {
|
|
20286
|
-
const payload = parsedPayload;
|
|
20287
|
-
const errorPayload = payload.error;
|
|
20288
|
-
if (errorPayload && typeof errorPayload === 'object') {
|
|
20289
|
-
const normalizedErrorPayload = errorPayload;
|
|
20290
|
-
const message = typeof normalizedErrorPayload.message === 'string' ? normalizedErrorPayload.message : '';
|
|
20291
|
-
const errors = Array.isArray(normalizedErrorPayload.errors) ? normalizedErrorPayload.errors : [];
|
|
20292
|
-
const flattenedErrors = errors
|
|
20293
|
-
.map((errorEntry) => {
|
|
20294
|
-
if (!errorEntry || typeof errorEntry !== 'object') {
|
|
20295
|
-
return '';
|
|
20296
|
-
}
|
|
20297
|
-
const normalizedErrorEntry = errorEntry;
|
|
20298
|
-
const detailMessage = typeof normalizedErrorEntry.message === 'string' ? normalizedErrorEntry.message : '';
|
|
20299
|
-
const reason = typeof normalizedErrorEntry.reason === 'string' ? normalizedErrorEntry.reason : '';
|
|
20300
|
-
return [detailMessage, reason].filter(Boolean).join(' | ');
|
|
20301
|
-
})
|
|
20302
|
-
.filter(Boolean);
|
|
20303
|
-
if (message || flattenedErrors.length > 0) {
|
|
20304
|
-
return [message, ...flattenedErrors].filter(Boolean).join(' | ');
|
|
20305
|
-
}
|
|
20306
|
-
}
|
|
20307
|
-
}
|
|
20308
|
-
return fallbackText || 'Unknown Google Calendar API error';
|
|
20309
|
-
}
|
|
20310
|
-
|
|
20311
20255
|
/**
|
|
20312
20256
|
* Hostnames accepted for Google Calendar references.
|
|
20313
20257
|
*
|
|
@@ -20489,6 +20433,96 @@ function removeTokenFromLine(line, token) {
|
|
|
20489
20433
|
}
|
|
20490
20434
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
20491
20435
|
|
|
20436
|
+
/**
|
|
20437
|
+
* Base Google Calendar API URL.
|
|
20438
|
+
*
|
|
20439
|
+
* @private constant of callGoogleCalendarApi
|
|
20440
|
+
*/
|
|
20441
|
+
const GOOGLE_CALENDAR_API_BASE_URL = 'https://www.googleapis.com/calendar/v3';
|
|
20442
|
+
/**
|
|
20443
|
+
* Runs one Google Calendar API request and parses JSON response payload.
|
|
20444
|
+
*
|
|
20445
|
+
* @private function of UseCalendarCommitmentDefinition
|
|
20446
|
+
*/
|
|
20447
|
+
async function callGoogleCalendarApi(accessToken, options) {
|
|
20448
|
+
const url = new URL(options.path, GOOGLE_CALENDAR_API_BASE_URL);
|
|
20449
|
+
if (options.query) {
|
|
20450
|
+
for (const [key, value] of Object.entries(options.query)) {
|
|
20451
|
+
if (value && value.trim()) {
|
|
20452
|
+
url.searchParams.set(key, value);
|
|
20453
|
+
}
|
|
20454
|
+
}
|
|
20455
|
+
}
|
|
20456
|
+
const response = await fetch(url.toString(), {
|
|
20457
|
+
method: options.method,
|
|
20458
|
+
headers: {
|
|
20459
|
+
Authorization: `Bearer ${accessToken}`,
|
|
20460
|
+
Accept: 'application/json',
|
|
20461
|
+
'Content-Type': 'application/json',
|
|
20462
|
+
},
|
|
20463
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
20464
|
+
});
|
|
20465
|
+
const textPayload = await response.text();
|
|
20466
|
+
const parsedPayload = tryParseJson$2(textPayload);
|
|
20467
|
+
if (options.allowNotFound && response.status === 404) {
|
|
20468
|
+
return null;
|
|
20469
|
+
}
|
|
20470
|
+
if (!response.ok) {
|
|
20471
|
+
throw new Error(spaceTrim$1(`
|
|
20472
|
+
Google Calendar API request failed (${response.status} ${response.statusText}):
|
|
20473
|
+
${extractGoogleCalendarApiErrorMessage(parsedPayload, textPayload)}
|
|
20474
|
+
`));
|
|
20475
|
+
}
|
|
20476
|
+
return parsedPayload;
|
|
20477
|
+
}
|
|
20478
|
+
/**
|
|
20479
|
+
* Parses raw text into JSON when possible.
|
|
20480
|
+
*
|
|
20481
|
+
* @private function of callGoogleCalendarApi
|
|
20482
|
+
*/
|
|
20483
|
+
function tryParseJson$2(rawText) {
|
|
20484
|
+
if (!rawText.trim()) {
|
|
20485
|
+
return {};
|
|
20486
|
+
}
|
|
20487
|
+
try {
|
|
20488
|
+
return JSON.parse(rawText);
|
|
20489
|
+
}
|
|
20490
|
+
catch (_a) {
|
|
20491
|
+
return rawText;
|
|
20492
|
+
}
|
|
20493
|
+
}
|
|
20494
|
+
/**
|
|
20495
|
+
* Extracts a user-friendly Google Calendar API error message.
|
|
20496
|
+
*
|
|
20497
|
+
* @private function of callGoogleCalendarApi
|
|
20498
|
+
*/
|
|
20499
|
+
function extractGoogleCalendarApiErrorMessage(parsedPayload, fallbackText) {
|
|
20500
|
+
if (parsedPayload && typeof parsedPayload === 'object') {
|
|
20501
|
+
const payload = parsedPayload;
|
|
20502
|
+
const errorPayload = payload.error;
|
|
20503
|
+
if (errorPayload && typeof errorPayload === 'object') {
|
|
20504
|
+
const normalizedErrorPayload = errorPayload;
|
|
20505
|
+
const message = typeof normalizedErrorPayload.message === 'string' ? normalizedErrorPayload.message : '';
|
|
20506
|
+
const errors = Array.isArray(normalizedErrorPayload.errors) ? normalizedErrorPayload.errors : [];
|
|
20507
|
+
const flattenedErrors = errors
|
|
20508
|
+
.map((errorEntry) => {
|
|
20509
|
+
if (!errorEntry || typeof errorEntry !== 'object') {
|
|
20510
|
+
return '';
|
|
20511
|
+
}
|
|
20512
|
+
const normalizedErrorEntry = errorEntry;
|
|
20513
|
+
const detailMessage = typeof normalizedErrorEntry.message === 'string' ? normalizedErrorEntry.message : '';
|
|
20514
|
+
const reason = typeof normalizedErrorEntry.reason === 'string' ? normalizedErrorEntry.reason : '';
|
|
20515
|
+
return [detailMessage, reason].filter(Boolean).join(' | ');
|
|
20516
|
+
})
|
|
20517
|
+
.filter(Boolean);
|
|
20518
|
+
if (message || flattenedErrors.length > 0) {
|
|
20519
|
+
return [message, ...flattenedErrors].filter(Boolean).join(' | ');
|
|
20520
|
+
}
|
|
20521
|
+
}
|
|
20522
|
+
}
|
|
20523
|
+
return fallbackText || 'Unknown Google Calendar API error';
|
|
20524
|
+
}
|
|
20525
|
+
|
|
20492
20526
|
/**
|
|
20493
20527
|
* Wallet metadata used by USE CALENDAR when resolving Google Calendar credentials.
|
|
20494
20528
|
*
|
|
@@ -21389,18 +21423,20 @@ class UseCalendarCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21389
21423
|
if (parsedCommitment.calendar) {
|
|
21390
21424
|
addConfiguredCalendarIfMissing(existingConfiguredCalendars, parsedCommitment.calendar);
|
|
21391
21425
|
}
|
|
21392
|
-
const
|
|
21393
|
-
? existingConfiguredCalendars
|
|
21394
|
-
|
|
21395
|
-
`- ${calendar.provider}: ${calendar.url}`,
|
|
21396
|
-
calendar.scopes.length > 0 ? ` scopes: ${calendar.scopes.join(', ')}` : '',
|
|
21397
|
-
]
|
|
21398
|
-
.filter(Boolean)
|
|
21399
|
-
.join('\n'))
|
|
21400
|
-
.join('\n')
|
|
21401
|
-
: '- Calendar is resolved from runtime context';
|
|
21426
|
+
const calendarBullets = existingConfiguredCalendars.length > 0
|
|
21427
|
+
? existingConfiguredCalendars.map((calendar) => `- ${calendar.provider}: ${calendar.url}`).join('\n')
|
|
21428
|
+
: '- Calendar is resolved from runtime context';
|
|
21402
21429
|
const extraInstructions = formatOptionalInstructionBlock('Calendar instructions', parsedCommitment.instructions);
|
|
21403
|
-
|
|
21430
|
+
const calendarSectionContent = spaceTrim$1((block) => `
|
|
21431
|
+
## Calendar
|
|
21432
|
+
|
|
21433
|
+
- 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.
|
|
21434
|
+
- Supported operations include read, create, update, delete, invite guests, and reminders.
|
|
21435
|
+
- Configured calendars:
|
|
21436
|
+
${block(calendarBullets)}
|
|
21437
|
+
${block(extraInstructions)}
|
|
21438
|
+
`);
|
|
21439
|
+
return this.replaceOrCreateSection({
|
|
21404
21440
|
...requirements,
|
|
21405
21441
|
tools: createUseCalendarTools(requirements.tools || []),
|
|
21406
21442
|
_metadata: {
|
|
@@ -21408,16 +21444,7 @@ class UseCalendarCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21408
21444
|
useCalendar: true,
|
|
21409
21445
|
useCalendars: existingConfiguredCalendars,
|
|
21410
21446
|
},
|
|
21411
|
-
},
|
|
21412
|
-
Calendar tools:
|
|
21413
|
-
- You can inspect and manage events in configured calendars.
|
|
21414
|
-
- Supported operations include read, create, update, delete, invite guests, and reminders.
|
|
21415
|
-
- Configured calendars:
|
|
21416
|
-
${block(calendarsList)}
|
|
21417
|
-
- USE CALENDAR credentials are read from wallet records (ACCESS_TOKEN, service "${UseCalendarWallet.service}", key "${UseCalendarWallet.key}").
|
|
21418
|
-
- If credentials are missing, ask user to connect calendar credentials in host UI and/or add them to wallet.
|
|
21419
|
-
${block(extraInstructions)}
|
|
21420
|
-
`));
|
|
21447
|
+
}, 'Calendar', calendarSectionContent);
|
|
21421
21448
|
}
|
|
21422
21449
|
/**
|
|
21423
21450
|
* Gets human-readable titles for tool functions provided by this commitment.
|
|
@@ -21754,18 +21781,6 @@ async function sendEmailViaBrowser(args, agentsServerUrl) {
|
|
|
21754
21781
|
* @private internal USE EMAIL constant
|
|
21755
21782
|
*/
|
|
21756
21783
|
const SEND_EMAIL_TOOL_NAME = 'send_email';
|
|
21757
|
-
/**
|
|
21758
|
-
* Wallet service used for SMTP credentials required by USE EMAIL.
|
|
21759
|
-
*
|
|
21760
|
-
* @private internal USE EMAIL constant
|
|
21761
|
-
*/
|
|
21762
|
-
const USE_EMAIL_SMTP_WALLET_SERVICE = 'smtp';
|
|
21763
|
-
/**
|
|
21764
|
-
* Wallet key used for SMTP credentials required by USE EMAIL.
|
|
21765
|
-
*
|
|
21766
|
-
* @private internal USE EMAIL constant
|
|
21767
|
-
*/
|
|
21768
|
-
const USE_EMAIL_SMTP_WALLET_KEY = 'use-email-smtp-credentials';
|
|
21769
21784
|
/**
|
|
21770
21785
|
* USE EMAIL commitment definition.
|
|
21771
21786
|
*
|
|
@@ -21824,31 +21839,41 @@ class UseEmailCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21824
21839
|
`);
|
|
21825
21840
|
}
|
|
21826
21841
|
applyToAgentModelRequirements(requirements, content) {
|
|
21842
|
+
var _a;
|
|
21827
21843
|
const parsedCommitment = parseUseEmailCommitmentContent(content);
|
|
21828
|
-
const extraInstructions = formatOptionalInstructionBlock('Email instructions', parsedCommitment.instructions);
|
|
21829
|
-
const senderInstruction = parsedCommitment.senderEmail
|
|
21830
|
-
? `- Default sender address from commitment: "${parsedCommitment.senderEmail}".`
|
|
21831
|
-
: '';
|
|
21832
21844
|
const updatedTools = addUseEmailTools(requirements.tools || []);
|
|
21833
|
-
|
|
21845
|
+
// Collect all configured sender emails across multiple USE EMAIL commitments
|
|
21846
|
+
const existingSenders = Array.isArray((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.useEmailSenders)
|
|
21847
|
+
? [...requirements._metadata.useEmailSenders]
|
|
21848
|
+
: [];
|
|
21849
|
+
if (parsedCommitment.senderEmail && !existingSenders.includes(parsedCommitment.senderEmail)) {
|
|
21850
|
+
existingSenders.push(parsedCommitment.senderEmail);
|
|
21851
|
+
}
|
|
21852
|
+
const senderBullets = existingSenders.length > 0
|
|
21853
|
+
? existingSenders
|
|
21854
|
+
.map((email, index) => index === 0
|
|
21855
|
+
? `- Default sender address: "${email}".`
|
|
21856
|
+
: `- Additional sender address: "${email}".`)
|
|
21857
|
+
.join('\n')
|
|
21858
|
+
: '';
|
|
21859
|
+
const extraInstructions = formatOptionalInstructionBlock('Email instructions', parsedCommitment.instructions);
|
|
21860
|
+
const emailSectionContent = spaceTrim$1((block) => `
|
|
21861
|
+
## Emails
|
|
21862
|
+
|
|
21863
|
+
- Use \`${SEND_EMAIL_TOOL_NAME}\` to send outbound emails.
|
|
21864
|
+
${block(senderBullets)}
|
|
21865
|
+
${block(extraInstructions)}
|
|
21866
|
+
`);
|
|
21867
|
+
return this.replaceOrCreateSection({
|
|
21834
21868
|
...requirements,
|
|
21835
21869
|
tools: updatedTools,
|
|
21836
21870
|
_metadata: {
|
|
21837
21871
|
...requirements._metadata,
|
|
21838
21872
|
useEmail: true,
|
|
21839
21873
|
...(parsedCommitment.senderEmail ? { useEmailSender: parsedCommitment.senderEmail } : {}),
|
|
21874
|
+
useEmailSenders: existingSenders,
|
|
21840
21875
|
},
|
|
21841
|
-
},
|
|
21842
|
-
Email tool:
|
|
21843
|
-
- Use "${SEND_EMAIL_TOOL_NAME}" to send outbound emails.
|
|
21844
|
-
- Prefer \`message\` argument compatible with Promptbook \`Message\` type.
|
|
21845
|
-
- Include subject in \`message.metadata.subject\` (or use legacy \`subject\` argument).
|
|
21846
|
-
- USE EMAIL credentials are read from wallet records (ACCESS_TOKEN, service "${USE_EMAIL_SMTP_WALLET_SERVICE}", key "${USE_EMAIL_SMTP_WALLET_KEY}").
|
|
21847
|
-
- Wallet secret must contain SMTP credentials in JSON format with fields \`host\`, \`port\`, \`secure\`, \`username\`, \`password\`.
|
|
21848
|
-
- If credentials are missing, ask user to add wallet credentials.
|
|
21849
|
-
${block(senderInstruction)}
|
|
21850
|
-
${block(extraInstructions)}
|
|
21851
|
-
`));
|
|
21876
|
+
}, 'Emails', emailSectionContent);
|
|
21852
21877
|
}
|
|
21853
21878
|
/**
|
|
21854
21879
|
* Gets human-readable titles for tool functions provided by this commitment.
|
|
@@ -21884,13 +21909,13 @@ function addUseEmailTools(existingTools) {
|
|
|
21884
21909
|
...existingTools,
|
|
21885
21910
|
{
|
|
21886
21911
|
name: SEND_EMAIL_TOOL_NAME,
|
|
21887
|
-
description: 'Send an outbound email
|
|
21912
|
+
description: 'Send an outbound email.',
|
|
21888
21913
|
parameters: {
|
|
21889
21914
|
type: 'object',
|
|
21890
21915
|
properties: {
|
|
21891
21916
|
message: {
|
|
21892
21917
|
type: 'object',
|
|
21893
|
-
description: '
|
|
21918
|
+
description: 'Email payload. Use metadata.subject for the subject line.',
|
|
21894
21919
|
},
|
|
21895
21920
|
to: {
|
|
21896
21921
|
type: 'string',
|
|
@@ -21994,13 +22019,14 @@ class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21994
22019
|
useImageGenerator: content || true,
|
|
21995
22020
|
},
|
|
21996
22021
|
}, spaceTrim$1((block) => `
|
|
21997
|
-
Image generation
|
|
21998
|
-
|
|
21999
|
-
-
|
|
22000
|
-
|
|
22001
|
-
|
|
22002
|
-
-
|
|
22003
|
-
-
|
|
22022
|
+
## Image generation
|
|
22023
|
+
|
|
22024
|
+
- You do not generate images directly and you do not call any image tool.
|
|
22025
|
+
- When the user asks for an image, include markdown notation in your message:
|
|
22026
|
+
\`\`
|
|
22027
|
+
- Keep \`<alt text>\` short and descriptive.
|
|
22028
|
+
- Keep \`<prompt>\` detailed so the generated image matches the request.
|
|
22029
|
+
- You can include normal explanatory text before and after the notation.
|
|
22004
22030
|
${block(extraInstructions)}
|
|
22005
22031
|
`));
|
|
22006
22032
|
}
|
|
@@ -22180,11 +22206,12 @@ class UsePopupCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
22180
22206
|
usePopup: content || true,
|
|
22181
22207
|
},
|
|
22182
22208
|
}, spaceTrim$1((block) => `
|
|
22183
|
-
|
|
22184
|
-
|
|
22185
|
-
-
|
|
22209
|
+
## Popup
|
|
22210
|
+
|
|
22211
|
+
- You can open a popup window with a specific URL using the tool \`open_popup\`.
|
|
22212
|
+
- Use this when you want the user to see or interact with a specific website.
|
|
22186
22213
|
${block(extraInstructions)}
|
|
22187
|
-
|
|
22214
|
+
`));
|
|
22188
22215
|
}
|
|
22189
22216
|
/**
|
|
22190
22217
|
* Gets human-readable titles for tool functions provided by this commitment.
|
|
@@ -22358,11 +22385,12 @@ class UsePrivacyCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
22358
22385
|
usePrivacy: content || true,
|
|
22359
22386
|
},
|
|
22360
22387
|
}, spaceTrim$1((block) => `
|
|
22361
|
-
Privacy
|
|
22362
|
-
|
|
22363
|
-
-
|
|
22364
|
-
-
|
|
22365
|
-
-
|
|
22388
|
+
## Privacy
|
|
22389
|
+
|
|
22390
|
+
- Use \`${TURN_PRIVACY_ON_TOOL_NAME}\` when the user asks for a private/sensitive conversation.
|
|
22391
|
+
- This tool requests a UI confirmation dialog. Private mode is enabled only after user confirms.
|
|
22392
|
+
- Current implementation uses the existing chat private mode (no chat persistence, memory persistence, or self-learning while active).
|
|
22393
|
+
- Do not claim that end-to-end encryption is implemented yet.
|
|
22366
22394
|
${block(extraInstructions)}
|
|
22367
22395
|
`));
|
|
22368
22396
|
}
|
|
@@ -23986,9 +24014,16 @@ class UseProjectCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
23986
24014
|
}
|
|
23987
24015
|
const existingConfiguredProjects = normalizeConfiguredProjects((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.useProjects);
|
|
23988
24016
|
addConfiguredProjectIfMissing(existingConfiguredProjects, parsedCommitment.repository);
|
|
23989
|
-
const repositoriesList = existingConfiguredProjects.map((project) => `- ${project.url}`).join('\n');
|
|
23990
24017
|
const extraInstructions = formatOptionalInstructionBlock('Project instructions', parsedCommitment.instructions);
|
|
23991
|
-
|
|
24018
|
+
const sectionContent = spaceTrim$1((block) => `
|
|
24019
|
+
- You can inspect and edit configured GitHub repositories using project tools.
|
|
24020
|
+
- Configured repositories:
|
|
24021
|
+
${block(existingConfiguredProjects.map((project) => `- ${project.url}`).join('\n'))}
|
|
24022
|
+
- When a repository is not obvious from context, pass \`repository\` in tool arguments explicitly.
|
|
24023
|
+
- If credentials are missing, ask the user to connect their GitHub account in the host UI.
|
|
24024
|
+
${block(extraInstructions)}
|
|
24025
|
+
`);
|
|
24026
|
+
return this.replaceOrCreateSection({
|
|
23992
24027
|
...requirements,
|
|
23993
24028
|
tools: createUseProjectTools(requirements.tools || []),
|
|
23994
24029
|
_metadata: {
|
|
@@ -23996,16 +24031,7 @@ class UseProjectCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
23996
24031
|
useProject: true,
|
|
23997
24032
|
useProjects: existingConfiguredProjects,
|
|
23998
24033
|
},
|
|
23999
|
-
},
|
|
24000
|
-
Project tools:
|
|
24001
|
-
- You can inspect and edit configured GitHub repositories using project tools.
|
|
24002
|
-
- Configured repositories:
|
|
24003
|
-
${block(repositoriesList)}
|
|
24004
|
-
- When a repository is not obvious from context, pass "repository" in tool arguments explicitly.
|
|
24005
|
-
- USE PROJECT credentials are read from wallet records (ACCESS_TOKEN, service "${UseProjectWallet.service}", key "${UseProjectWallet.key}").
|
|
24006
|
-
- If credentials are missing, ask the user to connect credentials in host UI and/or add them to wallet.
|
|
24007
|
-
${block(extraInstructions)}
|
|
24008
|
-
`));
|
|
24034
|
+
}, 'GitHub repositories', sectionContent);
|
|
24009
24035
|
}
|
|
24010
24036
|
/**
|
|
24011
24037
|
* Gets human-readable titles for tool functions provided by this commitment.
|
|
@@ -24352,11 +24378,12 @@ class UseSpawnCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
24352
24378
|
useSpawn: content || true,
|
|
24353
24379
|
},
|
|
24354
24380
|
}, spaceTrim$1((block) => `
|
|
24355
|
-
Spawning agents
|
|
24356
|
-
|
|
24357
|
-
-
|
|
24358
|
-
-
|
|
24359
|
-
-
|
|
24381
|
+
## Spawning agents
|
|
24382
|
+
|
|
24383
|
+
- Use \`${SPAWN_AGENT_TOOL_NAME}\` only when user asks to create a persistent new agent.
|
|
24384
|
+
- Pass full agent source in \`source\`.
|
|
24385
|
+
- Keep \`source\` concise; the maximum accepted length is ${CREATE_AGENT_INPUT_SOURCE_MAX_LENGTH} characters.
|
|
24386
|
+
- Do not add unknown fields in tool arguments.
|
|
24360
24387
|
${block(extraInstructions)}
|
|
24361
24388
|
`));
|
|
24362
24389
|
}
|
|
@@ -24390,13 +24417,14 @@ class UseSpawnCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
24390
24417
|
*/
|
|
24391
24418
|
function createTimeoutSystemMessage(extraInstructions) {
|
|
24392
24419
|
return spaceTrim$1((block) => `
|
|
24393
|
-
Timeout scheduling
|
|
24394
|
-
|
|
24395
|
-
-
|
|
24396
|
-
-
|
|
24397
|
-
-
|
|
24398
|
-
-
|
|
24399
|
-
-
|
|
24420
|
+
## Timeout scheduling
|
|
24421
|
+
|
|
24422
|
+
- Use \`set_timeout\` to wake this same chat thread in the future.
|
|
24423
|
+
- Use \`list_timeouts\` to review timeout ids/details across all chats for the same user+agent scope.
|
|
24424
|
+
- \`cancel_timeout\` accepts either one timeout id or \`allActive: true\` to cancel all active timeouts in this same user+agent scope.
|
|
24425
|
+
- Use \`update_timeout\` to pause/resume, edit next run, edit recurrence, or update timeout payload details.
|
|
24426
|
+
- 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\`.
|
|
24427
|
+
- Do not claim a timer was set or cancelled unless the tool confirms it.
|
|
24400
24428
|
${block(extraInstructions)}
|
|
24401
24429
|
`);
|
|
24402
24430
|
}
|
|
@@ -25496,10 +25524,11 @@ class UseUserLocationCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
25496
25524
|
useUserLocation: content || true,
|
|
25497
25525
|
},
|
|
25498
25526
|
}, spaceTrim$1((block) => `
|
|
25499
|
-
User location
|
|
25500
|
-
|
|
25501
|
-
-
|
|
25502
|
-
-
|
|
25527
|
+
## User location
|
|
25528
|
+
|
|
25529
|
+
- Use \`${GET_USER_LOCATION_TOOL_NAME}\` only when location is needed for a better answer.
|
|
25530
|
+
- If the tool returns "unavailable" or "permission-denied", ask user to share location or provide city manually.
|
|
25531
|
+
- Do not invent coordinates or local facts when location is unavailable.
|
|
25503
25532
|
${block(extraInstructions)}
|
|
25504
25533
|
`));
|
|
25505
25534
|
}
|
|
@@ -29740,7 +29769,7 @@ function createExampleInteractionsContent(parseResult, samples) {
|
|
|
29740
29769
|
if (examples.length === 0) {
|
|
29741
29770
|
return null;
|
|
29742
29771
|
}
|
|
29743
|
-
return
|
|
29772
|
+
return `## Sample of communication with the agent:\n\n${examples.join('\n\n')}`;
|
|
29744
29773
|
}
|
|
29745
29774
|
/**
|
|
29746
29775
|
* Collects the individual lines used in the example interaction section.
|
|
@@ -29756,11 +29785,11 @@ function collectExampleInteractionLines(parseResult, samples) {
|
|
|
29756
29785
|
const examples = [];
|
|
29757
29786
|
const initialMessage = (_a = parseResult.commitments.find((commitment) => commitment.type === 'INITIAL MESSAGE')) === null || _a === void 0 ? void 0 : _a.content;
|
|
29758
29787
|
if (initialMessage) {
|
|
29759
|
-
examples.push(
|
|
29788
|
+
examples.push(`**Agent:**\n${initialMessage}`);
|
|
29760
29789
|
}
|
|
29761
29790
|
if (samples && samples.length > 0) {
|
|
29762
29791
|
for (const sample of samples) {
|
|
29763
|
-
examples.push(
|
|
29792
|
+
examples.push(`**User:** ${sample.question}\n\n**Agent:**\n${sample.answer}`);
|
|
29764
29793
|
}
|
|
29765
29794
|
}
|
|
29766
29795
|
return examples;
|
|
@@ -34308,8 +34337,8 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
34308
34337
|
* Prepares an AgentKit agent with optional knowledge sources and tool definitions.
|
|
34309
34338
|
*/
|
|
34310
34339
|
async prepareAgentKitAgent(options) {
|
|
34311
|
-
var _a, _b;
|
|
34312
|
-
const { name, instructions, knowledgeSources, tools, vectorStoreId: cachedVectorStoreId, storeAsPrepared, } = options;
|
|
34340
|
+
var _a, _b, _c;
|
|
34341
|
+
const { name, instructions, knowledgeSources, tools, nativeAgentKitTools, vectorStoreId: cachedVectorStoreId, storeAsPrepared, } = options;
|
|
34313
34342
|
await this.ensureAgentKitDefaults();
|
|
34314
34343
|
if (this.options.isVerbose) {
|
|
34315
34344
|
console.info('[🤰]', 'Preparing OpenAI AgentKit agent', {
|
|
@@ -34317,6 +34346,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
34317
34346
|
instructionsLength: instructions.length,
|
|
34318
34347
|
knowledgeSourcesCount: (_a = knowledgeSources === null || knowledgeSources === void 0 ? void 0 : knowledgeSources.length) !== null && _a !== void 0 ? _a : 0,
|
|
34319
34348
|
toolsCount: (_b = tools === null || tools === void 0 ? void 0 : tools.length) !== null && _b !== void 0 ? _b : 0,
|
|
34349
|
+
nativeAgentKitToolsCount: (_c = nativeAgentKitTools === null || nativeAgentKitTools === void 0 ? void 0 : nativeAgentKitTools.length) !== null && _c !== void 0 ? _c : 0,
|
|
34320
34350
|
});
|
|
34321
34351
|
}
|
|
34322
34352
|
let vectorStoreId = cachedVectorStoreId;
|
|
@@ -34335,7 +34365,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
34335
34365
|
vectorStoreId,
|
|
34336
34366
|
});
|
|
34337
34367
|
}
|
|
34338
|
-
const agentKitTools = this.buildAgentKitTools({ tools, vectorStoreId });
|
|
34368
|
+
const agentKitTools = this.buildAgentKitTools({ tools, nativeAgentKitTools, vectorStoreId });
|
|
34339
34369
|
const openAiAgentKitAgent = new Agent$1({
|
|
34340
34370
|
name,
|
|
34341
34371
|
model: this.agentKitModelName,
|
|
@@ -34374,11 +34404,14 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
34374
34404
|
* Builds the tool list for AgentKit, including hosted file search when applicable.
|
|
34375
34405
|
*/
|
|
34376
34406
|
buildAgentKitTools(options) {
|
|
34377
|
-
const { tools, vectorStoreId } = options;
|
|
34407
|
+
const { tools, nativeAgentKitTools, vectorStoreId } = options;
|
|
34378
34408
|
const agentKitTools = [];
|
|
34379
34409
|
if (vectorStoreId) {
|
|
34380
34410
|
agentKitTools.push(fileSearchTool(vectorStoreId));
|
|
34381
34411
|
}
|
|
34412
|
+
if (nativeAgentKitTools && nativeAgentKitTools.length > 0) {
|
|
34413
|
+
agentKitTools.push(...nativeAgentKitTools);
|
|
34414
|
+
}
|
|
34382
34415
|
if (tools && tools.length > 0) {
|
|
34383
34416
|
let scriptTools = null;
|
|
34384
34417
|
for (const toolDefinition of tools) {
|