@promptbook/wizard 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 +822 -42
  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 +3 -2
  30. package/umd/index.umd.js +822 -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
@@ -49,7 +49,7 @@
49
49
  * @generated
50
50
  * @see https://github.com/webgptorg/promptbook
51
51
  */
52
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-62';
52
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-64';
53
53
  /**
54
54
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
55
55
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -20745,6 +20745,18 @@
20745
20745
  return count;
20746
20746
  }
20747
20747
 
20748
+ /**
20749
+ * Name of the tool used by agents to search configured `KNOWLEDGE` sources.
20750
+ *
20751
+ * @public exported from `@promptbook/core`
20752
+ */
20753
+ const KNOWLEDGE_SEARCH_TOOL_NAME = 'knowledge_search';
20754
+ /**
20755
+ * Title of the system-message section generated for `KNOWLEDGE` commitments.
20756
+ *
20757
+ * @private constant of `KnowledgeCommitmentDefinition`
20758
+ */
20759
+ const KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE = 'Knowledge Search';
20748
20760
  /**
20749
20761
  * KNOWLEDGE commitment definition
20750
20762
  *
@@ -20866,9 +20878,17 @@
20866
20878
  knowledgeInfoEntries.push(`Knowledge Source Inline: ${inlineSource.filename} (derived from inline content and processed for retrieval during chat)`);
20867
20879
  }
20868
20880
  if (knowledgeInfoEntries.length === 0) {
20869
- return nextRequirements;
20881
+ return addKnowledgeSearchToolAndSystemSection(nextRequirements);
20870
20882
  }
20871
- return this.appendToSystemMessage(nextRequirements, knowledgeInfoEntries.join('\n'), '\n\n');
20883
+ return addKnowledgeSearchToolAndSystemSection(nextRequirements);
20884
+ }
20885
+ /**
20886
+ * Gets human-readable titles for tool functions provided by this commitment.
20887
+ */
20888
+ getToolTitles() {
20889
+ return {
20890
+ [KNOWLEDGE_SEARCH_TOOL_NAME]: 'Knowledge search',
20891
+ };
20872
20892
  }
20873
20893
  }
