@promptbook/core 0.112.0-61 → 0.112.0-63
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 +844 -43
- package/esm/index.es.js.map +1 -1
- package/esm/src/_packages/components.index.d.ts +4 -0
- package/esm/src/_packages/core.index.d.ts +2 -0
- package/esm/src/_packages/types.index.d.ts +2 -0
- package/esm/src/book-components/Chat/Chat/TeamToolCallModalContent.d.ts +0 -2
- package/esm/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.d.ts +7 -1
- package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +1 -1
- package/esm/src/book-components/Chat/Chat/useChatInputAreaDictation.d.ts +2 -2
- package/esm/src/book-components/Chat/hooks/useChatAutoScroll.d.ts +6 -3
- package/esm/src/book-components/Chat/types/ChatMessage.d.ts +34 -0
- package/esm/src/cli/cli-commands/agent/agentProjectPaths.d.ts +54 -0
- package/esm/src/cli/cli-commands/agent/agentRunCliOptions.d.ts +13 -0
- package/esm/src/cli/cli-commands/agent/init.d.ts +10 -0
- package/esm/src/cli/cli-commands/agent/initializeAgentProjectConfiguration.d.ts +21 -0
- package/esm/src/cli/cli-commands/agent/printAgentInitializationSummary.d.ts +7 -0
- package/esm/src/cli/cli-commands/agent/run.d.ts +10 -0
- package/esm/src/cli/cli-commands/agent/run.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/agent/tick.d.ts +10 -0
- package/esm/src/cli/cli-commands/agent.d.ts +15 -0
- package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +86 -0
- package/esm/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +11 -0
- package/esm/src/commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts +1 -0
- package/esm/src/commitments/_common/toolRuntimeContext.d.ts +6 -0
- package/esm/src/commitments/index.d.ts +2 -1
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +4 -2
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +9 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -1
- package/umd/index.umd.js +844 -42
- package/umd/index.umd.js.map +1 -1
- package/umd/src/_packages/components.index.d.ts +4 -0
- package/umd/src/_packages/core.index.d.ts +2 -0
- package/umd/src/_packages/types.index.d.ts +2 -0
- package/umd/src/book-components/Chat/Chat/TeamToolCallModalContent.d.ts +0 -2
- package/umd/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.d.ts +7 -1
- package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +1 -1
- package/umd/src/book-components/Chat/Chat/useChatInputAreaDictation.d.ts +2 -2
- package/umd/src/book-components/Chat/hooks/useChatAutoScroll.d.ts +6 -3
- package/umd/src/book-components/Chat/types/ChatMessage.d.ts +34 -0
- package/umd/src/cli/cli-commands/agent/agentProjectPaths.d.ts +54 -0
- package/umd/src/cli/cli-commands/agent/agentRunCliOptions.d.ts +13 -0
- package/umd/src/cli/cli-commands/agent/init.d.ts +10 -0
- package/umd/src/cli/cli-commands/agent/initializeAgentProjectConfiguration.d.ts +21 -0
- package/umd/src/cli/cli-commands/agent/printAgentInitializationSummary.d.ts +7 -0
- package/umd/src/cli/cli-commands/agent/run.d.ts +10 -0
- package/umd/src/cli/cli-commands/agent/run.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/agent/tick.d.ts +10 -0
- package/umd/src/cli/cli-commands/agent.d.ts +15 -0
- package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +86 -0
- package/umd/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +11 -0
- package/umd/src/commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts +1 -0
- package/umd/src/commitments/_common/toolRuntimeContext.d.ts +6 -0
- package/umd/src/commitments/index.d.ts +2 -1
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +4 -2
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +9 -0
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-63';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -12088,6 +12088,18 @@ function parseDataUrlKnowledgeSource(source) {
|
|
|
12088
12088
|
}
|
|
12089
12089
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
12090
12090
|
|
|
12091
|
+
/**
|
|
12092
|
+
* Name of the tool used by agents to search configured `KNOWLEDGE` sources.
|
|
12093
|
+
*
|
|
12094
|
+
* @public exported from `@promptbook/core`
|
|
12095
|
+
*/
|
|
12096
|
+
const KNOWLEDGE_SEARCH_TOOL_NAME = 'knowledge_search';
|
|
12097
|
+
/**
|
|
12098
|
+
* Title of the system-message section generated for `KNOWLEDGE` commitments.
|
|
12099
|
+
*
|
|
12100
|
+
* @private constant of `KnowledgeCommitmentDefinition`
|
|
12101
|
+
*/
|
|
12102
|
+
const KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE = 'Knowledge Search';
|
|
12091
12103
|
/**
|
|
12092
12104
|
* KNOWLEDGE commitment definition
|
|
12093
12105
|
*
|
|
@@ -12209,9 +12221,17 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
12209
12221
|
knowledgeInfoEntries.push(`Knowledge Source Inline: ${inlineSource.filename} (derived from inline content and processed for retrieval during chat)`);
|
|
12210
12222
|
}
|
|
12211
12223
|
if (knowledgeInfoEntries.length === 0) {
|
|
12212
|
-
return nextRequirements;
|
|
12224
|
+
return addKnowledgeSearchToolAndSystemSection(nextRequirements);
|
|
12213
12225
|
}
|
|
12214
|
-
return
|
|
12226
|
+
return addKnowledgeSearchToolAndSystemSection(nextRequirements);
|
|
12227
|
+
}
|
|
12228
|
+
/**
|
|
12229
|
+
* Gets human-readable titles for tool functions provided by this commitment.
|
|
12230
|
+
*/
|
|
12231
|
+
getToolTitles() {
|
|
12232
|
+
return {
|
|
12233
|
+
[KNOWLEDGE_SEARCH_TOOL_NAME]: 'Knowledge search',
|
|
12234
|
+
};
|
|
12215
12235
|
}
|
|
12216
12236
|
}
|
|
12217
12237
|
/**
|
|
@@ -12225,6 +12245,128 @@ function hasMeaningfulNonUrlText(content, urls) {
|
|
|
12225
12245
|
const significantText = contentWithoutUrls.replace(/[\s.,!?;:'"`()[\]{}<>/-]+/g, '');
|
|
12226
12246
|
return significantText.length > 0;
|
|
12227
12247
|
}
|
|
12248
|
+
/**
|
|
12249
|
+
* Adds the shared `knowledge_search` tool definition and the consolidated system-message section.
|
|
12250
|
+
*
|
|
12251
|
+
* @param requirements - Requirements after one `KNOWLEDGE` commitment was applied.
|
|
12252
|
+
* @returns Requirements with the knowledge search instructions and tool definition.
|
|
12253
|
+
*
|
|
12254
|
+
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12255
|
+
*/
|
|
12256
|
+
function addKnowledgeSearchToolAndSystemSection(requirements) {
|
|
12257
|
+
const nextRequirements = addKnowledgeSearchTool(requirements);
|
|
12258
|
+
const section = createKnowledgeSearchSystemSection(nextRequirements);
|
|
12259
|
+
const sectionHeader = `## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}`;
|
|
12260
|
+
if (nextRequirements.systemMessage.includes(sectionHeader)) {
|
|
12261
|
+
return {
|
|
12262
|
+
...nextRequirements,
|
|
12263
|
+
systemMessage: nextRequirements.systemMessage.replace(new RegExp(`## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), section),
|
|
12264
|
+
};
|
|
12265
|
+
}
|
|
12266
|
+
return {
|
|
12267
|
+
...nextRequirements,
|
|
12268
|
+
systemMessage: nextRequirements.systemMessage.trim()
|
|
12269
|
+
? `${nextRequirements.systemMessage}\n\n${section}`
|
|
12270
|
+
: section,
|
|
12271
|
+
};
|
|
12272
|
+
}
|
|
12273
|
+
/**
|
|
12274
|
+
* Adds the `knowledge_search` model tool when it is not already present.
|
|
12275
|
+
*
|
|
12276
|
+
* @param requirements - Current model requirements.
|
|
12277
|
+
* @returns Requirements with the tool definition available to the model.
|
|
12278
|
+
*
|
|
12279
|
+
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12280
|
+
*/
|
|
12281
|
+
function addKnowledgeSearchTool(requirements) {
|
|
12282
|
+
const existingTools = requirements.tools || [];
|
|
12283
|
+
if (existingTools.some((tool) => tool.name === KNOWLEDGE_SEARCH_TOOL_NAME)) {
|
|
12284
|
+
return requirements;
|
|
12285
|
+
}
|
|
12286
|
+
return {
|
|
12287
|
+
...requirements,
|
|
12288
|
+
tools: [
|
|
12289
|
+
...existingTools,
|
|
12290
|
+
{
|
|
12291
|
+
name: KNOWLEDGE_SEARCH_TOOL_NAME,
|
|
12292
|
+
description: spaceTrim$1(`
|
|
12293
|
+
Search the agent's configured knowledge sources and return relevant excerpts with citation ids.
|
|
12294
|
+
Use this before answering questions that may depend on the agent's KNOWLEDGE commitments.
|
|
12295
|
+
`),
|
|
12296
|
+
parameters: {
|
|
12297
|
+
type: 'object',
|
|
12298
|
+
properties: {
|
|
12299
|
+
query: {
|
|
12300
|
+
type: 'string',
|
|
12301
|
+
description: 'The natural-language search query for the knowledge base.',
|
|
12302
|
+
},
|
|
12303
|
+
limit: {
|
|
12304
|
+
type: 'integer',
|
|
12305
|
+
description: 'Maximum number of matching source excerpts to return.',
|
|
12306
|
+
},
|
|
12307
|
+
},
|
|
12308
|
+
required: ['query'],
|
|
12309
|
+
},
|
|
12310
|
+
},
|
|
12311
|
+
],
|
|
12312
|
+
};
|
|
12313
|
+
}
|
|
12314
|
+
/**
|
|
12315
|
+
* Creates the model-facing system-message section for knowledge search.
|
|
12316
|
+
*
|
|
12317
|
+
* @param requirements - Current model requirements.
|
|
12318
|
+
* @returns Markdown system-message section.
|
|
12319
|
+
*
|
|
12320
|
+
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12321
|
+
*/
|
|
12322
|
+
function createKnowledgeSearchSystemSection(requirements) {
|
|
12323
|
+
const sourceEntries = createKnowledgeSourceSystemEntries(requirements);
|
|
12324
|
+
const sourceList = sourceEntries.length > 0 ? sourceEntries.map((entry) => `- ${entry}`).join('\n') : '- None';
|
|
12325
|
+
return spaceTrim$1(`
|
|
12326
|
+
## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}
|
|
12327
|
+
|
|
12328
|
+
- Use \`${KNOWLEDGE_SEARCH_TOOL_NAME}\` to search the configured knowledge sources before answering questions that depend on this agent's knowledge base.
|
|
12329
|
+
- Base source-backed factual answers on the returned excerpts.
|
|
12330
|
+
- When you use a returned excerpt, include its citation marker in the answer body, for example \`[0:0]\`.
|
|
12331
|
+
- If the search returns no relevant information, say that the knowledge base did not contain the answer instead of inventing it.
|
|
12332
|
+
|
|
12333
|
+
Configured knowledge sources:
|
|
12334
|
+
${sourceList}
|
|
12335
|
+
`);
|
|
12336
|
+
}
|
|
12337
|
+
/**
|
|
12338
|
+
* Builds a stable list of configured knowledge sources for system-message diagnostics.
|
|
12339
|
+
*
|
|
12340
|
+
* @param requirements - Current model requirements.
|
|
12341
|
+
* @returns Human-readable source entries.
|
|
12342
|
+
*
|
|
12343
|
+
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
12344
|
+
*/
|
|
12345
|
+
function createKnowledgeSourceSystemEntries(requirements) {
|
|
12346
|
+
var _a;
|
|
12347
|
+
const entries = [];
|
|
12348
|
+
const seenEntries = new Set();
|
|
12349
|
+
for (const source of requirements.knowledgeSources || []) {
|
|
12350
|
+
const entry = `Source URL: ${source} (processed for retrieval during chat)`;
|
|
12351
|
+
if (seenEntries.has(entry)) {
|
|
12352
|
+
continue;
|
|
12353
|
+
}
|
|
12354
|
+
seenEntries.add(entry);
|
|
12355
|
+
entries.push(entry);
|
|
12356
|
+
}
|
|
12357
|
+
const inlineSources = (((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.inlineKnowledgeSources) || [])
|
|
12358
|
+
.map((source) => source.filename)
|
|
12359
|
+
.filter(Boolean);
|
|
12360
|
+
for (const filename of inlineSources) {
|
|
12361
|
+
const entry = `Knowledge Source Inline: ${filename} (Inline source: processed for retrieval during chat)`;
|
|
12362
|
+
if (seenEntries.has(entry)) {
|
|
12363
|
+
continue;
|
|
12364
|
+
}
|
|
12365
|
+
seenEntries.add(entry);
|
|
12366
|
+
entries.push(entry);
|
|
12367
|
+
}
|
|
12368
|
+
return entries;
|
|
12369
|
+
}
|
|
12228
12370
|
|
|
12229
12371
|
/**
|
|
12230
12372
|
* LANGUAGE commitment definition
|
|
@@ -19802,7 +19944,7 @@ function resolveUseCalendarToolRuntime(args) {
|
|
|
19802
19944
|
const runtimeContext = (readToolRuntimeContextFromToolArgs(args) ||
|
|
19803
19945
|
{});
|
|
19804
19946
|
const configuredCalendars = normalizeConfiguredCalendars$1((_a = runtimeContext.calendars) === null || _a === void 0 ? void 0 : _a.connections);
|
|
19805
|
-
const calendarArgument = normalizeOptionalText$
|
|
19947
|
+
const calendarArgument = normalizeOptionalText$2(args.calendarUrl);
|
|
19806
19948
|
let calendarReference = null;
|
|
19807
19949
|
if (calendarArgument) {
|
|
19808
19950
|
calendarReference = parseGoogleCalendarReference(calendarArgument);
|
|
@@ -19822,7 +19964,7 @@ function resolveUseCalendarToolRuntime(args) {
|
|
|
19822
19964
|
if (!calendarReference) {
|
|
19823
19965
|
throw new Error('Calendar is required but was not resolved.');
|
|
19824
19966
|
}
|
|
19825
|
-
const accessToken = normalizeOptionalText$
|
|
19967
|
+
const accessToken = normalizeOptionalText$2((_b = runtimeContext.calendars) === null || _b === void 0 ? void 0 : _b.googleAccessToken) || '';
|
|
19826
19968
|
if (!accessToken) {
|
|
19827
19969
|
throw new CalendarWalletCredentialRequiredError({
|
|
19828
19970
|
calendarReference,
|
|
@@ -19855,7 +19997,7 @@ function normalizeConfiguredCalendars$1(rawCalendars) {
|
|
|
19855
19997
|
continue;
|
|
19856
19998
|
}
|
|
19857
19999
|
const calendar = rawCalendar;
|
|
19858
|
-
const rawUrl = normalizeOptionalText$
|
|
20000
|
+
const rawUrl = normalizeOptionalText$2(calendar.url);
|
|
19859
20001
|
if (!rawUrl) {
|
|
19860
20002
|
continue;
|
|
19861
20003
|
}
|
|
@@ -19906,7 +20048,7 @@ function createCalendarWalletCredentialRequiredResult(error) {
|
|
|
19906
20048
|
*
|
|
19907
20049
|
* @private function of resolveUseCalendarToolRuntimeOrWalletCredentialResult
|
|
19908
20050
|
*/
|
|
19909
|
-
function normalizeOptionalText$
|
|
20051
|
+
function normalizeOptionalText$2(value) {
|
|
19910
20052
|
if (typeof value !== 'string') {
|
|
19911
20053
|
return undefined;
|
|
19912
20054
|
}
|
|
@@ -19938,13 +20080,13 @@ function createUseCalendarToolFunctions() {
|
|
|
19938
20080
|
async [UseCalendarToolNames.listEvents](args) {
|
|
19939
20081
|
return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
|
|
19940
20082
|
const query = {};
|
|
19941
|
-
if (normalizeOptionalText(args.timeMin)) {
|
|
20083
|
+
if (normalizeOptionalText$1(args.timeMin)) {
|
|
19942
20084
|
query.timeMin = args.timeMin.trim();
|
|
19943
20085
|
}
|
|
19944
|
-
if (normalizeOptionalText(args.timeMax)) {
|
|
20086
|
+
if (normalizeOptionalText$1(args.timeMax)) {
|
|
19945
20087
|
query.timeMax = args.timeMax.trim();
|
|
19946
20088
|
}
|
|
19947
|
-
if (normalizeOptionalText(args.query)) {
|
|
20089
|
+
if (normalizeOptionalText$1(args.query)) {
|
|
19948
20090
|
query.q = args.query.trim();
|
|
19949
20091
|
}
|
|
19950
20092
|
if (typeof args.maxResults === 'number' && Number.isFinite(args.maxResults) && args.maxResults > 0) {
|
|
@@ -19956,7 +20098,7 @@ function createUseCalendarToolFunctions() {
|
|
|
19956
20098
|
if (args.orderBy === 'startTime' || args.orderBy === 'updated') {
|
|
19957
20099
|
query.orderBy = args.orderBy;
|
|
19958
20100
|
}
|
|
19959
|
-
if (normalizeOptionalText(args.timeZone)) {
|
|
20101
|
+
if (normalizeOptionalText$1(args.timeZone)) {
|
|
19960
20102
|
query.timeZone = args.timeZone.trim();
|
|
19961
20103
|
}
|
|
19962
20104
|
const payload = await callGoogleCalendarApi(accessToken, {
|
|
@@ -19994,11 +20136,11 @@ function createUseCalendarToolFunctions() {
|
|
|
19994
20136
|
return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
|
|
19995
20137
|
const requestBody = createGoogleCalendarEventPayload({
|
|
19996
20138
|
summary: normalizeRequiredText(args.summary, 'summary'),
|
|
19997
|
-
description: normalizeOptionalText(args.description),
|
|
19998
|
-
location: normalizeOptionalText(args.location),
|
|
20139
|
+
description: normalizeOptionalText$1(args.description),
|
|
20140
|
+
location: normalizeOptionalText$1(args.location),
|
|
19999
20141
|
start: normalizeRequiredText(args.start, 'start'),
|
|
20000
20142
|
end: normalizeRequiredText(args.end, 'end'),
|
|
20001
|
-
timeZone: normalizeOptionalText(args.timeZone),
|
|
20143
|
+
timeZone: normalizeOptionalText$1(args.timeZone),
|
|
20002
20144
|
attendees: normalizeAttendees(args.attendees),
|
|
20003
20145
|
reminderMinutes: normalizeReminderMinutes(args.reminderMinutes),
|
|
20004
20146
|
});
|
|
@@ -20020,12 +20162,12 @@ function createUseCalendarToolFunctions() {
|
|
|
20020
20162
|
return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
|
|
20021
20163
|
const eventId = normalizeRequiredText(args.eventId, 'eventId');
|
|
20022
20164
|
const requestBody = createGoogleCalendarEventPayload({
|
|
20023
|
-
summary: normalizeOptionalText(args.summary),
|
|
20024
|
-
description: normalizeOptionalText(args.description),
|
|
20025
|
-
location: normalizeOptionalText(args.location),
|
|
20026
|
-
start: normalizeOptionalText(args.start),
|
|
20027
|
-
end: normalizeOptionalText(args.end),
|
|
20028
|
-
timeZone: normalizeOptionalText(args.timeZone),
|
|
20165
|
+
summary: normalizeOptionalText$1(args.summary),
|
|
20166
|
+
description: normalizeOptionalText$1(args.description),
|
|
20167
|
+
location: normalizeOptionalText$1(args.location),
|
|
20168
|
+
start: normalizeOptionalText$1(args.start),
|
|
20169
|
+
end: normalizeOptionalText$1(args.end),
|
|
20170
|
+
timeZone: normalizeOptionalText$1(args.timeZone),
|
|
20029
20171
|
attendees: normalizeAttendees(args.attendees),
|
|
20030
20172
|
reminderMinutes: normalizeReminderMinutes(args.reminderMinutes),
|
|
20031
20173
|
});
|
|
@@ -20072,7 +20214,7 @@ function createUseCalendarToolFunctions() {
|
|
|
20072
20214
|
path: `/calendars/${encodeGoogleCalendarId(calendarReference.calendarId)}/events/${encodeURIComponent(eventId)}`,
|
|
20073
20215
|
});
|
|
20074
20216
|
const existingAttendees = ((existingEvent === null || existingEvent === void 0 ? void 0 : existingEvent.attendees) || [])
|
|
20075
|
-
.map((attendee) => normalizeOptionalText(attendee.email))
|
|
20217
|
+
.map((attendee) => normalizeOptionalText$1(attendee.email))
|
|
20076
20218
|
.filter((email) => Boolean(email));
|
|
20077
20219
|
const mergedAttendees = [...new Set([...existingAttendees, ...guests])];
|
|
20078
20220
|
const payload = await callGoogleCalendarApi(accessToken, {
|
|
@@ -20120,7 +20262,7 @@ function encodeGoogleCalendarId(calendarId) {
|
|
|
20120
20262
|
* @private function of createUseCalendarToolFunctions
|
|
20121
20263
|
*/
|
|
20122
20264
|
function normalizeRequiredText(value, fieldName) {
|
|
20123
|
-
const normalizedValue = normalizeOptionalText(value);
|
|
20265
|
+
const normalizedValue = normalizeOptionalText$1(value);
|
|
20124
20266
|
if (!normalizedValue) {
|
|
20125
20267
|
throw new Error(`Tool "${fieldName}" requires non-empty value.`);
|
|
20126
20268
|
}
|
|
@@ -20131,7 +20273,7 @@ function normalizeRequiredText(value, fieldName) {
|
|
|
20131
20273
|
*
|
|
20132
20274
|
* @private function of createUseCalendarToolFunctions
|
|
20133
20275
|
*/
|
|
20134
|
-
function normalizeOptionalText(value) {
|
|
20276
|
+
function normalizeOptionalText$1(value) {
|
|
20135
20277
|
if (typeof value !== 'string') {
|
|
20136
20278
|
return undefined;
|
|
20137
20279
|
}
|
|
@@ -24798,6 +24940,580 @@ class UseUserLocationCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
24798
24940
|
}
|
|
24799
24941
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24800
24942
|
|
|
24943
|
+
/**
|
|
24944
|
+
* Names of tools used by the WALLET commitment.
|
|
24945
|
+
*
|
|
24946
|
+
* @private constant of WalletCommitmentDefinition
|
|
24947
|
+
*/
|
|
24948
|
+
const WalletToolNames = {
|
|
24949
|
+
retrieve: 'retrieve_wallet_records',
|
|
24950
|
+
store: 'store_wallet_record',
|
|
24951
|
+
update: 'update_wallet_record',
|
|
24952
|
+
delete: 'delete_wallet_record',
|
|
24953
|
+
request: 'request_wallet_record',
|
|
24954
|
+
};
|
|
24955
|
+
|
|
24956
|
+
/**
|
|
24957
|
+
* Creates WALLET system-message instructions.
|
|
24958
|
+
*
|
|
24959
|
+
* @private function of WalletCommitmentDefinition
|
|
24960
|
+
*/
|
|
24961
|
+
function createWalletSystemMessage(extraInstructions) {
|
|
24962
|
+
return spaceTrim$1((block) => `
|
|
24963
|
+
Wallet:
|
|
24964
|
+
- Use "${WalletToolNames.retrieve}" before authenticated operations.
|
|
24965
|
+
- Use "${WalletToolNames.store}" and "${WalletToolNames.update}" to maintain credentials.
|
|
24966
|
+
- Use "${WalletToolNames.delete}" to remove invalid credentials.
|
|
24967
|
+
- Use "${WalletToolNames.request}" to request missing credentials via UI popup.
|
|
24968
|
+
- Scope records by user (\`isUserScoped\`) and/or by agent (\`isGlobal=false\`) as needed.
|
|
24969
|
+
- Never expose raw credentials in chat responses.
|
|
24970
|
+
${block(extraInstructions)}
|
|
24971
|
+
`);
|
|
24972
|
+
}
|
|
24973
|
+
|
|
24974
|
+
/**
|
|
24975
|
+
* Resolves disabled message for wallet runtime context.
|
|
24976
|
+
*
|
|
24977
|
+
* @private function of WalletCommitmentDefinition
|
|
24978
|
+
*/
|
|
24979
|
+
function resolveWalletDisabledMessage(runtimeContext) {
|
|
24980
|
+
if (runtimeContext.isPrivateMode) {
|
|
24981
|
+
return 'Wallet is disabled because private mode is active.';
|
|
24982
|
+
}
|
|
24983
|
+
if (runtimeContext.isTeamConversation) {
|
|
24984
|
+
return 'Wallet is disabled for TEAM conversations.';
|
|
24985
|
+
}
|
|
24986
|
+
if (!runtimeContext.enabled) {
|
|
24987
|
+
return 'Wallet is disabled for unauthenticated users.';
|
|
24988
|
+
}
|
|
24989
|
+
return null;
|
|
24990
|
+
}
|
|
24991
|
+
/**
|
|
24992
|
+
* Resolves runtime adapter for wallet tools or returns disabled payload when unavailable.
|
|
24993
|
+
*
|
|
24994
|
+
* @private function of WalletCommitmentDefinition
|
|
24995
|
+
*/
|
|
24996
|
+
function getWalletToolRuntimeAdapterOrDisabledResult(action, runtimeContext) {
|
|
24997
|
+
const disabledMessage = resolveWalletDisabledMessage(runtimeContext);
|
|
24998
|
+
if (disabledMessage) {
|
|
24999
|
+
return {
|
|
25000
|
+
adapter: null,
|
|
25001
|
+
disabledResult: {
|
|
25002
|
+
action,
|
|
25003
|
+
status: 'disabled',
|
|
25004
|
+
records: action === 'retrieve' ? [] : undefined,
|
|
25005
|
+
message: disabledMessage,
|
|
25006
|
+
},
|
|
25007
|
+
};
|
|
25008
|
+
}
|
|
25009
|
+
{
|
|
25010
|
+
return {
|
|
25011
|
+
adapter: null,
|
|
25012
|
+
disabledResult: {
|
|
25013
|
+
action,
|
|
25014
|
+
status: 'disabled',
|
|
25015
|
+
records: action === 'retrieve' ? [] : undefined,
|
|
25016
|
+
message: 'Wallet runtime is not available in this environment.',
|
|
25017
|
+
},
|
|
25018
|
+
};
|
|
25019
|
+
}
|
|
25020
|
+
}
|
|
25021
|
+
|
|
25022
|
+
/**
|
|
25023
|
+
* Parses store/update wallet payload.
|
|
25024
|
+
*
|
|
25025
|
+
* @private function of WalletCommitmentDefinition
|
|
25026
|
+
*/
|
|
25027
|
+
function parseWalletPayload(args) {
|
|
25028
|
+
const recordType = parseWalletRecordType(args.recordType);
|
|
25029
|
+
return {
|
|
25030
|
+
recordType,
|
|
25031
|
+
service: parseWalletService(args.service),
|
|
25032
|
+
key: parseWalletKey(args.key),
|
|
25033
|
+
isUserScoped: args.isUserScoped === true,
|
|
25034
|
+
isGlobal: args.isGlobal === true,
|
|
25035
|
+
...parseWalletSecrets({
|
|
25036
|
+
recordType,
|
|
25037
|
+
username: args.username,
|
|
25038
|
+
password: args.password,
|
|
25039
|
+
secret: args.secret,
|
|
25040
|
+
cookies: args.cookies,
|
|
25041
|
+
}),
|
|
25042
|
+
};
|
|
25043
|
+
}
|
|
25044
|
+
/**
|
|
25045
|
+
* Parses text argument and returns trimmed text when available.
|
|
25046
|
+
*
|
|
25047
|
+
* @private function of WalletCommitmentDefinition
|
|
25048
|
+
*/
|
|
25049
|
+
function normalizeOptionalText(value) {
|
|
25050
|
+
if (typeof value !== 'string') {
|
|
25051
|
+
return undefined;
|
|
25052
|
+
}
|
|
25053
|
+
const trimmed = value.trim();
|
|
25054
|
+
return trimmed || undefined;
|
|
25055
|
+
}
|
|
25056
|
+
/**
|
|
25057
|
+
* Parses wallet service argument.
|
|
25058
|
+
*
|
|
25059
|
+
* @private function of WalletCommitmentDefinition
|
|
25060
|
+
*/
|
|
25061
|
+
function parseWalletService(value) {
|
|
25062
|
+
return (normalizeOptionalText(value) || 'generic').toLowerCase();
|
|
25063
|
+
}
|
|
25064
|
+
/**
|
|
25065
|
+
* Parses wallet key argument.
|
|
25066
|
+
*
|
|
25067
|
+
* @private function of WalletCommitmentDefinition
|
|
25068
|
+
*/
|
|
25069
|
+
function parseWalletKey(value) {
|
|
25070
|
+
return normalizeOptionalText(value) || 'default';
|
|
25071
|
+
}
|
|
25072
|
+
/**
|
|
25073
|
+
* Parses one wallet record id argument.
|
|
25074
|
+
*
|
|
25075
|
+
* @private function of WalletCommitmentDefinition
|
|
25076
|
+
*/
|
|
25077
|
+
function parseWalletId(value) {
|
|
25078
|
+
const walletId = normalizeOptionalText(value);
|
|
25079
|
+
if (!walletId) {
|
|
25080
|
+
throw new Error('Wallet id is required.');
|
|
25081
|
+
}
|
|
25082
|
+
return walletId;
|
|
25083
|
+
}
|
|
25084
|
+
/**
|
|
25085
|
+
* Parses wallet record type.
|
|
25086
|
+
*
|
|
25087
|
+
* @private function of WalletCommitmentDefinition
|
|
25088
|
+
*/
|
|
25089
|
+
function parseWalletRecordType(value, fallback) {
|
|
25090
|
+
var _a;
|
|
25091
|
+
const normalizedType = (_a = normalizeOptionalText(value)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
25092
|
+
if (normalizedType === 'USERNAME_PASSWORD') {
|
|
25093
|
+
return 'USERNAME_PASSWORD';
|
|
25094
|
+
}
|
|
25095
|
+
if (normalizedType === 'SESSION_COOKIE') {
|
|
25096
|
+
return 'SESSION_COOKIE';
|
|
25097
|
+
}
|
|
25098
|
+
if (normalizedType === 'ACCESS_TOKEN') {
|
|
25099
|
+
return 'ACCESS_TOKEN';
|
|
25100
|
+
}
|
|
25101
|
+
if (fallback) {
|
|
25102
|
+
return fallback;
|
|
25103
|
+
}
|
|
25104
|
+
throw new Error('Unsupported wallet recordType. Expected one of: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.');
|
|
25105
|
+
}
|
|
25106
|
+
/**
|
|
25107
|
+
* Parses wallet secret fields according to record type.
|
|
25108
|
+
*
|
|
25109
|
+
* @private function of WalletCommitmentDefinition
|
|
25110
|
+
*/
|
|
25111
|
+
function parseWalletSecrets(args) {
|
|
25112
|
+
const username = normalizeOptionalText(args.username);
|
|
25113
|
+
const password = normalizeOptionalText(args.password);
|
|
25114
|
+
const secret = normalizeOptionalText(args.secret);
|
|
25115
|
+
const cookies = normalizeOptionalText(args.cookies);
|
|
25116
|
+
if (args.recordType === 'USERNAME_PASSWORD') {
|
|
25117
|
+
if (!username || !password) {
|
|
25118
|
+
throw new Error('Both username and password are required for USERNAME_PASSWORD.');
|
|
25119
|
+
}
|
|
25120
|
+
return { username, password };
|
|
25121
|
+
}
|
|
25122
|
+
if (args.recordType === 'SESSION_COOKIE') {
|
|
25123
|
+
if (!cookies) {
|
|
25124
|
+
throw new Error('Cookies are required for SESSION_COOKIE.');
|
|
25125
|
+
}
|
|
25126
|
+
return { cookies };
|
|
25127
|
+
}
|
|
25128
|
+
if (!secret) {
|
|
25129
|
+
throw new Error('Secret is required for ACCESS_TOKEN.');
|
|
25130
|
+
}
|
|
25131
|
+
return { secret };
|
|
25132
|
+
}
|
|
25133
|
+
/**
|
|
25134
|
+
* Collection of WALLET tool argument parsers.
|
|
25135
|
+
*
|
|
25136
|
+
* @private function of WalletCommitmentDefinition
|
|
25137
|
+
*/
|
|
25138
|
+
const parseWalletToolArgs = {
|
|
25139
|
+
/**
|
|
25140
|
+
* Parses retrieve arguments.
|
|
25141
|
+
*/
|
|
25142
|
+
retrieve(args) {
|
|
25143
|
+
const limit = typeof args.limit === 'number' && Number.isFinite(args.limit) ? Math.floor(args.limit) : undefined;
|
|
25144
|
+
return {
|
|
25145
|
+
query: normalizeOptionalText(args.query),
|
|
25146
|
+
recordType: normalizeOptionalText(args.recordType) ? parseWalletRecordType(args.recordType) : undefined,
|
|
25147
|
+
service: normalizeOptionalText(args.service) ? parseWalletService(args.service) : undefined,
|
|
25148
|
+
key: normalizeOptionalText(args.key) ? parseWalletKey(args.key) : undefined,
|
|
25149
|
+
limit: limit && limit > 0 ? Math.min(limit, 20) : undefined,
|
|
25150
|
+
};
|
|
25151
|
+
},
|
|
25152
|
+
/**
|
|
25153
|
+
* Parses store payload.
|
|
25154
|
+
*/
|
|
25155
|
+
store(args) {
|
|
25156
|
+
return parseWalletPayload(args);
|
|
25157
|
+
},
|
|
25158
|
+
/**
|
|
25159
|
+
* Parses update payload.
|
|
25160
|
+
*/
|
|
25161
|
+
update(args) {
|
|
25162
|
+
const walletId = parseWalletId(args.walletId);
|
|
25163
|
+
const record = parseWalletPayload(args);
|
|
25164
|
+
return {
|
|
25165
|
+
...record,
|
|
25166
|
+
walletId,
|
|
25167
|
+
};
|
|
25168
|
+
},
|
|
25169
|
+
/**
|
|
25170
|
+
* Parses delete payload.
|
|
25171
|
+
*/
|
|
25172
|
+
delete(args) {
|
|
25173
|
+
return { walletId: parseWalletId(args.walletId) };
|
|
25174
|
+
},
|
|
25175
|
+
/**
|
|
25176
|
+
* Parses request payload for user wallet input prompt.
|
|
25177
|
+
*/
|
|
25178
|
+
request(args) {
|
|
25179
|
+
return {
|
|
25180
|
+
recordType: parseWalletRecordType(args.recordType, 'ACCESS_TOKEN'),
|
|
25181
|
+
service: parseWalletService(args.service),
|
|
25182
|
+
key: parseWalletKey(args.key),
|
|
25183
|
+
message: normalizeOptionalText(args.message),
|
|
25184
|
+
isUserScoped: args.isUserScoped === true,
|
|
25185
|
+
isGlobal: args.isGlobal === true,
|
|
25186
|
+
};
|
|
25187
|
+
},
|
|
25188
|
+
};
|
|
25189
|
+
|
|
25190
|
+
/**
|
|
25191
|
+
* Resolves runtime context from hidden tool arguments.
|
|
25192
|
+
*
|
|
25193
|
+
* @private function of WalletCommitmentDefinition
|
|
25194
|
+
*/
|
|
25195
|
+
function resolveWalletRuntimeContext(args) {
|
|
25196
|
+
const runtimeContext = readToolRuntimeContextFromToolArgs(args);
|
|
25197
|
+
const memoryContext = runtimeContext === null || runtimeContext === void 0 ? void 0 : runtimeContext.memory;
|
|
25198
|
+
return {
|
|
25199
|
+
enabled: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.enabled) === true,
|
|
25200
|
+
userId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.userId,
|
|
25201
|
+
username: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.username,
|
|
25202
|
+
agentId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentId,
|
|
25203
|
+
agentName: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentName,
|
|
25204
|
+
isTeamConversation: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isTeamConversation) === true,
|
|
25205
|
+
isPrivateMode: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isPrivateMode) === true,
|
|
25206
|
+
};
|
|
25207
|
+
}
|
|
25208
|
+
|
|
25209
|
+
/**
|
|
25210
|
+
* Creates runtime wallet tool function implementations.
|
|
25211
|
+
*
|
|
25212
|
+
* @private function of WalletCommitmentDefinition
|
|
25213
|
+
*/
|
|
25214
|
+
function createWalletToolFunctions() {
|
|
25215
|
+
return {
|
|
25216
|
+
async [WalletToolNames.retrieve](args) {
|
|
25217
|
+
const runtimeContext = resolveWalletRuntimeContext(args);
|
|
25218
|
+
const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('retrieve', runtimeContext);
|
|
25219
|
+
if (!adapter || disabledResult) {
|
|
25220
|
+
return JSON.stringify(disabledResult);
|
|
25221
|
+
}
|
|
25222
|
+
try {
|
|
25223
|
+
const parsedArgs = parseWalletToolArgs.retrieve(args);
|
|
25224
|
+
const records = await adapter.retrieveWalletRecords(parsedArgs, runtimeContext);
|
|
25225
|
+
return JSON.stringify({
|
|
25226
|
+
action: 'retrieve',
|
|
25227
|
+
status: 'ok',
|
|
25228
|
+
query: parsedArgs.query,
|
|
25229
|
+
records,
|
|
25230
|
+
});
|
|
25231
|
+
}
|
|
25232
|
+
catch (error) {
|
|
25233
|
+
return JSON.stringify({
|
|
25234
|
+
action: 'retrieve',
|
|
25235
|
+
status: 'error',
|
|
25236
|
+
records: [],
|
|
25237
|
+
message: error instanceof Error ? error.message : String(error),
|
|
25238
|
+
});
|
|
25239
|
+
}
|
|
25240
|
+
},
|
|
25241
|
+
async [WalletToolNames.store](args) {
|
|
25242
|
+
const runtimeContext = resolveWalletRuntimeContext(args);
|
|
25243
|
+
const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('store', runtimeContext);
|
|
25244
|
+
if (!adapter || disabledResult) {
|
|
25245
|
+
return JSON.stringify(disabledResult);
|
|
25246
|
+
}
|
|
25247
|
+
try {
|
|
25248
|
+
const parsedArgs = parseWalletToolArgs.store(args);
|
|
25249
|
+
const record = await adapter.storeWalletRecord(parsedArgs, runtimeContext);
|
|
25250
|
+
return JSON.stringify({
|
|
25251
|
+
action: 'store',
|
|
25252
|
+
status: 'stored',
|
|
25253
|
+
record,
|
|
25254
|
+
});
|
|
25255
|
+
}
|
|
25256
|
+
catch (error) {
|
|
25257
|
+
return JSON.stringify({
|
|
25258
|
+
action: 'store',
|
|
25259
|
+
status: 'error',
|
|
25260
|
+
message: error instanceof Error ? error.message : String(error),
|
|
25261
|
+
});
|
|
25262
|
+
}
|
|
25263
|
+
},
|
|
25264
|
+
async [WalletToolNames.update](args) {
|
|
25265
|
+
const runtimeContext = resolveWalletRuntimeContext(args);
|
|
25266
|
+
const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
|
|
25267
|
+
if (!adapter || disabledResult) {
|
|
25268
|
+
return JSON.stringify(disabledResult);
|
|
25269
|
+
}
|
|
25270
|
+
try {
|
|
25271
|
+
const parsedArgs = parseWalletToolArgs.update(args);
|
|
25272
|
+
const record = await adapter.updateWalletRecord(parsedArgs, runtimeContext);
|
|
25273
|
+
return JSON.stringify({
|
|
25274
|
+
action: 'update',
|
|
25275
|
+
status: 'updated',
|
|
25276
|
+
record,
|
|
25277
|
+
});
|
|
25278
|
+
}
|
|
25279
|
+
catch (error) {
|
|
25280
|
+
return JSON.stringify({
|
|
25281
|
+
action: 'update',
|
|
25282
|
+
status: 'error',
|
|
25283
|
+
message: error instanceof Error ? error.message : String(error),
|
|
25284
|
+
});
|
|
25285
|
+
}
|
|
25286
|
+
},
|
|
25287
|
+
async [WalletToolNames.delete](args) {
|
|
25288
|
+
const runtimeContext = resolveWalletRuntimeContext(args);
|
|
25289
|
+
const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('delete', runtimeContext);
|
|
25290
|
+
if (!adapter || disabledResult) {
|
|
25291
|
+
return JSON.stringify(disabledResult);
|
|
25292
|
+
}
|
|
25293
|
+
try {
|
|
25294
|
+
const parsedArgs = parseWalletToolArgs.delete(args);
|
|
25295
|
+
const deleted = await adapter.deleteWalletRecord(parsedArgs, runtimeContext);
|
|
25296
|
+
return JSON.stringify({
|
|
25297
|
+
action: 'delete',
|
|
25298
|
+
status: 'deleted',
|
|
25299
|
+
walletId: deleted.id,
|
|
25300
|
+
});
|
|
25301
|
+
}
|
|
25302
|
+
catch (error) {
|
|
25303
|
+
return JSON.stringify({
|
|
25304
|
+
action: 'delete',
|
|
25305
|
+
status: 'error',
|
|
25306
|
+
message: error instanceof Error ? error.message : String(error),
|
|
25307
|
+
});
|
|
25308
|
+
}
|
|
25309
|
+
},
|
|
25310
|
+
async [WalletToolNames.request](args) {
|
|
25311
|
+
const runtimeContext = resolveWalletRuntimeContext(args);
|
|
25312
|
+
const disabledMessage = resolveWalletDisabledMessage(runtimeContext);
|
|
25313
|
+
if (disabledMessage) {
|
|
25314
|
+
return JSON.stringify({
|
|
25315
|
+
action: 'request',
|
|
25316
|
+
status: 'disabled',
|
|
25317
|
+
message: disabledMessage,
|
|
25318
|
+
});
|
|
25319
|
+
}
|
|
25320
|
+
const request = parseWalletToolArgs.request(args);
|
|
25321
|
+
return JSON.stringify({
|
|
25322
|
+
action: 'request',
|
|
25323
|
+
status: 'requested',
|
|
25324
|
+
request,
|
|
25325
|
+
message: request.message ||
|
|
25326
|
+
`Request user to provide ${request.recordType} credentials for service "${request.service}".`,
|
|
25327
|
+
});
|
|
25328
|
+
},
|
|
25329
|
+
};
|
|
25330
|
+
}
|
|
25331
|
+
|
|
25332
|
+
/**
|
|
25333
|
+
* Creates tool definitions required by WALLET commitment.
|
|
25334
|
+
*
|
|
25335
|
+
* @private function of WalletCommitmentDefinition
|
|
25336
|
+
*/
|
|
25337
|
+
function createWalletTools(existingTools) {
|
|
25338
|
+
const tools = [...(existingTools || [])];
|
|
25339
|
+
addWalletToolIfMissing(tools, {
|
|
25340
|
+
name: WalletToolNames.retrieve,
|
|
25341
|
+
description: 'Retrieve wallet records relevant to the current task.',
|
|
25342
|
+
parameters: {
|
|
25343
|
+
type: 'object',
|
|
25344
|
+
properties: {
|
|
25345
|
+
query: { type: 'string', description: 'Optional text query used to filter wallet records.' },
|
|
25346
|
+
recordType: {
|
|
25347
|
+
type: 'string',
|
|
25348
|
+
description: 'Optional record type filter (USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN).',
|
|
25349
|
+
},
|
|
25350
|
+
service: { type: 'string', description: 'Optional service filter, for example github.' },
|
|
25351
|
+
key: { type: 'string', description: 'Optional wallet key filter.' },
|
|
25352
|
+
limit: { type: 'integer', description: 'Optional maximum number of records (default 5, max 20).' },
|
|
25353
|
+
},
|
|
25354
|
+
required: [],
|
|
25355
|
+
},
|
|
25356
|
+
});
|
|
25357
|
+
addWalletToolIfMissing(tools, {
|
|
25358
|
+
name: WalletToolNames.store,
|
|
25359
|
+
description: 'Store one wallet record.',
|
|
25360
|
+
parameters: {
|
|
25361
|
+
type: 'object',
|
|
25362
|
+
properties: {
|
|
25363
|
+
recordType: {
|
|
25364
|
+
type: 'string',
|
|
25365
|
+
description: 'Record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
|
|
25366
|
+
},
|
|
25367
|
+
service: { type: 'string', description: 'Service identifier, for example github.' },
|
|
25368
|
+
key: { type: 'string', description: 'Logical credential key.' },
|
|
25369
|
+
username: { type: 'string', description: 'Username for USERNAME_PASSWORD.' },
|
|
25370
|
+
password: { type: 'string', description: 'Password for USERNAME_PASSWORD.' },
|
|
25371
|
+
secret: { type: 'string', description: 'Token/API key for ACCESS_TOKEN.' },
|
|
25372
|
+
cookies: { type: 'string', description: 'Cookie header/json for SESSION_COOKIE.' },
|
|
25373
|
+
isUserScoped: { type: 'boolean', description: 'Set true to scope this record to current user.' },
|
|
25374
|
+
isGlobal: { type: 'boolean', description: 'Set true to make this record global.' },
|
|
25375
|
+
},
|
|
25376
|
+
required: ['recordType', 'service'],
|
|
25377
|
+
},
|
|
25378
|
+
});
|
|
25379
|
+
addWalletToolIfMissing(tools, {
|
|
25380
|
+
name: WalletToolNames.update,
|
|
25381
|
+
description: 'Update one existing wallet record.',
|
|
25382
|
+
parameters: {
|
|
25383
|
+
type: 'object',
|
|
25384
|
+
properties: {
|
|
25385
|
+
walletId: { type: 'string', description: 'Wallet record id to update.' },
|
|
25386
|
+
recordType: {
|
|
25387
|
+
type: 'string',
|
|
25388
|
+
description: 'Record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
|
|
25389
|
+
},
|
|
25390
|
+
service: { type: 'string', description: 'Service identifier, for example github.' },
|
|
25391
|
+
key: { type: 'string', description: 'Logical credential key.' },
|
|
25392
|
+
username: { type: 'string', description: 'Username for USERNAME_PASSWORD.' },
|
|
25393
|
+
password: { type: 'string', description: 'Password for USERNAME_PASSWORD.' },
|
|
25394
|
+
secret: { type: 'string', description: 'Token/API key for ACCESS_TOKEN.' },
|
|
25395
|
+
cookies: { type: 'string', description: 'Cookie header/json for SESSION_COOKIE.' },
|
|
25396
|
+
isUserScoped: { type: 'boolean', description: 'Set true to scope this record to current user.' },
|
|
25397
|
+
isGlobal: { type: 'boolean', description: 'Set true to make this record global.' },
|
|
25398
|
+
},
|
|
25399
|
+
required: ['walletId', 'recordType', 'service'],
|
|
25400
|
+
},
|
|
25401
|
+
});
|
|
25402
|
+
addWalletToolIfMissing(tools, {
|
|
25403
|
+
name: WalletToolNames.delete,
|
|
25404
|
+
description: 'Delete one wallet record.',
|
|
25405
|
+
parameters: {
|
|
25406
|
+
type: 'object',
|
|
25407
|
+
properties: {
|
|
25408
|
+
walletId: { type: 'string', description: 'Wallet record id to delete.' },
|
|
25409
|
+
},
|
|
25410
|
+
required: ['walletId'],
|
|
25411
|
+
},
|
|
25412
|
+
});
|
|
25413
|
+
addWalletToolIfMissing(tools, {
|
|
25414
|
+
name: WalletToolNames.request,
|
|
25415
|
+
description: 'Request missing credential from user via popup.',
|
|
25416
|
+
parameters: {
|
|
25417
|
+
type: 'object',
|
|
25418
|
+
properties: {
|
|
25419
|
+
recordType: {
|
|
25420
|
+
type: 'string',
|
|
25421
|
+
description: 'Requested record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
|
|
25422
|
+
},
|
|
25423
|
+
service: { type: 'string', description: 'Service identifier.' },
|
|
25424
|
+
key: { type: 'string', description: 'Logical credential key.' },
|
|
25425
|
+
message: { type: 'string', description: 'Optional UI message for user.' },
|
|
25426
|
+
isUserScoped: {
|
|
25427
|
+
type: 'boolean',
|
|
25428
|
+
description: 'Set true when record should be scoped to current user.',
|
|
25429
|
+
},
|
|
25430
|
+
isGlobal: { type: 'boolean', description: 'Set true when record should be global.' },
|
|
25431
|
+
},
|
|
25432
|
+
required: [],
|
|
25433
|
+
},
|
|
25434
|
+
});
|
|
25435
|
+
return tools;
|
|
25436
|
+
}
|
|
25437
|
+
/**
|
|
25438
|
+
* Registers one wallet tool when missing in current tool list.
|
|
25439
|
+
*
|
|
25440
|
+
* @private function of WalletCommitmentDefinition
|
|
25441
|
+
*/
|
|
25442
|
+
function addWalletToolIfMissing(tools, tool) {
|
|
25443
|
+
if (!tools.some((existingTool) => existingTool.name === tool.name)) {
|
|
25444
|
+
tools.push(tool);
|
|
25445
|
+
}
|
|
25446
|
+
}
|
|
25447
|
+
|
|
25448
|
+
/**
|
|
25449
|
+
* Gets markdown documentation for WALLET commitment.
|
|
25450
|
+
*
|
|
25451
|
+
* @private function of WalletCommitmentDefinition
|
|
25452
|
+
*/
|
|
25453
|
+
function getWalletCommitmentDocumentation(type) {
|
|
25454
|
+
return spaceTrim$1(`
|
|
25455
|
+
# ${type}
|
|
25456
|
+
|
|
25457
|
+
Enables private credential storage for tokens, usernames/passwords, and session cookies.
|
|
25458
|
+
`);
|
|
25459
|
+
}
|
|
25460
|
+
|
|
25461
|
+
/**
|
|
25462
|
+
* Gets human-readable titles for WALLET tool functions.
|
|
25463
|
+
*
|
|
25464
|
+
* @private function of WalletCommitmentDefinition
|
|
25465
|
+
*/
|
|
25466
|
+
function getWalletToolTitles() {
|
|
25467
|
+
return {
|
|
25468
|
+
[WalletToolNames.retrieve]: 'Wallet',
|
|
25469
|
+
[WalletToolNames.store]: 'Store wallet record',
|
|
25470
|
+
[WalletToolNames.update]: 'Update wallet record',
|
|
25471
|
+
[WalletToolNames.delete]: 'Delete wallet record',
|
|
25472
|
+
[WalletToolNames.request]: 'Request wallet record',
|
|
25473
|
+
};
|
|
25474
|
+
}
|
|
25475
|
+
|
|
25476
|
+
/**
|
|
25477
|
+
* WALLET commitment definition.
|
|
25478
|
+
*
|
|
25479
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
25480
|
+
*/
|
|
25481
|
+
class WalletCommitmentDefinition extends BaseCommitmentDefinition {
|
|
25482
|
+
constructor(type = 'WALLET') {
|
|
25483
|
+
super(type);
|
|
25484
|
+
}
|
|
25485
|
+
get requiresContent() {
|
|
25486
|
+
return false;
|
|
25487
|
+
}
|
|
25488
|
+
get description() {
|
|
25489
|
+
return 'Enable persistent private credential storage (tokens, logins, cookies) scoped per agent or globally.';
|
|
25490
|
+
}
|
|
25491
|
+
get icon() {
|
|
25492
|
+
return '👛';
|
|
25493
|
+
}
|
|
25494
|
+
get documentation() {
|
|
25495
|
+
return getWalletCommitmentDocumentation(this.type);
|
|
25496
|
+
}
|
|
25497
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
25498
|
+
const extraInstructions = formatOptionalInstructionBlock('Wallet instructions', content);
|
|
25499
|
+
return this.appendToSystemMessage({
|
|
25500
|
+
...requirements,
|
|
25501
|
+
tools: createWalletTools(requirements.tools),
|
|
25502
|
+
_metadata: {
|
|
25503
|
+
...requirements._metadata,
|
|
25504
|
+
useWallet: content || true,
|
|
25505
|
+
},
|
|
25506
|
+
}, createWalletSystemMessage(extraInstructions));
|
|
25507
|
+
}
|
|
25508
|
+
getToolTitles() {
|
|
25509
|
+
return getWalletToolTitles();
|
|
25510
|
+
}
|
|
25511
|
+
getToolFunctions() {
|
|
25512
|
+
return createWalletToolFunctions();
|
|
25513
|
+
}
|
|
25514
|
+
}
|
|
25515
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
25516
|
+
|
|
24801
25517
|
/**
|
|
24802
25518
|
* `WRITING RULES` commitment definition.
|
|
24803
25519
|
*
|
|
@@ -25072,6 +25788,8 @@ const COMMITMENT_REGISTRY = [
|
|
|
25072
25788
|
new MessageSuffixCommitmentDefinition(),
|
|
25073
25789
|
new MessageCommitmentDefinition('MESSAGE'),
|
|
25074
25790
|
new MessageCommitmentDefinition('MESSAGES'),
|
|
25791
|
+
new WalletCommitmentDefinition('WALLET'),
|
|
25792
|
+
new WalletCommitmentDefinition('WALLETS'),
|
|
25075
25793
|
new ScenarioCommitmentDefinition('SCENARIO'),
|
|
25076
25794
|
new ScenarioCommitmentDefinition('SCENARIOS'),
|
|
25077
25795
|
new DeleteCommitmentDefinition('DELETE'),
|
|
@@ -25910,6 +26628,12 @@ const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
|
|
|
25910
26628
|
['GOAL', 'GOAL'],
|
|
25911
26629
|
['GOALS', 'GOAL'],
|
|
25912
26630
|
]);
|
|
26631
|
+
/**
|
|
26632
|
+
* Legacy commitments that should be parsed for compatibility but ignored by the model-requirements pipeline.
|
|
26633
|
+
*
|
|
26634
|
+
* @private internal constant of `filterCommitmentsForAgentModelRequirements`
|
|
26635
|
+
*/
|
|
26636
|
+
const IGNORED_COMMITMENT_TYPES = new Set(['WALLET', 'WALLETS']);
|
|
25913
26637
|
/**
|
|
25914
26638
|
* Applies the commitment filtering rules used before commitment definitions are executed.
|
|
25915
26639
|
*
|
|
@@ -25958,6 +26682,9 @@ function filterOverwrittenCommitments(commitments) {
|
|
|
25958
26682
|
function filterDeletedCommitments(commitments) {
|
|
25959
26683
|
const filteredCommitments = [];
|
|
25960
26684
|
for (const commitment of commitments) {
|
|
26685
|
+
if (isIgnoredCommitmentType(commitment.type)) {
|
|
26686
|
+
continue;
|
|
26687
|
+
}
|
|
25961
26688
|
if (!isDeleteCommitmentType(commitment.type)) {
|
|
25962
26689
|
filteredCommitments.push(commitment);
|
|
25963
26690
|
continue;
|
|
@@ -25988,6 +26715,17 @@ function filterDeletedCommitments(commitments) {
|
|
|
25988
26715
|
function isDeleteCommitmentType(commitmentType) {
|
|
25989
26716
|
return DELETE_COMMITMENT_TYPES.has(commitmentType);
|
|
25990
26717
|
}
|
|
26718
|
+
/**
|
|
26719
|
+
* Checks whether a parsed commitment is intentionally ignored by the current model compiler.
|
|
26720
|
+
*
|
|
26721
|
+
* @param commitmentType - Commitment type to check.
|
|
26722
|
+
* @returns `true` when the commitment should not affect model requirements.
|
|
26723
|
+
*
|
|
26724
|
+
* @private internal utility of `filterDeletedCommitments`
|
|
26725
|
+
*/
|
|
26726
|
+
function isIgnoredCommitmentType(commitmentType) {
|
|
26727
|
+
return IGNORED_COMMITMENT_TYPES.has(commitmentType);
|
|
26728
|
+
}
|
|
25991
26729
|
/**
|
|
25992
26730
|
* Extracts normalized parameter names used for DELETE-like invalidation matching.
|
|
25993
26731
|
*
|
|
@@ -26586,7 +27324,6 @@ function createInheritanceCapability(content) {
|
|
|
26586
27324
|
if (isVoidPseudoAgentReference(reference)) {
|
|
26587
27325
|
label = VOID_PSEUDO_AGENT_REFERENCE; // <- {Void} label
|
|
26588
27326
|
iconName = 'ShieldAlert';
|
|
26589
|
-
return null; // <- Note: Do not show `{Void}` in capabilities, it's only used for internal logic
|
|
26590
27327
|
}
|
|
26591
27328
|
return {
|
|
26592
27329
|
type: 'inheritance',
|
|
@@ -27643,11 +28380,11 @@ async function pipelineCollectionToJson(collection) {
|
|
|
27643
28380
|
*/
|
|
27644
28381
|
const IMPORTANT_COMMITMENT_TYPE_SORT_ORDER = new Map([
|
|
27645
28382
|
['GOAL', 0],
|
|
27646
|
-
['
|
|
27647
|
-
['
|
|
27648
|
-
['
|
|
27649
|
-
['
|
|
27650
|
-
['
|
|
28383
|
+
['RULE', 1],
|
|
28384
|
+
['KNOWLEDGE', 2],
|
|
28385
|
+
['TEAM', 3],
|
|
28386
|
+
['GOALS', 4],
|
|
28387
|
+
['RULES', 5],
|
|
27651
28388
|
]);
|
|
27652
28389
|
/**
|
|
27653
28390
|
* Sort rank used when unfinished, low-level, and deprecated commitments should be grouped last.
|
|
@@ -27775,6 +28512,11 @@ function getGroupedCommitmentDefinitions() {
|
|
|
27775
28512
|
isUnfinishedLast: true,
|
|
27776
28513
|
isLowLevelLast: true,
|
|
27777
28514
|
})) {
|
|
28515
|
+
const existingGroup = findExistingCommitmentGroup(groupedCommitments, commitment);
|
|
28516
|
+
if (existingGroup) {
|
|
28517
|
+
existingGroup.aliases.push(commitment.type);
|
|
28518
|
+
continue;
|
|
28519
|
+
}
|
|
27778
28520
|
const lastGroup = groupedCommitments[groupedCommitments.length - 1];
|
|
27779
28521
|
// Check if we should group with the previous item
|
|
27780
28522
|
let shouldGroup = false;
|
|
@@ -27809,6 +28551,22 @@ function getGroupedCommitmentDefinitions() {
|
|
|
27809
28551
|
}
|
|
27810
28552
|
return $deepFreeze(groupedCommitments);
|
|
27811
28553
|
}
|
|
28554
|
+
/**
|
|
28555
|
+
* Finds an existing group for aliases that were separated from their primary commitment by priority sorting.
|
|
28556
|
+
*
|
|
28557
|
+
* @param groupedCommitments - Groups collected so far.
|
|
28558
|
+
* @param commitment - Commitment definition that may be an alias of an earlier group.
|
|
28559
|
+
* @returns Existing alias group or `null` when a new group should be created.
|
|
28560
|
+
*
|
|
28561
|
+
* @private internal utility of `getGroupedCommitmentDefinitions`
|
|
28562
|
+
*/
|
|
28563
|
+
function findExistingCommitmentGroup(groupedCommitments, commitment) {
|
|
28564
|
+
if (commitment instanceof NotYetImplementedCommitmentDefinition) {
|
|
28565
|
+
return null;
|
|
28566
|
+
}
|
|
28567
|
+
return (groupedCommitments.find((group) => !(group.primary instanceof NotYetImplementedCommitmentDefinition) &&
|
|
28568
|
+
group.primary.constructor === commitment.constructor) || null);
|
|
28569
|
+
}
|
|
27812
28570
|
|
|
27813
28571
|
/**
|
|
27814
28572
|
* Checks if a commitment type is supported
|
|
@@ -36812,8 +37570,8 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
36812
37570
|
* Prepares an AgentKit agent with optional knowledge sources and tool definitions.
|
|
36813
37571
|
*/
|
|
36814
37572
|
async prepareAgentKitAgent(options) {
|
|
36815
|
-
var _a, _b
|
|
36816
|
-
const { name, instructions, knowledgeSources, tools,
|
|
37573
|
+
var _a, _b;
|
|
37574
|
+
const { name, instructions, knowledgeSources, tools, vectorStoreId: cachedVectorStoreId, storeAsPrepared, } = options;
|
|
36817
37575
|
await this.ensureAgentKitDefaults();
|
|
36818
37576
|
if (this.options.isVerbose) {
|
|
36819
37577
|
console.info('[🤰]', 'Preparing OpenAI AgentKit agent', {
|
|
@@ -36821,11 +37579,10 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
36821
37579
|
instructionsLength: instructions.length,
|
|
36822
37580
|
knowledgeSourcesCount: (_a = knowledgeSources === null || knowledgeSources === void 0 ? void 0 : knowledgeSources.length) !== null && _a !== void 0 ? _a : 0,
|
|
36823
37581
|
toolsCount: (_b = tools === null || tools === void 0 ? void 0 : tools.length) !== null && _b !== void 0 ? _b : 0,
|
|
36824
|
-
nativeAgentKitToolsCount: (_c = nativeAgentKitTools === null || nativeAgentKitTools === void 0 ? void 0 : nativeAgentKitTools.length) !== null && _c !== void 0 ? _c : 0,
|
|
36825
37582
|
});
|
|
36826
37583
|
}
|
|
36827
37584
|
let vectorStoreId = cachedVectorStoreId;
|
|
36828
|
-
if (!vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
|
|
37585
|
+
if (this.isNativeKnowledgeSearchEnabled && !vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
|
|
36829
37586
|
const vectorStoreResult = await this.createVectorStoreWithKnowledgeSources({
|
|
36830
37587
|
client: await this.getClient(),
|
|
36831
37588
|
name,
|
|
@@ -36834,13 +37591,19 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
36834
37591
|
});
|
|
36835
37592
|
vectorStoreId = vectorStoreResult.vectorStoreId;
|
|
36836
37593
|
}
|
|
36837
|
-
else if (vectorStoreId && this.options.isVerbose) {
|
|
37594
|
+
else if (this.isNativeKnowledgeSearchEnabled && vectorStoreId && this.options.isVerbose) {
|
|
36838
37595
|
console.info('[🤰]', 'Using cached vector store for AgentKit agent', {
|
|
36839
37596
|
name,
|
|
36840
37597
|
vectorStoreId,
|
|
36841
37598
|
});
|
|
36842
37599
|
}
|
|
36843
|
-
|
|
37600
|
+
if (!this.isNativeKnowledgeSearchEnabled) {
|
|
37601
|
+
vectorStoreId = undefined;
|
|
37602
|
+
}
|
|
37603
|
+
const agentKitTools = this.buildAgentKitTools({
|
|
37604
|
+
tools,
|
|
37605
|
+
vectorStoreId,
|
|
37606
|
+
});
|
|
36844
37607
|
const openAiAgentKitAgent = new Agent$1({
|
|
36845
37608
|
name,
|
|
36846
37609
|
model: this.agentKitModelName,
|
|
@@ -36859,7 +37622,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
36859
37622
|
name,
|
|
36860
37623
|
model: this.agentKitModelName,
|
|
36861
37624
|
toolCount: agentKitTools.length,
|
|
36862
|
-
hasVectorStore: Boolean(vectorStoreId),
|
|
37625
|
+
hasVectorStore: this.isNativeKnowledgeSearchEnabled && Boolean(vectorStoreId),
|
|
36863
37626
|
});
|
|
36864
37627
|
}
|
|
36865
37628
|
return preparedAgent;
|
|
@@ -36879,14 +37642,11 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
36879
37642
|
* Builds the tool list for AgentKit, including hosted file search when applicable.
|
|
36880
37643
|
*/
|
|
36881
37644
|
buildAgentKitTools(options) {
|
|
36882
|
-
const { tools,
|
|
37645
|
+
const { tools, vectorStoreId } = options;
|
|
36883
37646
|
const agentKitTools = [];
|
|
36884
37647
|
if (vectorStoreId) {
|
|
36885
37648
|
agentKitTools.push(fileSearchTool(vectorStoreId));
|
|
36886
37649
|
}
|
|
36887
|
-
if (nativeAgentKitTools && nativeAgentKitTools.length > 0) {
|
|
36888
|
-
agentKitTools.push(...nativeAgentKitTools);
|
|
36889
|
-
}
|
|
36890
37650
|
if (tools && tools.length > 0) {
|
|
36891
37651
|
let scriptTools = null;
|
|
36892
37652
|
for (const toolDefinition of tools) {
|
|
@@ -37361,6 +38121,12 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
37361
38121
|
get agentKitOptions() {
|
|
37362
38122
|
return this.options;
|
|
37363
38123
|
}
|
|
38124
|
+
/**
|
|
38125
|
+
* Returns true when hosted OpenAI vector-store search should back `knowledgeSources`.
|
|
38126
|
+
*/
|
|
38127
|
+
get isNativeKnowledgeSearchEnabled() {
|
|
38128
|
+
return this.agentKitOptions.isNativeKnowledgeSearchEnabled !== false;
|
|
38129
|
+
}
|
|
37364
38130
|
/**
|
|
37365
38131
|
* Discriminant for type guards.
|
|
37366
38132
|
*/
|
|
@@ -41884,7 +42650,7 @@ const SDK_TRANSPILER_KNOWLEDGE_THRESHOLD = 1000;
|
|
|
41884
42650
|
*/
|
|
41885
42651
|
async function prepareSdkTranspilerContext(book, options) {
|
|
41886
42652
|
const { agentName } = await parseAgentSource(book);
|
|
41887
|
-
const
|
|
42653
|
+
const rawModelRequirements = await createAgentModelRequirements(book, undefined, undefined, undefined, {
|
|
41888
42654
|
agentReferenceResolver: options === null || options === void 0 ? void 0 : options.agentReferenceResolver,
|
|
41889
42655
|
inlineKnowledgeSourceUploader: options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader,
|
|
41890
42656
|
teammateProfileResolver: options === null || options === void 0 ? void 0 : options.teammateProfileResolver,
|
|
@@ -41894,7 +42660,12 @@ async function prepareSdkTranspilerContext(book, options) {
|
|
|
41894
42660
|
const knowledgeContent = knowledgeCommitments.map((commitment) => commitment.content.trim());
|
|
41895
42661
|
const directKnowledge = knowledgeContent.filter((content) => !isKnowledgeSourceUrl(content));
|
|
41896
42662
|
const knowledgeSources = knowledgeContent.filter((content) => isKnowledgeSourceUrl(content));
|
|
41897
|
-
const isKnowledgeHandledWithRetrieval = directKnowledge.join('\n').length > SDK_TRANSPILER_KNOWLEDGE_THRESHOLD ||
|
|
42663
|
+
const isKnowledgeHandledWithRetrieval = directKnowledge.join('\n').length > SDK_TRANSPILER_KNOWLEDGE_THRESHOLD ||
|
|
42664
|
+
knowledgeSources.length > 0 ||
|
|
42665
|
+
knowledgeCommitments.length > 0;
|
|
42666
|
+
const modelRequirements = normalizeSdkTranspilerModelRequirements(rawModelRequirements, {
|
|
42667
|
+
isKnowledgeHandledWithRetrieval,
|
|
42668
|
+
});
|
|
41898
42669
|
const transpiledTeam = createTranspiledTeamExportForContext({
|
|
41899
42670
|
agentName,
|
|
41900
42671
|
agentSource: book,
|
|
@@ -41912,6 +42683,36 @@ async function prepareSdkTranspilerContext(book, options) {
|
|
|
41912
42683
|
transpiledTeam,
|
|
41913
42684
|
};
|
|
41914
42685
|
}
|
|
42686
|
+
/**
|
|
42687
|
+
* Removes the runtime-only knowledge-search tool from SDK harnesses that provide
|
|
42688
|
+
* their own generated retrieval scaffold.
|
|
42689
|
+
*
|
|
42690
|
+
* @param modelRequirements - Raw compiled model requirements.
|
|
42691
|
+
* @param options - Knowledge handling mode selected for the generated harness.
|
|
42692
|
+
* @returns Model requirements safe to embed into a standalone SDK export.
|
|
42693
|
+
*/
|
|
42694
|
+
function normalizeSdkTranspilerModelRequirements(modelRequirements, options) {
|
|
42695
|
+
var _a;
|
|
42696
|
+
if (!options.isKnowledgeHandledWithRetrieval) {
|
|
42697
|
+
return modelRequirements;
|
|
42698
|
+
}
|
|
42699
|
+
const tools = (_a = modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.filter((tool) => tool.name !== KNOWLEDGE_SEARCH_TOOL_NAME);
|
|
42700
|
+
return {
|
|
42701
|
+
...modelRequirements,
|
|
42702
|
+
systemMessage: removeKnowledgeSearchSystemSection(modelRequirements.systemMessage),
|
|
42703
|
+
...(tools ? { tools } : {}),
|
|
42704
|
+
};
|
|
42705
|
+
}
|
|
42706
|
+
/**
|
|
42707
|
+
* Removes the generated `## Knowledge Search` instructions from SDK exports
|
|
42708
|
+
* that answer with the transpiler's native retrieval scaffold instead.
|
|
42709
|
+
*
|
|
42710
|
+
* @param systemMessage - Raw system message from compiled model requirements.
|
|
42711
|
+
* @returns System message without the runtime-only knowledge-search section.
|
|
42712
|
+
*/
|
|
42713
|
+
function removeKnowledgeSearchSystemSection(systemMessage) {
|
|
42714
|
+
return systemMessage.replace(/(?:^|\n\n)## Knowledge Search[\s\S]*?(?=\n\n##|$)/, '').trim();
|
|
42715
|
+
}
|
|
41915
42716
|
/**
|
|
41916
42717
|
* Detects whether one knowledge commitment points to a URL instead of inline text.
|
|
41917
42718
|
*
|
|
@@ -44582,5 +45383,5 @@ function $generateBookBoilerplate(options) {
|
|
|
44582
45383
|
}
|
|
44583
45384
|
// TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
44584
45385
|
|
|
44585
|
-
export { $bookTranspilersRegister, $generateBookBoilerplate, $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, API_REQUEST_TIMEOUT, AbstractFormatError, Agent, AgentCollectionInSupabase, AgentLlmExecutionTools, AgentOsTranspiler, AnthropicClaudeManagedTranspiler, AnthropicClaudeSdkTranspiler, AuthenticationError, BIG_DATASET_TRESHOLD, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, COLOR_CONSTANTS, CORE_AGENTS_SERVER, CORE_AGENTS_SERVER_WELL_KNOWN_AGENT_NAMES, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CompletionFormfactorDefinition, ConflictError, CsvFormatError, CsvFormatParser, DEFAULT_AGENTS_DIRNAME, DEFAULT_BOOK, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_CONCURRENT_UPLOADS, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_MAX_RECURSION, DEFAULT_MAX_REQUESTS_PER_MINUTE, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_SIMULATED_DURATION_MS, DEFAULT_TASK_TITLE, DatabaseError, E2BTranspiler, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FAILED_VALUE_PLACEHOLDER, FORMFACTOR_DEFINITIONS, FormattedBookInMarkdownTranspiler, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, HTTP_STATUS_CODES, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LIMITS, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_ORDERS, MODEL_TRUST_LEVELS, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NETWORK_LIMITS, NonTaskSectionTypes, NotAllowed, NotFoundError, NotYetImplementedCommitmentDefinition, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, OpenAiAgentsTranspiler, OpenAiSdkTranspiler, PADDING_LINES, PENDING_VALUE_PLACEHOLDER, PLAYGROUND_APP_ID, PROMPTBOOK_CHAT_COLOR, PROMPTBOOK_COLOR, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, PROMPTBOOK_LEGAL_ENTITY, PROMPTBOOK_LOGO_URL, PROMPTBOOK_SYNTAX_COLORS, PROMPT_PARAMETER_SELF_LEARNING_ENABLED, PUBLIC_AGENTS_SERVERS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, RESERVED_PARAMETER_NAMES, RemoteAgent, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TIME_INTERVALS, TaskTypes, TextFormatParser, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, USER_CHAT_COLOR, UnexpectedError, VirusTotalFileSecurityChecker, WrappedError, ZERO_USAGE, ZERO_VALUE, _AgentMetadata, _AgentRegistration, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OllamaMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, aboutPromptbookInformation, addUsage, appendChatAttachmentContext, appendChatAttachmentContextWithContent, book, cacheLlmTools, compilePipeline, computeAgentHash, computeCosineSimilarity, countUsage, createAgentLlmExecutionTools, createAgentModelRequirements, createBasicAgentModelRequirements, createDefaultAgentName, createEmptyAgentModelRequirements, createLlmToolsFromConfiguration, createPipelineCollectionFromJson, createPipelineCollectionFromPromise, createPipelineCollectionFromUrl, createPipelineExecutor, createPipelineSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, formatChatAttachmentContentContext, formatChatAttachmentContext, generatePlaceholderAgentProfileImageUrl, getAllCommitmentDefinitions, getAllCommitmentTypes, getAllCommitmentsToolTitles, getCommitmentDefinition, getGroupedCommitmentDefinitions, getPipelineInterface, getSingleLlmExecutionTools, identificationToPromptbookToken, isCommitmentSupported, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidBook, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, migratePipeline, normalizeAgentName, normalizeChatAttachments, padBook, parseAgentSource, parseParameters, parsePipeline, pipelineCollectionToJson, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, resolveChatAttachmentContents, unpreparePipeline, usageToHuman, usageToWorktime, validateBook, validatePipeline, validatePipelineString };
|
|
45386
|
+
export { $bookTranspilersRegister, $generateBookBoilerplate, $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, API_REQUEST_TIMEOUT, AbstractFormatError, Agent, AgentCollectionInSupabase, AgentLlmExecutionTools, AgentOsTranspiler, AnthropicClaudeManagedTranspiler, AnthropicClaudeSdkTranspiler, AuthenticationError, BIG_DATASET_TRESHOLD, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, COLOR_CONSTANTS, CORE_AGENTS_SERVER, CORE_AGENTS_SERVER_WELL_KNOWN_AGENT_NAMES, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CompletionFormfactorDefinition, ConflictError, CsvFormatError, CsvFormatParser, DEFAULT_AGENTS_DIRNAME, DEFAULT_BOOK, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_CONCURRENT_UPLOADS, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_MAX_RECURSION, DEFAULT_MAX_REQUESTS_PER_MINUTE, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_SIMULATED_DURATION_MS, DEFAULT_TASK_TITLE, DatabaseError, E2BTranspiler, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FAILED_VALUE_PLACEHOLDER, FORMFACTOR_DEFINITIONS, FormattedBookInMarkdownTranspiler, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, HTTP_STATUS_CODES, ImageGeneratorFormfactorDefinition, KNOWLEDGE_SEARCH_TOOL_NAME, KnowledgeScrapeError, LIMITS, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_ORDERS, MODEL_TRUST_LEVELS, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NETWORK_LIMITS, NonTaskSectionTypes, NotAllowed, NotFoundError, NotYetImplementedCommitmentDefinition, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, OpenAiAgentsTranspiler, OpenAiSdkTranspiler, PADDING_LINES, PENDING_VALUE_PLACEHOLDER, PLAYGROUND_APP_ID, PROMPTBOOK_CHAT_COLOR, PROMPTBOOK_COLOR, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, PROMPTBOOK_LEGAL_ENTITY, PROMPTBOOK_LOGO_URL, PROMPTBOOK_SYNTAX_COLORS, PROMPT_PARAMETER_SELF_LEARNING_ENABLED, PUBLIC_AGENTS_SERVERS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, RESERVED_PARAMETER_NAMES, RemoteAgent, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TIME_INTERVALS, TaskTypes, TextFormatParser, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, USER_CHAT_COLOR, UnexpectedError, VirusTotalFileSecurityChecker, WrappedError, ZERO_USAGE, ZERO_VALUE, _AgentMetadata, _AgentRegistration, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OllamaMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, aboutPromptbookInformation, addUsage, appendChatAttachmentContext, appendChatAttachmentContextWithContent, book, cacheLlmTools, compilePipeline, computeAgentHash, computeCosineSimilarity, countUsage, createAgentLlmExecutionTools, createAgentModelRequirements, createBasicAgentModelRequirements, createDefaultAgentName, createEmptyAgentModelRequirements, createLlmToolsFromConfiguration, createPipelineCollectionFromJson, createPipelineCollectionFromPromise, createPipelineCollectionFromUrl, createPipelineExecutor, createPipelineSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, formatChatAttachmentContentContext, formatChatAttachmentContext, generatePlaceholderAgentProfileImageUrl, getAllCommitmentDefinitions, getAllCommitmentTypes, getAllCommitmentsToolTitles, getCommitmentDefinition, getGroupedCommitmentDefinitions, getPipelineInterface, getSingleLlmExecutionTools, identificationToPromptbookToken, isCommitmentSupported, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidBook, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, migratePipeline, normalizeAgentName, normalizeChatAttachments, padBook, parseAgentSource, parseParameters, parsePipeline, pipelineCollectionToJson, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, resolveChatAttachmentContents, unpreparePipeline, usageToHuman, usageToWorktime, validateBook, validatePipeline, validatePipelineString };
|
|
44586
45387
|
//# sourceMappingURL=index.es.js.map
|