@promptbook/browser 0.112.0-62 → 0.112.0-64

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.
Files changed (57) hide show
  1. package/esm/index.es.js +785 -40
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/src/_packages/components.index.d.ts +4 -0
  4. package/esm/src/_packages/core.index.d.ts +2 -0
  5. package/esm/src/_packages/types.index.d.ts +2 -0
  6. package/esm/src/book-components/Chat/Chat/TeamToolCallModalContent.d.ts +0 -2
  7. package/esm/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.d.ts +7 -1
  8. package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +1 -1
  9. package/esm/src/book-components/Chat/Chat/useChatInputAreaDictation.d.ts +2 -2
  10. package/esm/src/book-components/Chat/hooks/useChatAutoScroll.d.ts +6 -3
  11. package/esm/src/book-components/Chat/types/ChatMessage.d.ts +34 -0
  12. package/esm/src/cli/cli-commands/agent/agentProjectPaths.d.ts +54 -0
  13. package/esm/src/cli/cli-commands/agent/agentRunCliOptions.d.ts +13 -0
  14. package/esm/src/cli/cli-commands/agent/init.d.ts +10 -0
  15. package/esm/src/cli/cli-commands/agent/initializeAgentProjectConfiguration.d.ts +21 -0
  16. package/esm/src/cli/cli-commands/agent/printAgentInitializationSummary.d.ts +7 -0
  17. package/esm/src/cli/cli-commands/agent/run.d.ts +10 -0
  18. package/esm/src/cli/cli-commands/agent/run.test.d.ts +1 -0
  19. package/esm/src/cli/cli-commands/agent/tick.d.ts +10 -0
  20. package/esm/src/cli/cli-commands/agent.d.ts +15 -0
  21. package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +86 -0
  22. package/esm/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +11 -0
  23. package/esm/src/commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts +1 -0
  24. package/esm/src/commitments/_common/toolRuntimeContext.d.ts +6 -0
  25. package/esm/src/commitments/index.d.ts +2 -1
  26. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +4 -2
  27. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +9 -0
  28. package/esm/src/version.d.ts +1 -1
  29. package/package.json +2 -2
  30. package/umd/index.umd.js +785 -40
  31. package/umd/index.umd.js.map +1 -1
  32. package/umd/src/_packages/components.index.d.ts +4 -0
  33. package/umd/src/_packages/core.index.d.ts +2 -0
  34. package/umd/src/_packages/types.index.d.ts +2 -0
  35. package/umd/src/book-components/Chat/Chat/TeamToolCallModalContent.d.ts +0 -2
  36. package/umd/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.d.ts +7 -1
  37. package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +1 -1
  38. package/umd/src/book-components/Chat/Chat/useChatInputAreaDictation.d.ts +2 -2
  39. package/umd/src/book-components/Chat/hooks/useChatAutoScroll.d.ts +6 -3
  40. package/umd/src/book-components/Chat/types/ChatMessage.d.ts +34 -0
  41. package/umd/src/cli/cli-commands/agent/agentProjectPaths.d.ts +54 -0
  42. package/umd/src/cli/cli-commands/agent/agentRunCliOptions.d.ts +13 -0
  43. package/umd/src/cli/cli-commands/agent/init.d.ts +10 -0
  44. package/umd/src/cli/cli-commands/agent/initializeAgentProjectConfiguration.d.ts +21 -0
  45. package/umd/src/cli/cli-commands/agent/printAgentInitializationSummary.d.ts +7 -0
  46. package/umd/src/cli/cli-commands/agent/run.d.ts +10 -0
  47. package/umd/src/cli/cli-commands/agent/run.test.d.ts +1 -0
  48. package/umd/src/cli/cli-commands/agent/tick.d.ts +10 -0
  49. package/umd/src/cli/cli-commands/agent.d.ts +15 -0
  50. package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +86 -0
  51. package/umd/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +11 -0
  52. package/umd/src/commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts +1 -0
  53. package/umd/src/commitments/_common/toolRuntimeContext.d.ts +6 -0
  54. package/umd/src/commitments/index.d.ts +2 -1
  55. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +4 -2
  56. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +9 -0
  57. package/umd/src/version.d.ts +1 -1
package/umd/index.umd.js CHANGED
@@ -27,7 +27,7 @@
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-62';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-64';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -6975,6 +6975,18 @@
6975
6975
  }
6976
6976
  // Note: [💞] Ignore a discrepancy between file name and entity name
6977
6977
 
6978
+ /**
6979
+ * Name of the tool used by agents to search configured `KNOWLEDGE` sources.
6980
+ *
6981
+ * @public exported from `@promptbook/core`
6982
+ */
6983
+ const KNOWLEDGE_SEARCH_TOOL_NAME = 'knowledge_search';
6984
+ /**
6985
+ * Title of the system-message section generated for `KNOWLEDGE` commitments.
6986
+ *
6987
+ * @private constant of `KnowledgeCommitmentDefinition`
6988
+ */
6989
+ const KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE = 'Knowledge Search';
6978
6990
  /**
6979
6991
  * KNOWLEDGE commitment definition
6980
6992
  *
@@ -7096,9 +7108,17 @@
7096
7108
  knowledgeInfoEntries.push(`Knowledge Source Inline: ${inlineSource.filename} (derived from inline content and processed for retrieval during chat)`);
7097
7109
  }
7098
7110
  if (knowledgeInfoEntries.length === 0) {
7099
- return nextRequirements;
7111
+ return addKnowledgeSearchToolAndSystemSection(nextRequirements);
7100
7112
  }
7101
- return this.appendToSystemMessage(nextRequirements, knowledgeInfoEntries.join('\n'), '\n\n');
7113
+ return addKnowledgeSearchToolAndSystemSection(nextRequirements);
7114
+ }
7115
+ /**
7116
+ * Gets human-readable titles for tool functions provided by this commitment.
7117
+ */
7118
+ getToolTitles() {
7119
+ return {
7120
+ [KNOWLEDGE_SEARCH_TOOL_NAME]: 'Knowledge search',
7121
+ };
7102
7122
  }
7103
7123
  }
