@promptbook/wizard 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 +822 -42
- 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 +3 -2
- package/umd/index.umd.js +822 -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
|
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
38
38
|
* @generated
|
|
39
39
|
* @see https://github.com/webgptorg/promptbook
|
|
40
40
|
*/
|
|
41
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
41
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-63';
|
|
42
42
|
/**
|
|
43
43
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
44
44
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -20734,6 +20734,18 @@ function countOccurrences(value, searchedChar) {
|
|
|
20734
20734
|
return count;
|
|
20735
20735
|
}
|
|
20736
20736
|
|
|
20737
|
+
/**
|
|
20738
|
+
* Name of the tool used by agents to search configured `KNOWLEDGE` sources.
|
|
20739
|
+
*
|
|
20740
|
+
* @public exported from `@promptbook/core`
|
|
20741
|
+
*/
|
|
20742
|
+
const KNOWLEDGE_SEARCH_TOOL_NAME = 'knowledge_search';
|
|
20743
|
+
/**
|
|
20744
|
+
* Title of the system-message section generated for `KNOWLEDGE` commitments.
|
|
20745
|
+
*
|
|
20746
|
+
* @private constant of `KnowledgeCommitmentDefinition`
|
|
20747
|
+
*/
|
|
20748
|
+
const KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE = 'Knowledge Search';
|
|
20737
20749
|
/**
|
|
20738
20750
|
* KNOWLEDGE commitment definition
|
|
20739
20751
|
*
|
|
@@ -20855,9 +20867,17 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
20855
20867
|
knowledgeInfoEntries.push(`Knowledge Source Inline: ${inlineSource.filename} (derived from inline content and processed for retrieval during chat)`);
|
|
20856
20868
|
}
|
|
20857
20869
|
if (knowledgeInfoEntries.length === 0) {
|
|
20858
|
-
return nextRequirements;
|
|
20870
|
+
return addKnowledgeSearchToolAndSystemSection(nextRequirements);
|
|
20859
20871
|
}
|
|
20860
|
-
return
|
|
20872
|
+
return addKnowledgeSearchToolAndSystemSection(nextRequirements);
|
|
20873
|
+
}
|
|
20874
|
+
/**
|
|
20875
|
+
* Gets human-readable titles for tool functions provided by this commitment.
|
|
20876
|
+
*/
|
|
20877
|
+
getToolTitles() {
|
|
20878
|
+
return {
|
|
20879
|
+
[KNOWLEDGE_SEARCH_TOOL_NAME]: 'Knowledge search',
|
|
20880
|
+
};
|
|
20861
20881
|
}
|
|
20862
20882
|
}
|
|
20863
20883
|
/**
|
|
@@ -20871,6 +20891,128 @@ function hasMeaningfulNonUrlText(content, urls) {
|
|
|
20871
20891
|
const significantText = contentWithoutUrls.replace(/[\s.,!?;:'"`()[\]{}<>/-]+/g, '');
|
|
20872
20892
|
return significantText.length > 0;
|
|
20873
20893
|
}
|
|
20894
|
+
/**
|
|
20895
|
+
* Adds the shared `knowledge_search` tool definition and the consolidated system-message section.
|
|
20896
|
+
*
|
|
20897
|
+
* @param requirements - Requirements after one `KNOWLEDGE` commitment was applied.
|
|
20898
|
+
* @returns Requirements with the knowledge search instructions and tool definition.
|
|
20899
|
+
*
|
|
20900
|
+
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
20901
|
+
*/
|
|
20902
|
+
function addKnowledgeSearchToolAndSystemSection(requirements) {
|
|
20903
|
+
const nextRequirements = addKnowledgeSearchTool(requirements);
|
|
20904
|
+
const section = createKnowledgeSearchSystemSection(nextRequirements);
|
|
20905
|
+
const sectionHeader = `## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}`;
|
|
20906
|
+
if (nextRequirements.systemMessage.includes(sectionHeader)) {
|
|
20907
|
+
return {
|
|
20908
|
+
...nextRequirements,
|
|
20909
|
+
systemMessage: nextRequirements.systemMessage.replace(new RegExp(`## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), section),
|
|
20910
|
+
};
|
|
20911
|
+
}
|
|
20912
|
+
return {
|
|
20913
|
+
...nextRequirements,
|
|
20914
|
+
systemMessage: nextRequirements.systemMessage.trim()
|
|
20915
|
+
? `${nextRequirements.systemMessage}\n\n${section}`
|
|
20916
|
+
: section,
|
|
20917
|
+
};
|
|
20918
|
+
}
|
|
20919
|
+
/**
|
|
20920
|
+
* Adds the `knowledge_search` model tool when it is not already present.
|
|
20921
|
+
*
|
|
20922
|
+
* @param requirements - Current model requirements.
|
|
20923
|
+
* @returns Requirements with the tool definition available to the model.
|
|
20924
|
+
*
|
|
20925
|
+
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
20926
|
+
*/
|
|
20927
|
+
function addKnowledgeSearchTool(requirements) {
|
|
20928
|
+
const existingTools = requirements.tools || [];
|
|
20929
|
+
if (existingTools.some((tool) => tool.name === KNOWLEDGE_SEARCH_TOOL_NAME)) {
|
|
20930
|
+
return requirements;
|
|
20931
|
+
}
|
|
20932
|
+
return {
|
|
20933
|
+
...requirements,
|
|
20934
|
+
tools: [
|
|
20935
|
+
...existingTools,
|
|
20936
|
+
{
|
|
20937
|
+
name: KNOWLEDGE_SEARCH_TOOL_NAME,
|
|
20938
|
+
description: spaceTrim$1(`
|
|
20939
|
+
Search the agent's configured knowledge sources and return relevant excerpts with citation ids.
|
|
20940
|
+
Use this before answering questions that may depend on the agent's KNOWLEDGE commitments.
|
|
20941
|
+
`),
|
|
20942
|
+
parameters: {
|
|
20943
|
+
type: 'object',
|
|
20944
|
+
properties: {
|
|
20945
|
+
query: {
|
|
20946
|
+
type: 'string',
|
|
20947
|
+
description: 'The natural-language search query for the knowledge base.',
|
|
20948
|
+
},
|
|
20949
|
+
limit: {
|
|
20950
|
+
type: 'integer',
|
|
20951
|
+
description: 'Maximum number of matching source excerpts to return.',
|
|
20952
|
+
},
|
|
20953
|
+
},
|
|
20954
|
+
required: ['query'],
|
|
20955
|
+
},
|
|
20956
|
+
},
|
|
20957
|
+
],
|
|
20958
|
+
};
|
|
20959
|
+
}
|
|
20960
|
+
/**
|
|
20961
|
+
* Creates the model-facing system-message section for knowledge search.
|
|
20962
|
+
*
|
|
20963
|
+
* @param requirements - Current model requirements.
|
|
20964
|
+
* @returns Markdown system-message section.
|
|
20965
|
+
*
|
|
20966
|
+
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
20967
|
+
*/
|
|
20968
|
+
function createKnowledgeSearchSystemSection(requirements) {
|
|
20969
|
+
const sourceEntries = createKnowledgeSourceSystemEntries(requirements);
|
|
20970
|
+
const sourceList = sourceEntries.length > 0 ? sourceEntries.map((entry) => `- ${entry}`).join('\n') : '- None';
|
|
20971
|
+
return spaceTrim$1(`
|
|
20972
|
+
## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}
|
|
20973
|
+
|
|
20974
|
+
- Use \`${KNOWLEDGE_SEARCH_TOOL_NAME}\` to search the configured knowledge sources before answering questions that depend on this agent's knowledge base.
|
|
20975
|
+
- Base source-backed factual answers on the returned excerpts.
|
|
20976
|
+
- When you use a returned excerpt, include its citation marker in the answer body, for example \`[0:0]\`.
|
|
20977
|
+
- If the search returns no relevant information, say that the knowledge base did not contain the answer instead of inventing it.
|
|
20978
|
+
|
|
20979
|
+
Configured knowledge sources:
|
|
20980
|
+
${sourceList}
|
|
20981
|
+
`);
|
|
20982
|
+
}
|
|
20983
|
+
/**
|
|
20984
|
+
* Builds a stable list of configured knowledge sources for system-message diagnostics.
|
|
20985
|
+
*
|
|
20986
|
+
* @param requirements - Current model requirements.
|
|
20987
|
+
* @returns Human-readable source entries.
|
|
20988
|
+
*
|
|
20989
|
+
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
20990
|
+
*/
|
|
20991
|
+
function createKnowledgeSourceSystemEntries(requirements) {
|
|
20992
|
+
var _a;
|
|
20993
|
+
const entries = [];
|
|
20994
|
+
const seenEntries = new Set();
|
|
20995
|
+
for (const source of requirements.knowledgeSources || []) {
|
|
20996
|
+
const entry = `Source URL: ${source} (processed for retrieval during chat)`;
|
|
20997
|
+
if (seenEntries.has(entry)) {
|
|
20998
|
+
continue;
|
|
20999
|
+
}
|
|
21000
|
+
seenEntries.add(entry);
|
|
21001
|
+
entries.push(entry);
|
|
21002
|
+
}
|
|
21003
|
+
const inlineSources = (((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.inlineKnowledgeSources) || [])
|
|
21004
|
+
.map((source) => source.filename)
|
|
21005
|
+
.filter(Boolean);
|
|
21006
|
+
for (const filename of inlineSources) {
|
|
21007
|
+
const entry = `Knowledge Source Inline: ${filename} (Inline source: processed for retrieval during chat)`;
|
|
21008
|
+
if (seenEntries.has(entry)) {
|
|
21009
|
+
continue;
|
|
21010
|
+
}
|
|
21011
|
+
seenEntries.add(entry);
|
|
21012
|
+
entries.push(entry);
|
|
21013
|
+
}
|
|
21014
|
+
return entries;
|
|
21015
|
+
}
|
|
20874
21016
|
|
|
20875
21017
|
/**
|
|
20876
21018
|
* LANGUAGE commitment definition
|
|
@@ -28344,7 +28486,7 @@ function resolveUseCalendarToolRuntime(args) {
|
|
|
28344
28486
|
const runtimeContext = (readToolRuntimeContextFromToolArgs(args) ||
|
|
28345
28487
|
{});
|
|
28346
28488
|
const configuredCalendars = normalizeConfiguredCalendars$1((_a = runtimeContext.calendars) === null || _a === void 0 ? void 0 : _a.connections);
|
|
28347
|
-
const calendarArgument = normalizeOptionalText$
|
|
28489
|
+
const calendarArgument = normalizeOptionalText$2(args.calendarUrl);
|
|
28348
28490
|
let calendarReference = null;
|
|
28349
28491
|
if (calendarArgument) {
|
|
28350
28492
|
calendarReference = parseGoogleCalendarReference(calendarArgument);
|
|
@@ -28364,7 +28506,7 @@ function resolveUseCalendarToolRuntime(args) {
|
|
|
28364
28506
|
if (!calendarReference) {
|
|
28365
28507
|
throw new Error('Calendar is required but was not resolved.');
|
|
28366
28508
|
}
|
|
28367
|
-
const accessToken = normalizeOptionalText$
|
|
28509
|
+
const accessToken = normalizeOptionalText$2((_b = runtimeContext.calendars) === null || _b === void 0 ? void 0 : _b.googleAccessToken) || '';
|
|
28368
28510
|
if (!accessToken) {
|
|
28369
28511
|
throw new CalendarWalletCredentialRequiredError({
|
|
28370
28512
|
calendarReference,
|
|
@@ -28397,7 +28539,7 @@ function normalizeConfiguredCalendars$1(rawCalendars) {
|
|
|
28397
28539
|
continue;
|
|
28398
28540
|
}
|
|
28399
28541
|
const calendar = rawCalendar;
|
|
28400
|
-
const rawUrl = normalizeOptionalText$
|
|
28542
|
+
const rawUrl = normalizeOptionalText$2(calendar.url);
|
|
28401
28543
|
if (!rawUrl) {
|
|
28402
28544
|
continue;
|
|
28403
28545
|
}
|
|
@@ -28448,7 +28590,7 @@ function createCalendarWalletCredentialRequiredResult(error) {
|
|
|
28448
28590
|
*
|
|
28449
28591
|
* @private function of resolveUseCalendarToolRuntimeOrWalletCredentialResult
|
|
28450
28592
|
*/
|
|
28451
|
-
function normalizeOptionalText$
|
|
28593
|
+
function normalizeOptionalText$2(value) {
|
|
28452
28594
|
if (typeof value !== 'string') {
|
|
28453
28595
|
return undefined;
|
|
28454
28596
|
}
|
|
@@ -28480,13 +28622,13 @@ function createUseCalendarToolFunctions() {
|
|
|
28480
28622
|
async [UseCalendarToolNames.listEvents](args) {
|
|
28481
28623
|
return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
|
|
28482
28624
|
const query = {};
|
|
28483
|
-
if (normalizeOptionalText(args.timeMin)) {
|
|
28625
|
+
if (normalizeOptionalText$1(args.timeMin)) {
|
|
28484
28626
|
query.timeMin = args.timeMin.trim();
|
|
28485
28627
|
}
|
|
28486
|
-
if (normalizeOptionalText(args.timeMax)) {
|
|
28628
|
+
if (normalizeOptionalText$1(args.timeMax)) {
|
|
28487
28629
|
query.timeMax = args.timeMax.trim();
|
|
28488
28630
|
}
|
|
28489
|
-
if (normalizeOptionalText(args.query)) {
|
|
28631
|
+
if (normalizeOptionalText$1(args.query)) {
|
|
28490
28632
|
query.q = args.query.trim();
|
|
28491
28633
|
}
|
|
28492
28634
|
if (typeof args.maxResults === 'number' && Number.isFinite(args.maxResults) && args.maxResults > 0) {
|
|
@@ -28498,7 +28640,7 @@ function createUseCalendarToolFunctions() {
|
|
|
28498
28640
|
if (args.orderBy === 'startTime' || args.orderBy === 'updated') {
|
|
28499
28641
|
query.orderBy = args.orderBy;
|
|
28500
28642
|
}
|
|
28501
|
-
if (normalizeOptionalText(args.timeZone)) {
|
|
28643
|
+
if (normalizeOptionalText$1(args.timeZone)) {
|
|
28502
28644
|
query.timeZone = args.timeZone.trim();
|
|
28503
28645
|
}
|
|
28504
28646
|
const payload = await callGoogleCalendarApi(accessToken, {
|
|
@@ -28536,11 +28678,11 @@ function createUseCalendarToolFunctions() {
|
|
|
28536
28678
|
return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
|
|
28537
28679
|
const requestBody = createGoogleCalendarEventPayload({
|
|
28538
28680
|
summary: normalizeRequiredText(args.summary, 'summary'),
|
|
28539
|
-
description: normalizeOptionalText(args.description),
|
|
28540
|
-
location: normalizeOptionalText(args.location),
|
|
28681
|
+
description: normalizeOptionalText$1(args.description),
|
|
28682
|
+
location: normalizeOptionalText$1(args.location),
|
|
28541
28683
|
start: normalizeRequiredText(args.start, 'start'),
|
|
28542
28684
|
end: normalizeRequiredText(args.end, 'end'),
|
|
28543
|
-
timeZone: normalizeOptionalText(args.timeZone),
|
|
28685
|
+
timeZone: normalizeOptionalText$1(args.timeZone),
|
|
28544
28686
|
attendees: normalizeAttendees(args.attendees),
|
|
28545
28687
|
reminderMinutes: normalizeReminderMinutes(args.reminderMinutes),
|
|
28546
28688
|
});
|
|
@@ -28562,12 +28704,12 @@ function createUseCalendarToolFunctions() {
|
|
|
28562
28704
|
return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
|
|
28563
28705
|
const eventId = normalizeRequiredText(args.eventId, 'eventId');
|
|
28564
28706
|
const requestBody = createGoogleCalendarEventPayload({
|
|
28565
|
-
summary: normalizeOptionalText(args.summary),
|
|
28566
|
-
description: normalizeOptionalText(args.description),
|
|
28567
|
-
location: normalizeOptionalText(args.location),
|
|
28568
|
-
start: normalizeOptionalText(args.start),
|
|
28569
|
-
end: normalizeOptionalText(args.end),
|
|
28570
|
-
timeZone: normalizeOptionalText(args.timeZone),
|
|
28707
|
+
summary: normalizeOptionalText$1(args.summary),
|
|
28708
|
+
description: normalizeOptionalText$1(args.description),
|
|
28709
|
+
location: normalizeOptionalText$1(args.location),
|
|
28710
|
+
start: normalizeOptionalText$1(args.start),
|
|
28711
|
+
end: normalizeOptionalText$1(args.end),
|
|
28712
|
+
timeZone: normalizeOptionalText$1(args.timeZone),
|
|
28571
28713
|
attendees: normalizeAttendees(args.attendees),
|
|
28572
28714
|
reminderMinutes: normalizeReminderMinutes(args.reminderMinutes),
|
|
28573
28715
|
});
|
|
@@ -28614,7 +28756,7 @@ function createUseCalendarToolFunctions() {
|
|
|
28614
28756
|
path: `/calendars/${encodeGoogleCalendarId(calendarReference.calendarId)}/events/${encodeURIComponent(eventId)}`,
|
|
28615
28757
|
});
|
|
28616
28758
|
const existingAttendees = ((existingEvent === null || existingEvent === void 0 ? void 0 : existingEvent.attendees) || [])
|
|
28617
|
-
.map((attendee) => normalizeOptionalText(attendee.email))
|
|
28759
|
+
.map((attendee) => normalizeOptionalText$1(attendee.email))
|
|
28618
28760
|
.filter((email) => Boolean(email));
|
|
28619
28761
|
const mergedAttendees = [...new Set([...existingAttendees, ...guests])];
|
|
28620
28762
|
const payload = await callGoogleCalendarApi(accessToken, {
|
|
@@ -28662,7 +28804,7 @@ function encodeGoogleCalendarId(calendarId) {
|
|
|
28662
28804
|
* @private function of createUseCalendarToolFunctions
|
|
28663
28805
|
*/
|
|
28664
28806
|
function normalizeRequiredText(value, fieldName) {
|
|
28665
|
-
const normalizedValue = normalizeOptionalText(value);
|
|
28807
|
+
const normalizedValue = normalizeOptionalText$1(value);
|
|
28666
28808
|
if (!normalizedValue) {
|
|
28667
28809
|
throw new Error(`Tool "${fieldName}" requires non-empty value.`);
|
|
28668
28810
|
}
|
|
@@ -28673,7 +28815,7 @@ function normalizeRequiredText(value, fieldName) {
|
|
|
28673
28815
|
*
|
|
28674
28816
|
* @private function of createUseCalendarToolFunctions
|
|
28675
28817
|
*/
|
|
28676
|
-
function normalizeOptionalText(value) {
|
|
28818
|
+
function normalizeOptionalText$1(value) {
|
|
28677
28819
|
if (typeof value !== 'string') {
|
|
28678
28820
|
return undefined;
|
|
28679
28821
|
}
|
|
@@ -33293,6 +33435,580 @@ class UseUserLocationCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
33293
33435
|
}
|
|
33294
33436
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
33295
33437
|
|
|
33438
|
+
/**
|
|
33439
|
+
* Names of tools used by the WALLET commitment.
|
|
33440
|
+
*
|
|
33441
|
+
* @private constant of WalletCommitmentDefinition
|
|
33442
|
+
*/
|
|
33443
|
+
const WalletToolNames = {
|
|
33444
|
+
retrieve: 'retrieve_wallet_records',
|
|
33445
|
+
store: 'store_wallet_record',
|
|
33446
|
+
update: 'update_wallet_record',
|
|
33447
|
+
delete: 'delete_wallet_record',
|
|
33448
|
+
request: 'request_wallet_record',
|
|
33449
|
+
};
|
|
33450
|
+
|
|
33451
|
+
/**
|
|
33452
|
+
* Creates WALLET system-message instructions.
|
|
33453
|
+
*
|
|
33454
|
+
* @private function of WalletCommitmentDefinition
|
|
33455
|
+
*/
|
|
33456
|
+
function createWalletSystemMessage(extraInstructions) {
|
|
33457
|
+
return spaceTrim$1((block) => `
|
|
33458
|
+
Wallet:
|
|
33459
|
+
- Use "${WalletToolNames.retrieve}" before authenticated operations.
|
|
33460
|
+
- Use "${WalletToolNames.store}" and "${WalletToolNames.update}" to maintain credentials.
|
|
33461
|
+
- Use "${WalletToolNames.delete}" to remove invalid credentials.
|
|
33462
|
+
- Use "${WalletToolNames.request}" to request missing credentials via UI popup.
|
|
33463
|
+
- Scope records by user (\`isUserScoped\`) and/or by agent (\`isGlobal=false\`) as needed.
|
|
33464
|
+
- Never expose raw credentials in chat responses.
|
|
33465
|
+
${block(extraInstructions)}
|
|
33466
|
+
`);
|
|
33467
|
+
}
|
|
33468
|
+
|
|
33469
|
+
/**
|
|
33470
|
+
* Resolves disabled message for wallet runtime context.
|
|
33471
|
+
*
|
|
33472
|
+
* @private function of WalletCommitmentDefinition
|
|
33473
|
+
*/
|
|
33474
|
+
function resolveWalletDisabledMessage(runtimeContext) {
|
|
33475
|
+
if (runtimeContext.isPrivateMode) {
|
|
33476
|
+
return 'Wallet is disabled because private mode is active.';
|
|
33477
|
+
}
|
|
33478
|
+
if (runtimeContext.isTeamConversation) {
|
|
33479
|
+
return 'Wallet is disabled for TEAM conversations.';
|
|
33480
|
+
}
|
|
33481
|
+
if (!runtimeContext.enabled) {
|
|
33482
|
+
return 'Wallet is disabled for unauthenticated users.';
|
|
33483
|
+
}
|
|
33484
|
+
return null;
|
|
33485
|
+
}
|
|
33486
|
+
/**
|
|
33487
|
+
* Resolves runtime adapter for wallet tools or returns disabled payload when unavailable.
|
|
33488
|
+
*
|
|
33489
|
+
* @private function of WalletCommitmentDefinition
|
|
33490
|
+
*/
|
|
33491
|
+
function getWalletToolRuntimeAdapterOrDisabledResult(action, runtimeContext) {
|
|
33492
|
+
const disabledMessage = resolveWalletDisabledMessage(runtimeContext);
|
|
33493
|
+
if (disabledMessage) {
|
|
33494
|
+
return {
|
|
33495
|
+
adapter: null,
|
|
33496
|
+
disabledResult: {
|
|
33497
|
+
action,
|
|
33498
|
+
status: 'disabled',
|
|
33499
|
+
records: action === 'retrieve' ? [] : undefined,
|
|
33500
|
+
message: disabledMessage,
|
|
33501
|
+
},
|
|
33502
|
+
};
|
|
33503
|
+
}
|
|
33504
|
+
{
|
|
33505
|
+
return {
|
|
33506
|
+
adapter: null,
|
|
33507
|
+
disabledResult: {
|
|
33508
|
+
action,
|
|
33509
|
+
status: 'disabled',
|
|
33510
|
+
records: action === 'retrieve' ? [] : undefined,
|
|
33511
|
+
message: 'Wallet runtime is not available in this environment.',
|
|
33512
|
+
},
|
|
33513
|
+
};
|
|
33514
|
+
}
|
|
33515
|
+
}
|
|
33516
|
+
|
|
33517
|
+
/**
|
|
33518
|
+
* Parses store/update wallet payload.
|
|
33519
|
+
*
|
|
33520
|
+
* @private function of WalletCommitmentDefinition
|
|
33521
|
+
*/
|
|
33522
|
+
function parseWalletPayload(args) {
|
|
33523
|
+
const recordType = parseWalletRecordType(args.recordType);
|
|
33524
|
+
return {
|
|
33525
|
+
recordType,
|
|
33526
|
+
service: parseWalletService(args.service),
|
|
33527
|
+
key: parseWalletKey(args.key),
|
|
33528
|
+
isUserScoped: args.isUserScoped === true,
|
|
33529
|
+
isGlobal: args.isGlobal === true,
|
|
33530
|
+
...parseWalletSecrets({
|
|
33531
|
+
recordType,
|
|
33532
|
+
username: args.username,
|
|
33533
|
+
password: args.password,
|
|
33534
|
+
secret: args.secret,
|
|
33535
|
+
cookies: args.cookies,
|
|
33536
|
+
}),
|
|
33537
|
+
};
|
|
33538
|
+
}
|
|
33539
|
+
/**
|
|
33540
|
+
* Parses text argument and returns trimmed text when available.
|
|
33541
|
+
*
|
|
33542
|
+
* @private function of WalletCommitmentDefinition
|
|
33543
|
+
*/
|
|
33544
|
+
function normalizeOptionalText(value) {
|
|
33545
|
+
if (typeof value !== 'string') {
|
|
33546
|
+
return undefined;
|
|
33547
|
+
}
|
|
33548
|
+
const trimmed = value.trim();
|
|
33549
|
+
return trimmed || undefined;
|
|
33550
|
+
}
|
|
33551
|
+
/**
|
|
33552
|
+
* Parses wallet service argument.
|
|
33553
|
+
*
|
|
33554
|
+
* @private function of WalletCommitmentDefinition
|
|
33555
|
+
*/
|
|
33556
|
+
function parseWalletService(value) {
|
|
33557
|
+
return (normalizeOptionalText(value) || 'generic').toLowerCase();
|
|
33558
|
+
}
|
|
33559
|
+
/**
|
|
33560
|
+
* Parses wallet key argument.
|
|
33561
|
+
*
|
|
33562
|
+
* @private function of WalletCommitmentDefinition
|
|
33563
|
+
*/
|
|
33564
|
+
function parseWalletKey(value) {
|
|
33565
|
+
return normalizeOptionalText(value) || 'default';
|
|
33566
|
+
}
|
|
33567
|
+
/**
|
|
33568
|
+
* Parses one wallet record id argument.
|
|
33569
|
+
*
|
|
33570
|
+
* @private function of WalletCommitmentDefinition
|
|
33571
|
+
*/
|
|
33572
|
+
function parseWalletId(value) {
|
|
33573
|
+
const walletId = normalizeOptionalText(value);
|
|
33574
|
+
if (!walletId) {
|
|
33575
|
+
throw new Error('Wallet id is required.');
|
|
33576
|
+
}
|
|
33577
|
+
return walletId;
|
|
33578
|
+
}
|
|
33579
|
+
/**
|
|
33580
|
+
* Parses wallet record type.
|
|
33581
|
+
*
|
|
33582
|
+
* @private function of WalletCommitmentDefinition
|
|
33583
|
+
*/
|
|
33584
|
+
function parseWalletRecordType(value, fallback) {
|
|
33585
|
+
var _a;
|
|
33586
|
+
const normalizedType = (_a = normalizeOptionalText(value)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
33587
|
+
if (normalizedType === 'USERNAME_PASSWORD') {
|
|
33588
|
+
return 'USERNAME_PASSWORD';
|
|
33589
|
+
}
|
|
33590
|
+
if (normalizedType === 'SESSION_COOKIE') {
|
|
33591
|
+
return 'SESSION_COOKIE';
|
|
33592
|
+
}
|
|
33593
|
+
if (normalizedType === 'ACCESS_TOKEN') {
|
|
33594
|
+
return 'ACCESS_TOKEN';
|
|
33595
|
+
}
|
|
33596
|
+
if (fallback) {
|
|
33597
|
+
return fallback;
|
|
33598
|
+
}
|
|
33599
|
+
throw new Error('Unsupported wallet recordType. Expected one of: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.');
|
|
33600
|
+
}
|
|
33601
|
+
/**
|
|
33602
|
+
* Parses wallet secret fields according to record type.
|
|
33603
|
+
*
|
|
33604
|
+
* @private function of WalletCommitmentDefinition
|
|
33605
|
+
*/
|
|
33606
|
+
function parseWalletSecrets(args) {
|
|
33607
|
+
const username = normalizeOptionalText(args.username);
|
|
33608
|
+
const password = normalizeOptionalText(args.password);
|
|
33609
|
+
const secret = normalizeOptionalText(args.secret);
|
|
33610
|
+
const cookies = normalizeOptionalText(args.cookies);
|
|
33611
|
+
if (args.recordType === 'USERNAME_PASSWORD') {
|
|
33612
|
+
if (!username || !password) {
|
|
33613
|
+
throw new Error('Both username and password are required for USERNAME_PASSWORD.');
|
|
33614
|
+
}
|
|
33615
|
+
return { username, password };
|
|
33616
|
+
}
|
|
33617
|
+
if (args.recordType === 'SESSION_COOKIE') {
|
|
33618
|
+
if (!cookies) {
|
|
33619
|
+
throw new Error('Cookies are required for SESSION_COOKIE.');
|
|
33620
|
+
}
|
|
33621
|
+
return { cookies };
|
|
33622
|
+
}
|
|
33623
|
+
if (!secret) {
|
|
33624
|
+
throw new Error('Secret is required for ACCESS_TOKEN.');
|
|
33625
|
+
}
|
|
33626
|
+
return { secret };
|
|
33627
|
+
}
|
|
33628
|
+
/**
|
|
33629
|
+
* Collection of WALLET tool argument parsers.
|
|
33630
|
+
*
|
|
33631
|
+
* @private function of WalletCommitmentDefinition
|
|
33632
|
+
*/
|
|
33633
|
+
const parseWalletToolArgs = {
|
|
33634
|
+
/**
|
|
33635
|
+
* Parses retrieve arguments.
|
|
33636
|
+
*/
|
|
33637
|
+
retrieve(args) {
|
|
33638
|
+
const limit = typeof args.limit === 'number' && Number.isFinite(args.limit) ? Math.floor(args.limit) : undefined;
|
|
33639
|
+
return {
|
|
33640
|
+
query: normalizeOptionalText(args.query),
|
|
33641
|
+
recordType: normalizeOptionalText(args.recordType) ? parseWalletRecordType(args.recordType) : undefined,
|
|
33642
|
+
service: normalizeOptionalText(args.service) ? parseWalletService(args.service) : undefined,
|
|
33643
|
+
key: normalizeOptionalText(args.key) ? parseWalletKey(args.key) : undefined,
|
|
33644
|
+
limit: limit && limit > 0 ? Math.min(limit, 20) : undefined,
|
|
33645
|
+
};
|
|
33646
|
+
},
|
|
33647
|
+
/**
|
|
33648
|
+
* Parses store payload.
|
|
33649
|
+
*/
|
|
33650
|
+
store(args) {
|
|
33651
|
+
return parseWalletPayload(args);
|
|
33652
|
+
},
|
|
33653
|
+
/**
|
|
33654
|
+
* Parses update payload.
|
|
33655
|
+
*/
|
|
33656
|
+
update(args) {
|
|
33657
|
+
const walletId = parseWalletId(args.walletId);
|
|
33658
|
+
const record = parseWalletPayload(args);
|
|
33659
|
+
return {
|
|
33660
|
+
...record,
|
|
33661
|
+
walletId,
|
|
33662
|
+
};
|
|
33663
|
+
},
|
|
33664
|
+
/**
|
|
33665
|
+
* Parses delete payload.
|
|
33666
|
+
*/
|
|
33667
|
+
delete(args) {
|
|
33668
|
+
return { walletId: parseWalletId(args.walletId) };
|
|
33669
|
+
},
|
|
33670
|
+
/**
|
|
33671
|
+
* Parses request payload for user wallet input prompt.
|
|
33672
|
+
*/
|
|
33673
|
+
request(args) {
|
|
33674
|
+
return {
|
|
33675
|
+
recordType: parseWalletRecordType(args.recordType, 'ACCESS_TOKEN'),
|
|
33676
|
+
service: parseWalletService(args.service),
|
|
33677
|
+
key: parseWalletKey(args.key),
|
|
33678
|
+
message: normalizeOptionalText(args.message),
|
|
33679
|
+
isUserScoped: args.isUserScoped === true,
|
|
33680
|
+
isGlobal: args.isGlobal === true,
|
|
33681
|
+
};
|
|
33682
|
+
},
|
|
33683
|
+
};
|
|
33684
|
+
|
|
33685
|
+
/**
|
|
33686
|
+
* Resolves runtime context from hidden tool arguments.
|
|
33687
|
+
*
|
|
33688
|
+
* @private function of WalletCommitmentDefinition
|
|
33689
|
+
*/
|
|
33690
|
+
function resolveWalletRuntimeContext(args) {
|
|
33691
|
+
const runtimeContext = readToolRuntimeContextFromToolArgs(args);
|
|
33692
|
+
const memoryContext = runtimeContext === null || runtimeContext === void 0 ? void 0 : runtimeContext.memory;
|
|
33693
|
+
return {
|
|
33694
|
+
enabled: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.enabled) === true,
|
|
33695
|
+
userId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.userId,
|
|
33696
|
+
username: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.username,
|
|
33697
|
+
agentId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentId,
|
|
33698
|
+
agentName: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentName,
|
|
33699
|
+
isTeamConversation: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isTeamConversation) === true,
|
|
33700
|
+
isPrivateMode: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isPrivateMode) === true,
|
|
33701
|
+
};
|
|
33702
|
+
}
|
|
33703
|
+
|
|
33704
|
+
/**
|
|
33705
|
+
* Creates runtime wallet tool function implementations.
|
|
33706
|
+
*
|
|
33707
|
+
* @private function of WalletCommitmentDefinition
|
|
33708
|
+
*/
|
|
33709
|
+
function createWalletToolFunctions() {
|
|
33710
|
+
return {
|
|
33711
|
+
async [WalletToolNames.retrieve](args) {
|
|
33712
|
+
const runtimeContext = resolveWalletRuntimeContext(args);
|
|
33713
|
+
const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('retrieve', runtimeContext);
|
|
33714
|
+
if (!adapter || disabledResult) {
|
|
33715
|
+
return JSON.stringify(disabledResult);
|
|
33716
|
+
}
|
|
33717
|
+
try {
|
|
33718
|
+
const parsedArgs = parseWalletToolArgs.retrieve(args);
|
|
33719
|
+
const records = await adapter.retrieveWalletRecords(parsedArgs, runtimeContext);
|
|
33720
|
+
return JSON.stringify({
|
|
33721
|
+
action: 'retrieve',
|
|
33722
|
+
status: 'ok',
|
|
33723
|
+
query: parsedArgs.query,
|
|
33724
|
+
records,
|
|
33725
|
+
});
|
|
33726
|
+
}
|
|
33727
|
+
catch (error) {
|
|
33728
|
+
return JSON.stringify({
|
|
33729
|
+
action: 'retrieve',
|
|
33730
|
+
status: 'error',
|
|
33731
|
+
records: [],
|
|
33732
|
+
message: error instanceof Error ? error.message : String(error),
|
|
33733
|
+
});
|
|
33734
|
+
}
|
|
33735
|
+
},
|
|
33736
|
+
async [WalletToolNames.store](args) {
|
|
33737
|
+
const runtimeContext = resolveWalletRuntimeContext(args);
|
|
33738
|
+
const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('store', runtimeContext);
|
|
33739
|
+
if (!adapter || disabledResult) {
|
|
33740
|
+
return JSON.stringify(disabledResult);
|
|
33741
|
+
}
|
|
33742
|
+
try {
|
|
33743
|
+
const parsedArgs = parseWalletToolArgs.store(args);
|
|
33744
|
+
const record = await adapter.storeWalletRecord(parsedArgs, runtimeContext);
|
|
33745
|
+
return JSON.stringify({
|
|
33746
|
+
action: 'store',
|
|
33747
|
+
status: 'stored',
|
|
33748
|
+
record,
|
|
33749
|
+
});
|
|
33750
|
+
}
|
|
33751
|
+
catch (error) {
|
|
33752
|
+
return JSON.stringify({
|
|
33753
|
+
action: 'store',
|
|
33754
|
+
status: 'error',
|
|
33755
|
+
message: error instanceof Error ? error.message : String(error),
|
|
33756
|
+
});
|
|
33757
|
+
}
|
|
33758
|
+
},
|
|
33759
|
+
async [WalletToolNames.update](args) {
|
|
33760
|
+
const runtimeContext = resolveWalletRuntimeContext(args);
|
|
33761
|
+
const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
|
|
33762
|
+
if (!adapter || disabledResult) {
|
|
33763
|
+
return JSON.stringify(disabledResult);
|
|
33764
|
+
}
|
|
33765
|
+
try {
|
|
33766
|
+
const parsedArgs = parseWalletToolArgs.update(args);
|
|
33767
|
+
const record = await adapter.updateWalletRecord(parsedArgs, runtimeContext);
|
|
33768
|
+
return JSON.stringify({
|
|
33769
|
+
action: 'update',
|
|
33770
|
+
status: 'updated',
|
|
33771
|
+
record,
|
|
33772
|
+
});
|
|
33773
|
+
}
|
|
33774
|
+
catch (error) {
|
|
33775
|
+
return JSON.stringify({
|
|
33776
|
+
action: 'update',
|
|
33777
|
+
status: 'error',
|
|
33778
|
+
message: error instanceof Error ? error.message : String(error),
|
|
33779
|
+
});
|
|
33780
|
+
}
|
|
33781
|
+
},
|
|
33782
|
+
async [WalletToolNames.delete](args) {
|
|
33783
|
+
const runtimeContext = resolveWalletRuntimeContext(args);
|
|
33784
|
+
const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('delete', runtimeContext);
|
|
33785
|
+
if (!adapter || disabledResult) {
|
|
33786
|
+
return JSON.stringify(disabledResult);
|
|
33787
|
+
}
|
|
33788
|
+
try {
|
|
33789
|
+
const parsedArgs = parseWalletToolArgs.delete(args);
|
|
33790
|
+
const deleted = await adapter.deleteWalletRecord(parsedArgs, runtimeContext);
|
|
33791
|
+
return JSON.stringify({
|
|
33792
|
+
action: 'delete',
|
|
33793
|
+
status: 'deleted',
|
|
33794
|
+
walletId: deleted.id,
|
|
33795
|
+
});
|
|
33796
|
+
}
|
|
33797
|
+
catch (error) {
|
|
33798
|
+
return JSON.stringify({
|
|
33799
|
+
action: 'delete',
|
|
33800
|
+
status: 'error',
|
|
33801
|
+
message: error instanceof Error ? error.message : String(error),
|
|
33802
|
+
});
|
|
33803
|
+
}
|
|
33804
|
+
},
|
|
33805
|
+
async [WalletToolNames.request](args) {
|
|
33806
|
+
const runtimeContext = resolveWalletRuntimeContext(args);
|
|
33807
|
+
const disabledMessage = resolveWalletDisabledMessage(runtimeContext);
|
|
33808
|
+
if (disabledMessage) {
|
|
33809
|
+
return JSON.stringify({
|
|
33810
|
+
action: 'request',
|
|
33811
|
+
status: 'disabled',
|
|
33812
|
+
message: disabledMessage,
|
|
33813
|
+
});
|
|
33814
|
+
}
|
|
33815
|
+
const request = parseWalletToolArgs.request(args);
|
|
33816
|
+
return JSON.stringify({
|
|
33817
|
+
action: 'request',
|
|
33818
|
+
status: 'requested',
|
|
33819
|
+
request,
|
|
33820
|
+
message: request.message ||
|
|
33821
|
+
`Request user to provide ${request.recordType} credentials for service "${request.service}".`,
|
|
33822
|
+
});
|
|
33823
|
+
},
|
|
33824
|
+
};
|
|
33825
|
+
}
|
|
33826
|
+
|
|
33827
|
+
/**
|
|
33828
|
+
* Creates tool definitions required by WALLET commitment.
|
|
33829
|
+
*
|
|
33830
|
+
* @private function of WalletCommitmentDefinition
|
|
33831
|
+
*/
|
|
33832
|
+
function createWalletTools(existingTools) {
|
|
33833
|
+
const tools = [...(existingTools || [])];
|
|
33834
|
+
addWalletToolIfMissing(tools, {
|
|
33835
|
+
name: WalletToolNames.retrieve,
|
|
33836
|
+
description: 'Retrieve wallet records relevant to the current task.',
|
|
33837
|
+
parameters: {
|
|
33838
|
+
type: 'object',
|
|
33839
|
+
properties: {
|
|
33840
|
+
query: { type: 'string', description: 'Optional text query used to filter wallet records.' },
|
|
33841
|
+
recordType: {
|
|
33842
|
+
type: 'string',
|
|
33843
|
+
description: 'Optional record type filter (USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN).',
|
|
33844
|
+
},
|
|
33845
|
+
service: { type: 'string', description: 'Optional service filter, for example github.' },
|
|
33846
|
+
key: { type: 'string', description: 'Optional wallet key filter.' },
|
|
33847
|
+
limit: { type: 'integer', description: 'Optional maximum number of records (default 5, max 20).' },
|
|
33848
|
+
},
|
|
33849
|
+
required: [],
|
|
33850
|
+
},
|
|
33851
|
+
});
|
|
33852
|
+
addWalletToolIfMissing(tools, {
|
|
33853
|
+
name: WalletToolNames.store,
|
|
33854
|
+
description: 'Store one wallet record.',
|
|
33855
|
+
parameters: {
|
|
33856
|
+
type: 'object',
|
|
33857
|
+
properties: {
|
|
33858
|
+
recordType: {
|
|
33859
|
+
type: 'string',
|
|
33860
|
+
description: 'Record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
|
|
33861
|
+
},
|
|
33862
|
+
service: { type: 'string', description: 'Service identifier, for example github.' },
|
|
33863
|
+
key: { type: 'string', description: 'Logical credential key.' },
|
|
33864
|
+
username: { type: 'string', description: 'Username for USERNAME_PASSWORD.' },
|
|
33865
|
+
password: { type: 'string', description: 'Password for USERNAME_PASSWORD.' },
|
|
33866
|
+
secret: { type: 'string', description: 'Token/API key for ACCESS_TOKEN.' },
|
|
33867
|
+
cookies: { type: 'string', description: 'Cookie header/json for SESSION_COOKIE.' },
|
|
33868
|
+
isUserScoped: { type: 'boolean', description: 'Set true to scope this record to current user.' },
|
|
33869
|
+
isGlobal: { type: 'boolean', description: 'Set true to make this record global.' },
|
|
33870
|
+
},
|
|
33871
|
+
required: ['recordType', 'service'],
|
|
33872
|
+
},
|
|
33873
|
+
});
|
|
33874
|
+
addWalletToolIfMissing(tools, {
|
|
33875
|
+
name: WalletToolNames.update,
|
|
33876
|
+
description: 'Update one existing wallet record.',
|
|
33877
|
+
parameters: {
|
|
33878
|
+
type: 'object',
|
|
33879
|
+
properties: {
|
|
33880
|
+
walletId: { type: 'string', description: 'Wallet record id to update.' },
|
|
33881
|
+
recordType: {
|
|
33882
|
+
type: 'string',
|
|
33883
|
+
description: 'Record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
|
|
33884
|
+
},
|
|
33885
|
+
service: { type: 'string', description: 'Service identifier, for example github.' },
|
|
33886
|
+
key: { type: 'string', description: 'Logical credential key.' },
|
|
33887
|
+
username: { type: 'string', description: 'Username for USERNAME_PASSWORD.' },
|
|
33888
|
+
password: { type: 'string', description: 'Password for USERNAME_PASSWORD.' },
|
|
33889
|
+
secret: { type: 'string', description: 'Token/API key for ACCESS_TOKEN.' },
|
|
33890
|
+
cookies: { type: 'string', description: 'Cookie header/json for SESSION_COOKIE.' },
|
|
33891
|
+
isUserScoped: { type: 'boolean', description: 'Set true to scope this record to current user.' },
|
|
33892
|
+
isGlobal: { type: 'boolean', description: 'Set true to make this record global.' },
|
|
33893
|
+
},
|
|
33894
|
+
required: ['walletId', 'recordType', 'service'],
|
|
33895
|
+
},
|
|
33896
|
+
});
|
|
33897
|
+
addWalletToolIfMissing(tools, {
|
|
33898
|
+
name: WalletToolNames.delete,
|
|
33899
|
+
description: 'Delete one wallet record.',
|
|
33900
|
+
parameters: {
|
|
33901
|
+
type: 'object',
|
|
33902
|
+
properties: {
|
|
33903
|
+
walletId: { type: 'string', description: 'Wallet record id to delete.' },
|
|
33904
|
+
},
|
|
33905
|
+
required: ['walletId'],
|
|
33906
|
+
},
|
|
33907
|
+
});
|
|
33908
|
+
addWalletToolIfMissing(tools, {
|
|
33909
|
+
name: WalletToolNames.request,
|
|
33910
|
+
description: 'Request missing credential from user via popup.',
|
|
33911
|
+
parameters: {
|
|
33912
|
+
type: 'object',
|
|
33913
|
+
properties: {
|
|
33914
|
+
recordType: {
|
|
33915
|
+
type: 'string',
|
|
33916
|
+
description: 'Requested record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
|
|
33917
|
+
},
|
|
33918
|
+
service: { type: 'string', description: 'Service identifier.' },
|
|
33919
|
+
key: { type: 'string', description: 'Logical credential key.' },
|
|
33920
|
+
message: { type: 'string', description: 'Optional UI message for user.' },
|
|
33921
|
+
isUserScoped: {
|
|
33922
|
+
type: 'boolean',
|
|
33923
|
+
description: 'Set true when record should be scoped to current user.',
|
|
33924
|
+
},
|
|
33925
|
+
isGlobal: { type: 'boolean', description: 'Set true when record should be global.' },
|
|
33926
|
+
},
|
|
33927
|
+
required: [],
|
|
33928
|
+
},
|
|
33929
|
+
});
|
|
33930
|
+
return tools;
|
|
33931
|
+
}
|
|
33932
|
+
/**
|
|
33933
|
+
* Registers one wallet tool when missing in current tool list.
|
|
33934
|
+
*
|
|
33935
|
+
* @private function of WalletCommitmentDefinition
|
|
33936
|
+
*/
|
|
33937
|
+
function addWalletToolIfMissing(tools, tool) {
|
|
33938
|
+
if (!tools.some((existingTool) => existingTool.name === tool.name)) {
|
|
33939
|
+
tools.push(tool);
|
|
33940
|
+
}
|
|
33941
|
+
}
|
|
33942
|
+
|
|
33943
|
+
/**
|
|
33944
|
+
* Gets markdown documentation for WALLET commitment.
|
|
33945
|
+
*
|
|
33946
|
+
* @private function of WalletCommitmentDefinition
|
|
33947
|
+
*/
|
|
33948
|
+
function getWalletCommitmentDocumentation(type) {
|
|
33949
|
+
return spaceTrim$1(`
|
|
33950
|
+
# ${type}
|
|
33951
|
+
|
|
33952
|
+
Enables private credential storage for tokens, usernames/passwords, and session cookies.
|
|
33953
|
+
`);
|
|
33954
|
+
}
|
|
33955
|
+
|
|
33956
|
+
/**
|
|
33957
|
+
* Gets human-readable titles for WALLET tool functions.
|
|
33958
|
+
*
|
|
33959
|
+
* @private function of WalletCommitmentDefinition
|
|
33960
|
+
*/
|
|
33961
|
+
function getWalletToolTitles() {
|
|
33962
|
+
return {
|
|
33963
|
+
[WalletToolNames.retrieve]: 'Wallet',
|
|
33964
|
+
[WalletToolNames.store]: 'Store wallet record',
|
|
33965
|
+
[WalletToolNames.update]: 'Update wallet record',
|
|
33966
|
+
[WalletToolNames.delete]: 'Delete wallet record',
|
|
33967
|
+
[WalletToolNames.request]: 'Request wallet record',
|
|
33968
|
+
};
|
|
33969
|
+
}
|
|
33970
|
+
|
|
33971
|
+
/**
|
|
33972
|
+
* WALLET commitment definition.
|
|
33973
|
+
*
|
|
33974
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
33975
|
+
*/
|
|
33976
|
+
class WalletCommitmentDefinition extends BaseCommitmentDefinition {
|
|
33977
|
+
constructor(type = 'WALLET') {
|
|
33978
|
+
super(type);
|
|
33979
|
+
}
|
|
33980
|
+
get requiresContent() {
|
|
33981
|
+
return false;
|
|
33982
|
+
}
|
|
33983
|
+
get description() {
|
|
33984
|
+
return 'Enable persistent private credential storage (tokens, logins, cookies) scoped per agent or globally.';
|
|
33985
|
+
}
|
|
33986
|
+
get icon() {
|
|
33987
|
+
return '👛';
|
|
33988
|
+
}
|
|
33989
|
+
get documentation() {
|
|
33990
|
+
return getWalletCommitmentDocumentation(this.type);
|
|
33991
|
+
}
|
|
33992
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
33993
|
+
const extraInstructions = formatOptionalInstructionBlock('Wallet instructions', content);
|
|
33994
|
+
return this.appendToSystemMessage({
|
|
33995
|
+
...requirements,
|
|
33996
|
+
tools: createWalletTools(requirements.tools),
|
|
33997
|
+
_metadata: {
|
|
33998
|
+
...requirements._metadata,
|
|
33999
|
+
useWallet: content || true,
|
|
34000
|
+
},
|
|
34001
|
+
}, createWalletSystemMessage(extraInstructions));
|
|
34002
|
+
}
|
|
34003
|
+
getToolTitles() {
|
|
34004
|
+
return getWalletToolTitles();
|
|
34005
|
+
}
|
|
34006
|
+
getToolFunctions() {
|
|
34007
|
+
return createWalletToolFunctions();
|
|
34008
|
+
}
|
|
34009
|
+
}
|
|
34010
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
34011
|
+
|
|
33296
34012
|
/**
|
|
33297
34013
|
* `WRITING RULES` commitment definition.
|
|
33298
34014
|
*
|
|
@@ -33567,6 +34283,8 @@ const COMMITMENT_REGISTRY = [
|
|
|
33567
34283
|
new MessageSuffixCommitmentDefinition(),
|
|
33568
34284
|
new MessageCommitmentDefinition('MESSAGE'),
|
|
33569
34285
|
new MessageCommitmentDefinition('MESSAGES'),
|
|
34286
|
+
new WalletCommitmentDefinition('WALLET'),
|
|
34287
|
+
new WalletCommitmentDefinition('WALLETS'),
|
|
33570
34288
|
new ScenarioCommitmentDefinition('SCENARIO'),
|
|
33571
34289
|
new ScenarioCommitmentDefinition('SCENARIOS'),
|
|
33572
34290
|
new DeleteCommitmentDefinition('DELETE'),
|
|
@@ -34405,6 +35123,12 @@ const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
|
|
|
34405
35123
|
['GOAL', 'GOAL'],
|
|
34406
35124
|
['GOALS', 'GOAL'],
|
|
34407
35125
|
]);
|
|
35126
|
+
/**
|
|
35127
|
+
* Legacy commitments that should be parsed for compatibility but ignored by the model-requirements pipeline.
|
|
35128
|
+
*
|
|
35129
|
+
* @private internal constant of `filterCommitmentsForAgentModelRequirements`
|
|
35130
|
+
*/
|
|
35131
|
+
const IGNORED_COMMITMENT_TYPES = new Set(['WALLET', 'WALLETS']);
|
|
34408
35132
|
/**
|
|
34409
35133
|
* Applies the commitment filtering rules used before commitment definitions are executed.
|
|
34410
35134
|
*
|
|
@@ -34453,6 +35177,9 @@ function filterOverwrittenCommitments(commitments) {
|
|
|
34453
35177
|
function filterDeletedCommitments(commitments) {
|
|
34454
35178
|
const filteredCommitments = [];
|
|
34455
35179
|
for (const commitment of commitments) {
|
|
35180
|
+
if (isIgnoredCommitmentType(commitment.type)) {
|
|
35181
|
+
continue;
|
|
35182
|
+
}
|
|
34456
35183
|
if (!isDeleteCommitmentType(commitment.type)) {
|
|
34457
35184
|
filteredCommitments.push(commitment);
|
|
34458
35185
|
continue;
|
|
@@ -34483,6 +35210,17 @@ function filterDeletedCommitments(commitments) {
|
|
|
34483
35210
|
function isDeleteCommitmentType(commitmentType) {
|
|
34484
35211
|
return DELETE_COMMITMENT_TYPES.has(commitmentType);
|
|
34485
35212
|
}
|
|
35213
|
+
/**
|
|
35214
|
+
* Checks whether a parsed commitment is intentionally ignored by the current model compiler.
|
|
35215
|
+
*
|
|
35216
|
+
* @param commitmentType - Commitment type to check.
|
|
35217
|
+
* @returns `true` when the commitment should not affect model requirements.
|
|
35218
|
+
*
|
|
35219
|
+
* @private internal utility of `filterDeletedCommitments`
|
|
35220
|
+
*/
|
|
35221
|
+
function isIgnoredCommitmentType(commitmentType) {
|
|
35222
|
+
return IGNORED_COMMITMENT_TYPES.has(commitmentType);
|
|
35223
|
+
}
|
|
34486
35224
|
/**
|
|
34487
35225
|
* Extracts normalized parameter names used for DELETE-like invalidation matching.
|
|
34488
35226
|
*
|
|
@@ -35090,7 +35828,6 @@ function createInheritanceCapability(content) {
|
|
|
35090
35828
|
if (isVoidPseudoAgentReference(reference)) {
|
|
35091
35829
|
label = VOID_PSEUDO_AGENT_REFERENCE; // <- {Void} label
|
|
35092
35830
|
iconName = 'ShieldAlert';
|
|
35093
|
-
return null; // <- Note: Do not show `{Void}` in capabilities, it's only used for internal logic
|
|
35094
35831
|
}
|
|
35095
35832
|
return {
|
|
35096
35833
|
type: 'inheritance',
|
|
@@ -35395,11 +36132,11 @@ function extractMcpServers(agentSource) {
|
|
|
35395
36132
|
*/
|
|
35396
36133
|
const IMPORTANT_COMMITMENT_TYPE_SORT_ORDER = new Map([
|
|
35397
36134
|
['GOAL', 0],
|
|
35398
|
-
['
|
|
35399
|
-
['
|
|
35400
|
-
['
|
|
35401
|
-
['
|
|
35402
|
-
['
|
|
36135
|
+
['RULE', 1],
|
|
36136
|
+
['KNOWLEDGE', 2],
|
|
36137
|
+
['TEAM', 3],
|
|
36138
|
+
['GOALS', 4],
|
|
36139
|
+
['RULES', 5],
|
|
35403
36140
|
]);
|
|
35404
36141
|
/**
|
|
35405
36142
|
* Sort rank used when unfinished, low-level, and deprecated commitments should be grouped last.
|
|
@@ -35498,7 +36235,7 @@ const SDK_TRANSPILER_KNOWLEDGE_THRESHOLD = 1000;
|
|
|
35498
36235
|
*/
|
|
35499
36236
|
async function prepareSdkTranspilerContext(book, options) {
|
|
35500
36237
|
const { agentName } = await parseAgentSource(book);
|
|
35501
|
-
const
|
|
36238
|
+
const rawModelRequirements = await createAgentModelRequirements(book, undefined, undefined, undefined, {
|
|
35502
36239
|
agentReferenceResolver: options === null || options === void 0 ? void 0 : options.agentReferenceResolver,
|
|
35503
36240
|
inlineKnowledgeSourceUploader: options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader,
|
|
35504
36241
|
teammateProfileResolver: options === null || options === void 0 ? void 0 : options.teammateProfileResolver,
|
|
@@ -35508,7 +36245,12 @@ async function prepareSdkTranspilerContext(book, options) {
|
|
|
35508
36245
|
const knowledgeContent = knowledgeCommitments.map((commitment) => commitment.content.trim());
|
|
35509
36246
|
const directKnowledge = knowledgeContent.filter((content) => !isKnowledgeSourceUrl(content));
|
|
35510
36247
|
const knowledgeSources = knowledgeContent.filter((content) => isKnowledgeSourceUrl(content));
|
|
35511
|
-
const isKnowledgeHandledWithRetrieval = directKnowledge.join('\n').length > SDK_TRANSPILER_KNOWLEDGE_THRESHOLD ||
|
|
36248
|
+
const isKnowledgeHandledWithRetrieval = directKnowledge.join('\n').length > SDK_TRANSPILER_KNOWLEDGE_THRESHOLD ||
|
|
36249
|
+
knowledgeSources.length > 0 ||
|
|
36250
|
+
knowledgeCommitments.length > 0;
|
|
36251
|
+
const modelRequirements = normalizeSdkTranspilerModelRequirements(rawModelRequirements, {
|
|
36252
|
+
isKnowledgeHandledWithRetrieval,
|
|
36253
|
+
});
|
|
35512
36254
|
const transpiledTeam = createTranspiledTeamExportForContext({
|
|
35513
36255
|
agentName,
|
|
35514
36256
|
agentSource: book,
|
|
@@ -35526,6 +36268,36 @@ async function prepareSdkTranspilerContext(book, options) {
|
|
|
35526
36268
|
transpiledTeam,
|
|
35527
36269
|
};
|
|
35528
36270
|
}
|
|
36271
|
+
/**
|
|
36272
|
+
* Removes the runtime-only knowledge-search tool from SDK harnesses that provide
|
|
36273
|
+
* their own generated retrieval scaffold.
|
|
36274
|
+
*
|
|
36275
|
+
* @param modelRequirements - Raw compiled model requirements.
|
|
36276
|
+
* @param options - Knowledge handling mode selected for the generated harness.
|
|
36277
|
+
* @returns Model requirements safe to embed into a standalone SDK export.
|
|
36278
|
+
*/
|
|
36279
|
+
function normalizeSdkTranspilerModelRequirements(modelRequirements, options) {
|
|
36280
|
+
var _a;
|
|
36281
|
+
if (!options.isKnowledgeHandledWithRetrieval) {
|
|
36282
|
+
return modelRequirements;
|
|
36283
|
+
}
|
|
36284
|
+
const tools = (_a = modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.filter((tool) => tool.name !== KNOWLEDGE_SEARCH_TOOL_NAME);
|
|
36285
|
+
return {
|
|
36286
|
+
...modelRequirements,
|
|
36287
|
+
systemMessage: removeKnowledgeSearchSystemSection(modelRequirements.systemMessage),
|
|
36288
|
+
...(tools ? { tools } : {}),
|
|
36289
|
+
};
|
|
36290
|
+
}
|
|
36291
|
+
/**
|
|
36292
|
+
* Removes the generated `## Knowledge Search` instructions from SDK exports
|
|
36293
|
+
* that answer with the transpiler's native retrieval scaffold instead.
|
|
36294
|
+
*
|
|
36295
|
+
* @param systemMessage - Raw system message from compiled model requirements.
|
|
36296
|
+
* @returns System message without the runtime-only knowledge-search section.
|
|
36297
|
+
*/
|
|
36298
|
+
function removeKnowledgeSearchSystemSection(systemMessage) {
|
|
36299
|
+
return systemMessage.replace(/(?:^|\n\n)## Knowledge Search[\s\S]*?(?=\n\n##|$)/, '').trim();
|
|
36300
|
+
}
|
|
35529
36301
|
/**
|
|
35530
36302
|
* Detects whether one knowledge commitment points to a URL instead of inline text.
|
|
35531
36303
|
*
|
|
@@ -45504,8 +46276,8 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
45504
46276
|
* Prepares an AgentKit agent with optional knowledge sources and tool definitions.
|
|
45505
46277
|
*/
|
|
45506
46278
|
async prepareAgentKitAgent(options) {
|
|
45507
|
-
var _a, _b
|
|
45508
|
-
const { name, instructions, knowledgeSources, tools,
|
|
46279
|
+
var _a, _b;
|
|
46280
|
+
const { name, instructions, knowledgeSources, tools, vectorStoreId: cachedVectorStoreId, storeAsPrepared, } = options;
|
|
45509
46281
|
await this.ensureAgentKitDefaults();
|
|
45510
46282
|
if (this.options.isVerbose) {
|
|
45511
46283
|
console.info('[🤰]', 'Preparing OpenAI AgentKit agent', {
|
|
@@ -45513,11 +46285,10 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
45513
46285
|
instructionsLength: instructions.length,
|
|
45514
46286
|
knowledgeSourcesCount: (_a = knowledgeSources === null || knowledgeSources === void 0 ? void 0 : knowledgeSources.length) !== null && _a !== void 0 ? _a : 0,
|
|
45515
46287
|
toolsCount: (_b = tools === null || tools === void 0 ? void 0 : tools.length) !== null && _b !== void 0 ? _b : 0,
|
|
45516
|
-
nativeAgentKitToolsCount: (_c = nativeAgentKitTools === null || nativeAgentKitTools === void 0 ? void 0 : nativeAgentKitTools.length) !== null && _c !== void 0 ? _c : 0,
|
|
45517
46288
|
});
|
|
45518
46289
|
}
|
|
45519
46290
|
let vectorStoreId = cachedVectorStoreId;
|
|
45520
|
-
if (!vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
|
|
46291
|
+
if (this.isNativeKnowledgeSearchEnabled && !vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
|
|
45521
46292
|
const vectorStoreResult = await this.createVectorStoreWithKnowledgeSources({
|
|
45522
46293
|
client: await this.getClient(),
|
|
45523
46294
|
name,
|
|
@@ -45526,13 +46297,19 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
45526
46297
|
});
|
|
45527
46298
|
vectorStoreId = vectorStoreResult.vectorStoreId;
|
|
45528
46299
|
}
|
|
45529
|
-
else if (vectorStoreId && this.options.isVerbose) {
|
|
46300
|
+
else if (this.isNativeKnowledgeSearchEnabled && vectorStoreId && this.options.isVerbose) {
|
|
45530
46301
|
console.info('[🤰]', 'Using cached vector store for AgentKit agent', {
|
|
45531
46302
|
name,
|
|
45532
46303
|
vectorStoreId,
|
|
45533
46304
|
});
|
|
45534
46305
|
}
|
|
45535
|
-
|
|
46306
|
+
if (!this.isNativeKnowledgeSearchEnabled) {
|
|
46307
|
+
vectorStoreId = undefined;
|
|
46308
|
+
}
|
|
46309
|
+
const agentKitTools = this.buildAgentKitTools({
|
|
46310
|
+
tools,
|
|
46311
|
+
vectorStoreId,
|
|
46312
|
+
});
|
|
45536
46313
|
const openAiAgentKitAgent = new Agent$1({
|
|
45537
46314
|
name,
|
|
45538
46315
|
model: this.agentKitModelName,
|
|
@@ -45551,7 +46328,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
45551
46328
|
name,
|
|
45552
46329
|
model: this.agentKitModelName,
|
|
45553
46330
|
toolCount: agentKitTools.length,
|
|
45554
|
-
hasVectorStore: Boolean(vectorStoreId),
|
|
46331
|
+
hasVectorStore: this.isNativeKnowledgeSearchEnabled && Boolean(vectorStoreId),
|
|
45555
46332
|
});
|
|
45556
46333
|
}
|
|
45557
46334
|
return preparedAgent;
|
|
@@ -45571,14 +46348,11 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
45571
46348
|
* Builds the tool list for AgentKit, including hosted file search when applicable.
|
|
45572
46349
|
*/
|
|
45573
46350
|
buildAgentKitTools(options) {
|
|
45574
|
-
const { tools,
|
|
46351
|
+
const { tools, vectorStoreId } = options;
|
|
45575
46352
|
const agentKitTools = [];
|
|
45576
46353
|
if (vectorStoreId) {
|
|
45577
46354
|
agentKitTools.push(fileSearchTool(vectorStoreId));
|
|
45578
46355
|
}
|
|
45579
|
-
if (nativeAgentKitTools && nativeAgentKitTools.length > 0) {
|
|
45580
|
-
agentKitTools.push(...nativeAgentKitTools);
|
|
45581
|
-
}
|
|
45582
46356
|
if (tools && tools.length > 0) {
|
|
45583
46357
|
let scriptTools = null;
|
|
45584
46358
|
for (const toolDefinition of tools) {
|
|
@@ -46053,6 +46827,12 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
46053
46827
|
get agentKitOptions() {
|
|
46054
46828
|
return this.options;
|
|
46055
46829
|
}
|
|
46830
|
+
/**
|
|
46831
|
+
* Returns true when hosted OpenAI vector-store search should back `knowledgeSources`.
|
|
46832
|
+
*/
|
|
46833
|
+
get isNativeKnowledgeSearchEnabled() {
|
|
46834
|
+
return this.agentKitOptions.isNativeKnowledgeSearchEnabled !== false;
|
|
46835
|
+
}
|
|
46056
46836
|
/**
|
|
46057
46837
|
* Discriminant for type guards.
|
|
46058
46838
|
*/
|