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