7104
7124
  /**
@@ -7112,6 +7132,128 @@
7112
7132
  const significantText = contentWithoutUrls.replace(/[\s.,!?;:'"`()[\]{}<>/-]+/g, '');
7113
7133
  return significantText.length > 0;
7114
7134
  }
7135
+ /**
7136
+ * Adds the shared `knowledge_search` tool definition and the consolidated system-message section.
7137
+ *
7138
+ * @param requirements - Requirements after one `KNOWLEDGE` commitment was applied.
7139
+ * @returns Requirements with the knowledge search instructions and tool definition.
7140
+ *
7141
+ * @private internal utility of `KnowledgeCommitmentDefinition`
7142
+ */
7143
+ function addKnowledgeSearchToolAndSystemSection(requirements) {
7144
+ const nextRequirements = addKnowledgeSearchTool(requirements);
7145
+ const section = createKnowledgeSearchSystemSection(nextRequirements);
7146
+ const sectionHeader = `## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}`;
7147
+ if (nextRequirements.systemMessage.includes(sectionHeader)) {
7148
+ return {
7149
+ ...nextRequirements,
7150
+ systemMessage: nextRequirements.systemMessage.replace(new RegExp(`## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), section),
7151
+ };
7152
+ }
7153
+ return {
7154
+ ...nextRequirements,
7155
+ systemMessage: nextRequirements.systemMessage.trim()
7156
+ ? `${nextRequirements.systemMessage}\n\n${section}`
7157
+ : section,
7158
+ };
7159
+ }
7160
+ /**
7161
+ * Adds the `knowledge_search` model tool when it is not already present.
7162
+ *
7163
+ * @param requirements - Current model requirements.
7164
+ * @returns Requirements with the tool definition available to the model.
7165
+ *
7166
+ * @private internal utility of `KnowledgeCommitmentDefinition`
7167
+ */
7168
+ function addKnowledgeSearchTool(requirements) {
7169
+ const existingTools = requirements.tools || [];
7170
+ if (existingTools.some((tool) => tool.name === KNOWLEDGE_SEARCH_TOOL_NAME)) {
7171
+ return requirements;
7172
+ }
7173
+ return {
7174
+ ...requirements,
7175
+ tools: [
7176
+ ...existingTools,
7177
+ {
7178
+ name: KNOWLEDGE_SEARCH_TOOL_NAME,
7179
+ description: spacetrim.spaceTrim(`
7180
+ Search the agent's configured knowledge sources and return relevant excerpts with citation ids.
7181
+ Use this before answering questions that may depend on the agent's KNOWLEDGE commitments.
7182
+ `),
7183
+ parameters: {
7184
+ type: 'object',
7185
+ properties: {
7186
+ query: {
7187
+ type: 'string',
7188
+ description: 'The natural-language search query for the knowledge base.',
7189
+ },
7190
+ limit: {
7191
+ type: 'integer',
7192
+ description: 'Maximum number of matching source excerpts to return.',
7193
+ },
7194
+ },
7195
+ required: ['query'],
7196
+ },
7197
+ },
7198
+ ],
7199
+ };
7200
+ }
7201
+ /**
7202
+ * Creates the model-facing system-message section for knowledge search.
7203
+ *
7204
+ * @param requirements - Current model requirements.
7205
+ * @returns Markdown system-message section.
7206
+ *
7207
+ * @private internal utility of `KnowledgeCommitmentDefinition`
7208
+ */
7209
+ function createKnowledgeSearchSystemSection(requirements) {
7210
+ const sourceEntries = createKnowledgeSourceSystemEntries(requirements);
7211
+ const sourceList = sourceEntries.length > 0 ? sourceEntries.map((entry) => `- ${entry}`).join('\n') : '- None';
7212
+ return spacetrim.spaceTrim(`
7213
+ ## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}
7214
+
7215
+ - Use \`${KNOWLEDGE_SEARCH_TOOL_NAME}\` to search the configured knowledge sources before answering questions that depend on this agent's knowledge base.
7216
+ - Base source-backed factual answers on the returned excerpts.
7217
+ - When you use a returned excerpt, include its citation marker in the answer body, for example \`[0:0]\`.
7218
+ - If the search returns no relevant information, say that the knowledge base did not contain the answer instead of inventing it.
7219
+
7220
+ Configured knowledge sources:
7221
+ ${sourceList}
7222
+ `);
7223
+ }
7224
+ /**
7225
+ * Builds a stable list of configured knowledge sources for system-message diagnostics.
7226
+ *
7227
+ * @param requirements - Current model requirements.
7228
+ * @returns Human-readable source entries.
7229
+ *
7230
+ * @private internal utility of `KnowledgeCommitmentDefinition`
7231
+ */
7232
+ function createKnowledgeSourceSystemEntries(requirements) {
7233
+ var _a;
7234
+ const entries = [];
7235
+ const seenEntries = new Set();
7236
+ for (const source of requirements.knowledgeSources || []) {
7237
+ const entry = `Source URL: ${source} (processed for retrieval during chat)`;
7238
+ if (seenEntries.has(entry)) {
7239
+ continue;
7240
+ }
7241
+ seenEntries.add(entry);
7242
+ entries.push(entry);
7243
+ }
7244
+ const inlineSources = (((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.inlineKnowledgeSources) || [])
7245
+ .map((source) => source.filename)
7246
+ .filter(Boolean);
7247
+ for (const filename of inlineSources) {
7248
+ const entry = `Knowledge Source Inline: ${filename} (Inline source: processed for retrieval during chat)`;
7249
+ if (seenEntries.has(entry)) {
7250
+ continue;
7251
+ }
7252
+ seenEntries.add(entry);
7253
+ entries.push(entry);
7254
+ }
7255
+ return entries;
7256
+ }
7115
7257
 
7116
7258
  /**
7117
7259
  * LANGUAGE commitment definition
@@ -14871,7 +15013,7 @@
14871
15013
  const runtimeContext = (readToolRuntimeContextFromToolArgs(args) ||
14872
15014
  {});
14873
15015
  const configuredCalendars = normalizeConfiguredCalendars$1((_a = runtimeContext.calendars) === null || _a === void 0 ? void 0 : _a.connections);
14874
- const calendarArgument = normalizeOptionalText$1(args.calendarUrl);
15016
+ const calendarArgument = normalizeOptionalText$2(args.calendarUrl);
14875
15017
  let calendarReference = null;
14876
15018
  if (calendarArgument) {
14877
15019
  calendarReference = parseGoogleCalendarReference(calendarArgument);
@@ -14891,7 +15033,7 @@
14891
15033
  if (!calendarReference) {
14892
15034
  throw new Error('Calendar is required but was not resolved.');
14893
15035
  }
14894
- const accessToken = normalizeOptionalText$1((_b = runtimeContext.calendars) === null || _b === void 0 ? void 0 : _b.googleAccessToken) || '';
15036
+ const accessToken = normalizeOptionalText$2((_b = runtimeContext.calendars) === null || _b === void 0 ? void 0 : _b.googleAccessToken) || '';
14895
15037
  if (!accessToken) {
14896
15038
  throw new CalendarWalletCredentialRequiredError({
14897
15039
  calendarReference,
@@ -14924,7 +15066,7 @@
14924
15066
  continue;
14925
15067
  }
14926
15068
  const calendar = rawCalendar;
14927
- const rawUrl = normalizeOptionalText$1(calendar.url);
15069
+ const rawUrl = normalizeOptionalText$2(calendar.url);
14928
15070
  if (!rawUrl) {
14929
15071
  continue;
14930
15072
  }
@@ -14975,7 +15117,7 @@
14975
15117
  *
14976
15118
  * @private function of resolveUseCalendarToolRuntimeOrWalletCredentialResult
14977
15119
  */
14978
- function normalizeOptionalText$1(value) {
15120
+ function normalizeOptionalText$2(value) {
14979
15121
  if (typeof value !== 'string') {
14980
15122
  return undefined;
14981
15123
  }
@@ -15007,13 +15149,13 @@
15007
15149
  async [UseCalendarToolNames.listEvents](args) {
15008
15150
  return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
15009
15151
  const query = {};
15010
- if (normalizeOptionalText(args.timeMin)) {
15152
+ if (normalizeOptionalText$1(args.timeMin)) {
15011
15153
  query.timeMin = args.timeMin.trim();
15012
15154
  }
15013
- if (normalizeOptionalText(args.timeMax)) {
15155
+ if (normalizeOptionalText$1(args.timeMax)) {
15014
15156
  query.timeMax = args.timeMax.trim();
15015
15157
  }
15016
- if (normalizeOptionalText(args.query)) {
15158
+ if (normalizeOptionalText$1(args.query)) {
15017
15159
  query.q = args.query.trim();
15018
15160
  }
15019
15161
  if (typeof args.maxResults === 'number' && Number.isFinite(args.maxResults) && args.maxResults > 0) {
@@ -15025,7 +15167,7 @@
15025
15167
  if (args.orderBy === 'startTime' || args.orderBy === 'updated') {
15026
15168
  query.orderBy = args.orderBy;
15027
15169
  }
15028
- if (normalizeOptionalText(args.timeZone)) {
15170
+ if (normalizeOptionalText$1(args.timeZone)) {
15029
15171
  query.timeZone = args.timeZone.trim();
15030
15172
  }
15031
15173
  const payload = await callGoogleCalendarApi(accessToken, {
@@ -15063,11 +15205,11 @@
15063
15205
  return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
15064
15206
  const requestBody = createGoogleCalendarEventPayload({
15065
15207
  summary: normalizeRequiredText(args.summary, 'summary'),
15066
- description: normalizeOptionalText(args.description),
15067
- location: normalizeOptionalText(args.location),
15208
+ description: normalizeOptionalText$1(args.description),
15209
+ location: normalizeOptionalText$1(args.location),
15068
15210
  start: normalizeRequiredText(args.start, 'start'),
15069
15211
  end: normalizeRequiredText(args.end, 'end'),
15070
- timeZone: normalizeOptionalText(args.timeZone),
15212
+ timeZone: normalizeOptionalText$1(args.timeZone),
15071
15213
  attendees: normalizeAttendees(args.attendees),
15072
15214
  reminderMinutes: normalizeReminderMinutes(args.reminderMinutes),
15073
15215
  });
@@ -15089,12 +15231,12 @@
15089
15231
  return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
15090
15232
  const eventId = normalizeRequiredText(args.eventId, 'eventId');
15091
15233
  const requestBody = createGoogleCalendarEventPayload({
15092
- summary: normalizeOptionalText(args.summary),
15093
- description: normalizeOptionalText(args.description),
15094
- location: normalizeOptionalText(args.location),
15095
- start: normalizeOptionalText(args.start),
15096
- end: normalizeOptionalText(args.end),
15097
- timeZone: normalizeOptionalText(args.timeZone),
15234
+ summary: normalizeOptionalText$1(args.summary),
15235
+ description: normalizeOptionalText$1(args.description),
15236
+ location: normalizeOptionalText$1(args.location),
15237
+ start: normalizeOptionalText$1(args.start),
15238
+ end: normalizeOptionalText$1(args.end),
15239
+ timeZone: normalizeOptionalText$1(args.timeZone),
15098
15240
  attendees: normalizeAttendees(args.attendees),
15099
15241
  reminderMinutes: normalizeReminderMinutes(args.reminderMinutes),
15100
15242
  });
@@ -15141,7 +15283,7 @@
15141
15283
  path: `/calendars/${encodeGoogleCalendarId(calendarReference.calendarId)}/events/${encodeURIComponent(eventId)}`,
15142
15284
  });
15143
15285
  const existingAttendees = ((existingEvent === null || existingEvent === void 0 ? void 0 : existingEvent.attendees) || [])
15144
- .map((attendee) => normalizeOptionalText(attendee.email))
15286
+ .map((attendee) => normalizeOptionalText$1(attendee.email))
15145
15287
  .filter((email) => Boolean(email));
15146
15288
  const mergedAttendees = [...new Set([...existingAttendees, ...guests])];
15147
15289
  const payload = await callGoogleCalendarApi(accessToken, {
@@ -15189,7 +15331,7 @@
15189
15331
  * @private function of createUseCalendarToolFunctions
15190
15332
  */
15191
15333
  function normalizeRequiredText(value, fieldName) {
15192
- const normalizedValue = normalizeOptionalText(value);
15334
+ const normalizedValue = normalizeOptionalText$1(value);
15193
15335
  if (!normalizedValue) {
15194
15336
  throw new Error(`Tool "${fieldName}" requires non-empty value.`);
15195
15337
  }
@@ -15200,7 +15342,7 @@
15200
15342
  *
15201
15343
  * @private function of createUseCalendarToolFunctions
15202
15344
  */
15203
- function normalizeOptionalText(value) {
15345
+ function normalizeOptionalText$1(value) {
15204
15346
  if (typeof value !== 'string') {
15205
15347
  return undefined;
15206
15348
  }
@@ -19886,6 +20028,580 @@
19886
20028
  }
19887
20029
  // Note: [💞] Ignore a discrepancy between file name and entity name
19888
20030
 
20031
+ /**
20032
+ * Names of tools used by the WALLET commitment.
20033
+ *
20034
+ * @private constant of WalletCommitmentDefinition
20035
+ */
20036
+ const WalletToolNames = {
20037
+ retrieve: 'retrieve_wallet_records',
20038
+ store: 'store_wallet_record',
20039
+ update: 'update_wallet_record',
20040
+ delete: 'delete_wallet_record',
20041
+ request: 'request_wallet_record',
20042
+ };
20043
+
20044
+ /**
20045
+ * Creates WALLET system-message instructions.
20046
+ *
20047
+ * @private function of WalletCommitmentDefinition
20048
+ */
20049
+ function createWalletSystemMessage(extraInstructions) {
20050
+ return spacetrim.spaceTrim((block) => `
20051
+ Wallet:
20052
+ - Use "${WalletToolNames.retrieve}" before authenticated operations.
20053
+ - Use "${WalletToolNames.store}" and "${WalletToolNames.update}" to maintain credentials.
20054
+ - Use "${WalletToolNames.delete}" to remove invalid credentials.
20055
+ - Use "${WalletToolNames.request}" to request missing credentials via UI popup.
20056
+ - Scope records by user (\`isUserScoped\`) and/or by agent (\`isGlobal=false\`) as needed.
20057
+ - Never expose raw credentials in chat responses.
20058
+ ${block(extraInstructions)}
20059
+ `);
20060
+ }
20061
+
20062
+ /**
20063
+ * Resolves disabled message for wallet runtime context.
20064
+ *
20065
+ * @private function of WalletCommitmentDefinition
20066
+ */
20067
+ function resolveWalletDisabledMessage(runtimeContext) {
20068
+ if (runtimeContext.isPrivateMode) {
20069
+ return 'Wallet is disabled because private mode is active.';
20070
+ }
20071
+ if (runtimeContext.isTeamConversation) {
20072
+ return 'Wallet is disabled for TEAM conversations.';
20073
+ }
20074
+ if (!runtimeContext.enabled) {
20075
+ return 'Wallet is disabled for unauthenticated users.';
20076
+ }
20077
+ return null;
20078
+ }
20079
+ /**
20080
+ * Resolves runtime adapter for wallet tools or returns disabled payload when unavailable.
20081
+ *
20082
+ * @private function of WalletCommitmentDefinition
20083
+ */
20084
+ function getWalletToolRuntimeAdapterOrDisabledResult(action, runtimeContext) {
20085
+ const disabledMessage = resolveWalletDisabledMessage(runtimeContext);
20086
+ if (disabledMessage) {
20087
+ return {
20088
+ adapter: null,
20089
+ disabledResult: {
20090
+ action,
20091
+ status: 'disabled',
20092
+ records: action === 'retrieve' ? [] : undefined,
20093
+ message: disabledMessage,
20094
+ },
20095
+ };
20096
+ }
20097
+ {
20098
+ return {
20099
+ adapter: null,
20100
+ disabledResult: {
20101
+ action,
20102
+ status: 'disabled',
20103
+ records: action === 'retrieve' ? [] : undefined,
20104
+ message: 'Wallet runtime is not available in this environment.',
20105
+ },
20106
+ };
20107
+ }
20108
+ }
20109
+
20110
+ /**
20111
+ * Parses store/update wallet payload.
20112
+ *
20113
+ * @private function of WalletCommitmentDefinition
20114
+ */
20115
+ function parseWalletPayload(args) {
20116
+ const recordType = parseWalletRecordType(args.recordType);
20117
+ return {
20118
+ recordType,
20119
+ service: parseWalletService(args.service),
20120
+ key: parseWalletKey(args.key),
20121
+ isUserScoped: args.isUserScoped === true,
20122
+ isGlobal: args.isGlobal === true,
20123
+ ...parseWalletSecrets({
20124
+ recordType,
20125
+ username: args.username,
20126
+ password: args.password,
20127
+ secret: args.secret,
20128
+ cookies: args.cookies,
20129
+ }),
20130
+ };
20131
+ }
20132
+ /**
20133
+ * Parses text argument and returns trimmed text when available.
20134
+ *
20135
+ * @private function of WalletCommitmentDefinition
20136
+ */
20137
+ function normalizeOptionalText(value) {
20138
+ if (typeof value !== 'string') {
20139
+ return undefined;
20140
+ }
20141
+ const trimmed = value.trim();
20142
+ return trimmed || undefined;
20143
+ }
20144
+ /**
20145
+ * Parses wallet service argument.
20146
+ *
20147
+ * @private function of WalletCommitmentDefinition
20148
+ */
20149
+ function parseWalletService(value) {
20150
+ return (normalizeOptionalText(value) || 'generic').toLowerCase();
20151
+ }
20152
+ /**
20153
+ * Parses wallet key argument.
20154
+ *
20155
+ * @private function of WalletCommitmentDefinition
20156
+ */
20157
+ function parseWalletKey(value) {
20158
+ return normalizeOptionalText(value) || 'default';
20159
+ }
20160
+ /**
20161
+ * Parses one wallet record id argument.
20162
+ *
20163
+ * @private function of WalletCommitmentDefinition
20164
+ */
20165
+ function parseWalletId(value) {
20166
+ const walletId = normalizeOptionalText(value);
20167
+ if (!walletId) {
20168
+ throw new Error('Wallet id is required.');
20169
+ }
20170
+ return walletId;
20171
+ }
20172
+ /**
20173
+ * Parses wallet record type.
20174
+ *
20175
+ * @private function of WalletCommitmentDefinition
20176
+ */
20177
+ function parseWalletRecordType(value, fallback) {
20178
+ var _a;
20179
+ const normalizedType = (_a = normalizeOptionalText(value)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
20180
+ if (normalizedType === 'USERNAME_PASSWORD') {
20181
+ return 'USERNAME_PASSWORD';
20182
+ }
20183
+ if (normalizedType === 'SESSION_COOKIE') {
20184
+ return 'SESSION_COOKIE';
20185
+ }
20186
+ if (normalizedType === 'ACCESS_TOKEN') {
20187
+ return 'ACCESS_TOKEN';
20188
+ }
20189
+ if (fallback) {
20190
+ return fallback;
20191
+ }
20192
+ throw new Error('Unsupported wallet recordType. Expected one of: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.');
20193
+ }
20194
+ /**
20195
+ * Parses wallet secret fields according to record type.
20196
+ *
20197
+ * @private function of WalletCommitmentDefinition
20198
+ */
20199
+ function parseWalletSecrets(args) {
20200
+ const username = normalizeOptionalText(args.username);
20201
+ const password = normalizeOptionalText(args.password);
20202
+ const secret = normalizeOptionalText(args.secret);
20203
+ const cookies = normalizeOptionalText(args.cookies);
20204
+ if (args.recordType === 'USERNAME_PASSWORD') {
20205
+ if (!username || !password) {
20206
+ throw new Error('Both username and password are required for USERNAME_PASSWORD.');
20207
+ }
20208
+ return { username, password };
20209
+ }
20210
+ if (args.recordType === 'SESSION_COOKIE') {
20211
+ if (!cookies) {
20212
+ throw new Error('Cookies are required for SESSION_COOKIE.');
20213
+ }
20214
+ return { cookies };
20215
+ }
20216
+ if (!secret) {
20217
+ throw new Error('Secret is required for ACCESS_TOKEN.');
20218
+ }
20219
+ return { secret };
20220
+ }
20221
+ /**
20222
+ * Collection of WALLET tool argument parsers.
20223
+ *
20224
+ * @private function of WalletCommitmentDefinition
20225
+ */
20226
+ const parseWalletToolArgs = {
20227
+ /**
20228
+ * Parses retrieve arguments.
20229
+ */
20230
+ retrieve(args) {
20231
+ const limit = typeof args.limit === 'number' && Number.isFinite(args.limit) ? Math.floor(args.limit) : undefined;
20232
+ return {
20233
+ query: normalizeOptionalText(args.query),
20234
+ recordType: normalizeOptionalText(args.recordType) ? parseWalletRecordType(args.recordType) : undefined,
20235
+ service: normalizeOptionalText(args.service) ? parseWalletService(args.service) : undefined,
20236
+ key: normalizeOptionalText(args.key) ? parseWalletKey(args.key) : undefined,
20237
+ limit: limit && limit > 0 ? Math.min(limit, 20) : undefined,
20238
+ };
20239
+ },
20240
+ /**
20241
+ * Parses store payload.
20242
+ */
20243
+ store(args) {
20244
+ return parseWalletPayload(args);
20245
+ },
20246
+ /**
20247
+ * Parses update payload.
20248
+ */
20249
+ update(args) {
20250
+ const walletId = parseWalletId(args.walletId);
20251
+ const record = parseWalletPayload(args);
20252
+ return {
20253
+ ...record,
20254
+ walletId,
20255
+ };
20256
+ },
20257
+ /**
20258
+ * Parses delete payload.
20259
+ */
20260
+ delete(args) {
20261
+ return { walletId: parseWalletId(args.walletId) };
20262
+ },
20263
+ /**
20264
+ * Parses request payload for user wallet input prompt.
20265
+ */
20266
+ request(args) {
20267
+ return {
20268
+ recordType: parseWalletRecordType(args.recordType, 'ACCESS_TOKEN'),
20269
+ service: parseWalletService(args.service),
20270
+ key: parseWalletKey(args.key),
20271
+ message: normalizeOptionalText(args.message),
20272
+ isUserScoped: args.isUserScoped === true,
20273
+ isGlobal: args.isGlobal === true,
20274
+ };
20275
+ },
20276
+ };
20277
+
20278
+ /**
20279
+ * Resolves runtime context from hidden tool arguments.
20280
+ *
20281
+ * @private function of WalletCommitmentDefinition
20282
+ */
20283
+ function resolveWalletRuntimeContext(args) {
20284
+ const runtimeContext = readToolRuntimeContextFromToolArgs(args);
20285
+ const memoryContext = runtimeContext === null || runtimeContext === void 0 ? void 0 : runtimeContext.memory;
20286
+ return {
20287
+ enabled: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.enabled) === true,
20288
+ userId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.userId,
20289
+ username: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.username,
20290
+ agentId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentId,
20291
+ agentName: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentName,
20292
+ isTeamConversation: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isTeamConversation) === true,
20293
+ isPrivateMode: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isPrivateMode) === true,
20294
+ };
20295
+ }
20296
+
20297
+ /**
20298
+ * Creates runtime wallet tool function implementations.
20299
+ *
20300
+ * @private function of WalletCommitmentDefinition
20301
+ */
20302
+ function createWalletToolFunctions() {
20303
+ return {
20304
+ async [WalletToolNames.retrieve](args) {
20305
+ const runtimeContext = resolveWalletRuntimeContext(args);
20306
+ const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('retrieve', runtimeContext);
20307
+ if (!adapter || disabledResult) {
20308
+ return JSON.stringify(disabledResult);
20309
+ }
20310
+ try {
20311
+ const parsedArgs = parseWalletToolArgs.retrieve(args);
20312
+ const records = await adapter.retrieveWalletRecords(parsedArgs, runtimeContext);
20313
+ return JSON.stringify({
20314
+ action: 'retrieve',
20315
+ status: 'ok',
20316
+ query: parsedArgs.query,
20317
+ records,
20318
+ });
20319
+ }
20320
+ catch (error) {
20321
+ return JSON.stringify({
20322
+ action: 'retrieve',
20323
+ status: 'error',
20324
+ records: [],
20325
+ message: error instanceof Error ? error.message : String(error),
20326
+ });
20327
+ }
20328
+ },
20329
+ async [WalletToolNames.store](args) {
20330
+ const runtimeContext = resolveWalletRuntimeContext(args);
20331
+ const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('store', runtimeContext);
20332
+ if (!adapter || disabledResult) {
20333
+ return JSON.stringify(disabledResult);
20334
+ }
20335
+ try {
20336
+ const parsedArgs = parseWalletToolArgs.store(args);
20337
+ const record = await adapter.storeWalletRecord(parsedArgs, runtimeContext);
20338
+ return JSON.stringify({
20339
+ action: 'store',
20340
+ status: 'stored',
20341
+ record,
20342
+ });
20343
+ }
20344
+ catch (error) {
20345
+ return JSON.stringify({
20346
+ action: 'store',
20347
+ status: 'error',
20348
+ message: error instanceof Error ? error.message : String(error),
20349
+ });
20350
+ }
20351
+ },
20352
+ async [WalletToolNames.update](args) {
20353
+ const runtimeContext = resolveWalletRuntimeContext(args);
20354
+ const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
20355
+ if (!adapter || disabledResult) {
20356
+ return JSON.stringify(disabledResult);
20357
+ }
20358
+ try {
20359
+ const parsedArgs = parseWalletToolArgs.update(args);
20360
+ const record = await adapter.updateWalletRecord(parsedArgs, runtimeContext);
20361
+ return JSON.stringify({
20362
+ action: 'update',
20363
+ status: 'updated',
20364
+ record,
20365
+ });
20366
+ }
20367
+ catch (error) {
20368
+ return JSON.stringify({
20369
+ action: 'update',
20370
+ status: 'error',
20371
+ message: error instanceof Error ? error.message : String(error),
20372
+ });
20373
+ }
20374
+ },
20375
+ async [WalletToolNames.delete](args) {
20376
+ const runtimeContext = resolveWalletRuntimeContext(args);
20377
+ const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('delete', runtimeContext);
20378
+ if (!adapter || disabledResult) {
20379
+ return JSON.stringify(disabledResult);
20380
+ }
20381
+ try {
20382
+ const parsedArgs = parseWalletToolArgs.delete(args);
20383
+ const deleted = await adapter.deleteWalletRecord(parsedArgs, runtimeContext);
20384
+ return JSON.stringify({
20385
+ action: 'delete',
20386
+ status: 'deleted',
20387
+ walletId: deleted.id,
20388
+ });
20389
+ }
20390
+ catch (error) {
20391
+ return JSON.stringify({
20392
+ action: 'delete',
20393
+ status: 'error',
20394
+ message: error instanceof Error ? error.message : String(error),
20395
+ });
20396
+ }
20397
+ },
20398
+ async [WalletToolNames.request](args) {
20399
+ const runtimeContext = resolveWalletRuntimeContext(args);
20400
+ const disabledMessage = resolveWalletDisabledMessage(runtimeContext);
20401
+ if (disabledMessage) {
20402
+ return JSON.stringify({
20403
+ action: 'request',
20404
+ status: 'disabled',
20405
+ message: disabledMessage,
20406
+ });
20407
+ }
20408
+ const request = parseWalletToolArgs.request(args);
20409
+ return JSON.stringify({
20410
+ action: 'request',
20411
+ status: 'requested',
20412
+ request,
20413
+ message: request.message ||
20414
+ `Request user to provide ${request.recordType} credentials for service "${request.service}".`,
20415
+ });
20416
+ },
20417
+ };
20418
+ }
20419
+
20420
+ /**
20421
+ * Creates tool definitions required by WALLET commitment.
20422
+ *
20423
+ * @private function of WalletCommitmentDefinition
20424
+ */
20425
+ function createWalletTools(existingTools) {
20426
+ const tools = [...(existingTools || [])];
20427
+ addWalletToolIfMissing(tools, {
20428
+ name: WalletToolNames.retrieve,
20429
+ description: 'Retrieve wallet records relevant to the current task.',
20430
+ parameters: {
20431
+ type: 'object',
20432
+ properties: {
20433
+ query: { type: 'string', description: 'Optional text query used to filter wallet records.' },
20434
+ recordType: {
20435
+ type: 'string',
20436
+ description: 'Optional record type filter (USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN).',
20437
+ },
20438
+ service: { type: 'string', description: 'Optional service filter, for example github.' },
20439
+ key: { type: 'string', description: 'Optional wallet key filter.' },
20440
+ limit: { type: 'integer', description: 'Optional maximum number of records (default 5, max 20).' },
20441
+ },
20442
+ required: [],
20443
+ },
20444
+ });
20445
+ addWalletToolIfMissing(tools, {
20446
+ name: WalletToolNames.store,
20447
+ description: 'Store one wallet record.',
20448
+ parameters: {
20449
+ type: 'object',
20450
+ properties: {
20451
+ recordType: {
20452
+ type: 'string',
20453
+ description: 'Record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
20454
+ },
20455
+ service: { type: 'string', description: 'Service identifier, for example github.' },
20456
+ key: { type: 'string', description: 'Logical credential key.' },
20457
+ username: { type: 'string', description: 'Username for USERNAME_PASSWORD.' },
20458
+ password: { type: 'string', description: 'Password for USERNAME_PASSWORD.' },
20459
+ secret: { type: 'string', description: 'Token/API key for ACCESS_TOKEN.' },
20460
+ cookies: { type: 'string', description: 'Cookie header/json for SESSION_COOKIE.' },
20461
+ isUserScoped: { type: 'boolean', description: 'Set true to scope this record to current user.' },
20462
+ isGlobal: { type: 'boolean', description: 'Set true to make this record global.' },
20463
+ },
20464
+ required: ['recordType', 'service'],
20465
+ },
20466
+ });
20467
+ addWalletToolIfMissing(tools, {
20468
+ name: WalletToolNames.update,
20469
+ description: 'Update one existing wallet record.',
20470
+ parameters: {
20471
+ type: 'object',
20472
+ properties: {
20473
+ walletId: { type: 'string', description: 'Wallet record id to update.' },
20474
+ recordType: {
20475
+ type: 'string',
20476
+ description: 'Record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
20477
+ },
20478
+ service: { type: 'string', description: 'Service identifier, for example github.' },
20479
+ key: { type: 'string', description: 'Logical credential key.' },
20480
+ username: { type: 'string', description: 'Username for USERNAME_PASSWORD.' },
20481
+ password: { type: 'string', description: 'Password for USERNAME_PASSWORD.' },
20482
+ secret: { type: 'string', description: 'Token/API key for ACCESS_TOKEN.' },
20483
+ cookies: { type: 'string', description: 'Cookie header/json for SESSION_COOKIE.' },
20484
+ isUserScoped: { type: 'boolean', description: 'Set true to scope this record to current user.' },
20485
+ isGlobal: { type: 'boolean', description: 'Set true to make this record global.' },
20486
+ },
20487
+ required: ['walletId', 'recordType', 'service'],
20488
+ },
20489
+ });
20490
+ addWalletToolIfMissing(tools, {
20491
+ name: WalletToolNames.delete,
20492
+ description: 'Delete one wallet record.',
20493
+ parameters: {
20494
+ type: 'object',
20495
+ properties: {
20496
+ walletId: { type: 'string', description: 'Wallet record id to delete.' },
20497
+ },
20498
+ required: ['walletId'],
20499
+ },
20500
+ });
20501
+ addWalletToolIfMissing(tools, {
20502
+ name: WalletToolNames.request,
20503
+ description: 'Request missing credential from user via popup.',
20504
+ parameters: {
20505
+ type: 'object',
20506
+ properties: {
20507
+ recordType: {
20508
+ type: 'string',
20509
+ description: 'Requested record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
20510
+ },
20511
+ service: { type: 'string', description: 'Service identifier.' },
20512
+ key: { type: 'string', description: 'Logical credential key.' },
20513
+ message: { type: 'string', description: 'Optional UI message for user.' },
20514
+ isUserScoped: {
20515
+ type: 'boolean',
20516
+ description: 'Set true when record should be scoped to current user.',
20517
+ },
20518
+ isGlobal: { type: 'boolean', description: 'Set true when record should be global.' },
20519
+ },
20520
+ required: [],
20521
+ },
20522
+ });
20523
+ return tools;
20524
+ }
20525
+ /**
20526
+ * Registers one wallet tool when missing in current tool list.
20527
+ *
20528
+ * @private function of WalletCommitmentDefinition
20529
+ */
20530
+ function addWalletToolIfMissing(tools, tool) {
20531
+ if (!tools.some((existingTool) => existingTool.name === tool.name)) {
20532
+ tools.push(tool);
20533
+ }
20534
+ }
20535
+
20536
+ /**
20537
+ * Gets markdown documentation for WALLET commitment.
20538
+ *
20539
+ * @private function of WalletCommitmentDefinition
20540
+ */
20541
+ function getWalletCommitmentDocumentation(type) {
20542
+ return spacetrim.spaceTrim(`
20543
+ # ${type}
20544
+
20545
+ Enables private credential storage for tokens, usernames/passwords, and session cookies.
20546
+ `);
20547
+ }
20548
+
20549
+ /**
20550
+ * Gets human-readable titles for WALLET tool functions.
20551
+ *
20552
+ * @private function of WalletCommitmentDefinition
20553
+ */
20554
+ function getWalletToolTitles() {
20555
+ return {
20556
+ [WalletToolNames.retrieve]: 'Wallet',
20557
+ [WalletToolNames.store]: 'Store wallet record',
20558
+ [WalletToolNames.update]: 'Update wallet record',
20559
+ [WalletToolNames.delete]: 'Delete wallet record',
20560
+ [WalletToolNames.request]: 'Request wallet record',
20561
+ };
20562
+ }
20563
+
20564
+ /**
20565
+ * WALLET commitment definition.
20566
+ *
20567
+ * @private [🪔] Maybe export the commitments through some package
20568
+ */
20569
+ class WalletCommitmentDefinition extends BaseCommitmentDefinition {
20570
+ constructor(type = 'WALLET') {
20571
+ super(type);
20572
+ }
20573
+ get requiresContent() {
20574
+ return false;
20575
+ }
20576
+ get description() {
20577
+ return 'Enable persistent private credential storage (tokens, logins, cookies) scoped per agent or globally.';
20578
+ }
20579
+ get icon() {
20580
+ return '👛';
20581
+ }
20582
+ get documentation() {
20583
+ return getWalletCommitmentDocumentation(this.type);
20584
+ }
20585
+ applyToAgentModelRequirements(requirements, content) {
20586
+ const extraInstructions = formatOptionalInstructionBlock('Wallet instructions', content);
20587
+ return this.appendToSystemMessage({
20588
+ ...requirements,
20589
+ tools: createWalletTools(requirements.tools),
20590
+ _metadata: {
20591
+ ...requirements._metadata,
20592
+ useWallet: content || true,
20593
+ },
20594
+ }, createWalletSystemMessage(extraInstructions));
20595
+ }
20596
+ getToolTitles() {
20597
+ return getWalletToolTitles();
20598
+ }
20599
+ getToolFunctions() {
20600
+ return createWalletToolFunctions();
20601
+ }
20602
+ }
20603
+ // Note: [💞] Ignore a discrepancy between file name and entity name
20604
+
19889
20605
  /**
19890
20606
  * `WRITING RULES` commitment definition.
19891
20607
  *
@@ -20160,6 +20876,8 @@
20160
20876
  new MessageSuffixCommitmentDefinition(),
20161
20877
  new MessageCommitmentDefinition('MESSAGE'),
20162
20878
  new MessageCommitmentDefinition('MESSAGES'),
20879
+ new WalletCommitmentDefinition('WALLET'),
20880
+ new WalletCommitmentDefinition('WALLETS'),
20163
20881
  new ScenarioCommitmentDefinition('SCENARIO'),
20164
20882
  new ScenarioCommitmentDefinition('SCENARIOS'),
20165
20883
  new DeleteCommitmentDefinition('DELETE'),
@@ -20206,11 +20924,11 @@
20206
20924
  */
20207
20925
  const IMPORTANT_COMMITMENT_TYPE_SORT_ORDER = new Map([
20208
20926
  ['GOAL', 0],
20209
- ['GOALS', 1],
20210
- ['RULE', 2],
20211
- ['RULES', 3],
20212
- ['KNOWLEDGE', 4],
20213
- ['TEAM', 5],
20927
+ ['RULE', 1],
20928
+ ['KNOWLEDGE', 2],
20929
+ ['TEAM', 3],
20930
+ ['GOALS', 4],
20931
+ ['RULES', 5],
20214
20932
  ]);
20215
20933
  /**
20216
20934
  * Sort rank used when unfinished, low-level, and deprecated commitments should be grouped last.
@@ -21459,7 +22177,6 @@
21459
22177
  if (isVoidPseudoAgentReference(reference)) {
21460
22178
  label = VOID_PSEUDO_AGENT_REFERENCE; // <- {Void} label
21461
22179
  iconName = 'ShieldAlert';
21462
- return null; // <- Note: Do not show `{Void}` in capabilities, it's only used for internal logic
21463
22180
  }
21464
22181
  return {
21465
22182
  type: 'inheritance',
@@ -27088,6 +27805,12 @@
27088
27805
  ['GOAL', 'GOAL'],
27089
27806
  ['GOALS', 'GOAL'],
27090
27807
  ]);
27808
+ /**
27809
+ * Legacy commitments that should be parsed for compatibility but ignored by the model-requirements pipeline.
27810
+ *
27811
+ * @private internal constant of `filterCommitmentsForAgentModelRequirements`
27812
+ */
27813
+ const IGNORED_COMMITMENT_TYPES = new Set(['WALLET', 'WALLETS']);
27091
27814
  /**
27092
27815
  * Applies the commitment filtering rules used before commitment definitions are executed.
27093
27816
  *
@@ -27136,6 +27859,9 @@
27136
27859
  function filterDeletedCommitments(commitments) {
27137
27860
  const filteredCommitments = [];
27138
27861
  for (const commitment of commitments) {
27862
+ if (isIgnoredCommitmentType(commitment.type)) {
27863
+ continue;
27864
+ }
27139
27865
  if (!isDeleteCommitmentType(commitment.type)) {
27140
27866
  filteredCommitments.push(commitment);
27141
27867
  continue;
@@ -27166,6 +27892,17 @@
27166
27892
  function isDeleteCommitmentType(commitmentType) {
27167
27893
  return DELETE_COMMITMENT_TYPES.has(commitmentType);
27168
27894
  }
27895
+ /**
27896
+ * Checks whether a parsed commitment is intentionally ignored by the current model compiler.
27897
+ *
27898
+ * @param commitmentType - Commitment type to check.
27899
+ * @returns `true` when the commitment should not affect model requirements.
27900
+ *
27901
+ * @private internal utility of `filterDeletedCommitments`
27902
+ */
27903
+ function isIgnoredCommitmentType(commitmentType) {
27904
+ return IGNORED_COMMITMENT_TYPES.has(commitmentType);
27905
+ }
27169
27906
  /**
27170
27907
  * Extracts normalized parameter names used for DELETE-like invalidation matching.
27171
27908
  *
@@ -31574,8 +32311,8 @@
31574
32311
  * Prepares an AgentKit agent with optional knowledge sources and tool definitions.
31575
32312
  */
31576
32313
  async prepareAgentKitAgent(options) {
31577
- var _a, _b, _c;
31578
- const { name, instructions, knowledgeSources, tools, nativeAgentKitTools, vectorStoreId: cachedVectorStoreId, storeAsPrepared, } = options;
32314
+ var _a, _b;
32315
+ const { name, instructions, knowledgeSources, tools, vectorStoreId: cachedVectorStoreId, storeAsPrepared, } = options;
31579
32316
  await this.ensureAgentKitDefaults();
31580
32317
  if (this.options.isVerbose) {
31581
32318
  console.info('[🤰]', 'Preparing OpenAI AgentKit agent', {
@@ -31583,11 +32320,10 @@
31583
32320
  instructionsLength: instructions.length,
31584
32321
  knowledgeSourcesCount: (_a = knowledgeSources === null || knowledgeSources === void 0 ? void 0 : knowledgeSources.length) !== null && _a !== void 0 ? _a : 0,
31585
32322
  toolsCount: (_b = tools === null || tools === void 0 ? void 0 : tools.length) !== null && _b !== void 0 ? _b : 0,
31586
- nativeAgentKitToolsCount: (_c = nativeAgentKitTools === null || nativeAgentKitTools === void 0 ? void 0 : nativeAgentKitTools.length) !== null && _c !== void 0 ? _c : 0,
31587
32323
  });
31588
32324
  }
31589
32325
  let vectorStoreId = cachedVectorStoreId;
31590
- if (!vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
32326
+ if (this.isNativeKnowledgeSearchEnabled && !vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
31591
32327
  const vectorStoreResult = await this.createVectorStoreWithKnowledgeSources({
31592
32328
  client: await this.getClient(),
31593
32329
  name,
@@ -31596,13 +32332,19 @@
31596
32332
  });
31597
32333
  vectorStoreId = vectorStoreResult.vectorStoreId;
31598
32334
  }
31599
- else if (vectorStoreId && this.options.isVerbose) {
32335
+ else if (this.isNativeKnowledgeSearchEnabled && vectorStoreId && this.options.isVerbose) {
31600
32336
  console.info('[🤰]', 'Using cached vector store for AgentKit agent', {
31601
32337
  name,
31602
32338
  vectorStoreId,
31603
32339
  });
31604
32340
  }
31605
- const agentKitTools = this.buildAgentKitTools({ tools, nativeAgentKitTools, vectorStoreId });
32341
+ if (!this.isNativeKnowledgeSearchEnabled) {
32342
+ vectorStoreId = undefined;
32343
+ }
32344
+ const agentKitTools = this.buildAgentKitTools({
32345
+ tools,
32346
+ vectorStoreId,
32347
+ });
31606
32348
  const openAiAgentKitAgent = new agents.Agent({
31607
32349
  name,
31608
32350
  model: this.agentKitModelName,
@@ -31621,7 +32363,7 @@
31621
32363
  name,
31622
32364
  model: this.agentKitModelName,
31623
32365
  toolCount: agentKitTools.length,
31624
- hasVectorStore: Boolean(vectorStoreId),
32366
+ hasVectorStore: this.isNativeKnowledgeSearchEnabled && Boolean(vectorStoreId),
31625
32367
  });
31626
32368
  }
31627
32369
  return preparedAgent;
@@ -31641,14 +32383,11 @@
31641
32383
  * Builds the tool list for AgentKit, including hosted file search when applicable.
31642
32384
  */
31643
32385
  buildAgentKitTools(options) {
31644
- const { tools, nativeAgentKitTools, vectorStoreId } = options;
32386
+ const { tools, vectorStoreId } = options;
31645
32387
  const agentKitTools = [];
31646
32388
  if (vectorStoreId) {
31647
32389
  agentKitTools.push(agents.fileSearchTool(vectorStoreId));
31648
32390
  }
31649
- if (nativeAgentKitTools && nativeAgentKitTools.length > 0) {
31650
- agentKitTools.push(...nativeAgentKitTools);
31651
- }
31652
32391
  if (tools && tools.length > 0) {
31653
32392
  let scriptTools = null;
31654
32393
  for (const toolDefinition of tools) {
@@ -32123,6 +32862,12 @@
32123
32862
  get agentKitOptions() {
32124
32863
  return this.options;
32125
32864
  }
32865
+ /**
32866
+ * Returns true when hosted OpenAI vector-store search should back `knowledgeSources`.
32867
+ */
32868
+ get isNativeKnowledgeSearchEnabled() {
32869
+ return this.agentKitOptions.isNativeKnowledgeSearchEnabled !== false;
32870
+ }
32126
32871
  /**
32127
32872
  * Discriminant for type guards.
32128
32873
  */