20874
20894
  /**
@@ -20882,6 +20902,128 @@
20882
20902
  const significantText = contentWithoutUrls.replace(/[\s.,!?;:'"`()[\]{}<>/-]+/g, '');
20883
20903
  return significantText.length > 0;
20884
20904
  }
20905
+ /**
20906
+ * Adds the shared `knowledge_search` tool definition and the consolidated system-message section.
20907
+ *
20908
+ * @param requirements - Requirements after one `KNOWLEDGE` commitment was applied.
20909
+ * @returns Requirements with the knowledge search instructions and tool definition.
20910
+ *
20911
+ * @private internal utility of `KnowledgeCommitmentDefinition`
20912
+ */
20913
+ function addKnowledgeSearchToolAndSystemSection(requirements) {
20914
+ const nextRequirements = addKnowledgeSearchTool(requirements);
20915
+ const section = createKnowledgeSearchSystemSection(nextRequirements);
20916
+ const sectionHeader = `## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}`;
20917
+ if (nextRequirements.systemMessage.includes(sectionHeader)) {
20918
+ return {
20919
+ ...nextRequirements,
20920
+ systemMessage: nextRequirements.systemMessage.replace(new RegExp(`## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), section),
20921
+ };
20922
+ }
20923
+ return {
20924
+ ...nextRequirements,
20925
+ systemMessage: nextRequirements.systemMessage.trim()
20926
+ ? `${nextRequirements.systemMessage}\n\n${section}`
20927
+ : section,
20928
+ };
20929
+ }
20930
+ /**
20931
+ * Adds the `knowledge_search` model tool when it is not already present.
20932
+ *
20933
+ * @param requirements - Current model requirements.
20934
+ * @returns Requirements with the tool definition available to the model.
20935
+ *
20936
+ * @private internal utility of `KnowledgeCommitmentDefinition`
20937
+ */
20938
+ function addKnowledgeSearchTool(requirements) {
20939
+ const existingTools = requirements.tools || [];
20940
+ if (existingTools.some((tool) => tool.name === KNOWLEDGE_SEARCH_TOOL_NAME)) {
20941
+ return requirements;
20942
+ }
20943
+ return {
20944
+ ...requirements,
20945
+ tools: [
20946
+ ...existingTools,
20947
+ {
20948
+ name: KNOWLEDGE_SEARCH_TOOL_NAME,
20949
+ description: _spaceTrim.spaceTrim(`
20950
+ Search the agent's configured knowledge sources and return relevant excerpts with citation ids.
20951
+ Use this before answering questions that may depend on the agent's KNOWLEDGE commitments.
20952
+ `),
20953
+ parameters: {
20954
+ type: 'object',
20955
+ properties: {
20956
+ query: {
20957
+ type: 'string',
20958
+ description: 'The natural-language search query for the knowledge base.',
20959
+ },
20960
+ limit: {
20961
+ type: 'integer',
20962
+ description: 'Maximum number of matching source excerpts to return.',
20963
+ },
20964
+ },
20965
+ required: ['query'],
20966
+ },
20967
+ },
20968
+ ],
20969
+ };
20970
+ }
20971
+ /**
20972
+ * Creates the model-facing system-message section for knowledge search.
20973
+ *
20974
+ * @param requirements - Current model requirements.
20975
+ * @returns Markdown system-message section.
20976
+ *
20977
+ * @private internal utility of `KnowledgeCommitmentDefinition`
20978
+ */
20979
+ function createKnowledgeSearchSystemSection(requirements) {
20980
+ const sourceEntries = createKnowledgeSourceSystemEntries(requirements);
20981
+ const sourceList = sourceEntries.length > 0 ? sourceEntries.map((entry) => `- ${entry}`).join('\n') : '- None';
20982
+ return _spaceTrim.spaceTrim(`
20983
+ ## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}
20984
+
20985
+ - Use \`${KNOWLEDGE_SEARCH_TOOL_NAME}\` to search the configured knowledge sources before answering questions that depend on this agent's knowledge base.
20986
+ - Base source-backed factual answers on the returned excerpts.
20987
+ - When you use a returned excerpt, include its citation marker in the answer body, for example \`[0:0]\`.
20988
+ - If the search returns no relevant information, say that the knowledge base did not contain the answer instead of inventing it.
20989
+
20990
+ Configured knowledge sources:
20991
+ ${sourceList}
20992
+ `);
20993
+ }
20994
+ /**
20995
+ * Builds a stable list of configured knowledge sources for system-message diagnostics.
20996
+ *
20997
+ * @param requirements - Current model requirements.
20998
+ * @returns Human-readable source entries.
20999
+ *
21000
+ * @private internal utility of `KnowledgeCommitmentDefinition`
21001
+ */
21002
+ function createKnowledgeSourceSystemEntries(requirements) {
21003
+ var _a;
21004
+ const entries = [];
21005
+ const seenEntries = new Set();
21006
+ for (const source of requirements.knowledgeSources || []) {
21007
+ const entry = `Source URL: ${source} (processed for retrieval during chat)`;
21008
+ if (seenEntries.has(entry)) {
21009
+ continue;
21010
+ }
21011
+ seenEntries.add(entry);
21012
+ entries.push(entry);
21013
+ }
21014
+ const inlineSources = (((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.inlineKnowledgeSources) || [])
21015
+ .map((source) => source.filename)
21016
+ .filter(Boolean);
21017
+ for (const filename of inlineSources) {
21018
+ const entry = `Knowledge Source Inline: ${filename} (Inline source: processed for retrieval during chat)`;
21019
+ if (seenEntries.has(entry)) {
21020
+ continue;
21021
+ }
21022
+ seenEntries.add(entry);
21023
+ entries.push(entry);
21024
+ }
21025
+ return entries;
21026
+ }
20885
21027
 
20886
21028
  /**
20887
21029
  * LANGUAGE commitment definition
@@ -28355,7 +28497,7 @@
28355
28497
  const runtimeContext = (readToolRuntimeContextFromToolArgs(args) ||
28356
28498
  {});
28357
28499
  const configuredCalendars = normalizeConfiguredCalendars$1((_a = runtimeContext.calendars) === null || _a === void 0 ? void 0 : _a.connections);
28358
- const calendarArgument = normalizeOptionalText$1(args.calendarUrl);
28500
+ const calendarArgument = normalizeOptionalText$2(args.calendarUrl);
28359
28501
  let calendarReference = null;
28360
28502
  if (calendarArgument) {
28361
28503
  calendarReference = parseGoogleCalendarReference(calendarArgument);
@@ -28375,7 +28517,7 @@
28375
28517
  if (!calendarReference) {
28376
28518
  throw new Error('Calendar is required but was not resolved.');
28377
28519
  }
28378
- const accessToken = normalizeOptionalText$1((_b = runtimeContext.calendars) === null || _b === void 0 ? void 0 : _b.googleAccessToken) || '';
28520
+ const accessToken = normalizeOptionalText$2((_b = runtimeContext.calendars) === null || _b === void 0 ? void 0 : _b.googleAccessToken) || '';
28379
28521
  if (!accessToken) {
28380
28522
  throw new CalendarWalletCredentialRequiredError({
28381
28523
  calendarReference,
@@ -28408,7 +28550,7 @@
28408
28550
  continue;
28409
28551
  }
28410
28552
  const calendar = rawCalendar;
28411
- const rawUrl = normalizeOptionalText$1(calendar.url);
28553
+ const rawUrl = normalizeOptionalText$2(calendar.url);
28412
28554
  if (!rawUrl) {
28413
28555
  continue;
28414
28556
  }
@@ -28459,7 +28601,7 @@
28459
28601
  *
28460
28602
  * @private function of resolveUseCalendarToolRuntimeOrWalletCredentialResult
28461
28603
  */
28462
- function normalizeOptionalText$1(value) {
28604
+ function normalizeOptionalText$2(value) {
28463
28605
  if (typeof value !== 'string') {
28464
28606
  return undefined;
28465
28607
  }
@@ -28491,13 +28633,13 @@
28491
28633
  async [UseCalendarToolNames.listEvents](args) {
28492
28634
  return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
28493
28635
  const query = {};
28494
- if (normalizeOptionalText(args.timeMin)) {
28636
+ if (normalizeOptionalText$1(args.timeMin)) {
28495
28637
  query.timeMin = args.timeMin.trim();
28496
28638
  }
28497
- if (normalizeOptionalText(args.timeMax)) {
28639
+ if (normalizeOptionalText$1(args.timeMax)) {
28498
28640
  query.timeMax = args.timeMax.trim();
28499
28641
  }
28500
- if (normalizeOptionalText(args.query)) {
28642
+ if (normalizeOptionalText$1(args.query)) {
28501
28643
  query.q = args.query.trim();
28502
28644
  }
28503
28645
  if (typeof args.maxResults === 'number' && Number.isFinite(args.maxResults) && args.maxResults > 0) {
@@ -28509,7 +28651,7 @@
28509
28651
  if (args.orderBy === 'startTime' || args.orderBy === 'updated') {
28510
28652
  query.orderBy = args.orderBy;
28511
28653
  }
28512
- if (normalizeOptionalText(args.timeZone)) {
28654
+ if (normalizeOptionalText$1(args.timeZone)) {
28513
28655
  query.timeZone = args.timeZone.trim();
28514
28656
  }
28515
28657
  const payload = await callGoogleCalendarApi(accessToken, {
@@ -28547,11 +28689,11 @@
28547
28689
  return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
28548
28690
  const requestBody = createGoogleCalendarEventPayload({
28549
28691
  summary: normalizeRequiredText(args.summary, 'summary'),
28550
- description: normalizeOptionalText(args.description),
28551
- location: normalizeOptionalText(args.location),
28692
+ description: normalizeOptionalText$1(args.description),
28693
+ location: normalizeOptionalText$1(args.location),
28552
28694
  start: normalizeRequiredText(args.start, 'start'),
28553
28695
  end: normalizeRequiredText(args.end, 'end'),
28554
- timeZone: normalizeOptionalText(args.timeZone),
28696
+ timeZone: normalizeOptionalText$1(args.timeZone),
28555
28697
  attendees: normalizeAttendees(args.attendees),
28556
28698
  reminderMinutes: normalizeReminderMinutes(args.reminderMinutes),
28557
28699
  });
@@ -28573,12 +28715,12 @@
28573
28715
  return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
28574
28716
  const eventId = normalizeRequiredText(args.eventId, 'eventId');
28575
28717
  const requestBody = createGoogleCalendarEventPayload({
28576
- summary: normalizeOptionalText(args.summary),
28577
- description: normalizeOptionalText(args.description),
28578
- location: normalizeOptionalText(args.location),
28579
- start: normalizeOptionalText(args.start),
28580
- end: normalizeOptionalText(args.end),
28581
- timeZone: normalizeOptionalText(args.timeZone),
28718
+ summary: normalizeOptionalText$1(args.summary),
28719
+ description: normalizeOptionalText$1(args.description),
28720
+ location: normalizeOptionalText$1(args.location),
28721
+ start: normalizeOptionalText$1(args.start),
28722
+ end: normalizeOptionalText$1(args.end),
28723
+ timeZone: normalizeOptionalText$1(args.timeZone),
28582
28724
  attendees: normalizeAttendees(args.attendees),
28583
28725
  reminderMinutes: normalizeReminderMinutes(args.reminderMinutes),
28584
28726
  });
@@ -28625,7 +28767,7 @@
28625
28767
  path: `/calendars/${encodeGoogleCalendarId(calendarReference.calendarId)}/events/${encodeURIComponent(eventId)}`,
28626
28768
  });
28627
28769
  const existingAttendees = ((existingEvent === null || existingEvent === void 0 ? void 0 : existingEvent.attendees) || [])
28628
- .map((attendee) => normalizeOptionalText(attendee.email))
28770
+ .map((attendee) => normalizeOptionalText$1(attendee.email))
28629
28771
  .filter((email) => Boolean(email));
28630
28772
  const mergedAttendees = [...new Set([...existingAttendees, ...guests])];
28631
28773
  const payload = await callGoogleCalendarApi(accessToken, {
@@ -28673,7 +28815,7 @@
28673
28815
  * @private function of createUseCalendarToolFunctions
28674
28816
  */
28675
28817
  function normalizeRequiredText(value, fieldName) {
28676
- const normalizedValue = normalizeOptionalText(value);
28818
+ const normalizedValue = normalizeOptionalText$1(value);
28677
28819
  if (!normalizedValue) {
28678
28820
  throw new Error(`Tool "${fieldName}" requires non-empty value.`);
28679
28821
  }
@@ -28684,7 +28826,7 @@
28684
28826
  *
28685
28827
  * @private function of createUseCalendarToolFunctions
28686
28828
  */
28687
- function normalizeOptionalText(value) {
28829
+ function normalizeOptionalText$1(value) {
28688
28830
  if (typeof value !== 'string') {
28689
28831
  return undefined;
28690
28832
  }
@@ -33304,6 +33446,580 @@
33304
33446
  }
33305
33447
  // Note: [💞] Ignore a discrepancy between file name and entity name
33306
33448
 
33449
+ /**
33450
+ * Names of tools used by the WALLET commitment.
33451
+ *
33452
+ * @private constant of WalletCommitmentDefinition
33453
+ */
33454
+ const WalletToolNames = {
33455
+ retrieve: 'retrieve_wallet_records',
33456
+ store: 'store_wallet_record',
33457
+ update: 'update_wallet_record',
33458
+ delete: 'delete_wallet_record',
33459
+ request: 'request_wallet_record',
33460
+ };
33461
+
33462
+ /**
33463
+ * Creates WALLET system-message instructions.
33464
+ *
33465
+ * @private function of WalletCommitmentDefinition
33466
+ */
33467
+ function createWalletSystemMessage(extraInstructions) {
33468
+ return _spaceTrim.spaceTrim((block) => `
33469
+ Wallet:
33470
+ - Use "${WalletToolNames.retrieve}" before authenticated operations.
33471
+ - Use "${WalletToolNames.store}" and "${WalletToolNames.update}" to maintain credentials.
33472
+ - Use "${WalletToolNames.delete}" to remove invalid credentials.
33473
+ - Use "${WalletToolNames.request}" to request missing credentials via UI popup.
33474
+ - Scope records by user (\`isUserScoped\`) and/or by agent (\`isGlobal=false\`) as needed.
33475
+ - Never expose raw credentials in chat responses.
33476
+ ${block(extraInstructions)}
33477
+ `);
33478
+ }
33479
+
33480
+ /**
33481
+ * Resolves disabled message for wallet runtime context.
33482
+ *
33483
+ * @private function of WalletCommitmentDefinition
33484
+ */
33485
+ function resolveWalletDisabledMessage(runtimeContext) {
33486
+ if (runtimeContext.isPrivateMode) {
33487
+ return 'Wallet is disabled because private mode is active.';
33488
+ }
33489
+ if (runtimeContext.isTeamConversation) {
33490
+ return 'Wallet is disabled for TEAM conversations.';
33491
+ }
33492
+ if (!runtimeContext.enabled) {
33493
+ return 'Wallet is disabled for unauthenticated users.';
33494
+ }
33495
+ return null;
33496
+ }
33497
+ /**
33498
+ * Resolves runtime adapter for wallet tools or returns disabled payload when unavailable.
33499
+ *
33500
+ * @private function of WalletCommitmentDefinition
33501
+ */
33502
+ function getWalletToolRuntimeAdapterOrDisabledResult(action, runtimeContext) {
33503
+ const disabledMessage = resolveWalletDisabledMessage(runtimeContext);
33504
+ if (disabledMessage) {
33505
+ return {
33506
+ adapter: null,
33507
+ disabledResult: {
33508
+ action,
33509
+ status: 'disabled',
33510
+ records: action === 'retrieve' ? [] : undefined,
33511
+ message: disabledMessage,
33512
+ },
33513
+ };
33514
+ }
33515
+ {
33516
+ return {
33517
+ adapter: null,
33518
+ disabledResult: {
33519
+ action,
33520
+ status: 'disabled',
33521
+ records: action === 'retrieve' ? [] : undefined,
33522
+ message: 'Wallet runtime is not available in this environment.',
33523
+ },
33524
+ };
33525
+ }
33526
+ }
33527
+
33528
+ /**
33529
+ * Parses store/update wallet payload.
33530
+ *
33531
+ * @private function of WalletCommitmentDefinition
33532
+ */
33533
+ function parseWalletPayload(args) {
33534
+ const recordType = parseWalletRecordType(args.recordType);
33535
+ return {
33536
+ recordType,
33537
+ service: parseWalletService(args.service),
33538
+ key: parseWalletKey(args.key),
33539
+ isUserScoped: args.isUserScoped === true,
33540
+ isGlobal: args.isGlobal === true,
33541
+ ...parseWalletSecrets({
33542
+ recordType,
33543
+ username: args.username,
33544
+ password: args.password,
33545
+ secret: args.secret,
33546
+ cookies: args.cookies,
33547
+ }),
33548
+ };
33549
+ }
33550
+ /**
33551
+ * Parses text argument and returns trimmed text when available.
33552
+ *
33553
+ * @private function of WalletCommitmentDefinition
33554
+ */
33555
+ function normalizeOptionalText(value) {
33556
+ if (typeof value !== 'string') {
33557
+ return undefined;
33558
+ }
33559
+ const trimmed = value.trim();
33560
+ return trimmed || undefined;
33561
+ }
33562
+ /**
33563
+ * Parses wallet service argument.
33564
+ *
33565
+ * @private function of WalletCommitmentDefinition
33566
+ */
33567
+ function parseWalletService(value) {
33568
+ return (normalizeOptionalText(value) || 'generic').toLowerCase();
33569
+ }
33570
+ /**
33571
+ * Parses wallet key argument.
33572
+ *
33573
+ * @private function of WalletCommitmentDefinition
33574
+ */
33575
+ function parseWalletKey(value) {
33576
+ return normalizeOptionalText(value) || 'default';
33577
+ }
33578
+ /**
33579
+ * Parses one wallet record id argument.
33580
+ *
33581
+ * @private function of WalletCommitmentDefinition
33582
+ */
33583
+ function parseWalletId(value) {
33584
+ const walletId = normalizeOptionalText(value);
33585
+ if (!walletId) {
33586
+ throw new Error('Wallet id is required.');
33587
+ }
33588
+ return walletId;
33589
+ }
33590
+ /**
33591
+ * Parses wallet record type.
33592
+ *
33593
+ * @private function of WalletCommitmentDefinition
33594
+ */
33595
+ function parseWalletRecordType(value, fallback) {
33596
+ var _a;
33597
+ const normalizedType = (_a = normalizeOptionalText(value)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
33598
+ if (normalizedType === 'USERNAME_PASSWORD') {
33599
+ return 'USERNAME_PASSWORD';
33600
+ }
33601
+ if (normalizedType === 'SESSION_COOKIE') {
33602
+ return 'SESSION_COOKIE';
33603
+ }
33604
+ if (normalizedType === 'ACCESS_TOKEN') {
33605
+ return 'ACCESS_TOKEN';
33606
+ }
33607
+ if (fallback) {
33608
+ return fallback;
33609
+ }
33610
+ throw new Error('Unsupported wallet recordType. Expected one of: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.');
33611
+ }
33612
+ /**
33613
+ * Parses wallet secret fields according to record type.
33614
+ *
33615
+ * @private function of WalletCommitmentDefinition
33616
+ */
33617
+ function parseWalletSecrets(args) {
33618
+ const username = normalizeOptionalText(args.username);
33619
+ const password = normalizeOptionalText(args.password);
33620
+ const secret = normalizeOptionalText(args.secret);
33621
+ const cookies = normalizeOptionalText(args.cookies);
33622
+ if (args.recordType === 'USERNAME_PASSWORD') {
33623
+ if (!username || !password) {
33624
+ throw new Error('Both username and password are required for USERNAME_PASSWORD.');
33625
+ }
33626
+ return { username, password };
33627
+ }
33628
+ if (args.recordType === 'SESSION_COOKIE') {
33629
+ if (!cookies) {
33630
+ throw new Error('Cookies are required for SESSION_COOKIE.');
33631
+ }
33632
+ return { cookies };
33633
+ }
33634
+ if (!secret) {
33635
+ throw new Error('Secret is required for ACCESS_TOKEN.');
33636
+ }
33637
+ return { secret };
33638
+ }
33639
+ /**
33640
+ * Collection of WALLET tool argument parsers.
33641
+ *
33642
+ * @private function of WalletCommitmentDefinition
33643
+ */
33644
+ const parseWalletToolArgs = {
33645
+ /**
33646
+ * Parses retrieve arguments.
33647
+ */
33648
+ retrieve(args) {
33649
+ const limit = typeof args.limit === 'number' && Number.isFinite(args.limit) ? Math.floor(args.limit) : undefined;
33650
+ return {
33651
+ query: normalizeOptionalText(args.query),
33652
+ recordType: normalizeOptionalText(args.recordType) ? parseWalletRecordType(args.recordType) : undefined,
33653
+ service: normalizeOptionalText(args.service) ? parseWalletService(args.service) : undefined,
33654
+ key: normalizeOptionalText(args.key) ? parseWalletKey(args.key) : undefined,
33655
+ limit: limit && limit > 0 ? Math.min(limit, 20) : undefined,
33656
+ };
33657
+ },
33658
+ /**
33659
+ * Parses store payload.
33660
+ */
33661
+ store(args) {
33662
+ return parseWalletPayload(args);
33663
+ },
33664
+ /**
33665
+ * Parses update payload.
33666
+ */
33667
+ update(args) {
33668
+ const walletId = parseWalletId(args.walletId);
33669
+ const record = parseWalletPayload(args);
33670
+ return {
33671
+ ...record,
33672
+ walletId,
33673
+ };
33674
+ },
33675
+ /**
33676
+ * Parses delete payload.
33677
+ */
33678
+ delete(args) {
33679
+ return { walletId: parseWalletId(args.walletId) };
33680
+ },
33681
+ /**
33682
+ * Parses request payload for user wallet input prompt.
33683
+ */
33684
+ request(args) {
33685
+ return {
33686
+ recordType: parseWalletRecordType(args.recordType, 'ACCESS_TOKEN'),
33687
+ service: parseWalletService(args.service),
33688
+ key: parseWalletKey(args.key),
33689
+ message: normalizeOptionalText(args.message),
33690
+ isUserScoped: args.isUserScoped === true,
33691
+ isGlobal: args.isGlobal === true,
33692
+ };
33693
+ },
33694
+ };
33695
+
33696
+ /**
33697
+ * Resolves runtime context from hidden tool arguments.
33698
+ *
33699
+ * @private function of WalletCommitmentDefinition
33700
+ */
33701
+ function resolveWalletRuntimeContext(args) {
33702
+ const runtimeContext = readToolRuntimeContextFromToolArgs(args);
33703
+ const memoryContext = runtimeContext === null || runtimeContext === void 0 ? void 0 : runtimeContext.memory;
33704
+ return {
33705
+ enabled: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.enabled) === true,
33706
+ userId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.userId,
33707
+ username: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.username,
33708
+ agentId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentId,
33709
+ agentName: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentName,
33710
+ isTeamConversation: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isTeamConversation) === true,
33711
+ isPrivateMode: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isPrivateMode) === true,
33712
+ };
33713
+ }
33714
+
33715
+ /**
33716
+ * Creates runtime wallet tool function implementations.
33717
+ *
33718
+ * @private function of WalletCommitmentDefinition
33719
+ */
33720
+ function createWalletToolFunctions() {
33721
+ return {
33722
+ async [WalletToolNames.retrieve](args) {
33723
+ const runtimeContext = resolveWalletRuntimeContext(args);
33724
+ const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('retrieve', runtimeContext);
33725
+ if (!adapter || disabledResult) {
33726
+ return JSON.stringify(disabledResult);
33727
+ }
33728
+ try {
33729
+ const parsedArgs = parseWalletToolArgs.retrieve(args);
33730
+ const records = await adapter.retrieveWalletRecords(parsedArgs, runtimeContext);
33731
+ return JSON.stringify({
33732
+ action: 'retrieve',
33733
+ status: 'ok',
33734
+ query: parsedArgs.query,
33735
+ records,
33736
+ });
33737
+ }
33738
+ catch (error) {
33739
+ return JSON.stringify({
33740
+ action: 'retrieve',
33741
+ status: 'error',
33742
+ records: [],
33743
+ message: error instanceof Error ? error.message : String(error),
33744
+ });
33745
+ }
33746
+ },
33747
+ async [WalletToolNames.store](args) {
33748
+ const runtimeContext = resolveWalletRuntimeContext(args);
33749
+ const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('store', runtimeContext);
33750
+ if (!adapter || disabledResult) {
33751
+ return JSON.stringify(disabledResult);
33752
+ }
33753
+ try {
33754
+ const parsedArgs = parseWalletToolArgs.store(args);
33755
+ const record = await adapter.storeWalletRecord(parsedArgs, runtimeContext);
33756
+ return JSON.stringify({
33757
+ action: 'store',
33758
+ status: 'stored',
33759
+ record,
33760
+ });
33761
+ }
33762
+ catch (error) {
33763
+ return JSON.stringify({
33764
+ action: 'store',
33765
+ status: 'error',
33766
+ message: error instanceof Error ? error.message : String(error),
33767
+ });
33768
+ }
33769
+ },
33770
+ async [WalletToolNames.update](args) {
33771
+ const runtimeContext = resolveWalletRuntimeContext(args);
33772
+ const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
33773
+ if (!adapter || disabledResult) {
33774
+ return JSON.stringify(disabledResult);
33775
+ }
33776
+ try {
33777
+ const parsedArgs = parseWalletToolArgs.update(args);
33778
+ const record = await adapter.updateWalletRecord(parsedArgs, runtimeContext);
33779
+ return JSON.stringify({
33780
+ action: 'update',
33781
+ status: 'updated',
33782
+ record,
33783
+ });
33784
+ }
33785
+ catch (error) {
33786
+ return JSON.stringify({
33787
+ action: 'update',
33788
+ status: 'error',
33789
+ message: error instanceof Error ? error.message : String(error),
33790
+ });
33791
+ }
33792
+ },
33793
+ async [WalletToolNames.delete](args) {
33794
+ const runtimeContext = resolveWalletRuntimeContext(args);
33795
+ const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('delete', runtimeContext);
33796
+ if (!adapter || disabledResult) {
33797
+ return JSON.stringify(disabledResult);
33798
+ }
33799
+ try {
33800
+ const parsedArgs = parseWalletToolArgs.delete(args);
33801
+ const deleted = await adapter.deleteWalletRecord(parsedArgs, runtimeContext);
33802
+ return JSON.stringify({
33803
+ action: 'delete',
33804
+ status: 'deleted',
33805
+ walletId: deleted.id,
33806
+ });
33807
+ }
33808
+ catch (error) {
33809
+ return JSON.stringify({
33810
+ action: 'delete',
33811
+ status: 'error',
33812
+ message: error instanceof Error ? error.message : String(error),
33813
+ });
33814
+ }
33815
+ },
33816
+ async [WalletToolNames.request](args) {
33817
+ const runtimeContext = resolveWalletRuntimeContext(args);
33818
+ const disabledMessage = resolveWalletDisabledMessage(runtimeContext);
33819
+ if (disabledMessage) {
33820
+ return JSON.stringify({
33821
+ action: 'request',
33822
+ status: 'disabled',
33823
+ message: disabledMessage,
33824
+ });
33825
+ }
33826
+ const request = parseWalletToolArgs.request(args);
33827
+ return JSON.stringify({
33828
+ action: 'request',
33829
+ status: 'requested',
33830
+ request,
33831
+ message: request.message ||
33832
+ `Request user to provide ${request.recordType} credentials for service "${request.service}".`,
33833
+ });
33834
+ },
33835
+ };
33836
+ }
33837
+
33838
+ /**
33839
+ * Creates tool definitions required by WALLET commitment.
33840
+ *
33841
+ * @private function of WalletCommitmentDefinition
33842
+ */
33843
+ function createWalletTools(existingTools) {
33844
+ const tools = [...(existingTools || [])];
33845
+ addWalletToolIfMissing(tools, {
33846
+ name: WalletToolNames.retrieve,
33847
+ description: 'Retrieve wallet records relevant to the current task.',
33848
+ parameters: {
33849
+ type: 'object',
33850
+ properties: {
33851
+ query: { type: 'string', description: 'Optional text query used to filter wallet records.' },
33852
+ recordType: {
33853
+ type: 'string',
33854
+ description: 'Optional record type filter (USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN).',
33855
+ },
33856
+ service: { type: 'string', description: 'Optional service filter, for example github.' },
33857
+ key: { type: 'string', description: 'Optional wallet key filter.' },
33858
+ limit: { type: 'integer', description: 'Optional maximum number of records (default 5, max 20).' },
33859
+ },
33860
+ required: [],
33861
+ },
33862
+ });
33863
+ addWalletToolIfMissing(tools, {
33864
+ name: WalletToolNames.store,
33865
+ description: 'Store one wallet record.',
33866
+ parameters: {
33867
+ type: 'object',
33868
+ properties: {
33869
+ recordType: {
33870
+ type: 'string',
33871
+ description: 'Record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
33872
+ },
33873
+ service: { type: 'string', description: 'Service identifier, for example github.' },
33874
+ key: { type: 'string', description: 'Logical credential key.' },
33875
+ username: { type: 'string', description: 'Username for USERNAME_PASSWORD.' },
33876
+ password: { type: 'string', description: 'Password for USERNAME_PASSWORD.' },
33877
+ secret: { type: 'string', description: 'Token/API key for ACCESS_TOKEN.' },
33878
+ cookies: { type: 'string', description: 'Cookie header/json for SESSION_COOKIE.' },
33879
+ isUserScoped: { type: 'boolean', description: 'Set true to scope this record to current user.' },
33880
+ isGlobal: { type: 'boolean', description: 'Set true to make this record global.' },
33881
+ },
33882
+ required: ['recordType', 'service'],
33883
+ },
33884
+ });
33885
+ addWalletToolIfMissing(tools, {
33886
+ name: WalletToolNames.update,
33887
+ description: 'Update one existing wallet record.',
33888
+ parameters: {
33889
+ type: 'object',
33890
+ properties: {
33891
+ walletId: { type: 'string', description: 'Wallet record id to update.' },
33892
+ recordType: {
33893
+ type: 'string',
33894
+ description: 'Record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
33895
+ },
33896
+ service: { type: 'string', description: 'Service identifier, for example github.' },
33897
+ key: { type: 'string', description: 'Logical credential key.' },
33898
+ username: { type: 'string', description: 'Username for USERNAME_PASSWORD.' },
33899
+ password: { type: 'string', description: 'Password for USERNAME_PASSWORD.' },
33900
+ secret: { type: 'string', description: 'Token/API key for ACCESS_TOKEN.' },
33901
+ cookies: { type: 'string', description: 'Cookie header/json for SESSION_COOKIE.' },
33902
+ isUserScoped: { type: 'boolean', description: 'Set true to scope this record to current user.' },
33903
+ isGlobal: { type: 'boolean', description: 'Set true to make this record global.' },
33904
+ },
33905
+ required: ['walletId', 'recordType', 'service'],
33906
+ },
33907
+ });
33908
+ addWalletToolIfMissing(tools, {
33909
+ name: WalletToolNames.delete,
33910
+ description: 'Delete one wallet record.',
33911
+ parameters: {
33912
+ type: 'object',
33913
+ properties: {
33914
+ walletId: { type: 'string', description: 'Wallet record id to delete.' },
33915
+ },
33916
+ required: ['walletId'],
33917
+ },
33918
+ });
33919
+ addWalletToolIfMissing(tools, {
33920
+ name: WalletToolNames.request,
33921
+ description: 'Request missing credential from user via popup.',
33922
+ parameters: {
33923
+ type: 'object',
33924
+ properties: {
33925
+ recordType: {
33926
+ type: 'string',
33927
+ description: 'Requested record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
33928
+ },
33929
+ service: { type: 'string', description: 'Service identifier.' },
33930
+ key: { type: 'string', description: 'Logical credential key.' },
33931
+ message: { type: 'string', description: 'Optional UI message for user.' },
33932
+ isUserScoped: {
33933
+ type: 'boolean',
33934
+ description: 'Set true when record should be scoped to current user.',
33935
+ },
33936
+ isGlobal: { type: 'boolean', description: 'Set true when record should be global.' },
33937
+ },
33938
+ required: [],
33939
+ },
33940
+ });
33941
+ return tools;
33942
+ }
33943
+ /**
33944
+ * Registers one wallet tool when missing in current tool list.
33945
+ *
33946
+ * @private function of WalletCommitmentDefinition
33947
+ */
33948
+ function addWalletToolIfMissing(tools, tool) {
33949
+ if (!tools.some((existingTool) => existingTool.name === tool.name)) {
33950
+ tools.push(tool);
33951
+ }
33952
+ }
33953
+
33954
+ /**
33955
+ * Gets markdown documentation for WALLET commitment.
33956
+ *
33957
+ * @private function of WalletCommitmentDefinition
33958
+ */
33959
+ function getWalletCommitmentDocumentation(type) {
33960
+ return _spaceTrim.spaceTrim(`
33961
+ # ${type}
33962
+
33963
+ Enables private credential storage for tokens, usernames/passwords, and session cookies.
33964
+ `);
33965
+ }
33966
+
33967
+ /**
33968
+ * Gets human-readable titles for WALLET tool functions.
33969
+ *
33970
+ * @private function of WalletCommitmentDefinition
33971
+ */
33972
+ function getWalletToolTitles() {
33973
+ return {
33974
+ [WalletToolNames.retrieve]: 'Wallet',
33975
+ [WalletToolNames.store]: 'Store wallet record',
33976
+ [WalletToolNames.update]: 'Update wallet record',
33977
+ [WalletToolNames.delete]: 'Delete wallet record',
33978
+ [WalletToolNames.request]: 'Request wallet record',
33979
+ };
33980
+ }
33981
+
33982
+ /**
33983
+ * WALLET commitment definition.
33984
+ *
33985
+ * @private [🪔] Maybe export the commitments through some package
33986
+ */
33987
+ class WalletCommitmentDefinition extends BaseCommitmentDefinition {
33988
+ constructor(type = 'WALLET') {
33989
+ super(type);
33990
+ }
33991
+ get requiresContent() {
33992
+ return false;
33993
+ }
33994
+ get description() {
33995
+ return 'Enable persistent private credential storage (tokens, logins, cookies) scoped per agent or globally.';
33996
+ }
33997
+ get icon() {
33998
+ return '👛';
33999
+ }
34000
+ get documentation() {
34001
+ return getWalletCommitmentDocumentation(this.type);
34002
+ }
34003
+ applyToAgentModelRequirements(requirements, content) {
34004
+ const extraInstructions = formatOptionalInstructionBlock('Wallet instructions', content);
34005
+ return this.appendToSystemMessage({
34006
+ ...requirements,
34007
+ tools: createWalletTools(requirements.tools),
34008
+ _metadata: {
34009
+ ...requirements._metadata,
34010
+ useWallet: content || true,
34011
+ },
34012
+ }, createWalletSystemMessage(extraInstructions));
34013
+ }
34014
+ getToolTitles() {
34015
+ return getWalletToolTitles();
34016
+ }
34017
+ getToolFunctions() {
34018
+ return createWalletToolFunctions();
34019
+ }
34020
+ }
34021
+ // Note: [💞] Ignore a discrepancy between file name and entity name
34022
+
33307
34023
  /**
33308
34024
  * `WRITING RULES` commitment definition.
33309
34025
  *
@@ -33578,6 +34294,8 @@
33578
34294
  new MessageSuffixCommitmentDefinition(),
33579
34295
  new MessageCommitmentDefinition('MESSAGE'),
33580
34296
  new MessageCommitmentDefinition('MESSAGES'),
34297
+ new WalletCommitmentDefinition('WALLET'),
34298
+ new WalletCommitmentDefinition('WALLETS'),
33581
34299
  new ScenarioCommitmentDefinition('SCENARIO'),
33582
34300
  new ScenarioCommitmentDefinition('SCENARIOS'),
33583
34301
  new DeleteCommitmentDefinition('DELETE'),
@@ -34416,6 +35134,12 @@
34416
35134
  ['GOAL', 'GOAL'],
34417
35135
  ['GOALS', 'GOAL'],
34418
35136
  ]);
35137
+ /**
35138
+ * Legacy commitments that should be parsed for compatibility but ignored by the model-requirements pipeline.
35139
+ *
35140
+ * @private internal constant of `filterCommitmentsForAgentModelRequirements`
35141
+ */
35142
+ const IGNORED_COMMITMENT_TYPES = new Set(['WALLET', 'WALLETS']);
34419
35143
  /**
34420
35144
  * Applies the commitment filtering rules used before commitment definitions are executed.
34421
35145
  *
@@ -34464,6 +35188,9 @@
34464
35188
  function filterDeletedCommitments(commitments) {
34465
35189
  const filteredCommitments = [];
34466
35190
  for (const commitment of commitments) {
35191
+ if (isIgnoredCommitmentType(commitment.type)) {
35192
+ continue;
35193
+ }
34467
35194
  if (!isDeleteCommitmentType(commitment.type)) {
34468
35195
  filteredCommitments.push(commitment);
34469
35196
  continue;
@@ -34494,6 +35221,17 @@
34494
35221
  function isDeleteCommitmentType(commitmentType) {
34495
35222
  return DELETE_COMMITMENT_TYPES.has(commitmentType);
34496
35223
  }
35224
+ /**
35225
+ * Checks whether a parsed commitment is intentionally ignored by the current model compiler.
35226
+ *
35227
+ * @param commitmentType - Commitment type to check.
35228
+ * @returns `true` when the commitment should not affect model requirements.
35229
+ *
35230
+ * @private internal utility of `filterDeletedCommitments`
35231
+ */
35232
+ function isIgnoredCommitmentType(commitmentType) {
35233
+ return IGNORED_COMMITMENT_TYPES.has(commitmentType);
35234
+ }
34497
35235
  /**
34498
35236
  * Extracts normalized parameter names used for DELETE-like invalidation matching.
34499
35237
  *
@@ -35101,7 +35839,6 @@
35101
35839
  if (isVoidPseudoAgentReference(reference)) {
35102
35840
  label = VOID_PSEUDO_AGENT_REFERENCE; // <- {Void} label
35103
35841
  iconName = 'ShieldAlert';
35104
- return null; // <- Note: Do not show `{Void}` in capabilities, it's only used for internal logic
35105
35842
  }
35106
35843
  return {
35107
35844
  type: 'inheritance',
@@ -35406,11 +36143,11 @@
35406
36143
  */
35407
36144
  const IMPORTANT_COMMITMENT_TYPE_SORT_ORDER = new Map([
35408
36145
  ['GOAL', 0],
35409
- ['GOALS', 1],
35410
- ['RULE', 2],
35411
- ['RULES', 3],
35412
- ['KNOWLEDGE', 4],
35413
- ['TEAM', 5],
36146
+ ['RULE', 1],
36147
+ ['KNOWLEDGE', 2],
36148
+ ['TEAM', 3],
36149
+ ['GOALS', 4],
36150
+ ['RULES', 5],
35414
36151
  ]);
35415
36152
  /**
35416
36153
  * Sort rank used when unfinished, low-level, and deprecated commitments should be grouped last.
@@ -35509,7 +36246,7 @@
35509
36246
  */
35510
36247
  async function prepareSdkTranspilerContext(book, options) {
35511
36248
  const { agentName } = await parseAgentSource(book);
35512
- const modelRequirements = await createAgentModelRequirements(book, undefined, undefined, undefined, {
36249
+ const rawModelRequirements = await createAgentModelRequirements(book, undefined, undefined, undefined, {
35513
36250
  agentReferenceResolver: options === null || options === void 0 ? void 0 : options.agentReferenceResolver,
35514
36251
  inlineKnowledgeSourceUploader: options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader,
35515
36252
  teammateProfileResolver: options === null || options === void 0 ? void 0 : options.teammateProfileResolver,
@@ -35519,7 +36256,12 @@
35519
36256
  const knowledgeContent = knowledgeCommitments.map((commitment) => commitment.content.trim());
35520
36257
  const directKnowledge = knowledgeContent.filter((content) => !isKnowledgeSourceUrl(content));
35521
36258
  const knowledgeSources = knowledgeContent.filter((content) => isKnowledgeSourceUrl(content));
35522
- const isKnowledgeHandledWithRetrieval = directKnowledge.join('\n').length > SDK_TRANSPILER_KNOWLEDGE_THRESHOLD || knowledgeSources.length > 0;
36259
+ const isKnowledgeHandledWithRetrieval = directKnowledge.join('\n').length > SDK_TRANSPILER_KNOWLEDGE_THRESHOLD ||
36260
+ knowledgeSources.length > 0 ||
36261
+ knowledgeCommitments.length > 0;
36262
+ const modelRequirements = normalizeSdkTranspilerModelRequirements(rawModelRequirements, {
36263
+ isKnowledgeHandledWithRetrieval,
36264
+ });
35523
36265
  const transpiledTeam = createTranspiledTeamExportForContext({
35524
36266
  agentName,
35525
36267
  agentSource: book,
@@ -35537,6 +36279,36 @@
35537
36279
  transpiledTeam,
35538
36280
  };
35539
36281
  }
36282
+ /**
36283
+ * Removes the runtime-only knowledge-search tool from SDK harnesses that provide
36284
+ * their own generated retrieval scaffold.
36285
+ *
36286
+ * @param modelRequirements - Raw compiled model requirements.
36287
+ * @param options - Knowledge handling mode selected for the generated harness.
36288
+ * @returns Model requirements safe to embed into a standalone SDK export.
36289
+ */
36290
+ function normalizeSdkTranspilerModelRequirements(modelRequirements, options) {
36291
+ var _a;
36292
+ if (!options.isKnowledgeHandledWithRetrieval) {
36293
+ return modelRequirements;
36294
+ }
36295
+ const tools = (_a = modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.filter((tool) => tool.name !== KNOWLEDGE_SEARCH_TOOL_NAME);
36296
+ return {
36297
+ ...modelRequirements,
36298
+ systemMessage: removeKnowledgeSearchSystemSection(modelRequirements.systemMessage),
36299
+ ...(tools ? { tools } : {}),
36300
+ };
36301
+ }
36302
+ /**
36303
+ * Removes the generated `## Knowledge Search` instructions from SDK exports
36304
+ * that answer with the transpiler's native retrieval scaffold instead.
36305
+ *
36306
+ * @param systemMessage - Raw system message from compiled model requirements.
36307
+ * @returns System message without the runtime-only knowledge-search section.
36308
+ */
36309
+ function removeKnowledgeSearchSystemSection(systemMessage) {
36310
+ return systemMessage.replace(/(?:^|\n\n)## Knowledge Search[\s\S]*?(?=\n\n##|$)/, '').trim();
36311
+ }
35540
36312
  /**
35541
36313
  * Detects whether one knowledge commitment points to a URL instead of inline text.
35542
36314
  *
@@ -45515,8 +46287,8 @@
45515
46287
  * Prepares an AgentKit agent with optional knowledge sources and tool definitions.
45516
46288
  */
45517
46289
  async prepareAgentKitAgent(options) {
45518
- var _a, _b, _c;
45519
- const { name, instructions, knowledgeSources, tools, nativeAgentKitTools, vectorStoreId: cachedVectorStoreId, storeAsPrepared, } = options;
46290
+ var _a, _b;
46291
+ const { name, instructions, knowledgeSources, tools, vectorStoreId: cachedVectorStoreId, storeAsPrepared, } = options;
45520
46292
  await this.ensureAgentKitDefaults();
45521
46293
  if (this.options.isVerbose) {
45522
46294
  console.info('[🤰]', 'Preparing OpenAI AgentKit agent', {
@@ -45524,11 +46296,10 @@
45524
46296
  instructionsLength: instructions.length,
45525
46297
  knowledgeSourcesCount: (_a = knowledgeSources === null || knowledgeSources === void 0 ? void 0 : knowledgeSources.length) !== null && _a !== void 0 ? _a : 0,
45526
46298
  toolsCount: (_b = tools === null || tools === void 0 ? void 0 : tools.length) !== null && _b !== void 0 ? _b : 0,
45527
- nativeAgentKitToolsCount: (_c = nativeAgentKitTools === null || nativeAgentKitTools === void 0 ? void 0 : nativeAgentKitTools.length) !== null && _c !== void 0 ? _c : 0,
45528
46299
  });
45529
46300
  }
45530
46301
  let vectorStoreId = cachedVectorStoreId;
45531
- if (!vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
46302
+ if (this.isNativeKnowledgeSearchEnabled && !vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
45532
46303
  const vectorStoreResult = await this.createVectorStoreWithKnowledgeSources({
45533
46304
  client: await this.getClient(),
45534
46305
  name,
@@ -45537,13 +46308,19 @@
45537
46308
  });
45538
46309
  vectorStoreId = vectorStoreResult.vectorStoreId;
45539
46310
  }
45540
- else if (vectorStoreId && this.options.isVerbose) {
46311
+ else if (this.isNativeKnowledgeSearchEnabled && vectorStoreId && this.options.isVerbose) {
45541
46312
  console.info('[🤰]', 'Using cached vector store for AgentKit agent', {
45542
46313
  name,
45543
46314
  vectorStoreId,
45544
46315
  });
45545
46316
  }
45546
- const agentKitTools = this.buildAgentKitTools({ tools, nativeAgentKitTools, vectorStoreId });
46317
+ if (!this.isNativeKnowledgeSearchEnabled) {
46318
+ vectorStoreId = undefined;
46319
+ }
46320
+ const agentKitTools = this.buildAgentKitTools({
46321
+ tools,
46322
+ vectorStoreId,
46323
+ });
45547
46324
  const openAiAgentKitAgent = new agents.Agent({
45548
46325
  name,
45549
46326
  model: this.agentKitModelName,
@@ -45562,7 +46339,7 @@
45562
46339
  name,
45563
46340
  model: this.agentKitModelName,
45564
46341
  toolCount: agentKitTools.length,
45565
- hasVectorStore: Boolean(vectorStoreId),
46342
+ hasVectorStore: this.isNativeKnowledgeSearchEnabled && Boolean(vectorStoreId),
45566
46343
  });
45567
46344
  }
45568
46345
  return preparedAgent;
@@ -45582,14 +46359,11 @@
45582
46359
  * Builds the tool list for AgentKit, including hosted file search when applicable.
45583
46360
  */
45584
46361
  buildAgentKitTools(options) {
45585
- const { tools, nativeAgentKitTools, vectorStoreId } = options;
46362
+ const { tools, vectorStoreId } = options;
45586
46363
  const agentKitTools = [];
45587
46364
  if (vectorStoreId) {
45588
46365
  agentKitTools.push(agents.fileSearchTool(vectorStoreId));
45589
46366
  }
45590
- if (nativeAgentKitTools && nativeAgentKitTools.length > 0) {
45591
- agentKitTools.push(...nativeAgentKitTools);
45592
- }
45593
46367
  if (tools && tools.length > 0) {
45594
46368
  let scriptTools = null;
45595
46369
  for (const toolDefinition of tools) {
@@ -46064,6 +46838,12 @@
46064
46838
  get agentKitOptions() {
46065
46839
  return this.options;
46066
46840
  }
46841
+ /**
46842
+ * Returns true when hosted OpenAI vector-store search should back `knowledgeSources`.
46843
+ */
46844
+ get isNativeKnowledgeSearchEnabled() {
46845
+ return this.agentKitOptions.isNativeKnowledgeSearchEnabled !== false;
46846
+ }
46067
46847
  /**
46068
46848
  * Discriminant for type guards.
46069
46849
  */