@promptbook/core 0.114.0-3 → 0.114.0-4

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 (152) hide show
  1. package/README.md +1 -9
  2. package/esm/index.es.js +464 -3993
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +3 -3
  5. package/esm/src/cli/cli-commands/coder/boilerplateCount.d.ts +52 -0
  6. package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +3 -2
  7. package/esm/src/commitments/{COMPONENT/COMPONENT.d.ts → META_FULLNAME/META_FULLNAME.d.ts} +8 -5
  8. package/esm/src/commitments/META_ID/META_ID.d.ts +32 -0
  9. package/esm/src/commitments/index.d.ts +4 -12
  10. package/esm/src/llm-providers/agent/Agent.d.ts +1 -1
  11. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +1 -1
  12. package/esm/src/{commitments/USE_BROWSER → scrapers/_common/utils}/fetchUrlContent.d.ts +2 -3
  13. package/esm/src/version.d.ts +1 -1
  14. package/package.json +1 -1
  15. package/umd/index.umd.js +467 -3996
  16. package/umd/index.umd.js.map +1 -1
  17. package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +3 -3
  18. package/umd/src/cli/cli-commands/coder/boilerplateCount.d.ts +52 -0
  19. package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +3 -2
  20. package/umd/src/commitments/{COMPONENT/COMPONENT.d.ts → META_FULLNAME/META_FULLNAME.d.ts} +8 -5
  21. package/umd/src/commitments/META_ID/META_ID.d.ts +32 -0
  22. package/umd/src/commitments/index.d.ts +4 -12
  23. package/umd/src/llm-providers/agent/Agent.d.ts +1 -1
  24. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +1 -1
  25. package/umd/src/{commitments/USE_BROWSER → scrapers/_common/utils}/fetchUrlContent.d.ts +2 -3
  26. package/umd/src/version.d.ts +1 -1
  27. package/esm/src/commitments/MEMORY/MEMORY.d.ts +0 -48
  28. package/esm/src/commitments/MEMORY/MemoryToolNames.d.ts +0 -11
  29. package/esm/src/commitments/MEMORY/MemoryToolRuntimeAdapter.d.ts +0 -149
  30. package/esm/src/commitments/MEMORY/createMemorySystemMessage.d.ts +0 -6
  31. package/esm/src/commitments/MEMORY/createMemoryToolFunctions.d.ts +0 -8
  32. package/esm/src/commitments/MEMORY/createMemoryTools.d.ts +0 -14
  33. package/esm/src/commitments/MEMORY/getMemoryCommitmentDocumentation.d.ts +0 -6
  34. package/esm/src/commitments/MEMORY/getMemoryToolRuntimeAdapterOrDisabledResult.d.ts +0 -17
  35. package/esm/src/commitments/MEMORY/getMemoryToolTitles.d.ts +0 -7
  36. package/esm/src/commitments/MEMORY/parseMemoryToolArgs.d.ts +0 -61
  37. package/esm/src/commitments/MEMORY/resolveMemoryRuntimeContext.d.ts +0 -8
  38. package/esm/src/commitments/MEMORY/setMemoryToolRuntimeAdapter.d.ts +0 -13
  39. package/esm/src/commitments/META/META.d.ts +0 -65
  40. package/esm/src/commitments/USE/aggregateUseCommitmentSystemMessages.d.ts +0 -32
  41. package/esm/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +0 -58
  42. package/esm/src/commitments/USE_BROWSER/fetchUrlContentViaBrowser.d.ts +0 -13
  43. package/esm/src/commitments/USE_BROWSER/resolveRunBrowserToolForNode.d.ts +0 -10
  44. package/esm/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.d.ts +0 -47
  45. package/esm/src/commitments/USE_EMAIL/USE_EMAIL.d.ts +0 -38
  46. package/esm/src/commitments/USE_EMAIL/parseUseEmailCommitmentContent.d.ts +0 -21
  47. package/esm/src/commitments/USE_EMAIL/parseUseEmailCommitmentContent.test.d.ts +0 -1
  48. package/esm/src/commitments/USE_EMAIL/resolveSendEmailToolForNode.d.ts +0 -11
  49. package/esm/src/commitments/USE_EMAIL/sendEmailViaBrowser.d.ts +0 -13
  50. package/esm/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +0 -46
  51. package/esm/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.test.d.ts +0 -1
  52. package/esm/src/commitments/USE_SPAWN/USE_SPAWN.d.ts +0 -38
  53. package/esm/src/commitments/USE_SPAWN/USE_SPAWN.test.d.ts +0 -1
  54. package/esm/src/commitments/USE_SPAWN/resolveSpawnAgentToolForNode.d.ts +0 -9
  55. package/esm/src/commitments/USE_SPAWN/spawnAgentViaBrowser.d.ts +0 -12
  56. package/esm/src/commitments/USE_TIME/USE_TIME.d.ts +0 -43
  57. package/esm/src/commitments/USE_TIME/USE_TIME.test.d.ts +0 -1
  58. package/esm/src/commitments/USE_TIMEOUT/TimeoutToolNames.d.ts +0 -11
  59. package/esm/src/commitments/USE_TIMEOUT/TimeoutToolRuntimeAdapter.d.ts +0 -212
  60. package/esm/src/commitments/USE_TIMEOUT/USE_TIMEOUT.d.ts +0 -38
  61. package/esm/src/commitments/USE_TIMEOUT/USE_TIMEOUT.test.d.ts +0 -1
  62. package/esm/src/commitments/USE_TIMEOUT/createTimeoutSystemMessage.d.ts +0 -6
  63. package/esm/src/commitments/USE_TIMEOUT/createTimeoutToolFunctions.d.ts +0 -8
  64. package/esm/src/commitments/USE_TIMEOUT/createTimeoutTools.d.ts +0 -7
  65. package/esm/src/commitments/USE_TIMEOUT/getTimeoutToolRuntimeAdapterOrDisabledResult.d.ts +0 -17
  66. package/esm/src/commitments/USE_TIMEOUT/parseTimeoutToolArgs.d.ts +0 -78
  67. package/esm/src/commitments/USE_TIMEOUT/resolveTimeoutRuntimeContext.d.ts +0 -8
  68. package/esm/src/commitments/USE_TIMEOUT/setTimeoutToolRuntimeAdapter.d.ts +0 -13
  69. package/esm/src/commitments/WALLET/WALLET.d.ts +0 -21
  70. package/esm/src/commitments/WALLET/WALLET.test.d.ts +0 -1
  71. package/esm/src/commitments/WALLET/WalletToolNames.d.ts +0 -12
  72. package/esm/src/commitments/WALLET/WalletToolRuntimeAdapter.d.ts +0 -163
  73. package/esm/src/commitments/WALLET/createWalletSystemMessage.d.ts +0 -6
  74. package/esm/src/commitments/WALLET/createWalletToolFunctions.d.ts +0 -8
  75. package/esm/src/commitments/WALLET/createWalletTools.d.ts +0 -7
  76. package/esm/src/commitments/WALLET/getWalletCommitmentDocumentation.d.ts +0 -6
  77. package/esm/src/commitments/WALLET/getWalletToolRuntimeAdapterOrDisabledResult.d.ts +0 -16
  78. package/esm/src/commitments/WALLET/getWalletToolTitles.d.ts +0 -7
  79. package/esm/src/commitments/WALLET/parseWalletToolArgs.d.ts +0 -51
  80. package/esm/src/commitments/WALLET/resolveWalletRuntimeContext.d.ts +0 -8
  81. package/esm/src/commitments/WALLET/setWalletToolRuntimeAdapter.d.ts +0 -13
  82. package/esm/src/commitments/_common/createSerpSearchToolFunction.d.ts +0 -12
  83. package/umd/src/book-2.0/agent-source/createAgentModelRequirements.useCommitmentAggregation.test.d.ts +0 -1
  84. package/umd/src/commitments/MEMORY/MEMORY.d.ts +0 -48
  85. package/umd/src/commitments/MEMORY/MEMORY.test.d.ts +0 -1
  86. package/umd/src/commitments/MEMORY/MemoryToolNames.d.ts +0 -11
  87. package/umd/src/commitments/MEMORY/MemoryToolRuntimeAdapter.d.ts +0 -149
  88. package/umd/src/commitments/MEMORY/createMemorySystemMessage.d.ts +0 -6
  89. package/umd/src/commitments/MEMORY/createMemoryToolFunctions.d.ts +0 -8
  90. package/umd/src/commitments/MEMORY/createMemoryTools.d.ts +0 -14
  91. package/umd/src/commitments/MEMORY/getMemoryCommitmentDocumentation.d.ts +0 -6
  92. package/umd/src/commitments/MEMORY/getMemoryToolRuntimeAdapterOrDisabledResult.d.ts +0 -17
  93. package/umd/src/commitments/MEMORY/getMemoryToolTitles.d.ts +0 -7
  94. package/umd/src/commitments/MEMORY/parseMemoryToolArgs.d.ts +0 -61
  95. package/umd/src/commitments/MEMORY/resolveMemoryRuntimeContext.d.ts +0 -8
  96. package/umd/src/commitments/MEMORY/setMemoryToolRuntimeAdapter.d.ts +0 -13
  97. package/umd/src/commitments/META/META.d.ts +0 -65
  98. package/umd/src/commitments/USE/aggregateUseCommitmentSystemMessages.d.ts +0 -32
  99. package/umd/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +0 -58
  100. package/umd/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +0 -1
  101. package/umd/src/commitments/USE_BROWSER/fetchUrlContentViaBrowser.d.ts +0 -13
  102. package/umd/src/commitments/USE_BROWSER/resolveRunBrowserToolForNode.d.ts +0 -10
  103. package/umd/src/commitments/USE_BROWSER/resolveRunBrowserToolForNode.test.d.ts +0 -1
  104. package/umd/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.d.ts +0 -47
  105. package/umd/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.test.d.ts +0 -1
  106. package/umd/src/commitments/USE_EMAIL/USE_EMAIL.d.ts +0 -38
  107. package/umd/src/commitments/USE_EMAIL/USE_EMAIL.test.d.ts +0 -1
  108. package/umd/src/commitments/USE_EMAIL/parseUseEmailCommitmentContent.d.ts +0 -21
  109. package/umd/src/commitments/USE_EMAIL/parseUseEmailCommitmentContent.test.d.ts +0 -1
  110. package/umd/src/commitments/USE_EMAIL/resolveSendEmailToolForNode.d.ts +0 -11
  111. package/umd/src/commitments/USE_EMAIL/sendEmailViaBrowser.d.ts +0 -13
  112. package/umd/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +0 -46
  113. package/umd/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.test.d.ts +0 -1
  114. package/umd/src/commitments/USE_SPAWN/USE_SPAWN.d.ts +0 -38
  115. package/umd/src/commitments/USE_SPAWN/USE_SPAWN.test.d.ts +0 -1
  116. package/umd/src/commitments/USE_SPAWN/resolveSpawnAgentToolForNode.d.ts +0 -9
  117. package/umd/src/commitments/USE_SPAWN/spawnAgentViaBrowser.d.ts +0 -12
  118. package/umd/src/commitments/USE_TIME/USE_TIME.d.ts +0 -43
  119. package/umd/src/commitments/USE_TIME/USE_TIME.test.d.ts +0 -1
  120. package/umd/src/commitments/USE_TIMEOUT/TimeoutToolNames.d.ts +0 -11
  121. package/umd/src/commitments/USE_TIMEOUT/TimeoutToolRuntimeAdapter.d.ts +0 -212
  122. package/umd/src/commitments/USE_TIMEOUT/USE_TIMEOUT.d.ts +0 -38
  123. package/umd/src/commitments/USE_TIMEOUT/USE_TIMEOUT.test.d.ts +0 -1
  124. package/umd/src/commitments/USE_TIMEOUT/createTimeoutSystemMessage.d.ts +0 -6
  125. package/umd/src/commitments/USE_TIMEOUT/createTimeoutToolFunctions.d.ts +0 -8
  126. package/umd/src/commitments/USE_TIMEOUT/createTimeoutTools.d.ts +0 -7
  127. package/umd/src/commitments/USE_TIMEOUT/getTimeoutToolRuntimeAdapterOrDisabledResult.d.ts +0 -17
  128. package/umd/src/commitments/USE_TIMEOUT/parseTimeoutToolArgs.d.ts +0 -78
  129. package/umd/src/commitments/USE_TIMEOUT/resolveTimeoutRuntimeContext.d.ts +0 -8
  130. package/umd/src/commitments/USE_TIMEOUT/setTimeoutToolRuntimeAdapter.d.ts +0 -13
  131. package/umd/src/commitments/WALLET/WALLET.d.ts +0 -21
  132. package/umd/src/commitments/WALLET/WALLET.test.d.ts +0 -1
  133. package/umd/src/commitments/WALLET/WalletToolNames.d.ts +0 -12
  134. package/umd/src/commitments/WALLET/WalletToolRuntimeAdapter.d.ts +0 -163
  135. package/umd/src/commitments/WALLET/createWalletSystemMessage.d.ts +0 -6
  136. package/umd/src/commitments/WALLET/createWalletToolFunctions.d.ts +0 -8
  137. package/umd/src/commitments/WALLET/createWalletTools.d.ts +0 -7
  138. package/umd/src/commitments/WALLET/getWalletCommitmentDocumentation.d.ts +0 -6
  139. package/umd/src/commitments/WALLET/getWalletToolRuntimeAdapterOrDisabledResult.d.ts +0 -16
  140. package/umd/src/commitments/WALLET/getWalletToolTitles.d.ts +0 -7
  141. package/umd/src/commitments/WALLET/parseWalletToolArgs.d.ts +0 -51
  142. package/umd/src/commitments/WALLET/resolveWalletRuntimeContext.d.ts +0 -8
  143. package/umd/src/commitments/WALLET/setWalletToolRuntimeAdapter.d.ts +0 -13
  144. package/umd/src/commitments/_common/createSerpSearchToolFunction.d.ts +0 -12
  145. /package/esm/src/book-2.0/agent-source/{createAgentModelRequirements.useCommitmentAggregation.test.d.ts → createAgentModelRequirements.commitmentAggregation.test.d.ts} +0 -0
  146. /package/esm/src/{commitments/MEMORY/MEMORY.test.d.ts → cli/cli-commands/coder/boilerplateCount.test.d.ts} +0 -0
  147. /package/esm/src/{commitments/USE_BROWSER/USE_BROWSER.test.d.ts → cli/cli-commands/coder/generate-boilerplates.test.d.ts} +0 -0
  148. /package/esm/src/commitments/{META → META_DESCRIPTION}/META_DESCRIPTION.d.ts +0 -0
  149. /package/{esm/src/commitments/USE_BROWSER/resolveRunBrowserToolForNode.test.d.ts → umd/src/book-2.0/agent-source/createAgentModelRequirements.commitmentAggregation.test.d.ts} +0 -0
  150. /package/{esm/src/commitments/USE_DEEPSEARCH/USE_DEEPSEARCH.test.d.ts → umd/src/cli/cli-commands/coder/boilerplateCount.test.d.ts} +0 -0
  151. /package/{esm/src/commitments/USE_EMAIL/USE_EMAIL.test.d.ts → umd/src/cli/cli-commands/coder/generate-boilerplates.test.d.ts} +0 -0
  152. /package/umd/src/commitments/{META → META_DESCRIPTION}/META_DESCRIPTION.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -7,8 +7,8 @@ import sha256 from 'crypto-js/sha256';
7
7
  import { basename, join, dirname, isAbsolute } from 'path';
8
8
  import { lookup, extension } from 'mime-types';
9
9
  import papaparse from 'papaparse';
10
- import moment from 'moment';
11
10
  import { randomBytes } from 'crypto';
11
+ import moment from 'moment';
12
12
  import colors from 'colors';
13
13
  import Bottleneck from 'bottleneck';
14
14
 
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-3';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-4';
30
30
  /**
31
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
32
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -8794,188 +8794,6 @@ async function preparePersona(personaDescription, tools, options) {
8794
8794
  // TODO: [🏢] Check validity of `systemMessage` in pipeline
8795
8795
  // TODO: [🏢] Check validity of `temperature` in pipeline
8796
8796
 
8797
- /**
8798
- * @@@
8799
- *
8800
- * @private utility for commitments
8801
- */
8802
- function formatOptionalInstructionBlock(label, content) {
8803
- const trimmedContent = spaceTrim$1(content);
8804
- if (!trimmedContent) {
8805
- return '';
8806
- }
8807
- return spaceTrim$1((block) => `
8808
- - ${label}:
8809
- ${block(trimmedContent
8810
- .split(/\r?\n/)
8811
- .map((line) => `- ${line}`)
8812
- .join('\n'))}
8813
- `);
8814
- }
8815
-
8816
- /**
8817
- * All `USE` commitment types currently participating in final system-message aggregation.
8818
- *
8819
- * @private internal constant for `aggregateUseCommitmentSystemMessages`
8820
- */
8821
- const AGGREGATED_USE_COMMITMENT_TYPES = [
8822
- 'USE BROWSER',
8823
- 'USE DEEPSEARCH',
8824
- 'USE SEARCH ENGINE',
8825
- 'USE TIME',
8826
- ];
8827
- /**
8828
- * Prefix used for temporary in-system-message placeholders that preserve the first-occurrence position of aggregated `USE` sections.
8829
- *
8830
- * @private internal constant for `appendAggregatedUseCommitmentPlaceholder`
8831
- */
8832
- const AGGREGATED_USE_COMMITMENT_PLACEHOLDER_PREFIX = '# AGGREGATED USE COMMITMENT: ';
8833
- /**
8834
- * Type guard for `USE` commitment types that are aggregated in the final system message.
8835
- *
8836
- * @param type - Commitment type to check.
8837
- * @returns `true` when the commitment participates in `USE` system-message aggregation.
8838
- *
8839
- * @private internal utility of `aggregateUseCommitmentSystemMessages`
8840
- */
8841
- function isAggregatedUseCommitmentType(type) {
8842
- return AGGREGATED_USE_COMMITMENT_TYPES.includes(type);
8843
- }
8844
- /**
8845
- * Creates the placeholder token used to reserve the first-occurrence position of an aggregated `USE` system-message section.
8846
- *
8847
- * @param type - Aggregated `USE` commitment type.
8848
- * @returns Single-line placeholder comment stored in the interim system message.
8849
- *
8850
- * @private internal utility of `appendAggregatedUseCommitmentPlaceholder`
8851
- */
8852
- function getAggregatedUseCommitmentPlaceholder(type) {
8853
- return `${AGGREGATED_USE_COMMITMENT_PLACEHOLDER_PREFIX}${type}`;
8854
- }
8855
- /**
8856
- * Combines distinct additional instruction blocks in source order.
8857
- *
8858
- * @param additionalInstructions - Deduplicated instruction blocks collected from the agent source.
8859
- * @returns Combined instruction text ready for `formatOptionalInstructionBlock`.
8860
- *
8861
- * @private internal utility of `createAggregatedUseCommitmentSystemMessage`
8862
- */
8863
- function combineAdditionalInstructions(additionalInstructions) {
8864
- return additionalInstructions.join('\n');
8865
- }
8866
- /**
8867
- * Creates the final aggregated system-message section for a supported `USE` commitment type.
8868
- *
8869
- * @param type - Aggregated `USE` commitment type.
8870
- * @param additionalInstructions - Distinct additional instructions in source order.
8871
- * @returns Final system-message block for the commitment type.
8872
- *
8873
- * @private internal utility of `aggregateUseCommitmentSystemMessages`
8874
- */
8875
- function createAggregatedUseCommitmentSystemMessage(type, additionalInstructions) {
8876
- const combinedAdditionalInstructions = combineAdditionalInstructions(additionalInstructions);
8877
- switch (type) {
8878
- case 'USE TIME':
8879
- return spaceTrim$1((block) => `
8880
- ## Time and date context
8881
-
8882
- - It is ${moment().format('MMMM YYYY')} now.
8883
- - If you need more precise current time information, use the tool \`get_current_time\`.
8884
- ${block(formatOptionalInstructionBlock('Time instructions', combinedAdditionalInstructions))}
8885
- `);
8886
- case 'USE BROWSER':
8887
- return spaceTrim$1((block) => `
8888
- ## Browser
8889
-
8890
- - Use \`fetch_url_content\` to retrieve content from specific URLs (webpages or documents) using scrapers.
8891
- - Use \`run_browser\` for real interactive browser automation (navigation, clicks, typing, waiting, scrolling).
8892
- - When you need to know information from a specific website or document, use the tools provided.
8893
- ${block(formatOptionalInstructionBlock('Browser instructions', combinedAdditionalInstructions))}
8894
- `);
8895
- case 'USE SEARCH ENGINE':
8896
- return spaceTrim$1((block) => `
8897
- ## Web Search
8898
-
8899
- - Use \`web_search\` to find up-to-date information or facts.
8900
- - When you need to know some information from the internet, use the search tool provided.
8901
- - Do not make up information when you can search for it.
8902
- - Do not tell the user you cannot search for information, YOU CAN.
8903
- ${block(formatOptionalInstructionBlock('Search instructions', combinedAdditionalInstructions))}
8904
- `);
8905
- case 'USE DEEPSEARCH':
8906
- return spaceTrim$1((block) => `
8907
- ## Deep Research
8908
-
8909
- - Use \`deep_search\` for broader research tasks that need multi-step investigation, comparison, or synthesis across multiple sources.
8910
- - Prefer it over quick search when the user asks for a well-grounded brief, report, or deeper investigation.
8911
- - Do not pretend you cannot research current information when this tool is available.
8912
- ${block(formatOptionalInstructionBlock('DeepSearch instructions', combinedAdditionalInstructions))}
8913
- `);
8914
- }
8915
- }
8916
- /**
8917
- * Adds the placeholder for an aggregated `USE` system-message section only once, preserving the section position from the first occurrence.
8918
- *
8919
- * @param requirements - Current model requirements.
8920
- * @param type - Aggregated `USE` commitment type being applied.
8921
- * @returns Requirements with the placeholder inserted when it was not already present.
8922
- *
8923
- * @private internal utility of `USE` commitments
8924
- */
8925
- function appendAggregatedUseCommitmentPlaceholder(requirements, type) {
8926
- const placeholder = getAggregatedUseCommitmentPlaceholder(type);
8927
- if (requirements.systemMessage.includes(placeholder)) {
8928
- return requirements;
8929
- }
8930
- const systemMessage = requirements.systemMessage.trim()
8931
- ? `${requirements.systemMessage}\n\n${placeholder}`
8932
- : placeholder;
8933
- return {
8934
- ...requirements,
8935
- systemMessage,
8936
- };
8937
- }
8938
- /**
8939
- * Replaces temporary `USE` placeholders with one aggregated system-message block per commitment type.
8940
- *
8941
- * Distinct additional-instruction blocks are merged in stable source order while the hard-coded section is emitted only once.
8942
- *
8943
- * @param requirements - Model requirements produced by commitment-by-commitment application.
8944
- * @param commitments - Filtered commitments in their original source order.
8945
- * @returns Requirements with aggregated `USE` system-message sections.
8946
- *
8947
- * @private internal utility of `createAgentModelRequirementsWithCommitments`
8948
- */
8949
- function aggregateUseCommitmentSystemMessages(requirements, commitments) {
8950
- const additionalInstructionsByType = new Map();
8951
- for (const commitment of commitments) {
8952
- if (!isAggregatedUseCommitmentType(commitment.type)) {
8953
- continue;
8954
- }
8955
- let additionalInstructions = additionalInstructionsByType.get(commitment.type);
8956
- if (!additionalInstructions) {
8957
- additionalInstructions = [];
8958
- additionalInstructionsByType.set(commitment.type, additionalInstructions);
8959
- }
8960
- const normalizedContent = spaceTrim$1(commitment.content);
8961
- if (normalizedContent && !additionalInstructions.includes(normalizedContent)) {
8962
- additionalInstructions.push(normalizedContent);
8963
- }
8964
- }
8965
- let systemMessage = requirements.systemMessage;
8966
- for (const [type, additionalInstructions] of additionalInstructionsByType) {
8967
- const placeholder = getAggregatedUseCommitmentPlaceholder(type);
8968
- if (!systemMessage.includes(placeholder)) {
8969
- continue;
8970
- }
8971
- systemMessage = systemMessage.replace(placeholder, createAggregatedUseCommitmentSystemMessage(type, additionalInstructions));
8972
- }
8973
- return {
8974
- ...requirements,
8975
- systemMessage,
8976
- };
8977
- }
8978
-
8979
8797
  /**
8980
8798
  * Creates an empty/basic agent model requirements object
8981
8799
  * This serves as the starting point for the reduce-like pattern
@@ -9306,7 +9124,7 @@ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
9306
9124
  Research Assistant
9307
9125
 
9308
9126
  PERSONA You are a helpful research assistant
9309
- USE SEARCH ENGINE
9127
+ USE MCP https://mcp.example.com/server
9310
9128
  RULE Always cite your sources when providing information from the web
9311
9129
  \`\`\`
9312
9130
 
@@ -9326,8 +9144,8 @@ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
9326
9144
  Code Assistant
9327
9145
 
9328
9146
  PERSONA You are a programming assistant
9329
- USE BROWSER
9330
- USE SEARCH ENGINE
9147
+ USE PROJECT https://github.com/example/project
9148
+ USE MCP https://mcp.example.com/server
9331
9149
  RULE Prefer the narrowest useful capability for the task.
9332
9150
  \`\`\`
9333
9151
  `);
@@ -9410,65 +9228,6 @@ class ClosedCommitmentDefinition extends BaseCommitmentDefinition {
9410
9228
  }
9411
9229
  // Note: [💞] Ignore a discrepancy between file name and entity name
9412
9230
 
9413
- /**
9414
- * COMPONENT commitment definition
9415
- *
9416
- * The COMPONENT commitment defines a UI component that the agent can render in the chat.
9417
- *
9418
- * @private [🪔] Maybe export the commitments through some package
9419
- */
9420
- class ComponentCommitmentDefinition extends BaseCommitmentDefinition {
9421
- constructor() {
9422
- super('COMPONENT');
9423
- }
9424
- /**
9425
- * Short one-line description of COMPONENT.
9426
- */
9427
- get description() {
9428
- return 'Define a UI component that the agent can render in the chat.';
9429
- }
9430
- /**
9431
- * Icon for this commitment.
9432
- */
9433
- get icon() {
9434
- return '🧩';
9435
- }
9436
- /**
9437
- * Markdown documentation for COMPONENT commitment.
9438
- */
9439
- get documentation() {
9440
- return spaceTrim$1(`
9441
- # COMPONENT
9442
-
9443
- Defines a UI component that the agent can render in the chat.
9444
-
9445
- ## Key aspects
9446
-
9447
- - Tells the agent that a specific component is available.
9448
- - Provides syntax for using the component.
9449
-
9450
- ## Example
9451
-
9452
- \`\`\`book
9453
- COMPONENT Arrow
9454
- The agent should render an arrow component in the chat UI.
9455
- Syntax:
9456
- <Arrow direction="up" color="red" />
9457
- \`\`\`
9458
- `);
9459
- }
9460
- applyToAgentModelRequirements(requirements, content) {
9461
- const trimmedContent = content.trim();
9462
- if (!trimmedContent) {
9463
- return requirements;
9464
- }
9465
- // Add component capability to the system message
9466
- const componentSection = `Component: ${trimmedContent}`;
9467
- return this.appendToSystemMessage(requirements, componentSection, '\n\n');
9468
- }
9469
- }
9470
- // Note: [💞] Ignore a discrepancy between file name and entity name
9471
-
9472
9231
  /**
9473
9232
  * DELETE commitment definition
9474
9233
  *
@@ -10806,634 +10565,6 @@ class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
10806
10565
  }
10807
10566
  // Note: [💞] Ignore a discrepancy between file name and entity name
10808
10567
 
10809
- /**
10810
- * Names of tools used by the MEMORY commitment.
10811
- *
10812
- * @private function of MemoryCommitmentDefinition
10813
- */
10814
- const MemoryToolNames = {
10815
- retrieve: 'retrieve_user_memory',
10816
- store: 'store_user_memory',
10817
- update: 'update_user_memory',
10818
- delete: 'delete_user_memory',
10819
- };
10820
-
10821
- /**
10822
- * Builds the MEMORY instruction block appended to the system message.
10823
- *
10824
- * @private function of MemoryCommitmentDefinition
10825
- */
10826
- function createMemorySystemMessage(extraInstructions) {
10827
- return spaceTrim$1((block) => `
10828
- ## Memory
10829
-
10830
- - Prefer storing agent-scoped memories; only make them global when the fact should apply across all your agents.
10831
- - You can use persistent user memory tools.
10832
- - Use \`${MemoryToolNames.retrieve}\` to load relevant memory before answering.
10833
- - Use \`${MemoryToolNames.store}\` to save stable user-specific facts that improve future help.
10834
- - Use \`${MemoryToolNames.update}\` to refresh an existing memory when the content changes.
10835
- - Use \`${MemoryToolNames.delete}\` to delete memories that are no longer accurate (deletions are soft and hidden from future queries).
10836
- - Store concise memory items and avoid duplicates.
10837
- - Never claim memory was saved or loaded unless the tool confirms it.
10838
- ${block(extraInstructions)}
10839
- `);
10840
- }
10841
-
10842
- /**
10843
- * Builds a disabled memory-tool response payload.
10844
- *
10845
- * @private function of MemoryCommitmentDefinition
10846
- */
10847
- function createDisabledMemoryResult(action, message) {
10848
- if (action === 'retrieve') {
10849
- return {
10850
- action,
10851
- status: 'disabled',
10852
- memories: [],
10853
- message,
10854
- };
10855
- }
10856
- if (action === 'store') {
10857
- return {
10858
- action,
10859
- status: 'disabled',
10860
- message,
10861
- };
10862
- }
10863
- if (action === 'update') {
10864
- return {
10865
- action,
10866
- status: 'disabled',
10867
- message,
10868
- };
10869
- }
10870
- if (action === 'delete') {
10871
- return {
10872
- action,
10873
- status: 'disabled',
10874
- message,
10875
- };
10876
- }
10877
- throw new Error(`Unsupported memory tool action: ${action}`);
10878
- }
10879
- /**
10880
- * Gets the runtime adapter and returns a disabled result when unavailable.
10881
- *
10882
- * @private function of MemoryCommitmentDefinition
10883
- */
10884
- function getMemoryToolRuntimeAdapterOrDisabledResult(action, runtimeContext) {
10885
- if (!runtimeContext.enabled || runtimeContext.isTeamConversation || runtimeContext.isPrivateMode) {
10886
- const message = runtimeContext.isPrivateMode
10887
- ? 'Memory is disabled because private mode is active.'
10888
- : runtimeContext.isTeamConversation
10889
- ? 'Memory is disabled for TEAM conversations.'
10890
- : 'Memory is disabled for unauthenticated users.';
10891
- return {
10892
- adapter: null,
10893
- disabledResult: createDisabledMemoryResult(action, message),
10894
- };
10895
- }
10896
- {
10897
- return {
10898
- adapter: null,
10899
- disabledResult: createDisabledMemoryResult(action, 'Memory runtime is not available in this environment.'),
10900
- };
10901
- }
10902
- }
10903
-
10904
- /**
10905
- * Parses a memory identifier argument shared across MEMORY tools.
10906
- *
10907
- * @private function of MemoryCommitmentDefinition
10908
- */
10909
- function parseMemoryIdArg(value) {
10910
- const memoryId = typeof value === 'string' ? value.trim() : '';
10911
- if (!memoryId) {
10912
- throw new Error('Memory id is required.');
10913
- }
10914
- return memoryId;
10915
- }
10916
- /**
10917
- * Collection of MEMORY tool argument parsers.
10918
- *
10919
- * @private function of MemoryCommitmentDefinition
10920
- */
10921
- const parseMemoryToolArgs = {
10922
- /**
10923
- * Parses retrieve memory arguments.
10924
- */
10925
- retrieve(args) {
10926
- const query = typeof args.query === 'string' ? args.query.trim() : undefined;
10927
- const limit = typeof args.limit === 'number' && Number.isFinite(args.limit) ? Math.floor(args.limit) : undefined;
10928
- return {
10929
- query: query && query.length > 0 ? query : undefined,
10930
- limit: limit && limit > 0 ? Math.min(limit, 20) : undefined,
10931
- };
10932
- },
10933
- /**
10934
- * Parses store memory arguments.
10935
- */
10936
- store(args) {
10937
- const content = typeof args.content === 'string' ? args.content.trim() : '';
10938
- if (!content) {
10939
- throw new Error('Memory content is required.');
10940
- }
10941
- return {
10942
- content,
10943
- isGlobal: args.isGlobal === true,
10944
- };
10945
- },
10946
- /**
10947
- * Parses update memory arguments.
10948
- */
10949
- update(args) {
10950
- const memoryId = parseMemoryIdArg(args.memoryId);
10951
- const content = typeof args.content === 'string' ? args.content.trim() : '';
10952
- if (!content) {
10953
- throw new Error('Memory content is required.');
10954
- }
10955
- const isGlobal = typeof args.isGlobal === 'boolean' ? args.isGlobal : undefined;
10956
- return {
10957
- memoryId,
10958
- content,
10959
- isGlobal,
10960
- };
10961
- },
10962
- /**
10963
- * Parses delete memory arguments.
10964
- */
10965
- delete(args) {
10966
- return {
10967
- memoryId: parseMemoryIdArg(args.memoryId),
10968
- };
10969
- },
10970
- };
10971
-
10972
- /**
10973
- * Prompt parameter key used to pass hidden runtime context to tool execution.
10974
- *
10975
- * @private internal runtime wiring for commitment tools
10976
- */
10977
- const TOOL_RUNTIME_CONTEXT_PARAMETER = 'promptbookToolRuntimeContext';
10978
- /**
10979
- * Hidden argument key used to pass runtime context into individual tool calls.
10980
- *
10981
- * @private internal runtime wiring for commitment tools
10982
- */
10983
- const TOOL_RUNTIME_CONTEXT_ARGUMENT = '__promptbookToolRuntimeContext';
10984
- /**
10985
- * Prompt parameter key used to pass a hidden tool-progress listener token into script execution.
10986
- *
10987
- * @private internal runtime wiring for commitment tools
10988
- */
10989
- const TOOL_PROGRESS_TOKEN_PARAMETER = 'promptbookToolProgressToken';
10990
- /**
10991
- * Hidden argument key used to pass a tool-progress listener token into individual tool calls.
10992
- *
10993
- * @private internal runtime wiring for commitment tools
10994
- */
10995
- const TOOL_PROGRESS_TOKEN_ARGUMENT = '__promptbookToolProgressToken';
10996
- /**
10997
- * Monotonic counter used for hidden progress-listener tokens.
10998
- *
10999
- * @private internal runtime wiring for commitment tools
11000
- */
11001
- let toolCallProgressListenerCounter = 0;
11002
- /**
11003
- * Active tool-progress listeners keyed by hidden execution token.
11004
- *
11005
- * @private internal runtime wiring for commitment tools
11006
- */
11007
- const toolCallProgressListeners = new Map();
11008
- /**
11009
- * Parses unknown runtime context payload into a normalized object.
11010
- *
11011
- * @private internal runtime wiring for commitment tools
11012
- */
11013
- function parseToolRuntimeContext(rawValue) {
11014
- if (!rawValue) {
11015
- return null;
11016
- }
11017
- let parsed = rawValue;
11018
- if (typeof rawValue === 'string') {
11019
- try {
11020
- parsed = JSON.parse(rawValue);
11021
- }
11022
- catch (_a) {
11023
- return null;
11024
- }
11025
- }
11026
- if (!parsed || typeof parsed !== 'object') {
11027
- return null;
11028
- }
11029
- return parsed;
11030
- }
11031
- /**
11032
- * Reads runtime context attached to tool call arguments.
11033
- *
11034
- * @private internal runtime wiring for commitment tools
11035
- */
11036
- function readToolRuntimeContextFromToolArgs(args) {
11037
- return parseToolRuntimeContext(args[TOOL_RUNTIME_CONTEXT_ARGUMENT]);
11038
- }
11039
- /**
11040
- * Serializes runtime context for prompt parameters.
11041
- *
11042
- * @private internal runtime wiring for commitment tools
11043
- */
11044
- function serializeToolRuntimeContext(context) {
11045
- return JSON.stringify(context);
11046
- }
11047
- /**
11048
- * Registers one in-memory listener that receives progress updates emitted by a running tool.
11049
- *
11050
- * The returned token is passed into script execution as a hidden argument so tool implementations
11051
- * can stream progress without exposing extra parameters to the model.
11052
- *
11053
- * @param listener - Listener notified about tool progress.
11054
- * @returns Hidden token used to route progress updates.
11055
- *
11056
- * @private internal runtime wiring for commitment tools
11057
- */
11058
- function registerToolCallProgressListener(listener) {
11059
- toolCallProgressListenerCounter += 1;
11060
- const token = `tool-progress:${Date.now()}:${toolCallProgressListenerCounter}`;
11061
- toolCallProgressListeners.set(token, listener);
11062
- return token;
11063
- }
11064
- /**
11065
- * Unregisters one in-memory progress listener.
11066
- *
11067
- * @param token - Token previously created by `registerToolCallProgressListener`.
11068
- *
11069
- * @private internal runtime wiring for commitment tools
11070
- */
11071
- function unregisterToolCallProgressListener(token) {
11072
- toolCallProgressListeners.delete(token);
11073
- }
11074
- // Note: [💞] Ignore a discrepancy between file name and entity name
11075
-
11076
- /**
11077
- * Resolves runtime context from hidden tool arguments.
11078
- *
11079
- * @private function of MemoryCommitmentDefinition
11080
- */
11081
- function resolveMemoryRuntimeContext(args) {
11082
- const runtimeContext = readToolRuntimeContextFromToolArgs(args);
11083
- const memoryContext = runtimeContext === null || runtimeContext === void 0 ? void 0 : runtimeContext.memory;
11084
- return {
11085
- enabled: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.enabled) === true,
11086
- userId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.userId,
11087
- username: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.username,
11088
- agentId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentId,
11089
- agentName: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentName,
11090
- isTeamConversation: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isTeamConversation) === true,
11091
- isPrivateMode: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isPrivateMode) === true,
11092
- };
11093
- }
11094
-
11095
- /**
11096
- * Gets MEMORY tool function implementations.
11097
- *
11098
- * @private function of MemoryCommitmentDefinition
11099
- */
11100
- function createMemoryToolFunctions() {
11101
- return {
11102
- async [MemoryToolNames.retrieve](args) {
11103
- const runtimeContext = resolveMemoryRuntimeContext(args);
11104
- const { adapter, disabledResult } = getMemoryToolRuntimeAdapterOrDisabledResult('retrieve', runtimeContext);
11105
- if (!adapter || disabledResult) {
11106
- return JSON.stringify(disabledResult);
11107
- }
11108
- const parsedArgs = parseMemoryToolArgs.retrieve(args);
11109
- try {
11110
- const memories = await adapter.retrieveMemories(parsedArgs, runtimeContext);
11111
- const result = {
11112
- action: 'retrieve',
11113
- status: 'ok',
11114
- query: parsedArgs.query,
11115
- memories,
11116
- };
11117
- return JSON.stringify(result);
11118
- }
11119
- catch (error) {
11120
- const result = {
11121
- action: 'retrieve',
11122
- status: 'error',
11123
- query: parsedArgs.query,
11124
- memories: [],
11125
- message: error instanceof Error ? error.message : String(error),
11126
- };
11127
- return JSON.stringify(result);
11128
- }
11129
- },
11130
- async [MemoryToolNames.store](args) {
11131
- const runtimeContext = resolveMemoryRuntimeContext(args);
11132
- const { adapter, disabledResult } = getMemoryToolRuntimeAdapterOrDisabledResult('store', runtimeContext);
11133
- if (!adapter || disabledResult) {
11134
- return JSON.stringify(disabledResult);
11135
- }
11136
- try {
11137
- const parsedArgs = parseMemoryToolArgs.store(args);
11138
- const memory = await adapter.storeMemory(parsedArgs, runtimeContext);
11139
- const result = {
11140
- action: 'store',
11141
- status: 'stored',
11142
- memory,
11143
- };
11144
- return JSON.stringify(result);
11145
- }
11146
- catch (error) {
11147
- const result = {
11148
- action: 'store',
11149
- status: 'error',
11150
- message: error instanceof Error ? error.message : String(error),
11151
- };
11152
- return JSON.stringify(result);
11153
- }
11154
- },
11155
- async [MemoryToolNames.update](args) {
11156
- const runtimeContext = resolveMemoryRuntimeContext(args);
11157
- const { adapter, disabledResult } = getMemoryToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
11158
- if (!adapter || disabledResult) {
11159
- return JSON.stringify(disabledResult);
11160
- }
11161
- try {
11162
- const parsedArgs = parseMemoryToolArgs.update(args);
11163
- const memory = await adapter.updateMemory(parsedArgs, runtimeContext);
11164
- const result = {
11165
- action: 'update',
11166
- status: 'updated',
11167
- memory,
11168
- };
11169
- return JSON.stringify(result);
11170
- }
11171
- catch (error) {
11172
- const result = {
11173
- action: 'update',
11174
- status: 'error',
11175
- message: error instanceof Error ? error.message : String(error),
11176
- };
11177
- return JSON.stringify(result);
11178
- }
11179
- },
11180
- async [MemoryToolNames.delete](args) {
11181
- const runtimeContext = resolveMemoryRuntimeContext(args);
11182
- const { adapter, disabledResult } = getMemoryToolRuntimeAdapterOrDisabledResult('delete', runtimeContext);
11183
- if (!adapter || disabledResult) {
11184
- return JSON.stringify(disabledResult);
11185
- }
11186
- try {
11187
- const parsedArgs = parseMemoryToolArgs.delete(args);
11188
- const deleted = await adapter.deleteMemory(parsedArgs, runtimeContext);
11189
- const result = {
11190
- action: 'delete',
11191
- status: 'deleted',
11192
- memoryId: deleted.id,
11193
- };
11194
- return JSON.stringify(result);
11195
- }
11196
- catch (error) {
11197
- const result = {
11198
- action: 'delete',
11199
- status: 'error',
11200
- message: error instanceof Error ? error.message : String(error),
11201
- };
11202
- return JSON.stringify(result);
11203
- }
11204
- },
11205
- };
11206
- }
11207
-
11208
- /**
11209
- * Creates MEMORY tool definitions while preserving already-registered tools.
11210
- *
11211
- * @private function of MemoryCommitmentDefinition
11212
- */
11213
- function createMemoryTools(existingTools) {
11214
- const tools = [...(existingTools || [])];
11215
- if (!tools.some((tool) => tool.name === MemoryToolNames.retrieve)) {
11216
- tools.push({
11217
- name: MemoryToolNames.retrieve,
11218
- description: spaceTrim$1(`
11219
- Retrieve previously stored user memories relevant to the current conversation.
11220
- Use this before responding when user context can improve the answer.
11221
- `),
11222
- parameters: {
11223
- type: 'object',
11224
- properties: {
11225
- query: {
11226
- type: 'string',
11227
- description: 'Optional query used to filter relevant memories.',
11228
- },
11229
- limit: {
11230
- type: 'integer',
11231
- description: 'Optional maximum number of memories to return (default 5, max 20).',
11232
- },
11233
- },
11234
- },
11235
- });
11236
- }
11237
- if (!tools.some((tool) => tool.name === MemoryToolNames.store)) {
11238
- tools.push({
11239
- name: MemoryToolNames.store,
11240
- description: spaceTrim$1(`
11241
- Store a durable user memory that should be remembered in future conversations.
11242
- Store only stable and useful user-specific facts or preferences.
11243
- `),
11244
- parameters: {
11245
- type: 'object',
11246
- properties: {
11247
- content: {
11248
- type: 'string',
11249
- description: 'Memory text to store.',
11250
- },
11251
- isGlobal: {
11252
- type: 'boolean',
11253
- description: 'Set true to make this memory global across all user agents.',
11254
- },
11255
- },
11256
- required: ['content'],
11257
- },
11258
- });
11259
- }
11260
- if (!tools.some((tool) => tool.name === MemoryToolNames.update)) {
11261
- tools.push({
11262
- name: MemoryToolNames.update,
11263
- description: spaceTrim$1(`
11264
- Update an existing user memory after retrieving it, so the stored fact stays accurate.
11265
- Always pass the memory id you retrieved along with the new content.
11266
- `),
11267
- parameters: {
11268
- type: 'object',
11269
- properties: {
11270
- memoryId: {
11271
- type: 'string',
11272
- description: 'Unique identifier of the memory entry to update.',
11273
- },
11274
- content: {
11275
- type: 'string',
11276
- description: 'Updated memory text.',
11277
- },
11278
- isGlobal: {
11279
- type: 'boolean',
11280
- description: 'Set true to keep the fact global; omit or false to keep it agent-scoped.',
11281
- },
11282
- },
11283
- required: ['memoryId', 'content'],
11284
- },
11285
- });
11286
- }
11287
- if (!tools.some((tool) => tool.name === MemoryToolNames.delete)) {
11288
- tools.push({
11289
- name: MemoryToolNames.delete,
11290
- description: spaceTrim$1(`
11291
- Delete a user memory that is no longer relevant. Deletions are soft so the record is hidden from future queries.
11292
- `),
11293
- parameters: {
11294
- type: 'object',
11295
- properties: {
11296
- memoryId: {
11297
- type: 'string',
11298
- description: 'Unique identifier of the memory entry to delete.',
11299
- },
11300
- },
11301
- required: ['memoryId'],
11302
- },
11303
- });
11304
- }
11305
- return tools;
11306
- }
11307
-
11308
- /**
11309
- * Markdown documentation for MEMORY commitment.
11310
- *
11311
- * @private function of MemoryCommitmentDefinition
11312
- */
11313
- function getMemoryCommitmentDocumentation(type) {
11314
- return spaceTrim$1(`
11315
- # ${type}
11316
-
11317
- Enables persistent user memory for the current agent. The memory is stored by the runtime and can be retrieved in future conversations.
11318
-
11319
- ## Key aspects
11320
-
11321
- - Both \`MEMORY\` and \`MEMORIES\` work identically.
11322
- - Stores user-specific details through runtime tools.
11323
- - Retrieves relevant memories for personalized responses.
11324
- - Supports optional extra instructions in the commitment content.
11325
-
11326
- ## Examples
11327
-
11328
- \`\`\`book
11329
- Personal Assistant
11330
-
11331
- PERSONA You are a personal productivity assistant
11332
- MEMORY Remember user projects and long-term preferences.
11333
- GOAL Help optimize daily productivity and workflow
11334
- \`\`\`
11335
-
11336
- \`\`\`book
11337
- Learning Companion
11338
-
11339
- PERSONA You are an educational companion for programming students
11340
- MEMORY Remember only the student's learning progress and preferred study style.
11341
- GOAL Provide progressive learning experiences tailored to student's pace
11342
- \`\`\`
11343
-
11344
- \`\`\`book
11345
- Customer Support Agent
11346
-
11347
- PERSONA You are a customer support representative
11348
- MEMORY Remember only important support history and communication preferences.
11349
- GOAL Provide personalized support based on customer history
11350
- \`\`\`
11351
- `);
11352
- }
11353
-
11354
- /**
11355
- * Gets human-readable titles for MEMORY tool functions.
11356
- *
11357
- * @private function of MemoryCommitmentDefinition
11358
- */
11359
- function getMemoryToolTitles() {
11360
- return {
11361
- [MemoryToolNames.retrieve]: 'User memory',
11362
- [MemoryToolNames.store]: 'Store user memory',
11363
- [MemoryToolNames.update]: 'Update user memory',
11364
- [MemoryToolNames.delete]: 'Delete user memory',
11365
- };
11366
- }
11367
-
11368
- /**
11369
- * MEMORY commitment definition
11370
- *
11371
- * The MEMORY commitment is similar to KNOWLEDGE but has a focus on remembering past
11372
- * interactions and user preferences. It helps the agent maintain context about the
11373
- * user's history, preferences, and previous conversations.
11374
- *
11375
- * Example usage in agent source:
11376
- *
11377
- * ```book
11378
- * MEMORY User prefers detailed technical explanations
11379
- * MEMORY Previously worked on React projects
11380
- * MEMORY Timezone: UTC-5 (Eastern Time)
11381
- * ```
11382
- *
11383
- * @private [🪔] Maybe export the commitments through some package
11384
- */
11385
- class MemoryCommitmentDefinition extends BaseCommitmentDefinition {
11386
- constructor(type = 'MEMORY') {
11387
- super(type);
11388
- }
11389
- get requiresContent() {
11390
- return false;
11391
- }
11392
- /**
11393
- * Short one-line description of MEMORY.
11394
- */
11395
- get description() {
11396
- return 'Remember past interactions and user **preferences** for personalized responses.';
11397
- }
11398
- /**
11399
- * Icon for this commitment.
11400
- */
11401
- get icon() {
11402
- return '🧠';
11403
- }
11404
- /**
11405
- * Markdown documentation for MEMORY commitment.
11406
- */
11407
- get documentation() {
11408
- return getMemoryCommitmentDocumentation(this.type);
11409
- }
11410
- applyToAgentModelRequirements(requirements, content) {
11411
- const extraInstructions = formatOptionalInstructionBlock('Memory instructions', content);
11412
- const tools = createMemoryTools(requirements.tools);
11413
- return this.appendToSystemMessage({
11414
- ...requirements,
11415
- tools,
11416
- _metadata: {
11417
- ...requirements._metadata,
11418
- useMemory: content || true,
11419
- },
11420
- }, createMemorySystemMessage(extraInstructions));
11421
- }
11422
- /**
11423
- * Gets human-readable titles for MEMORY tool functions.
11424
- */
11425
- getToolTitles() {
11426
- return getMemoryToolTitles();
11427
- }
11428
- /**
11429
- * Gets MEMORY tool function implementations.
11430
- */
11431
- getToolFunctions() {
11432
- return createMemoryToolFunctions();
11433
- }
11434
- }
11435
- // Note: [💞] Ignore a discrepancy between file name and entity name
11436
-
11437
10568
  /**
11438
10569
  * AGENT MESSAGE commitment definition
11439
10570
  *
@@ -11893,161 +11024,6 @@ class MessageSuffixCommitmentDefinition extends BaseCommitmentDefinition {
11893
11024
  }
11894
11025
  // Note: [💞] Ignore a discrepancy between file name and entity name
11895
11026
 
11896
- /**
11897
- * META commitment definition
11898
- *
11899
- * The META commitment handles all meta-information about the agent such as:
11900
- * - META AVATAR / META VISUAL: Sets the agent's built-in default avatar visual
11901
- * - META IMAGE: Sets the agent's avatar/profile image URL
11902
- * - META LINK: Provides profile/source links for the person the agent models
11903
- * - META DOMAIN: Sets the canonical custom domain/host of the agent
11904
- * - META TITLE: Sets the agent's display title
11905
- * - META DESCRIPTION: Sets the agent's description
11906
- * - META INPUT PLACEHOLDER: Sets chat input placeholder text
11907
- * - META THINKING MESSAGE: Adds custom thinking placeholder variants
11908
- * - META [ANYTHING]: Any other meta information in uppercase format
11909
- *
11910
- * These commitments are special because they don't affect the system message,
11911
- * but are handled separately in the parsing logic for profile display.
11912
- *
11913
- * Example usage in agent source:
11914
- *
11915
- * ```book
11916
- * META VISUAL pixel-art
11917
- * META IMAGE https://example.com/avatar.jpg
11918
- * META LINK https://twitter.com/username
11919
- * META DOMAIN my-agent.com
11920
- * META TITLE Professional Assistant
11921
- * META DESCRIPTION An AI assistant specialized in business tasks
11922
- * META INPUT PLACEHOLDER Write a message...
11923
- * META THINKING MESSAGE Thinking...
11924
- * META AUTHOR John Doe
11925
- * META VERSION 1.0
11926
- * ```
11927
- *
11928
- * @private [🪔] Maybe export the commitments through some package
11929
- */
11930
- class MetaCommitmentDefinition extends BaseCommitmentDefinition {
11931
- constructor() {
11932
- super('META');
11933
- }
11934
- /**
11935
- * Short one-line description of META commitments.
11936
- */
11937
- get description() {
11938
- return 'Set meta-information about the agent (IMAGE, LINK, TITLE, DESCRIPTION, etc.).';
11939
- }
11940
- /**
11941
- * Icon for this commitment.
11942
- */
11943
- get icon() {
11944
- return 'ℹ️';
11945
- }
11946
- /**
11947
- * Markdown documentation for META commitment.
11948
- */
11949
- get documentation() {
11950
- return spaceTrim$1(`
11951
- # META
11952
-
11953
- Sets meta-information about the agent that is used for display and attribution purposes.
11954
-
11955
- ## Supported META types
11956
-
11957
- - **META AVATAR** / **META VISUAL** - Sets the agent's built-in default avatar visual
11958
- - **META IMAGE** - Sets the agent's avatar/profile image URL
11959
- - **META LINK** - Provides profile/source links for the person the agent models
11960
- - **META DOMAIN** - Sets the canonical custom domain/host of the agent
11961
- - **META TITLE** - Sets the agent's display title
11962
- - **META DESCRIPTION** - Sets the agent's description
11963
- - **META INPUT PLACEHOLDER** - Sets chat input placeholder text
11964
- - **META THINKING MESSAGE** - Adds custom thinking placeholder variants
11965
- - **META [ANYTHING]** - Any other meta information in uppercase format
11966
-
11967
- ## Key aspects
11968
-
11969
- - Does not modify the agent's behavior or responses
11970
- - Used for visual representation and attribution in user interfaces
11971
- - Multiple META commitments of different types can be used
11972
- - Multiple META LINK commitments can be used for different social profiles
11973
- - Multiple META THINKING MESSAGE commitments can be used for different thinking placeholder variants
11974
- - If multiple META commitments of the same type are specified, the last one takes precedence (except for LINK)
11975
-
11976
- ## Examples
11977
-
11978
- ### Basic meta information
11979
-
11980
- \`\`\`book
11981
- Professional Assistant
11982
-
11983
- META VISUAL octopus3
11984
- META IMAGE https://example.com/professional-avatar.jpg
11985
- META TITLE Senior Business Consultant
11986
- META DESCRIPTION Specialized in strategic planning and project management
11987
- META LINK https://linkedin.com/in/professional
11988
- \`\`\`
11989
-
11990
- ### Multiple links and custom meta
11991
-
11992
- \`\`\`book
11993
- Open Source Developer
11994
-
11995
- META IMAGE /assets/dev-avatar.png
11996
- META LINK https://github.com/developer
11997
- META LINK https://twitter.com/devhandle
11998
- META AUTHOR Jane Smith
11999
- META VERSION 2.1
12000
- META LICENSE MIT
12001
- \`\`\`
12002
-
12003
- ### Creative assistant
12004
-
12005
- \`\`\`book
12006
- Creative Helper
12007
-
12008
- META IMAGE https://example.com/creative-bot.jpg
12009
- META TITLE Creative Writing Assistant
12010
- META DESCRIPTION Helps with brainstorming, storytelling, and creative projects
12011
- META INSPIRATION Books, movies, and real-world experiences
12012
- \`\`\`
12013
- `);
12014
- }
12015
- applyToAgentModelRequirements(requirements, content) {
12016
- // META commitments don't modify the system message or model requirements
12017
- // They are handled separately in the parsing logic for meta information extraction
12018
- // This method exists for consistency with the CommitmentDefinition interface
12019
- return requirements;
12020
- }
12021
- /**
12022
- * Extracts meta information from the content based on the meta type
12023
- * This is used by the parsing logic
12024
- */
12025
- extractMetaValue(metaType, content) {
12026
- const trimmedContent = content.trim();
12027
- return trimmedContent || null;
12028
- }
12029
- /**
12030
- * Validates if the provided content is a valid URL (for IMAGE and LINK types)
12031
- */
12032
- isValidUrl(content) {
12033
- try {
12034
- new URL(content.trim());
12035
- return true;
12036
- }
12037
- catch (_a) {
12038
- return false;
12039
- }
12040
- }
12041
- /**
12042
- * Checks if this is a known meta type
12043
- */
12044
- isKnownMetaType(metaType) {
12045
- const knownTypes = ['AVATAR', 'IMAGE', 'LINK', 'TITLE', 'DESCRIPTION', 'AUTHOR', 'VERSION', 'LICENSE'];
12046
- return knownTypes.includes(metaType.toUpperCase());
12047
- }
12048
- }
12049
- // Note: [💞] Ignore a discrepancy between file name and entity name
12050
-
12051
11027
  /**
12052
11028
  * Makes color transformer which darker the given color
12053
11029
  *
@@ -18298,6 +17274,81 @@ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
18298
17274
  }
18299
17275
  // Note: [💞] Ignore a discrepancy between file name and entity name
18300
17276
 
17277
+ /**
17278
+ * META DESCRIPTION commitment definition
17279
+ *
17280
+ * The META DESCRIPTION commitment sets the agent's meta description for the profile page.
17281
+ * This commitment is special because it doesn't affect the system message,
17282
+ * but is handled separately in the parsing logic.
17283
+ *
17284
+ * Example usage in agent source:
17285
+ *
17286
+ * ```book
17287
+ * META DESCRIPTION An AI assistant specialized in business tasks
17288
+ * ```
17289
+ *
17290
+ * @private [🪔] Maybe export the commitments through some package
17291
+ */
17292
+ class MetaDescriptionCommitmentDefinition extends BaseCommitmentDefinition {
17293
+ constructor() {
17294
+ super('META DESCRIPTION');
17295
+ }
17296
+ /**
17297
+ * Short one-line description of META DESCRIPTION.
17298
+ */
17299
+ get description() {
17300
+ return "Set the agent's meta description.";
17301
+ }
17302
+ /**
17303
+ * Icon for this commitment.
17304
+ */
17305
+ get icon() {
17306
+ return '📝';
17307
+ }
17308
+ /**
17309
+ * Markdown documentation for META DESCRIPTION commitment.
17310
+ */
17311
+ get documentation() {
17312
+ return spaceTrim$1(`
17313
+ # META DESCRIPTION
17314
+
17315
+ Sets the agent's meta description for the profile page.
17316
+
17317
+ ## Key aspects
17318
+
17319
+ - Does not modify the agent's behavior or responses.
17320
+ - Only one \`META DESCRIPTION\` should be used per agent.
17321
+ - If multiple are specified, the last one takes precedence.
17322
+ - Used for SEO and display in user interfaces.
17323
+ - If not present, the agent description falls back to \`PERSONA\` or the first few lines of the agent source.
17324
+
17325
+ ## Examples
17326
+
17327
+ \`\`\`book
17328
+ Professional Assistant
17329
+
17330
+ META DESCRIPTION Specialized in strategic planning and project management
17331
+ PERSONA You are a professional business assistant
17332
+ WRITING RULES Maintain a formal and courteous tone
17333
+ \`\`\`
17334
+ `);
17335
+ }
17336
+ applyToAgentModelRequirements(requirements, content) {
17337
+ // META DESCRIPTION doesn't modify the system message or model requirements
17338
+ // It's handled separately in the parsing logic
17339
+ return requirements;
17340
+ }
17341
+ /**
17342
+ * Extracts the meta description from the content
17343
+ * This is used by the parsing logic
17344
+ */
17345
+ extractMetaDescription(content) {
17346
+ const trimmedContent = content.trim();
17347
+ return trimmedContent || null;
17348
+ }
17349
+ }
17350
+ // Note: [💞] Ignore a discrepancy between file name and entity name
17351
+
18301
17352
  /**
18302
17353
  * META DOMAIN commitment definition
18303
17354
  *
@@ -18514,6 +17565,131 @@ class MetaFontCommitmentDefinition extends BaseCommitmentDefinition {
18514
17565
  }
18515
17566
  // Note: [💞] Ignore a discrepancy between file name and entity name
18516
17567
 
17568
+ /**
17569
+ * META FULLNAME commitment definition
17570
+ *
17571
+ * The `META FULLNAME` commitment sets the full display name of the agent, which can differ
17572
+ * from the agent name on the first line of the agent source, for example when the agent
17573
+ * should be presented with academic titles.
17574
+ * This commitment is metadata-only and does not modify model requirements.
17575
+ *
17576
+ * @private [🪔] Maybe export the commitments through some package
17577
+ */
17578
+ class MetaFullnameCommitmentDefinition extends BaseCommitmentDefinition {
17579
+ constructor() {
17580
+ super('META FULLNAME');
17581
+ }
17582
+ /**
17583
+ * Short one-line description of META FULLNAME.
17584
+ */
17585
+ get description() {
17586
+ return "Set the agent's full display name.";
17587
+ }
17588
+ /**
17589
+ * Icon for this commitment.
17590
+ */
17591
+ get icon() {
17592
+ return '🪪';
17593
+ }
17594
+ /**
17595
+ * Markdown documentation for META FULLNAME commitment.
17596
+ */
17597
+ get documentation() {
17598
+ return spaceTrim$1(`
17599
+ # META FULLNAME
17600
+
17601
+ Sets the full display name of the agent shown in profiles, chats, and exports.
17602
+
17603
+ ## Key aspects
17604
+
17605
+ - Does not modify the agent's behavior or responses.
17606
+ - If not present, the agent name from the first line of the agent source is used.
17607
+ - If multiple \`META FULLNAME\` commitments are specified, the last one takes precedence.
17608
+
17609
+ ## Examples
17610
+
17611
+ \`\`\`book
17612
+ Pavol Hejný
17613
+
17614
+ META FULLNAME Dr. Ing. Pavol Hejný, PhD.
17615
+ PERSONA Developer with 10 years of experience in building AI applications.
17616
+ \`\`\`
17617
+ `);
17618
+ }
17619
+ applyToAgentModelRequirements(requirements, content) {
17620
+ // META FULLNAME does not modify the model requirements.
17621
+ // It is consumed by profile parsing.
17622
+ return requirements;
17623
+ }
17624
+ }
17625
+ // Note: [💞] Ignore a discrepancy between file name and entity name
17626
+
17627
+ /**
17628
+ * META ID commitment definition
17629
+ *
17630
+ * The `META ID` commitment carries the permanent id of the agent when an agent source is moved
17631
+ * between systems. It is a low-level commitment which is normally written and stripped by the
17632
+ * persistence layer instead of being written by hand.
17633
+ * This commitment is metadata-only and does not modify model requirements.
17634
+ *
17635
+ * @private [🪔] Maybe export the commitments through some package
17636
+ */
17637
+ class MetaIdCommitmentDefinition extends BaseCommitmentDefinition {
17638
+ constructor() {
17639
+ super('META ID');
17640
+ }
17641
+ /**
17642
+ * Short one-line description of META ID.
17643
+ */
17644
+ get description() {
17645
+ return "Set the agent's permanent id.";
17646
+ }
17647
+ /**
17648
+ * Icon for this commitment.
17649
+ */
17650
+ get icon() {
17651
+ return '🔖';
17652
+ }
17653
+ /**
17654
+ * `META ID` is written by the persistence layer, not by agent authors.
17655
+ */
17656
+ get isLowLevel() {
17657
+ return true;
17658
+ }
17659
+ /**
17660
+ * Markdown documentation for META ID commitment.
17661
+ */
17662
+ get documentation() {
17663
+ return spaceTrim$1(`
17664
+ # META ID
17665
+
17666
+ Carries the permanent id of the agent inside the agent source.
17667
+
17668
+ ## Key aspects
17669
+
17670
+ - Does not modify the agent's behavior or responses.
17671
+ - Written and stripped by the persistence layer, it should not be written by hand.
17672
+ - When an agent source without \`META ID\` is stored, a fresh permanent id is assigned.
17673
+ - If multiple \`META ID\` commitments are specified, the last one takes precedence.
17674
+
17675
+ ## Examples
17676
+
17677
+ \`\`\`book
17678
+ My agent
17679
+
17680
+ META ID doQMRg82izNfJa
17681
+ PERSONA My agent is an expert in something.
17682
+ \`\`\`
17683
+ `);
17684
+ }
17685
+ applyToAgentModelRequirements(requirements, content) {
17686
+ // META ID does not modify the model requirements.
17687
+ // It is consumed by profile parsing and agent persistence.
17688
+ return requirements;
17689
+ }
17690
+ }
17691
+ // Note: [💞] Ignore a discrepancy between file name and entity name
17692
+
18517
17693
  /**
18518
17694
  * META IMAGE commitment definition
18519
17695
  *
@@ -20223,6 +19399,110 @@ function isSameOriginAgentUrl(agentUrl, localServerUrl) {
20223
19399
  }
20224
19400
  // Note: [💞] Ignore a discrepancy between file name and entity name
20225
19401
 
19402
+ /**
19403
+ * Prompt parameter key used to pass hidden runtime context to tool execution.
19404
+ *
19405
+ * @private internal runtime wiring for commitment tools
19406
+ */
19407
+ const TOOL_RUNTIME_CONTEXT_PARAMETER = 'promptbookToolRuntimeContext';
19408
+ /**
19409
+ * Hidden argument key used to pass runtime context into individual tool calls.
19410
+ *
19411
+ * @private internal runtime wiring for commitment tools
19412
+ */
19413
+ const TOOL_RUNTIME_CONTEXT_ARGUMENT = '__promptbookToolRuntimeContext';
19414
+ /**
19415
+ * Prompt parameter key used to pass a hidden tool-progress listener token into script execution.
19416
+ *
19417
+ * @private internal runtime wiring for commitment tools
19418
+ */
19419
+ const TOOL_PROGRESS_TOKEN_PARAMETER = 'promptbookToolProgressToken';
19420
+ /**
19421
+ * Hidden argument key used to pass a tool-progress listener token into individual tool calls.
19422
+ *
19423
+ * @private internal runtime wiring for commitment tools
19424
+ */
19425
+ const TOOL_PROGRESS_TOKEN_ARGUMENT = '__promptbookToolProgressToken';
19426
+ /**
19427
+ * Monotonic counter used for hidden progress-listener tokens.
19428
+ *
19429
+ * @private internal runtime wiring for commitment tools
19430
+ */
19431
+ let toolCallProgressListenerCounter = 0;
19432
+ /**
19433
+ * Active tool-progress listeners keyed by hidden execution token.
19434
+ *
19435
+ * @private internal runtime wiring for commitment tools
19436
+ */
19437
+ const toolCallProgressListeners = new Map();
19438
+ /**
19439
+ * Parses unknown runtime context payload into a normalized object.
19440
+ *
19441
+ * @private internal runtime wiring for commitment tools
19442
+ */
19443
+ function parseToolRuntimeContext(rawValue) {
19444
+ if (!rawValue) {
19445
+ return null;
19446
+ }
19447
+ let parsed = rawValue;
19448
+ if (typeof rawValue === 'string') {
19449
+ try {
19450
+ parsed = JSON.parse(rawValue);
19451
+ }
19452
+ catch (_a) {
19453
+ return null;
19454
+ }
19455
+ }
19456
+ if (!parsed || typeof parsed !== 'object') {
19457
+ return null;
19458
+ }
19459
+ return parsed;
19460
+ }
19461
+ /**
19462
+ * Reads runtime context attached to tool call arguments.
19463
+ *
19464
+ * @private internal runtime wiring for commitment tools
19465
+ */
19466
+ function readToolRuntimeContextFromToolArgs(args) {
19467
+ return parseToolRuntimeContext(args[TOOL_RUNTIME_CONTEXT_ARGUMENT]);
19468
+ }
19469
+ /**
19470
+ * Serializes runtime context for prompt parameters.
19471
+ *
19472
+ * @private internal runtime wiring for commitment tools
19473
+ */
19474
+ function serializeToolRuntimeContext(context) {
19475
+ return JSON.stringify(context);
19476
+ }
19477
+ /**
19478
+ * Registers one in-memory listener that receives progress updates emitted by a running tool.
19479
+ *
19480
+ * The returned token is passed into script execution as a hidden argument so tool implementations
19481
+ * can stream progress without exposing extra parameters to the model.
19482
+ *
19483
+ * @param listener - Listener notified about tool progress.
19484
+ * @returns Hidden token used to route progress updates.
19485
+ *
19486
+ * @private internal runtime wiring for commitment tools
19487
+ */
19488
+ function registerToolCallProgressListener(listener) {
19489
+ toolCallProgressListenerCounter += 1;
19490
+ const token = `tool-progress:${Date.now()}:${toolCallProgressListenerCounter}`;
19491
+ toolCallProgressListeners.set(token, listener);
19492
+ return token;
19493
+ }
19494
+ /**
19495
+ * Unregisters one in-memory progress listener.
19496
+ *
19497
+ * @param token - Token previously created by `registerToolCallProgressListener`.
19498
+ *
19499
+ * @private internal runtime wiring for commitment tools
19500
+ */
19501
+ function unregisterToolCallProgressListener(token) {
19502
+ toolCallProgressListeners.delete(token);
19503
+ }
19504
+ // Note: [💞] Ignore a discrepancy between file name and entity name
19505
+
20226
19506
  /**
20227
19507
  * Map of team tool functions.
20228
19508
  */
@@ -20810,267 +20090,23 @@ class TemplateCommitmentDefinition extends BaseCommitmentDefinition {
20810
20090
  // Note: [💞] Ignore a discrepancy between file name and entity name
20811
20091
 
20812
20092
  /**
20813
- * Client-side safe wrapper for fetching URL content
20814
- *
20815
- * This function proxies requests to the Agents Server API endpoint for scraping,
20816
- * making it safe to use in browser environments.
20817
- *
20818
- * @param url The URL to fetch and scrape
20819
- * @param agentsServerUrl The base URL of the agents server (defaults to current origin)
20820
- * @returns Markdown content from the URL
20821
- *
20822
- * @private internal utility for USE BROWSER commitment
20823
- */
20824
- async function fetchUrlContentViaBrowser(url, agentsServerUrl) {
20825
- try {
20826
- // Determine the agents server URL
20827
- const baseUrl = agentsServerUrl || (typeof window !== 'undefined' ? window.location.origin : '');
20828
- if (!baseUrl) {
20829
- throw new Error('Agents server URL is required in non-browser environments');
20830
- }
20831
- // Build the API endpoint URL
20832
- const apiUrl = new URL('/api/scrape', baseUrl);
20833
- apiUrl.searchParams.set('url', url);
20834
- // Fetch from the API endpoint
20835
- const response = await fetch(apiUrl.toString());
20836
- if (!response.ok) {
20837
- const errorData = await response.json().catch(() => ({ error: 'Unknown error' }));
20838
- throw new Error(`Failed to scrape URL: ${errorData.error || response.statusText}`);
20839
- }
20840
- const data = await response.json();
20841
- if (!data.success || !data.content) {
20842
- throw new Error(`Scraping failed: ${data.error || 'No content returned'}`);
20843
- }
20844
- return data.content;
20845
- }
20846
- catch (error) {
20847
- const errorMessage = error instanceof Error ? error.message : String(error);
20848
- throw new Error(`Error fetching URL content via browser: ${errorMessage}`);
20849
- }
20850
- }
20851
-
20852
- /**
20853
- * USE BROWSER commitment definition
20854
- *
20855
- * The `USE BROWSER` commitment indicates that the agent should utilize browser tools
20856
- * to access and retrieve up-to-date information from the internet when necessary.
20857
- *
20858
- * This commitment provides two levels of browser access:
20859
- * 1. One-shot URL fetching: Simple function to fetch and scrape URL content
20860
- * 2. Running browser: For complex tasks like scrolling, clicking, form filling, etc.
20861
- *
20862
- * The content following `USE BROWSER` is an arbitrary text that the agent should know
20863
- * (e.g. browsing scope or preferred sources).
20864
- *
20865
- * Example usage in agent source:
20866
- *
20867
- * ```book
20868
- * USE BROWSER
20869
- * USE BROWSER Prefer official documentation and source websites.
20870
- * ```
20093
+ * @@@
20871
20094
  *
20872
- * @private [🪔] Maybe export the commitments through some package
20095
+ * @private utility for commitments
20873
20096
  */
20874
- class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
20875
- constructor() {
20876
- super('USE BROWSER', ['BROWSER']);
20877
- }
20878
- /**
20879
- * The `USE BROWSER` commitment is standalone.
20880
- */
20881
- get requiresContent() {
20882
- return false;
20883
- }
20884
- /**
20885
- * Short one-line description of USE BROWSER.
20886
- */
20887
- get description() {
20888
- return 'Enable the agent to use browser tools for accessing internet information.';
20889
- }
20890
- /**
20891
- * Icon for this commitment.
20892
- */
20893
- get icon() {
20894
- return '🌐';
20895
- }
20896
- /**
20897
- * Markdown documentation for USE BROWSER commitment.
20898
- */
20899
- get documentation() {
20900
- return spaceTrim$1(`
20901
- # USE BROWSER
20902
-
20903
- Enables the agent to use browser tools to access and retrieve up-to-date information from the internet.
20904
-
20905
- ## Key aspects
20906
-
20907
- - The content following \`USE BROWSER\` is an arbitrary text that the agent should know (e.g. browsing scope or preferred sources).
20908
- - Provides two levels of browser access:
20909
- 1. **One-shot URL fetching**: Simple function to fetch and scrape URL content (active)
20910
- 2. **Running browser**: For complex tasks like scrolling, clicking, form filling, etc. (runtime-dependent)
20911
- - The actual browser tool usage is handled by the agent runtime
20912
- - On the Agents Server, every agent browses in its own persistent isolated browser profile, so cookies and logged-in sessions survive across chats (the profile is linked from the agent wallet)
20913
- - Allows the agent to fetch current information from websites and documents
20914
- - Useful for research tasks, fact-checking, and accessing dynamic content
20915
- - Supports various content types including HTML pages and PDF documents
20916
-
20917
- ## Examples
20918
-
20919
- \`\`\`book
20920
- Research Assistant
20921
-
20922
- PERSONA You are a helpful research assistant specialized in finding current information
20923
- USE BROWSER
20924
- RULE Always cite your sources when providing information from the web
20925
- \`\`\`
20926
-
20927
- \`\`\`book
20928
- News Analyst
20929
-
20930
- PERSONA You are a news analyst who stays up-to-date with current events
20931
- USE BROWSER
20932
- WRITING RULES Present news in a balanced and objective manner
20933
- ACTION Can search for and summarize news articles
20934
- \`\`\`
20935
-
20936
- \`\`\`book
20937
- Company Lawyer
20938
-
20939
- PERSONA You are a company lawyer providing legal advice
20940
- USE BROWSER
20941
- KNOWLEDGE Corporate law and legal procedures
20942
- RULE Always recommend consulting with a licensed attorney for specific legal matters
20943
- \`\`\`
20944
- `);
20945
- }
20946
- /**
20947
- * Gets human-readable titles for tool functions provided by this commitment.
20948
- */
20949
- getToolTitles() {
20950
- return {
20951
- fetch_url_content: 'Fetch URL content',
20952
- run_browser: 'Run browser',
20953
- };
20954
- }
20955
- applyToAgentModelRequirements(requirements, content) {
20956
- // Get existing tools array or create new one
20957
- const existingTools = requirements.tools || [];
20958
- // Add browser tools if not already present
20959
- const toolsToAdd = [];
20960
- // Tool 1: One-shot URL content fetching
20961
- if (!existingTools.some((tool) => tool.name === 'fetch_url_content')) {
20962
- toolsToAdd.push({
20963
- name: 'fetch_url_content',
20964
- description: spaceTrim$1(`
20965
- Fetches and scrapes the content from a URL (webpage or document).
20966
- This tool retrieves the content of the specified URL and converts it to markdown format.
20967
- Use this when you need to access information from a specific website or document.
20968
- Supports various content types including HTML pages and PDF documents.
20969
- `),
20970
- parameters: {
20971
- type: 'object',
20972
- properties: {
20973
- url: {
20974
- type: 'string',
20975
- description: 'The URL to fetch and scrape (e.g., "https://example.com" or "https://example.com/document.pdf")',
20976
- },
20977
- },
20978
- required: ['url'],
20979
- },
20980
- });
20981
- }
20982
- // Tool 2: Running browser for complex page interactions
20983
- if (!existingTools.some((tool) => tool.name === 'run_browser')) {
20984
- toolsToAdd.push({
20985
- name: 'run_browser',
20986
- description: spaceTrim$1(`
20987
- Launches a browser session for complex interactions.
20988
- This tool is for advanced browser automation tasks like scrolling, clicking, form filling, etc.
20989
- Use this when simple one-shot URL fetching is not enough.
20990
- `),
20991
- parameters: {
20992
- type: 'object',
20993
- properties: {
20994
- url: {
20995
- type: 'string',
20996
- description: 'The initial URL to navigate to',
20997
- },
20998
- actions: {
20999
- type: 'array',
21000
- description: 'Array of actions to perform in the browser',
21001
- items: {
21002
- type: 'object',
21003
- properties: {
21004
- type: {
21005
- type: 'string',
21006
- enum: ['navigate', 'click', 'scroll', 'type', 'wait'],
21007
- },
21008
- selector: {
21009
- type: 'string',
21010
- description: 'CSS selector for the element (for click, type actions)',
21011
- },
21012
- value: {
21013
- type: 'string',
21014
- description: 'Value to type or navigate to',
21015
- },
21016
- },
21017
- },
21018
- },
21019
- },
21020
- required: ['url'],
21021
- },
21022
- });
21023
- }
21024
- const updatedTools = [...existingTools, ...toolsToAdd];
21025
- return appendAggregatedUseCommitmentPlaceholder({
21026
- ...requirements,
21027
- tools: updatedTools,
21028
- _metadata: {
21029
- ...requirements._metadata,
21030
- useBrowser: true,
21031
- },
21032
- }, this.type);
21033
- }
21034
- /**
21035
- * Gets the browser tool function implementations.
21036
- *
21037
- * This method automatically detects the environment and uses:
21038
- * - Server-side: Direct scraping via fetchUrlContent (Node.js)
21039
- * - Browser: Proxy through Agents Server API via fetchUrlContentViaBrowser
21040
- */
21041
- getToolFunctions() {
21042
- return {
21043
- /**
21044
- * @@@
21045
- *
21046
- * Note: [🛺] This function has implementation both for browser and node, this is the proxied one for browser
21047
- */
21048
- async fetch_url_content(args) {
21049
- console.log('!!!! [Tool] fetch_url_content called', { args });
21050
- const { url } = args;
21051
- return await fetchUrlContentViaBrowser(url);
21052
- },
21053
- /**
21054
- * @@@
21055
- */
21056
- async run_browser(args) {
21057
- console.log('!!!! [Tool] run_browser called', { args });
21058
- const { url } = args;
21059
- return spaceTrim$1(`
21060
- # Running browser
21061
-
21062
- The running browser tool is not available in this runtime.
21063
-
21064
- This environment does not provide the server-side browser automation backend.
21065
- In Agents Server Node runtime, this tool is resolved to a Playwright CLI implementation.
21066
-
21067
- Requested URL: ${url}
21068
- `);
21069
- },
21070
- };
20097
+ function formatOptionalInstructionBlock(label, content) {
20098
+ const trimmedContent = spaceTrim$1(content);
20099
+ if (!trimmedContent) {
20100
+ return '';
21071
20101
  }
20102
+ return spaceTrim$1((block) => `
20103
+ - ${label}:
20104
+ ${block(trimmedContent
20105
+ .split(/\r?\n/)
20106
+ .map((line) => `- ${line}`)
20107
+ .join('\n'))}
20108
+ `);
21072
20109
  }
21073
- // Note: [💞] Ignore a discrepancy between file name and entity name
21074
20110
 
21075
20111
  /**
21076
20112
  * Hostnames accepted for Google Calendar references.
@@ -21395,7 +20431,7 @@ function resolveUseCalendarToolRuntime(args) {
21395
20431
  const runtimeContext = (readToolRuntimeContextFromToolArgs(args) ||
21396
20432
  {});
21397
20433
  const configuredCalendars = normalizeConfiguredCalendars$1((_a = runtimeContext.calendars) === null || _a === void 0 ? void 0 : _a.connections);
21398
- const calendarArgument = normalizeOptionalText$2(args.calendarUrl);
20434
+ const calendarArgument = normalizeOptionalText$1(args.calendarUrl);
21399
20435
  let calendarReference = null;
21400
20436
  if (calendarArgument) {
21401
20437
  calendarReference = parseGoogleCalendarReference(calendarArgument);
@@ -21415,7 +20451,7 @@ function resolveUseCalendarToolRuntime(args) {
21415
20451
  if (!calendarReference) {
21416
20452
  throw new Error('Calendar is required but was not resolved.');
21417
20453
  }
21418
- const accessToken = normalizeOptionalText$2((_b = runtimeContext.calendars) === null || _b === void 0 ? void 0 : _b.googleAccessToken) || '';
20454
+ const accessToken = normalizeOptionalText$1((_b = runtimeContext.calendars) === null || _b === void 0 ? void 0 : _b.googleAccessToken) || '';
21419
20455
  if (!accessToken) {
21420
20456
  throw new CalendarWalletCredentialRequiredError({
21421
20457
  calendarReference,
@@ -21448,7 +20484,7 @@ function normalizeConfiguredCalendars$1(rawCalendars) {
21448
20484
  continue;
21449
20485
  }
21450
20486
  const calendar = rawCalendar;
21451
- const rawUrl = normalizeOptionalText$2(calendar.url);
20487
+ const rawUrl = normalizeOptionalText$1(calendar.url);
21452
20488
  if (!rawUrl) {
21453
20489
  continue;
21454
20490
  }
@@ -21499,7 +20535,7 @@ function createCalendarWalletCredentialRequiredResult(error) {
21499
20535
  *
21500
20536
  * @private function of resolveUseCalendarToolRuntimeOrWalletCredentialResult
21501
20537
  */
21502
- function normalizeOptionalText$2(value) {
20538
+ function normalizeOptionalText$1(value) {
21503
20539
  if (typeof value !== 'string') {
21504
20540
  return undefined;
21505
20541
  }
@@ -21531,13 +20567,13 @@ function createUseCalendarToolFunctions() {
21531
20567
  async [UseCalendarToolNames.listEvents](args) {
21532
20568
  return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
21533
20569
  const query = {};
21534
- if (normalizeOptionalText$1(args.timeMin)) {
20570
+ if (normalizeOptionalText(args.timeMin)) {
21535
20571
  query.timeMin = args.timeMin.trim();
21536
20572
  }
21537
- if (normalizeOptionalText$1(args.timeMax)) {
20573
+ if (normalizeOptionalText(args.timeMax)) {
21538
20574
  query.timeMax = args.timeMax.trim();
21539
20575
  }
21540
- if (normalizeOptionalText$1(args.query)) {
20576
+ if (normalizeOptionalText(args.query)) {
21541
20577
  query.q = args.query.trim();
21542
20578
  }
21543
20579
  if (typeof args.maxResults === 'number' && Number.isFinite(args.maxResults) && args.maxResults > 0) {
@@ -21549,7 +20585,7 @@ function createUseCalendarToolFunctions() {
21549
20585
  if (args.orderBy === 'startTime' || args.orderBy === 'updated') {
21550
20586
  query.orderBy = args.orderBy;
21551
20587
  }
21552
- if (normalizeOptionalText$1(args.timeZone)) {
20588
+ if (normalizeOptionalText(args.timeZone)) {
21553
20589
  query.timeZone = args.timeZone.trim();
21554
20590
  }
21555
20591
  const payload = await callGoogleCalendarApi(accessToken, {
@@ -21587,11 +20623,11 @@ function createUseCalendarToolFunctions() {
21587
20623
  return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
21588
20624
  const requestBody = createGoogleCalendarEventPayload({
21589
20625
  summary: normalizeRequiredText(args.summary, 'summary'),
21590
- description: normalizeOptionalText$1(args.description),
21591
- location: normalizeOptionalText$1(args.location),
20626
+ description: normalizeOptionalText(args.description),
20627
+ location: normalizeOptionalText(args.location),
21592
20628
  start: normalizeRequiredText(args.start, 'start'),
21593
20629
  end: normalizeRequiredText(args.end, 'end'),
21594
- timeZone: normalizeOptionalText$1(args.timeZone),
20630
+ timeZone: normalizeOptionalText(args.timeZone),
21595
20631
  attendees: normalizeAttendees(args.attendees),
21596
20632
  reminderMinutes: normalizeReminderMinutes(args.reminderMinutes),
21597
20633
  });
@@ -21613,12 +20649,12 @@ function createUseCalendarToolFunctions() {
21613
20649
  return withUseCalendarRuntime(args, async ({ calendarReference, accessToken }) => {
21614
20650
  const eventId = normalizeRequiredText(args.eventId, 'eventId');
21615
20651
  const requestBody = createGoogleCalendarEventPayload({
21616
- summary: normalizeOptionalText$1(args.summary),
21617
- description: normalizeOptionalText$1(args.description),
21618
- location: normalizeOptionalText$1(args.location),
21619
- start: normalizeOptionalText$1(args.start),
21620
- end: normalizeOptionalText$1(args.end),
21621
- timeZone: normalizeOptionalText$1(args.timeZone),
20652
+ summary: normalizeOptionalText(args.summary),
20653
+ description: normalizeOptionalText(args.description),
20654
+ location: normalizeOptionalText(args.location),
20655
+ start: normalizeOptionalText(args.start),
20656
+ end: normalizeOptionalText(args.end),
20657
+ timeZone: normalizeOptionalText(args.timeZone),
21622
20658
  attendees: normalizeAttendees(args.attendees),
21623
20659
  reminderMinutes: normalizeReminderMinutes(args.reminderMinutes),
21624
20660
  });
@@ -21665,7 +20701,7 @@ function createUseCalendarToolFunctions() {
21665
20701
  path: `/calendars/${encodeGoogleCalendarId(calendarReference.calendarId)}/events/${encodeURIComponent(eventId)}`,
21666
20702
  });
21667
20703
  const existingAttendees = ((existingEvent === null || existingEvent === void 0 ? void 0 : existingEvent.attendees) || [])
21668
- .map((attendee) => normalizeOptionalText$1(attendee.email))
20704
+ .map((attendee) => normalizeOptionalText(attendee.email))
21669
20705
  .filter((email) => Boolean(email));
21670
20706
  const mergedAttendees = [...new Set([...existingAttendees, ...guests])];
21671
20707
  const payload = await callGoogleCalendarApi(accessToken, {
@@ -21713,7 +20749,7 @@ function encodeGoogleCalendarId(calendarId) {
21713
20749
  * @private function of createUseCalendarToolFunctions
21714
20750
  */
21715
20751
  function normalizeRequiredText(value, fieldName) {
21716
- const normalizedValue = normalizeOptionalText$1(value);
20752
+ const normalizedValue = normalizeOptionalText(value);
21717
20753
  if (!normalizedValue) {
21718
20754
  throw new Error(`Tool "${fieldName}" requires non-empty value.`);
21719
20755
  }
@@ -21724,7 +20760,7 @@ function normalizeRequiredText(value, fieldName) {
21724
20760
  *
21725
20761
  * @private function of createUseCalendarToolFunctions
21726
20762
  */
21727
- function normalizeOptionalText$1(value) {
20763
+ function normalizeOptionalText(value) {
21728
20764
  if (typeof value !== 'string') {
21729
20765
  return undefined;
21730
20766
  }
@@ -22298,469 +21334,6 @@ function addConfiguredCalendarIfMissing(configuredCalendars, calendarReference)
22298
21334
  }
22299
21335
  // Note: [💞] Ignore a discrepancy between file name and entity name
22300
21336
 
22301
- /**
22302
- * A search engine implementation that uses the SerpApi to fetch Google search results.
22303
- *
22304
- * @private <- TODO: !!!! Export via some package
22305
- */
22306
- class SerpSearchEngine {
22307
- get title() {
22308
- return 'SerpApi Search Engine';
22309
- }
22310
- get description() {
22311
- return 'Search engine that uses SerpApi to fetch Google search results';
22312
- }
22313
- checkConfiguration() {
22314
- if (!process.env.SERP_API_KEY) {
22315
- throw new Error('SERP_API_KEY is not configured');
22316
- }
22317
- }
22318
- async search(query, options = {}) {
22319
- const apiKey = process.env.SERP_API_KEY;
22320
- if (!apiKey) {
22321
- throw new Error('SERP_API_KEY is not configured');
22322
- }
22323
- const url = new URL('https://serpapi.com/search');
22324
- url.searchParams.set('api_key', apiKey);
22325
- url.searchParams.set('engine', 'google');
22326
- url.searchParams.set('q', query);
22327
- for (const [key, value] of Object.entries(options)) {
22328
- url.searchParams.set(key, String(value));
22329
- }
22330
- const response = await fetch(url.toString());
22331
- if (!response.ok) {
22332
- const body = await response.text();
22333
- throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
22334
- }
22335
- const data = (await response.json());
22336
- return (data.organic_results || []).map((item) => ({
22337
- title: item.title,
22338
- url: item.link,
22339
- snippet: item.snippet || '',
22340
- }));
22341
- }
22342
- }
22343
-
22344
- /**
22345
- * Creates one SERP-backed tool function used as a local fallback for search-like commitments.
22346
- *
22347
- * @param toolName - Technical tool name used for validation messages.
22348
- * @param resultLabel - Human-readable label used in formatted results.
22349
- * @returns Async tool function compatible with commitment tool registration.
22350
- *
22351
- * @private internal helper for search-like commitments
22352
- */
22353
- function createSerpSearchToolFunction(toolName, resultLabel) {
22354
- return async (rawArgs) => {
22355
- const { query, ...searchOptions } = rawArgs;
22356
- if (typeof query !== 'string' || !query.trim()) {
22357
- throw new Error(`${toolName} query is required`);
22358
- }
22359
- const searchEngine = new SerpSearchEngine();
22360
- const results = await searchEngine.search(query, searchOptions);
22361
- return spaceTrim$1((block) => `
22362
- ${resultLabel} results for "${query}"${Object.keys(searchOptions).length === 0 ? '' : ` with options ${JSON.stringify(searchOptions)}`}:
22363
-
22364
- ${block(results
22365
- .map((result) => spaceTrim$1(`
22366
- - **${result.title}**
22367
- ${result.url}
22368
- ${result.snippet}
22369
- `))
22370
- .join('\n\n'))}
22371
- `);
22372
- };
22373
- }
22374
-
22375
- /**
22376
- * USE DEEPSEARCH commitment definition
22377
- *
22378
- * The `USE DEEPSEARCH` commitment indicates that the agent should use a deeper research-oriented
22379
- * search workflow instead of lightweight web search when it needs fresh information from the internet.
22380
- *
22381
- * The content following `USE DEEPSEARCH` is an arbitrary text that the agent should know
22382
- * (e.g. search scope or research instructions).
22383
- *
22384
- * Example usage in agent source:
22385
- *
22386
- * ```book
22387
- * USE DEEPSEARCH
22388
- * USE DEEPSEARCH Compare official vendor documentation with independent benchmarks.
22389
- * ```
22390
- *
22391
- * @private [🪔] Maybe export the commitments through some package
22392
- */
22393
- class UseDeepSearchCommitmentDefinition extends BaseCommitmentDefinition {
22394
- constructor() {
22395
- super('USE DEEPSEARCH');
22396
- }
22397
- get requiresContent() {
22398
- return false;
22399
- }
22400
- /**
22401
- * Short one-line description of USE DEEPSEARCH.
22402
- */
22403
- get description() {
22404
- return 'Enable the agent to use DeepSearch for more thorough internet research.';
22405
- }
22406
- /**
22407
- * Icon for this commitment.
22408
- */
22409
- get icon() {
22410
- return '🔬';
22411
- }
22412
- /**
22413
- * Markdown documentation for USE DEEPSEARCH commitment.
22414
- */
22415
- get documentation() {
22416
- return spaceTrim$1(`
22417
- # USE DEEPSEARCH
22418
-
22419
- Enables the agent to use DeepSearch for broader, more thorough internet research than lightweight web search.
22420
-
22421
- ## Key aspects
22422
-
22423
- - The content following \`USE DEEPSEARCH\` is arbitrary guidance for the research workflow.
22424
- - In Agents Server, the OpenAI Agents SDK runtime uses a nested deep-research agent for this tool.
22425
- - Use this for investigations, comparisons, market scans, or other tasks that benefit from deeper synthesis.
22426
- - Prefer regular \`USE SEARCH ENGINE\` when a quick factual lookup is enough.
22427
-
22428
- ## Examples
22429
-
22430
- \`\`\`book
22431
- Due Diligence Researcher
22432
-
22433
- GOAL Investigate vendors thoroughly before making recommendations.
22434
- USE DEEPSEARCH Compare official sources with credible third-party analysis.
22435
- RULE Cite the strongest supporting sources in the final answer.
22436
- \`\`\`
22437
-
22438
- \`\`\`book
22439
- Market Analyst
22440
-
22441
- GOAL Build concise but well-grounded research briefs.
22442
- USE DEEPSEARCH Focus on recent public information and competing viewpoints.
22443
- CLOSED
22444
- \`\`\`
22445
- `);
22446
- }
22447
- applyToAgentModelRequirements(requirements, content) {
22448
- const existingTools = requirements.tools || [];
22449
- const updatedTools = existingTools.some((tool) => tool.name === 'deep_search')
22450
- ? existingTools
22451
- : [
22452
- ...existingTools,
22453
- {
22454
- name: 'deep_search',
22455
- description: spaceTrim$1(`
22456
- Research the internet deeply and synthesize a grounded answer.
22457
- Use this tool for broader investigations, comparisons, and requests that need more than a quick search.
22458
- `),
22459
- parameters: {
22460
- type: 'object',
22461
- properties: {
22462
- query: {
22463
- type: 'string',
22464
- description: 'The research question or investigation request.',
22465
- },
22466
- },
22467
- required: ['query'],
22468
- additionalProperties: false,
22469
- },
22470
- },
22471
- ];
22472
- return appendAggregatedUseCommitmentPlaceholder({
22473
- ...requirements,
22474
- tools: updatedTools,
22475
- _metadata: {
22476
- ...requirements._metadata,
22477
- useDeepSearch: content || true,
22478
- },
22479
- }, this.type);
22480
- }
22481
- /**
22482
- * Gets human-readable titles for tool functions provided by this commitment.
22483
- */
22484
- getToolTitles() {
22485
- return {
22486
- deep_search: 'DeepSearch',
22487
- };
22488
- }
22489
- /**
22490
- * Gets the local fallback implementation for the `deep_search` tool.
22491
- */
22492
- getToolFunctions() {
22493
- return {
22494
- deep_search: createSerpSearchToolFunction('deep_search', 'DeepSearch'),
22495
- };
22496
- }
22497
- }
22498
- // Note: [💞] Ignore a discrepancy between file name and entity name
22499
-
22500
- /**
22501
- * Lightweight email token matcher used for `USE EMAIL` first-line parsing.
22502
- *
22503
- * @private internal USE EMAIL constant
22504
- */
22505
- const EMAIL_TOKEN_PATTERN = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/;
22506
- /**
22507
- * Parses `USE EMAIL` commitment content into optional sender email + additional instructions.
22508
- *
22509
- * Examples:
22510
- * - `agent@example.com`
22511
- * - `agent@example.com Keep emails concise`
22512
- * - `Keep emails concise`
22513
- *
22514
- * @private internal utility of USE EMAIL commitment
22515
- */
22516
- function parseUseEmailCommitmentContent(content) {
22517
- const trimmedContent = spaceTrim$1(content);
22518
- if (!trimmedContent) {
22519
- return {
22520
- senderEmail: null,
22521
- senderEmailRaw: null,
22522
- instructions: '',
22523
- };
22524
- }
22525
- const lines = trimmedContent
22526
- .split(/\r?\n/)
22527
- .map((line) => line.trim())
22528
- .filter(Boolean);
22529
- if (lines.length === 0) {
22530
- return {
22531
- senderEmail: null,
22532
- senderEmailRaw: null,
22533
- instructions: '',
22534
- };
22535
- }
22536
- const firstLine = lines[0] || '';
22537
- const senderMatch = firstLine.match(EMAIL_TOKEN_PATTERN);
22538
- const senderEmailRaw = (senderMatch === null || senderMatch === void 0 ? void 0 : senderMatch[0]) || null;
22539
- const senderEmail = senderEmailRaw && isValidEmail(senderEmailRaw) ? senderEmailRaw : null;
22540
- let firstLineWithoutSender = firstLine;
22541
- if (senderEmailRaw) {
22542
- const matchIndex = firstLine.indexOf(senderEmailRaw);
22543
- const prefix = firstLine.slice(0, matchIndex).trim();
22544
- const suffix = firstLine.slice(matchIndex + senderEmailRaw.length).trim();
22545
- firstLineWithoutSender = [prefix, suffix].filter(Boolean).join(' ').trim();
22546
- }
22547
- const instructionLines = [firstLineWithoutSender, ...lines.slice(1)].filter(Boolean);
22548
- const instructions = instructionLines.join('\n').trim();
22549
- return {
22550
- senderEmail,
22551
- senderEmailRaw,
22552
- instructions,
22553
- };
22554
- }
22555
-
22556
- /**
22557
- * Client-side safe wrapper for sending emails.
22558
- *
22559
- * This function proxies requests to the Agents Server API endpoint for email queuing,
22560
- * making it safe to use in browser environments.
22561
- *
22562
- * @param args Email payload forwarded to the server-side `send_email` tool
22563
- * @param agentsServerUrl The base URL of the agents server (defaults to current origin)
22564
- * @returns Result string from the server-side send_email tool
22565
- *
22566
- * @private internal utility for USE EMAIL commitment
22567
- */
22568
- async function sendEmailViaBrowser(args, agentsServerUrl) {
22569
- try {
22570
- const baseUrl = agentsServerUrl || (typeof window !== 'undefined' ? window.location.origin : '');
22571
- if (!baseUrl) {
22572
- throw new Error('Agents server URL is required in non-browser environments');
22573
- }
22574
- const apiUrl = new URL('/api/send-email', baseUrl);
22575
- const response = await fetch(apiUrl.toString(), {
22576
- method: 'POST',
22577
- headers: {
22578
- 'Content-Type': 'application/json',
22579
- },
22580
- body: JSON.stringify(args),
22581
- });
22582
- if (!response.ok) {
22583
- const errorData = await response.json().catch(() => ({ error: 'Unknown error' }));
22584
- throw new Error(`Failed to send email: ${errorData.error || response.statusText}`);
22585
- }
22586
- const data = await response.json();
22587
- if (!data.success) {
22588
- throw new Error(`Email sending failed: ${data.error || 'Unknown error'}`);
22589
- }
22590
- return typeof data.result === 'string' ? data.result : JSON.stringify(data.result);
22591
- }
22592
- catch (error) {
22593
- const errorMessage = error instanceof Error ? error.message : String(error);
22594
- throw new Error(`Error sending email via browser: ${errorMessage}`);
22595
- }
22596
- }
22597
-
22598
- /**
22599
- * Tool name used by USE EMAIL.
22600
- *
22601
- * @private internal USE EMAIL constant
22602
- */
22603
- const SEND_EMAIL_TOOL_NAME = 'send_email';
22604
- /**
22605
- * USE EMAIL commitment definition.
22606
- *
22607
- * The `USE EMAIL` commitment enables outbound email sending through the `send_email` tool.
22608
- *
22609
- * @private [🪔] Maybe export the commitments through some package
22610
- */
22611
- class UseEmailCommitmentDefinition extends BaseCommitmentDefinition {
22612
- constructor() {
22613
- super('USE EMAIL', ['EMAIL', 'MAIL']);
22614
- }
22615
- get requiresContent() {
22616
- return false;
22617
- }
22618
- /**
22619
- * Short one-line description of USE EMAIL.
22620
- */
22621
- get description() {
22622
- return 'Enable outbound email sending through a wallet-backed SMTP configuration.';
22623
- }
22624
- /**
22625
- * Icon for this commitment.
22626
- */
22627
- get icon() {
22628
- return '📧';
22629
- }
22630
- /**
22631
- * Markdown documentation for USE EMAIL commitment.
22632
- */
22633
- get documentation() {
22634
- return spaceTrim$1(`
22635
- # USE EMAIL
22636
-
22637
- Enables the agent to send outbound emails through SMTP.
22638
-
22639
- ## Key aspects
22640
-
22641
- - The agent sends email via the \`send_email\` tool.
22642
- - SMTP credentials are expected from wallet records (\`ACCESS_TOKEN\`, service \`smtp\`, key \`use-email-smtp-credentials\`).
22643
- - Commitment content can optionally begin with a default sender email address:
22644
- - \`USE EMAIL agent@example.com\`
22645
- - Remaining commitment content is treated as optional email-writing instructions.
22646
-
22647
- ## Examples
22648
-
22649
- \`\`\`book
22650
- Writing Agent
22651
- USE EMAIL agent@example.com
22652
- RULE Write emails to customers according to the instructions from user.
22653
- \`\`\`
22654
-
22655
- \`\`\`book
22656
- Formal Email Assistant
22657
- USE EMAIL agent@example.com Keep emails concise and formal.
22658
- \`\`\`
22659
- `);
22660
- }
22661
- applyToAgentModelRequirements(requirements, content) {
22662
- var _a;
22663
- const parsedCommitment = parseUseEmailCommitmentContent(content);
22664
- const updatedTools = addUseEmailTools(requirements.tools || []);
22665
- // Collect all configured sender emails across multiple USE EMAIL commitments
22666
- const existingSenders = Array.isArray((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.useEmailSenders)
22667
- ? [...requirements._metadata.useEmailSenders]
22668
- : [];
22669
- if (parsedCommitment.senderEmail && !existingSenders.includes(parsedCommitment.senderEmail)) {
22670
- existingSenders.push(parsedCommitment.senderEmail);
22671
- }
22672
- const senderBullets = existingSenders.length > 0
22673
- ? existingSenders
22674
- .map((email, index) => index === 0
22675
- ? `- Default sender address: "${email}".`
22676
- : `- Additional sender address: "${email}".`)
22677
- .join('\n')
22678
- : '';
22679
- const extraInstructions = formatOptionalInstructionBlock('Email instructions', parsedCommitment.instructions);
22680
- const emailSectionContent = spaceTrim$1((block) => `
22681
- ## Emails
22682
-
22683
- - Use \`${SEND_EMAIL_TOOL_NAME}\` to send outbound emails.
22684
- ${block(senderBullets)}
22685
- ${block(extraInstructions)}
22686
- `);
22687
- return this.replaceOrCreateSection({
22688
- ...requirements,
22689
- tools: updatedTools,
22690
- _metadata: {
22691
- ...requirements._metadata,
22692
- useEmail: true,
22693
- ...(parsedCommitment.senderEmail ? { useEmailSender: parsedCommitment.senderEmail } : {}),
22694
- useEmailSenders: existingSenders,
22695
- },
22696
- }, 'Emails', emailSectionContent);
22697
- }
22698
- /**
22699
- * Gets human-readable titles for tool functions provided by this commitment.
22700
- */
22701
- getToolTitles() {
22702
- return {
22703
- [SEND_EMAIL_TOOL_NAME]: 'Send email',
22704
- };
22705
- }
22706
- /**
22707
- * Gets the browser-safe `send_email` implementation.
22708
- *
22709
- * Node.js runtime overrides this via `getAllCommitmentsToolFunctionsForNode`.
22710
- */
22711
- getToolFunctions() {
22712
- return {
22713
- async [SEND_EMAIL_TOOL_NAME](args) {
22714
- return sendEmailViaBrowser(args);
22715
- },
22716
- };
22717
- }
22718
- }
22719
- /**
22720
- * Adds USE EMAIL tool definition while keeping already registered tools untouched.
22721
- *
22722
- * @private utility of USE EMAIL commitment
22723
- */
22724
- function addUseEmailTools(existingTools) {
22725
- if (existingTools.some((tool) => tool.name === SEND_EMAIL_TOOL_NAME)) {
22726
- return [...existingTools];
22727
- }
22728
- return [
22729
- ...existingTools,
22730
- {
22731
- name: SEND_EMAIL_TOOL_NAME,
22732
- description: 'Send an outbound email.',
22733
- parameters: {
22734
- type: 'object',
22735
- properties: {
22736
- message: {
22737
- type: 'object',
22738
- description: 'Email payload. Use metadata.subject for the subject line.',
22739
- },
22740
- to: {
22741
- type: 'string',
22742
- description: 'Legacy alias for recipients (use comma-separated emails or JSON array encoded as string).',
22743
- },
22744
- cc: {
22745
- type: 'string',
22746
- description: 'Optional CC recipients (use comma-separated emails or JSON array encoded as string).',
22747
- },
22748
- subject: {
22749
- type: 'string',
22750
- description: 'Legacy alias for subject.',
22751
- },
22752
- body: {
22753
- type: 'string',
22754
- description: 'Legacy alias for markdown body content.',
22755
- },
22756
- },
22757
- required: [],
22758
- },
22759
- },
22760
- ];
22761
- }
22762
- // Note: [💞] Ignore a discrepancy between file name and entity name
22763
-
22764
21337
  /**
22765
21338
  * USE IMAGE GENERATOR commitment definition
22766
21339
  *
@@ -24970,1409 +23543,6 @@ function addConfiguredProjectIfMissing(configuredProjects, repositoryReference)
24970
23543
  }
24971
23544
  // Note: [💞] Ignore a discrepancy between file name and entity name
24972
23545
 
24973
- /**
24974
- * USE SEARCH ENGINE commitment definition
24975
- *
24976
- * The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
24977
- * to access and retrieve up-to-date information from the internet when necessary.
24978
- *
24979
- * The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
24980
- *
24981
- * Example usage in agent source:
24982
- *
24983
- * ```book
24984
- * USE SEARCH ENGINE
24985
- * USE SEARCH ENGINE Hledej informace o Přemyslovcích
24986
- * ```
24987
- *
24988
- * @private [🪔] Maybe export the commitments through some package
24989
- */
24990
- class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
24991
- constructor() {
24992
- super('USE SEARCH ENGINE', ['USE SEARCH']);
24993
- }
24994
- get requiresContent() {
24995
- return false;
24996
- }
24997
- /**
24998
- * Short one-line description of USE SEARCH ENGINE.
24999
- */
25000
- get description() {
25001
- return 'Enable the agent to use a search engine tool for accessing internet information.';
25002
- }
25003
- /**
25004
- * Icon for this commitment.
25005
- */
25006
- get icon() {
25007
- return '🔍';
25008
- }
25009
- /**
25010
- * Markdown documentation for USE SEARCH ENGINE commitment.
25011
- */
25012
- get documentation() {
25013
- return spaceTrim$1(`
25014
- # USE SEARCH ENGINE
25015
-
25016
- Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
25017
-
25018
- ## Key aspects
25019
-
25020
- - The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
25021
- - The actual search engine tool usage is handled by the agent runtime
25022
- - Allows the agent to search for current information from the web
25023
- - Useful for research tasks, finding facts, and accessing dynamic content
25024
-
25025
- ## Examples
25026
-
25027
- \`\`\`book
25028
- Research Assistant
25029
-
25030
- PERSONA You are a helpful research assistant specialized in finding current information
25031
- USE SEARCH ENGINE
25032
- RULE Always cite your sources when providing information from the web
25033
- \`\`\`
25034
-
25035
- \`\`\`book
25036
- Fact Checker
25037
-
25038
- PERSONA You are a fact checker
25039
- USE SEARCH ENGINE
25040
- ACTION Search for claims and verify them against reliable sources
25041
- \`\`\`
25042
- `);
25043
- }
25044
- applyToAgentModelRequirements(requirements, content) {
25045
- // Get existing tools array or create new one
25046
- const existingTools = requirements.tools || [];
25047
- // Add 'web_search' to tools if not already present
25048
- const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
25049
- ? existingTools
25050
- : [
25051
- ...existingTools,
25052
- {
25053
- name: 'web_search',
25054
- description: spaceTrim$1(`
25055
- Search the internet for information.
25056
- Use this tool when you need to find up-to-date information or facts that you don't know.
25057
- `),
25058
- parameters: {
25059
- type: 'object',
25060
- properties: {
25061
- query: {
25062
- type: 'string',
25063
- description: 'The search query',
25064
- },
25065
- location: {
25066
- type: 'string',
25067
- description: 'The location for the search (e.g., "Austin, Texas, United States" or "Prague, Czechia")',
25068
- },
25069
- gl: {
25070
- type: 'string',
25071
- description: 'The country code (e.g., "us" for United States, "cz" for Czechia)',
25072
- },
25073
- hl: {
25074
- type: 'string',
25075
- description: 'The language code (e.g., "en" for English, "cs" for Czech)',
25076
- },
25077
- num: {
25078
- type: 'integer',
25079
- description: 'Number of results to return',
25080
- },
25081
- engine: {
25082
- type: 'string',
25083
- description: 'The search engine to use (e.g., "google", "bing", "yahoo", "baidu")',
25084
- },
25085
- google_domain: {
25086
- type: 'string',
25087
- description: 'The Google domain to use (e.g., "google.com", "google.cz")',
25088
- },
25089
- },
25090
- required: ['query'],
25091
- },
25092
- },
25093
- ];
25094
- return appendAggregatedUseCommitmentPlaceholder({
25095
- ...requirements,
25096
- tools: updatedTools,
25097
- _metadata: {
25098
- ...requirements._metadata,
25099
- useSearchEngine: content || true,
25100
- },
25101
- }, this.type);
25102
- }
25103
- /**
25104
- * Gets human-readable titles for tool functions provided by this commitment.
25105
- */
25106
- getToolTitles() {
25107
- return {
25108
- web_search: 'Web search',
25109
- };
25110
- }
25111
- /**
25112
- * Gets the `web_search` tool function implementation.
25113
- */
25114
- getToolFunctions() {
25115
- return {
25116
- web_search: createSerpSearchToolFunction('web_search', 'Search'),
25117
- };
25118
- }
25119
- }
25120
- // Note: [💞] Ignore a discrepancy between file name and entity name
25121
-
25122
- /**
25123
- * Maximum allowed source length for create-agent payloads.
25124
- *
25125
- * @private shared create-agent contract
25126
- */
25127
- const CREATE_AGENT_INPUT_SOURCE_MAX_LENGTH = 120000;
25128
- /**
25129
- * Builds strict JSON schema for create-agent tool parameters.
25130
- *
25131
- * @private shared create-agent contract
25132
- */
25133
- function createCreateAgentInputToolParametersSchema() {
25134
- return {
25135
- type: 'object',
25136
- additionalProperties: false,
25137
- properties: {
25138
- source: {
25139
- type: 'string',
25140
- description: 'Full source of the new persisted agent (Promptbook/book markdown).',
25141
- },
25142
- folderId: {
25143
- type: 'number',
25144
- description: 'Optional folder identifier where the new agent should be placed.',
25145
- },
25146
- sortOrder: {
25147
- type: 'number',
25148
- description: 'Optional sort order inside the selected folder.',
25149
- },
25150
- visibility: {
25151
- type: 'string',
25152
- description: 'Optional visibility: PRIVATE, UNLISTED, or PUBLIC.',
25153
- },
25154
- },
25155
- required: ['source'],
25156
- };
25157
- }
25158
-
25159
- /**
25160
- * Browser-safe wrapper for spawning one persisted Agents Server agent.
25161
- *
25162
- * This function proxies requests to the Agents Server `/api/spawn-agent` endpoint.
25163
- *
25164
- * @param args Tool payload forwarded to server-side `spawn_agent` tool.
25165
- * @param agentsServerUrl Optional explicit agents server base URL.
25166
- * @returns JSON string with structured spawn result.
25167
- *
25168
- * @private internal utility for USE SPAWN commitment
25169
- */
25170
- async function spawnAgentViaBrowser(args, agentsServerUrl) {
25171
- try {
25172
- const baseUrl = agentsServerUrl || (typeof window !== 'undefined' ? window.location.origin : '');
25173
- if (!baseUrl) {
25174
- throw new Error('Agents server URL is required in non-browser environments');
25175
- }
25176
- const apiUrl = new URL('/api/spawn-agent', baseUrl);
25177
- const response = await fetch(apiUrl.toString(), {
25178
- method: 'POST',
25179
- headers: {
25180
- 'Content-Type': 'application/json',
25181
- },
25182
- body: JSON.stringify(args),
25183
- });
25184
- const payload = (await response.json().catch(() => ({})));
25185
- if (payload.result !== undefined) {
25186
- return typeof payload.result === 'string' ? payload.result : JSON.stringify(payload.result);
25187
- }
25188
- if (!response.ok || payload.success === false) {
25189
- throw new Error(`Failed to spawn agent: ${typeof payload.error === 'string' ? payload.error : response.statusText}`);
25190
- }
25191
- return JSON.stringify(payload);
25192
- }
25193
- catch (error) {
25194
- const errorMessage = error instanceof Error ? error.message : String(error);
25195
- throw new Error(`Error spawning agent via browser: ${errorMessage}`);
25196
- }
25197
- }
25198
-
25199
- /**
25200
- * Tool name used by USE SPAWN.
25201
- *
25202
- * @private internal USE SPAWN constant
25203
- */
25204
- const SPAWN_AGENT_TOOL_NAME = 'spawn_agent';
25205
- /**
25206
- * USE SPAWN commitment definition.
25207
- *
25208
- * The `USE SPAWN` commitment enables creating new persistent child agents through one tool call.
25209
- *
25210
- * @private [🪔] Maybe export the commitments through some package
25211
- */
25212
- class UseSpawnCommitmentDefinition extends BaseCommitmentDefinition {
25213
- constructor() {
25214
- super('USE SPAWN', ['SPAWN']);
25215
- }
25216
- get requiresContent() {
25217
- return false;
25218
- }
25219
- /**
25220
- * Short one-line description of USE SPAWN.
25221
- */
25222
- get description() {
25223
- return 'Enable the agent to create persistent child agents via Agents Server create-agent flow.';
25224
- }
25225
- /**
25226
- * Icon for this commitment.
25227
- */
25228
- get icon() {
25229
- return '🧬';
25230
- }
25231
- /**
25232
- * Markdown documentation for USE SPAWN commitment.
25233
- */
25234
- get documentation() {
25235
- return spaceTrim$1(`
25236
- # USE SPAWN
25237
-
25238
- Enables the agent to create a new persistent child agent using the \`spawn_agent\` tool.
25239
-
25240
- ## Key aspects
25241
-
25242
- - The spawned agent is persisted exactly like manually created agents.
25243
- - Tool input mirrors create-agent fields currently supported by Agents Server:
25244
- - \`source\` (required)
25245
- - \`folderId\` (optional)
25246
- - \`sortOrder\` (optional)
25247
- - \`visibility\` (optional)
25248
- - Unknown fields are rejected to avoid silent misconfiguration.
25249
- - \`source\` payload is size-limited.
25250
- - Agents Server applies permission and abuse protections (auth checks, limits).
25251
- - Optional text after \`USE SPAWN\` is treated as spawn-policy instructions.
25252
-
25253
- ## Examples
25254
-
25255
- \`\`\`book
25256
- Team Builder
25257
-
25258
- PERSONA You can create specialized assistants for the user.
25259
- USE SPAWN Spawn only when the user explicitly asks for a new persistent agent.
25260
- \`\`\`
25261
- `);
25262
- }
25263
- applyToAgentModelRequirements(requirements, content) {
25264
- const extraInstructions = formatOptionalInstructionBlock('Spawn instructions', content);
25265
- const existingTools = requirements.tools || [];
25266
- const tools = existingTools.some((tool) => tool.name === SPAWN_AGENT_TOOL_NAME)
25267
- ? existingTools
25268
- : [
25269
- ...existingTools,
25270
- {
25271
- name: SPAWN_AGENT_TOOL_NAME,
25272
- description: spaceTrim$1(`
25273
- Creates one new persistent child agent in Agents Server.
25274
- Use this when the user asks to create a new dedicated agent profile.
25275
- The tool returns JSON with \`status\`, \`agentId\`, and created \`agent\` or \`error\`.
25276
- `),
25277
- parameters: createCreateAgentInputToolParametersSchema(),
25278
- },
25279
- ];
25280
- return this.appendToSystemMessage({
25281
- ...requirements,
25282
- tools,
25283
- _metadata: {
25284
- ...requirements._metadata,
25285
- useSpawn: content || true,
25286
- },
25287
- }, spaceTrim$1((block) => `
25288
- ## Spawning agents
25289
-
25290
- - Use \`${SPAWN_AGENT_TOOL_NAME}\` only when user asks to create a persistent new agent.
25291
- - Pass full agent source in \`source\`.
25292
- - Keep \`source\` concise; the maximum accepted length is ${CREATE_AGENT_INPUT_SOURCE_MAX_LENGTH} characters.
25293
- - Do not add unknown fields in tool arguments.
25294
- ${block(extraInstructions)}
25295
- `));
25296
- }
25297
- /**
25298
- * Gets human-readable titles for tool functions provided by this commitment.
25299
- */
25300
- getToolTitles() {
25301
- return {
25302
- [SPAWN_AGENT_TOOL_NAME]: 'Spawn agent',
25303
- };
25304
- }
25305
- /**
25306
- * Gets browser-safe `spawn_agent` implementation.
25307
- *
25308
- * Node.js runtime overrides this through `getAllCommitmentsToolFunctionsForNode`.
25309
- */
25310
- getToolFunctions() {
25311
- return {
25312
- async [SPAWN_AGENT_TOOL_NAME](args) {
25313
- return spawnAgentViaBrowser(args);
25314
- },
25315
- };
25316
- }
25317
- }
25318
- // Note: [💞] Ignore a discrepancy between file name and entity name
25319
-
25320
- /**
25321
- * Creates system-message instructions for `USE TIMEOUT`.
25322
- *
25323
- * @private internal utility of USE TIMEOUT
25324
- */
25325
- function createTimeoutSystemMessage(extraInstructions) {
25326
- return spaceTrim$1((block) => `
25327
- ## Timeout scheduling
25328
-
25329
- - Use \`set_timeout\` to wake this same chat thread in the future.
25330
- - Use \`list_timeouts\` to review timeout ids/details across all chats for the same user+agent scope.
25331
- - \`cancel_timeout\` accepts either one timeout id or \`allActive: true\` to cancel all active timeouts in this same user+agent scope.
25332
- - Use \`update_timeout\` to pause/resume, edit next run, edit recurrence, or update timeout payload details.
25333
- - When one timeout elapses, you will receive a new user-like message that explicitly says it is a timeout wake-up and includes the \`timeoutId\`.
25334
- - Do not claim a timer was set or cancelled unless the tool confirms it.
25335
- ${block(extraInstructions)}
25336
- `);
25337
- }
25338
-
25339
- /**
25340
- * Marker property stored inside serialized tool-execution envelopes.
25341
- *
25342
- * @private internal tool-execution transport
25343
- */
25344
- const TOOL_EXECUTION_ENVELOPE_MARKER = '__promptbookToolExecutionEnvelope';
25345
- /**
25346
- * Creates one serialized tool-execution envelope.
25347
- *
25348
- * @private internal tool-execution transport
25349
- */
25350
- function createToolExecutionEnvelope(options) {
25351
- const envelope = {
25352
- [TOOL_EXECUTION_ENVELOPE_MARKER]: true,
25353
- assistantMessage: options.assistantMessage,
25354
- toolResult: options.toolResult,
25355
- };
25356
- return JSON.stringify(envelope);
25357
- }
25358
- /**
25359
- * Parses one serialized tool-execution envelope when present.
25360
- *
25361
- * @private internal tool-execution transport
25362
- */
25363
- function parseToolExecutionEnvelope(rawValue) {
25364
- if (typeof rawValue !== 'string') {
25365
- return null;
25366
- }
25367
- try {
25368
- const parsedValue = JSON.parse(rawValue);
25369
- if (!parsedValue ||
25370
- typeof parsedValue !== 'object' ||
25371
- parsedValue[TOOL_EXECUTION_ENVELOPE_MARKER] !== true ||
25372
- typeof parsedValue.assistantMessage !== 'string') {
25373
- return null;
25374
- }
25375
- return {
25376
- assistantMessage: parsedValue.assistantMessage,
25377
- toolResult: parsedValue.toolResult,
25378
- };
25379
- }
25380
- catch (_a) {
25381
- return null;
25382
- }
25383
- }
25384
- // Note: [💞] Ignore a discrepancy between file name and entity name
25385
-
25386
- /**
25387
- * Builds a disabled timeout-tool payload.
25388
- *
25389
- * @private internal utility of USE TIMEOUT
25390
- */
25391
- function createDisabledTimeoutResult(action, message) {
25392
- return {
25393
- action,
25394
- status: 'disabled',
25395
- message,
25396
- };
25397
- }
25398
- /**
25399
- * Resolves the runtime adapter for timeout tools or returns disabled payload when unavailable.
25400
- *
25401
- * @private internal utility of USE TIMEOUT
25402
- */
25403
- function getTimeoutToolRuntimeAdapterOrDisabledResult(action, runtimeContext) {
25404
- if (!runtimeContext.enabled || !runtimeContext.chatId) {
25405
- return {
25406
- adapter: null,
25407
- disabledResult: createDisabledTimeoutResult(action, 'Timeouts are unavailable because this conversation is not running inside a chat thread.'),
25408
- };
25409
- }
25410
- {
25411
- return {
25412
- adapter: null,
25413
- disabledResult: createDisabledTimeoutResult(action, 'Timeout runtime is not available in this environment.'),
25414
- };
25415
- }
25416
- }
25417
-
25418
- /**
25419
- * Default number of rows returned by `list_timeouts`.
25420
- *
25421
- * @private internal USE TIMEOUT constant
25422
- */
25423
- const DEFAULT_LIST_TIMEOUTS_LIMIT = 20;
25424
- /**
25425
- * Hard cap for `list_timeouts` page size.
25426
- *
25427
- * @private internal USE TIMEOUT constant
25428
- */
25429
- const MAX_LIST_TIMEOUTS_LIMIT = 100;
25430
- /**
25431
- * Creates one formatted timeout-argument validation error.
25432
- *
25433
- * @private internal utility of USE TIMEOUT
25434
- */
25435
- function createTimeoutToolArgsError(message) {
25436
- return new PipelineExecutionError(spaceTrim$1(`
25437
- ${message}
25438
- `));
25439
- }
25440
- /**
25441
- * Normalizes one optional timeout id string.
25442
- *
25443
- * @private internal utility of USE TIMEOUT
25444
- */
25445
- function normalizeOptionalTimeoutId(value) {
25446
- return typeof value === 'string' ? value.trim() : '';
25447
- }
25448
- /**
25449
- * Parses timeout target selection for tools that accept either `timeoutId` or `allActive: true`.
25450
- *
25451
- * @private internal utility of USE TIMEOUT
25452
- */
25453
- function parseTimeoutTargetSelection(args, options) {
25454
- const timeoutId = normalizeOptionalTimeoutId(args.timeoutId);
25455
- const allActive = args.allActive === true;
25456
- if (timeoutId && allActive) {
25457
- throw createTimeoutToolArgsError(options.bothMessage);
25458
- }
25459
- if (allActive) {
25460
- return { allActive: true };
25461
- }
25462
- if (!timeoutId) {
25463
- throw createTimeoutToolArgsError(options.missingMessage);
25464
- }
25465
- return {
25466
- timeoutId,
25467
- allActive: false,
25468
- };
25469
- }
25470
- /**
25471
- * Parses one explicit `dueAt` update value.
25472
- *
25473
- * @private internal utility of USE TIMEOUT
25474
- */
25475
- function parseOptionalTimeoutDueAt(value) {
25476
- if (typeof value !== 'string' || value.trim().length === 0) {
25477
- return undefined;
25478
- }
25479
- const normalizedDueAt = value.trim();
25480
- const dueAtTimestamp = Date.parse(normalizedDueAt);
25481
- if (!Number.isFinite(dueAtTimestamp)) {
25482
- throw createTimeoutToolArgsError('Timeout `dueAt` must be one valid ISO timestamp.');
25483
- }
25484
- return new Date(dueAtTimestamp).toISOString();
25485
- }
25486
- /**
25487
- * Parses one explicit `extendByMs` update value.
25488
- *
25489
- * @private internal utility of USE TIMEOUT
25490
- */
25491
- function parseOptionalTimeoutExtendByMs(value) {
25492
- if (typeof value !== 'number') {
25493
- return undefined;
25494
- }
25495
- if (!Number.isFinite(value) || value <= 0) {
25496
- throw createTimeoutToolArgsError('Timeout `extendByMs` must be a positive number of milliseconds.');
25497
- }
25498
- return Math.floor(value);
25499
- }
25500
- /**
25501
- * Parses one explicit `recurrenceIntervalMs` update value.
25502
- *
25503
- * @private internal utility of USE TIMEOUT
25504
- */
25505
- function parseOptionalTimeoutRecurrenceInterval(value) {
25506
- if (value === null) {
25507
- return null;
25508
- }
25509
- if (typeof value !== 'number') {
25510
- return undefined;
25511
- }
25512
- if (!Number.isFinite(value) || value <= 0) {
25513
- throw createTimeoutToolArgsError('Timeout `recurrenceIntervalMs` must be a positive number of milliseconds or `null`.');
25514
- }
25515
- return Math.floor(value);
25516
- }
25517
- /**
25518
- * Parses one explicit `message` update value.
25519
- *
25520
- * @private internal utility of USE TIMEOUT
25521
- */
25522
- function parseOptionalTimeoutMessage(value) {
25523
- if (value === null) {
25524
- return null;
25525
- }
25526
- if (typeof value !== 'string') {
25527
- return undefined;
25528
- }
25529
- const normalizedMessage = value.trim();
25530
- return normalizedMessage.length > 0 ? normalizedMessage : null;
25531
- }
25532
- /**
25533
- * Parses one explicit `parameters` update value.
25534
- *
25535
- * @private internal utility of USE TIMEOUT
25536
- */
25537
- function parseOptionalTimeoutParameters(value) {
25538
- if (value === undefined) {
25539
- return undefined;
25540
- }
25541
- if (!value || typeof value !== 'object' || Array.isArray(value)) {
25542
- throw createTimeoutToolArgsError('Timeout `parameters` must be one JSON object.');
25543
- }
25544
- return value;
25545
- }
25546
- /**
25547
- * Parses one explicit `paused` update value.
25548
- *
25549
- * @private internal utility of USE TIMEOUT
25550
- */
25551
- function parseOptionalTimeoutPaused(value) {
25552
- return typeof value === 'boolean' ? value : undefined;
25553
- }
25554
- /**
25555
- * Parses patch fields for `update_timeout`.
25556
- *
25557
- * @private internal utility of USE TIMEOUT
25558
- */
25559
- function parseTimeoutUpdatePatch(args) {
25560
- const patch = {};
25561
- const dueAt = parseOptionalTimeoutDueAt(args.dueAt);
25562
- const extendByMs = parseOptionalTimeoutExtendByMs(args.extendByMs);
25563
- const recurrenceIntervalMs = parseOptionalTimeoutRecurrenceInterval(args.recurrenceIntervalMs);
25564
- const message = parseOptionalTimeoutMessage(args.message);
25565
- const parameters = parseOptionalTimeoutParameters(args.parameters);
25566
- const paused = parseOptionalTimeoutPaused(args.paused);
25567
- if (dueAt !== undefined) {
25568
- patch.dueAt = dueAt;
25569
- }
25570
- if (extendByMs !== undefined) {
25571
- patch.extendByMs = extendByMs;
25572
- }
25573
- if (patch.dueAt !== undefined && patch.extendByMs !== undefined) {
25574
- throw createTimeoutToolArgsError('Timeout update cannot include both `dueAt` and `extendByMs`.');
25575
- }
25576
- if (recurrenceIntervalMs !== undefined) {
25577
- patch.recurrenceIntervalMs = recurrenceIntervalMs;
25578
- }
25579
- if (message !== undefined) {
25580
- patch.message = message;
25581
- }
25582
- if (parameters !== undefined) {
25583
- patch.parameters = parameters;
25584
- }
25585
- if (paused !== undefined) {
25586
- patch.paused = paused;
25587
- }
25588
- return patch;
25589
- }
25590
- /**
25591
- * Determines whether the patch contains fields that are only supported for single-timeout updates.
25592
- *
25593
- * @private internal utility of USE TIMEOUT
25594
- */
25595
- function hasSingleTimeoutOnlyPatchFields(patch) {
25596
- return (patch.dueAt !== undefined ||
25597
- patch.extendByMs !== undefined ||
25598
- patch.recurrenceIntervalMs !== undefined ||
25599
- patch.message !== undefined ||
25600
- patch.parameters !== undefined);
25601
- }
25602
- /**
25603
- * Parses bulk timeout update arguments.
25604
- *
25605
- * @private internal utility of USE TIMEOUT
25606
- */
25607
- function parseBulkTimeoutUpdateArgs(patch) {
25608
- if (patch.paused === undefined) {
25609
- throw createTimeoutToolArgsError('Bulk timeout update with `allActive: true` requires `paused` to be explicitly set.');
25610
- }
25611
- if (hasSingleTimeoutOnlyPatchFields(patch)) {
25612
- throw createTimeoutToolArgsError('Bulk timeout update only supports the `paused` field.');
25613
- }
25614
- return {
25615
- allActive: true,
25616
- paused: patch.paused,
25617
- };
25618
- }
25619
- /**
25620
- * Parses single-timeout update arguments.
25621
- *
25622
- * @private internal utility of USE TIMEOUT
25623
- */
25624
- function parseSingleTimeoutUpdateArgs(timeoutId, patch) {
25625
- if (!timeoutId) {
25626
- throw createTimeoutToolArgsError('Timeout `timeoutId` is required for single-timeout updates.');
25627
- }
25628
- if (Object.keys(patch).length === 0) {
25629
- throw createTimeoutToolArgsError('Timeout update must include at least one editable field.');
25630
- }
25631
- return {
25632
- timeoutId,
25633
- patch,
25634
- };
25635
- }
25636
- /**
25637
- * Parses and validates `USE TIMEOUT` tool arguments.
25638
- *
25639
- * @private internal utility of USE TIMEOUT
25640
- */
25641
- const parseTimeoutToolArgs = {
25642
- /**
25643
- * Parses `set_timeout` input.
25644
- */
25645
- set(args) {
25646
- const parsedMilliseconds = Number(args.milliseconds);
25647
- if (!Number.isFinite(parsedMilliseconds) || parsedMilliseconds <= 0) {
25648
- throw new PipelineExecutionError(spaceTrim$1(`
25649
- Timeout \`milliseconds\` must be a positive number.
25650
- `));
25651
- }
25652
- const message = typeof args.message === 'string' ? args.message.trim() : '';
25653
- return {
25654
- milliseconds: Math.floor(parsedMilliseconds),
25655
- ...(message ? { message } : {}),
25656
- };
25657
- },
25658
- /**
25659
- * Parses `cancel_timeout` input.
25660
- */
25661
- cancel(args) {
25662
- const target = parseTimeoutTargetSelection(args, {
25663
- bothMessage: 'Timeout cancellation must target either one `timeoutId` or `allActive: true`, not both.',
25664
- missingMessage: 'Timeout `timeoutId` is required unless you pass `allActive: true`.',
25665
- });
25666
- if (target.allActive) {
25667
- return { allActive: true };
25668
- }
25669
- return { timeoutId: target.timeoutId };
25670
- },
25671
- /**
25672
- * Parses `list_timeouts` input.
25673
- */
25674
- list(args) {
25675
- if (args.includeFinished !== undefined && typeof args.includeFinished !== 'boolean') {
25676
- throw new PipelineExecutionError(spaceTrim$1(`
25677
- Timeout \`includeFinished\` must be a boolean when provided.
25678
- `));
25679
- }
25680
- const parsedLimit = args.limit === undefined ? DEFAULT_LIST_TIMEOUTS_LIMIT : Math.floor(Number(args.limit));
25681
- if (!Number.isFinite(parsedLimit) || parsedLimit <= 0) {
25682
- throw new PipelineExecutionError(spaceTrim$1(`
25683
- Timeout \`limit\` must be a positive number.
25684
- `));
25685
- }
25686
- if (parsedLimit > MAX_LIST_TIMEOUTS_LIMIT) {
25687
- throw new PipelineExecutionError(spaceTrim$1(`
25688
- Timeout \`limit\` must be at most \`${MAX_LIST_TIMEOUTS_LIMIT}\`.
25689
- `));
25690
- }
25691
- return {
25692
- includeFinished: args.includeFinished === true,
25693
- limit: parsedLimit,
25694
- };
25695
- },
25696
- /**
25697
- * Parses `update_timeout` input.
25698
- */
25699
- update(args) {
25700
- const target = parseTimeoutTargetSelection(args, {
25701
- bothMessage: 'Timeout update must target either one `timeoutId` or `allActive: true`, not both.',
25702
- missingMessage: 'Timeout update requires one `timeoutId` or `allActive: true`.',
25703
- });
25704
- const patch = parseTimeoutUpdatePatch(args);
25705
- return target.allActive
25706
- ? parseBulkTimeoutUpdateArgs(patch)
25707
- : parseSingleTimeoutUpdateArgs(target.timeoutId, patch);
25708
- },
25709
- };
25710
-
25711
- /**
25712
- * Resolves timeout runtime context from hidden tool arguments.
25713
- *
25714
- * @private internal utility of USE TIMEOUT
25715
- */
25716
- function resolveTimeoutRuntimeContext(args) {
25717
- const runtimeContext = readToolRuntimeContextFromToolArgs(args);
25718
- const chatContext = runtimeContext === null || runtimeContext === void 0 ? void 0 : runtimeContext.chat;
25719
- return {
25720
- enabled: Boolean(chatContext === null || chatContext === void 0 ? void 0 : chatContext.chatId),
25721
- chatId: chatContext === null || chatContext === void 0 ? void 0 : chatContext.chatId,
25722
- userId: chatContext === null || chatContext === void 0 ? void 0 : chatContext.userId,
25723
- agentId: chatContext === null || chatContext === void 0 ? void 0 : chatContext.agentId,
25724
- agentName: chatContext === null || chatContext === void 0 ? void 0 : chatContext.agentName,
25725
- promptParameters: normalizePromptParameters(chatContext === null || chatContext === void 0 ? void 0 : chatContext.parameters),
25726
- };
25727
- }
25728
- /**
25729
- * Normalizes stored prompt parameters carried by timeout runtime context.
25730
- *
25731
- * @private internal utility of USE TIMEOUT
25732
- */
25733
- function normalizePromptParameters(rawParameters) {
25734
- if (!rawParameters || typeof rawParameters !== 'object' || Array.isArray(rawParameters)) {
25735
- return {};
25736
- }
25737
- const normalizedEntries = Object.entries(rawParameters).filter(([, value]) => typeof value === 'string');
25738
- return Object.fromEntries(normalizedEntries);
25739
- }
25740
-
25741
- /**
25742
- * Tool names provided by the `USE TIMEOUT` commitment.
25743
- *
25744
- * @private internal USE TIMEOUT constant
25745
- */
25746
- const TimeoutToolNames = {
25747
- set: 'set_timeout',
25748
- cancel: 'cancel_timeout',
25749
- list: 'list_timeouts',
25750
- update: 'update_timeout',
25751
- };
25752
-
25753
- /**
25754
- * Maximum number of timeout rows rendered into the assistant-visible `list_timeouts` message.
25755
- *
25756
- * @private internal USE TIMEOUT constant
25757
- */
25758
- const MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS = 20;
25759
- /**
25760
- * Maximum number of timeout ids rendered in bulk-action summaries.
25761
- *
25762
- * @private internal USE TIMEOUT constant
25763
- */
25764
- const MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS = 10;
25765
- /**
25766
- * Gets `USE TIMEOUT` tool function implementations.
25767
- *
25768
- * @private internal utility of USE TIMEOUT
25769
- */
25770
- function createTimeoutToolFunctions() {
25771
- return {
25772
- async [TimeoutToolNames.set](args) {
25773
- const runtimeContext = resolveTimeoutRuntimeContext(args);
25774
- const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('set', runtimeContext);
25775
- if (!adapter || disabledResult) {
25776
- return JSON.stringify(disabledResult);
25777
- }
25778
- try {
25779
- const parsedArgs = parseTimeoutToolArgs.set(args);
25780
- const scheduledTimeout = await adapter.scheduleTimeout(parsedArgs, runtimeContext);
25781
- const result = {
25782
- action: 'set',
25783
- status: 'set',
25784
- timeoutId: scheduledTimeout.timeoutId,
25785
- dueAt: scheduledTimeout.dueAt,
25786
- };
25787
- return createToolExecutionEnvelope({
25788
- assistantMessage: 'The timer was set.',
25789
- toolResult: result,
25790
- });
25791
- }
25792
- catch (error) {
25793
- const result = {
25794
- action: 'set',
25795
- status: 'error',
25796
- message: error instanceof Error ? error.message : String(error),
25797
- };
25798
- return JSON.stringify(result);
25799
- }
25800
- },
25801
- async [TimeoutToolNames.cancel](args) {
25802
- const runtimeContext = resolveTimeoutRuntimeContext(args);
25803
- const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('cancel', runtimeContext);
25804
- if (!adapter || disabledResult) {
25805
- return JSON.stringify(disabledResult);
25806
- }
25807
- try {
25808
- const parsedArgs = parseTimeoutToolArgs.cancel(args);
25809
- const cancelledTimeout = await adapter.cancelTimeout(parsedArgs, runtimeContext);
25810
- if (cancelledTimeout.status === 'cancelled_all') {
25811
- const result = {
25812
- action: 'cancel',
25813
- status: 'cancelled_all',
25814
- cancelledCount: cancelledTimeout.cancelledCount || 0,
25815
- cancelledTimeoutIds: cancelledTimeout.cancelledTimeoutIds || [],
25816
- hasMore: cancelledTimeout.hasMore,
25817
- };
25818
- return createToolExecutionEnvelope({
25819
- assistantMessage: createBulkCancelAssistantMessage({
25820
- cancelledCount: result.cancelledCount || 0,
25821
- cancelledTimeoutIds: result.cancelledTimeoutIds || [],
25822
- hasMore: result.hasMore,
25823
- }),
25824
- toolResult: result,
25825
- });
25826
- }
25827
- const result = {
25828
- action: 'cancel',
25829
- status: cancelledTimeout.status,
25830
- timeoutId: cancelledTimeout.timeoutId,
25831
- dueAt: cancelledTimeout.dueAt,
25832
- };
25833
- return createToolExecutionEnvelope({
25834
- assistantMessage: cancelledTimeout.status === 'cancelled'
25835
- ? 'The timer was cancelled.'
25836
- : 'The timer was already inactive.',
25837
- toolResult: result,
25838
- });
25839
- }
25840
- catch (error) {
25841
- const result = {
25842
- action: 'cancel',
25843
- status: 'error',
25844
- message: error instanceof Error ? error.message : String(error),
25845
- };
25846
- return JSON.stringify(result);
25847
- }
25848
- },
25849
- async [TimeoutToolNames.list](args) {
25850
- const runtimeContext = resolveTimeoutRuntimeContext(args);
25851
- const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('list', runtimeContext);
25852
- if (!adapter || disabledResult) {
25853
- return JSON.stringify(disabledResult);
25854
- }
25855
- try {
25856
- const parsedArgs = parseTimeoutToolArgs.list(args);
25857
- const listedTimeouts = await adapter.listTimeouts(parsedArgs, runtimeContext);
25858
- const result = {
25859
- action: 'list',
25860
- status: 'listed',
25861
- items: listedTimeouts.items,
25862
- total: listedTimeouts.total,
25863
- };
25864
- return createToolExecutionEnvelope({
25865
- assistantMessage: createListedTimeoutsAssistantMessage({
25866
- total: listedTimeouts.total,
25867
- items: listedTimeouts.items,
25868
- }),
25869
- toolResult: result,
25870
- });
25871
- }
25872
- catch (error) {
25873
- const result = {
25874
- action: 'list',
25875
- status: 'error',
25876
- message: error instanceof Error ? error.message : String(error),
25877
- };
25878
- return JSON.stringify(result);
25879
- }
25880
- },
25881
- async [TimeoutToolNames.update](args) {
25882
- const runtimeContext = resolveTimeoutRuntimeContext(args);
25883
- const { adapter, disabledResult } = getTimeoutToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
25884
- if (!adapter || disabledResult) {
25885
- return JSON.stringify(disabledResult);
25886
- }
25887
- try {
25888
- const parsedArgs = parseTimeoutToolArgs.update(args);
25889
- const updatedTimeout = await adapter.updateTimeout(parsedArgs, runtimeContext);
25890
- if (updatedTimeout.status === 'updated_all') {
25891
- const result = {
25892
- action: 'update',
25893
- status: 'updated_all',
25894
- updatedCount: updatedTimeout.updatedCount,
25895
- matchedCount: updatedTimeout.matchedCount,
25896
- updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
25897
- hasMore: updatedTimeout.hasMore,
25898
- };
25899
- return createToolExecutionEnvelope({
25900
- assistantMessage: createBulkUpdateAssistantMessage({
25901
- paused: 'allActive' in parsedArgs && parsedArgs.allActive ? parsedArgs.paused : false,
25902
- updatedCount: updatedTimeout.updatedCount,
25903
- matchedCount: updatedTimeout.matchedCount,
25904
- updatedTimeoutIds: updatedTimeout.updatedTimeoutIds,
25905
- hasMore: updatedTimeout.hasMore,
25906
- }),
25907
- toolResult: result,
25908
- });
25909
- }
25910
- if (updatedTimeout.status === 'not_found') {
25911
- const result = {
25912
- action: 'update',
25913
- status: 'not_found',
25914
- timeoutId: updatedTimeout.timeoutId,
25915
- };
25916
- return createToolExecutionEnvelope({
25917
- assistantMessage: 'The timeout was not found.',
25918
- toolResult: result,
25919
- });
25920
- }
25921
- if (updatedTimeout.status === 'conflict') {
25922
- const conflictMessage = updatedTimeout.reason === 'running'
25923
- ? 'Running timeout cannot be edited.'
25924
- : 'Finished timeout cannot be edited.';
25925
- const result = {
25926
- action: 'update',
25927
- status: 'conflict',
25928
- timeoutId: updatedTimeout.timeoutId,
25929
- message: conflictMessage,
25930
- };
25931
- return createToolExecutionEnvelope({
25932
- assistantMessage: conflictMessage,
25933
- toolResult: result,
25934
- });
25935
- }
25936
- const result = {
25937
- action: 'update',
25938
- status: 'updated',
25939
- timeoutId: updatedTimeout.timeout.timeoutId,
25940
- dueAt: updatedTimeout.timeout.dueAt,
25941
- paused: updatedTimeout.timeout.paused,
25942
- recurrenceIntervalMs: updatedTimeout.timeout.recurrenceIntervalMs,
25943
- };
25944
- return createToolExecutionEnvelope({
25945
- assistantMessage: `Updated timeout ${JSON.stringify(updatedTimeout.timeout.timeoutId)}.`,
25946
- toolResult: result,
25947
- });
25948
- }
25949
- catch (error) {
25950
- const result = {
25951
- action: 'update',
25952
- status: 'error',
25953
- message: error instanceof Error ? error.message : String(error),
25954
- };
25955
- return JSON.stringify(result);
25956
- }
25957
- },
25958
- };
25959
- }
25960
- /**
25961
- * Creates assistant-visible summary for one `list_timeouts` response.
25962
- *
25963
- * @private internal utility of USE TIMEOUT
25964
- */
25965
- function createListedTimeoutsAssistantMessage(options) {
25966
- if (options.total <= 0 || options.items.length === 0) {
25967
- return 'Found 0 timeouts.';
25968
- }
25969
- const visibleItems = options.items.slice(0, MAX_ASSISTANT_VISIBLE_TIMEOUT_ROWS);
25970
- const summaryRows = visibleItems.map((item, index) => `${index + 1}. ${formatTimeoutListRow(item)}`);
25971
- const hiddenCount = Math.max(0, options.total - visibleItems.length);
25972
- if (hiddenCount > 0) {
25973
- summaryRows.push(`...and ${hiddenCount} more.`);
25974
- }
25975
- return spaceTrim$1((block) => `
25976
- Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:
25977
- ${block(summaryRows.join('\n'))}
25978
- `);
25979
- }
25980
- /**
25981
- * Formats one timeout row for assistant-visible timeout listings.
25982
- *
25983
- * @private internal utility of USE TIMEOUT
25984
- */
25985
- function formatTimeoutListRow(item) {
25986
- const normalizedMessage = typeof item.message === 'string' ? item.message.trim() : '';
25987
- const messageSuffix = normalizedMessage ? ` | message ${JSON.stringify(normalizedMessage)}` : '';
25988
- const recurrenceSuffix = typeof item.recurrenceIntervalMs === 'number' && item.recurrenceIntervalMs > 0
25989
- ? ` | recurrence ${item.recurrenceIntervalMs}ms`
25990
- : '';
25991
- const pausedSuffix = item.paused ? ' (paused)' : '';
25992
- return `${item.timeoutId} | ${item.status}${pausedSuffix} | chat ${item.chatId} | due ${item.dueAt}${recurrenceSuffix}${messageSuffix}`;
25993
- }
25994
- /**
25995
- * Creates assistant-visible summary for bulk timeout cancellation.
25996
- *
25997
- * @private internal utility of USE TIMEOUT
25998
- */
25999
- function createBulkCancelAssistantMessage(options) {
26000
- if (options.cancelledCount <= 0) {
26001
- return 'No active timeouts were found to cancel.';
26002
- }
26003
- const visibleTimeoutIds = options.cancelledTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
26004
- const hiddenIdsCount = Math.max(0, options.cancelledTimeoutIds.length - visibleTimeoutIds.length);
26005
- const hasMoreSuffix = options.hasMore ? ' Additional active timeouts may still exist.' : '';
26006
- const idsSuffix = visibleTimeoutIds.length > 0
26007
- ? ` Cancelled ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
26008
- : '';
26009
- return `Cancelled ${options.cancelledCount} active ${options.cancelledCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${hasMoreSuffix}`;
26010
- }
26011
- /**
26012
- * Creates assistant-visible summary for bulk timeout pause/resume updates.
26013
- *
26014
- * @private internal utility of USE TIMEOUT
26015
- */
26016
- function createBulkUpdateAssistantMessage(options) {
26017
- if (options.matchedCount <= 0) {
26018
- return options.paused
26019
- ? 'No active queued timeouts were found to pause.'
26020
- : 'No paused queued timeouts were found to resume.';
26021
- }
26022
- const verb = options.paused ? 'Paused' : 'Resumed';
26023
- const visibleTimeoutIds = options.updatedTimeoutIds.slice(0, MAX_ASSISTANT_VISIBLE_BULK_TIMEOUT_IDS);
26024
- const hiddenIdsCount = Math.max(0, options.updatedTimeoutIds.length - visibleTimeoutIds.length);
26025
- const skippedCount = Math.max(0, options.matchedCount - options.updatedCount);
26026
- const idsSuffix = visibleTimeoutIds.length > 0
26027
- ? ` Updated ids: ${visibleTimeoutIds.join(', ')}${hiddenIdsCount > 0 ? `, and ${hiddenIdsCount} more.` : '.'}`
26028
- : '';
26029
- const skippedSuffix = skippedCount > 0 ? ` Skipped ${skippedCount} due to concurrent changes.` : '';
26030
- const hasMoreSuffix = options.hasMore ? ' Additional matching timeouts may still exist.' : '';
26031
- return `${verb} ${options.updatedCount} ${options.updatedCount === 1 ? 'timeout' : 'timeouts'}.${idsSuffix}${skippedSuffix}${hasMoreSuffix}`;
26032
- }
26033
-
26034
- /**
26035
- * Adds `USE TIMEOUT` tool definitions while preserving already registered tools.
26036
- *
26037
- * @private internal utility of USE TIMEOUT
26038
- */
26039
- function createTimeoutTools(existingTools = []) {
26040
- const tools = [...existingTools];
26041
- if (!tools.some((tool) => tool.name === TimeoutToolNames.set)) {
26042
- tools.push({
26043
- name: TimeoutToolNames.set,
26044
- description: 'Schedule one thread-scoped wake-up in the current chat. The timer returns immediately and wakes this same conversation later.',
26045
- parameters: {
26046
- type: 'object',
26047
- properties: {
26048
- milliseconds: {
26049
- type: 'number',
26050
- description: 'Delay in milliseconds before the timeout wakes the same chat thread.',
26051
- },
26052
- message: {
26053
- type: 'string',
26054
- description: 'Optional note appended to the future timeout wake-up message.',
26055
- },
26056
- },
26057
- required: ['milliseconds'],
26058
- },
26059
- });
26060
- }
26061
- if (!tools.some((tool) => tool.name === TimeoutToolNames.cancel)) {
26062
- tools.push({
26063
- name: TimeoutToolNames.cancel,
26064
- description: 'Cancel one timeout by id or cancel all active timeouts across chats for the same user+agent scope.',
26065
- parameters: {
26066
- type: 'object',
26067
- properties: {
26068
- timeoutId: {
26069
- type: 'string',
26070
- description: 'Identifier returned earlier by `set_timeout` or `list_timeouts`.',
26071
- },
26072
- allActive: {
26073
- type: 'boolean',
26074
- description: 'When true, cancel all currently active timeouts across chats in this user+agent scope.',
26075
- },
26076
- },
26077
- },
26078
- });
26079
- }
26080
- if (!tools.some((tool) => tool.name === TimeoutToolNames.list)) {
26081
- tools.push({
26082
- name: TimeoutToolNames.list,
26083
- description: 'List timeout details across all chats for this same user+agent scope so they can be reviewed and managed.',
26084
- parameters: {
26085
- type: 'object',
26086
- properties: {
26087
- includeFinished: {
26088
- type: 'boolean',
26089
- description: 'When true, include completed, failed, and cancelled rows in addition to active timeouts.',
26090
- },
26091
- limit: {
26092
- type: 'number',
26093
- description: 'Maximum number of rows to return (default 20, max 100).',
26094
- },
26095
- },
26096
- },
26097
- });
26098
- }
26099
- if (!tools.some((tool) => tool.name === TimeoutToolNames.update)) {
26100
- tools.push({
26101
- name: TimeoutToolNames.update,
26102
- description: 'Update one timeout (pause/resume, next run, recurrence, payload) or pause/resume all active queued timeouts across chats.',
26103
- parameters: {
26104
- type: 'object',
26105
- properties: {
26106
- timeoutId: {
26107
- type: 'string',
26108
- description: 'Identifier returned earlier by `set_timeout` or `list_timeouts` for one timeout update.',
26109
- },
26110
- allActive: {
26111
- type: 'boolean',
26112
- description: 'When true, run one bulk pause/resume across all active queued timeouts in this same user+agent scope.',
26113
- },
26114
- paused: {
26115
- type: 'boolean',
26116
- description: 'Pause (`true`) or resume (`false`) one timeout; with `allActive: true` this pauses/resumes all active queued timeouts.',
26117
- },
26118
- dueAt: {
26119
- type: 'string',
26120
- description: 'Set the next run timestamp (ISO string). Cannot be used with `extendByMs`.',
26121
- },
26122
- extendByMs: {
26123
- type: 'number',
26124
- description: 'Move next run by this many milliseconds. Cannot be used with `dueAt`.',
26125
- },
26126
- recurrenceIntervalMs: {
26127
- type: 'number',
26128
- description: 'Set recurrence interval in milliseconds; pass `null` to disable recurrence.',
26129
- },
26130
- message: {
26131
- type: 'string',
26132
- description: 'Set wake-up message text for this timeout; pass empty string to clear.',
26133
- },
26134
- parameters: {
26135
- type: 'object',
26136
- description: 'Replace stored JSON parameters passed back when timeout fires.',
26137
- },
26138
- },
26139
- },
26140
- });
26141
- }
26142
- return tools;
26143
- }
26144
-
26145
- /**
26146
- * `USE TIMEOUT` commitment definition.
26147
- *
26148
- * The `USE TIMEOUT` commitment enables timeout wake-ups and scoped timeout management.
26149
- *
26150
- * @private [🪔] Maybe export the commitments through some package
26151
- */
26152
- class UseTimeoutCommitmentDefinition extends BaseCommitmentDefinition {
26153
- constructor() {
26154
- super('USE TIMEOUT');
26155
- }
26156
- get requiresContent() {
26157
- return false;
26158
- }
26159
- /**
26160
- * Short one-line description of `USE TIMEOUT`.
26161
- */
26162
- get description() {
26163
- return 'Enable timeout wake-ups plus scoped timeout listing, updates, and cancellation across chats.';
26164
- }
26165
- /**
26166
- * Icon for this commitment.
26167
- */
26168
- get icon() {
26169
- return '⏱️';
26170
- }
26171
- /**
26172
- * Markdown documentation for `USE TIMEOUT`.
26173
- */
26174
- get documentation() {
26175
- return spaceTrim$1(`
26176
- # USE TIMEOUT
26177
-
26178
- Enables timeout wake-ups and timeout management for the same user+agent scope.
26179
-
26180
- ## Key aspects
26181
-
26182
- - The agent uses \`set_timeout\` to schedule a future wake-up in the same chat thread.
26183
- - The tool returns immediately while the timeout is stored and executed by the runtime later.
26184
- - The wake-up arrives as a new user-like timeout message in the same conversation.
26185
- - The agent can inspect known timeout details via \`list_timeouts\`.
26186
- - The agent can cancel one timeout by \`timeoutId\` or cancel all active timeouts via \`cancel_timeout\`.
26187
- - The agent can pause/resume and edit timeout details via \`update_timeout\`.
26188
- - Commitment content is treated as optional timeout policy instructions.
26189
-
26190
- ## Examples
26191
-
26192
- \`\`\`book
26193
- Follow-up Agent
26194
- USE TIMEOUT Remind yourself only when follow-up work is explicitly requested.
26195
- \`\`\`
26196
- `);
26197
- }
26198
- applyToAgentModelRequirements(requirements, content) {
26199
- const extraInstructions = formatOptionalInstructionBlock('Timeout instructions', content);
26200
- return this.appendToSystemMessage({
26201
- ...requirements,
26202
- tools: createTimeoutTools(requirements.tools || []),
26203
- _metadata: {
26204
- ...requirements._metadata,
26205
- useTimeout: content || true,
26206
- },
26207
- }, createTimeoutSystemMessage(extraInstructions));
26208
- }
26209
- /**
26210
- * Gets human-readable titles for tool functions provided by this commitment.
26211
- */
26212
- getToolTitles() {
26213
- return {
26214
- [TimeoutToolNames.set]: 'Set timer',
26215
- [TimeoutToolNames.cancel]: 'Cancel timer',
26216
- [TimeoutToolNames.list]: 'List timers',
26217
- [TimeoutToolNames.update]: 'Update timer',
26218
- };
26219
- }
26220
- /**
26221
- * Gets `USE TIMEOUT` tool function implementations.
26222
- */
26223
- getToolFunctions() {
26224
- return createTimeoutToolFunctions();
26225
- }
26226
- }
26227
- // Note: [💞] Ignore a discrepancy between file name and entity name
26228
-
26229
- /**
26230
- * USE TIME commitment definition
26231
- *
26232
- * The `USE TIME` commitment indicates that the agent should be able to determine the current date and time.
26233
- *
26234
- * Example usage in agent source:
26235
- *
26236
- * ```book
26237
- * USE TIME
26238
- * USE TIME Prefer the user's local timezone.
26239
- * ```
26240
- *
26241
- * @private [🪔] Maybe export the commitments through some package
26242
- */
26243
- class UseTimeCommitmentDefinition extends BaseCommitmentDefinition {
26244
- constructor() {
26245
- super('USE TIME', ['CURRENT TIME', 'TIME', 'DATE']);
26246
- }
26247
- get requiresContent() {
26248
- return false;
26249
- }
26250
- /**
26251
- * Short one-line description of USE TIME.
26252
- */
26253
- get description() {
26254
- return 'Enable the agent to determine the current date and time.';
26255
- }
26256
- /**
26257
- * Icon for this commitment.
26258
- */
26259
- get icon() {
26260
- return '🕒';
26261
- }
26262
- /**
26263
- * Markdown documentation for USE TIME commitment.
26264
- */
26265
- get documentation() {
26266
- return spaceTrim$1(`
26267
- # USE TIME
26268
-
26269
- Enables the agent to determine the current date and time.
26270
-
26271
- ## Key aspects
26272
-
26273
- - This tool won't receive any input.
26274
- - It outputs the current date and time as an ISO 8601 string.
26275
- - Allows the agent to answer questions about the current time or date.
26276
- - The content following \`USE TIME\` is an arbitrary text that the agent should know (e.g. timezone preference).
26277
-
26278
- ## Examples
26279
-
26280
- \`\`\`book
26281
- Time-aware Assistant
26282
-
26283
- PERSONA You are a helpful assistant who knows the current time.
26284
- USE TIME
26285
- \`\`\`
26286
-
26287
- \`\`\`book
26288
- Travel Assistant
26289
-
26290
- PERSONA You help travelers with planning.
26291
- USE TIME Prefer the user's local timezone.
26292
- \`\`\`
26293
- `);
26294
- }
26295
- applyToAgentModelRequirements(requirements, content) {
26296
- // Get existing tools array or create new one
26297
- const existingTools = requirements.tools || [];
26298
- // Add 'get_current_time' to tools if not already present
26299
- const updatedTools = existingTools.some((tool) => tool.name === 'get_current_time')
26300
- ? existingTools
26301
- : [
26302
- ...existingTools,
26303
- {
26304
- name: 'get_current_time',
26305
- description: 'Get the current date and time in ISO 8601 format.',
26306
- parameters: {
26307
- type: 'object',
26308
- properties: {
26309
- timezone: {
26310
- type: 'string',
26311
- description: 'Optional timezone name (e.g. "Europe/Prague", "UTC", "America/New_York").',
26312
- },
26313
- },
26314
- required: [],
26315
- },
26316
- },
26317
- // <- TODO: !!!! define the function in LLM tools
26318
- ];
26319
- return appendAggregatedUseCommitmentPlaceholder({
26320
- ...requirements,
26321
- tools: updatedTools,
26322
- _metadata: {
26323
- ...requirements._metadata,
26324
- },
26325
- }, this.type);
26326
- }
26327
- /**
26328
- * Gets human-readable titles for tool functions provided by this commitment.
26329
- */
26330
- getToolTitles() {
26331
- return {
26332
- get_current_time: 'Get current time',
26333
- };
26334
- }
26335
- /**
26336
- * Gets the `get_current_time` tool function implementation.
26337
- */
26338
- getToolFunctions() {
26339
- return {
26340
- async get_current_time(args) {
26341
- var _a;
26342
- console.log('!!!! [Tool] get_current_time called', { args });
26343
- const { timezone } = args;
26344
- if (!timezone) {
26345
- return new Date().toISOString();
26346
- }
26347
- try {
26348
- // Note: Returning ISO 8601 string but in the requested timezone
26349
- const formatter = new Intl.DateTimeFormat('en-CA', {
26350
- timeZone: timezone,
26351
- year: 'numeric',
26352
- month: '2-digit',
26353
- day: '2-digit',
26354
- hour: '2-digit',
26355
- minute: '2-digit',
26356
- second: '2-digit',
26357
- hour12: false,
26358
- timeZoneName: 'shortOffset',
26359
- });
26360
- const parts = formatter.formatToParts(new Date());
26361
- const part = (type) => { var _a; return (_a = parts.find((p) => p.type === type)) === null || _a === void 0 ? void 0 : _a.value; };
26362
- // en-CA format is YYYY-MM-DD
26363
- const isoString = `${part('year')}-${part('month')}-${part('day')}T${part('hour')}:${part('minute')}:${part('second')}${(_a = part('timeZoneName')) === null || _a === void 0 ? void 0 : _a.replace('GMT', '')}`;
26364
- return isoString;
26365
- }
26366
- catch (error) {
26367
- // Fallback to UTC if timezone is invalid
26368
- return new Date().toISOString();
26369
- }
26370
- },
26371
- };
26372
- }
26373
- }
26374
- // Note: [💞] Ignore a discrepancy between file name and entity name
26375
-
26376
23546
  /**
26377
23547
  * Tool name used by the USE USER LOCATION commitment.
26378
23548
  *
@@ -26587,580 +23757,6 @@ class UseUserLocationCommitmentDefinition extends BaseCommitmentDefinition {
26587
23757
  }
26588
23758
  // Note: [💞] Ignore a discrepancy between file name and entity name
26589
23759
 
26590
- /**
26591
- * Names of tools used by the WALLET commitment.
26592
- *
26593
- * @private constant of WalletCommitmentDefinition
26594
- */
26595
- const WalletToolNames = {
26596
- retrieve: 'retrieve_wallet_records',
26597
- store: 'store_wallet_record',
26598
- update: 'update_wallet_record',
26599
- delete: 'delete_wallet_record',
26600
- request: 'request_wallet_record',
26601
- };
26602
-
26603
- /**
26604
- * Creates WALLET system-message instructions.
26605
- *
26606
- * @private function of WalletCommitmentDefinition
26607
- */
26608
- function createWalletSystemMessage(extraInstructions) {
26609
- return spaceTrim$1((block) => `
26610
- Wallet:
26611
- - Use "${WalletToolNames.retrieve}" before authenticated operations.
26612
- - Use "${WalletToolNames.store}" and "${WalletToolNames.update}" to maintain credentials.
26613
- - Use "${WalletToolNames.delete}" to remove invalid credentials.
26614
- - Use "${WalletToolNames.request}" to request missing credentials via UI popup.
26615
- - Scope records by user (\`isUserScoped\`) and/or by agent (\`isGlobal=false\`) as needed.
26616
- - Never expose raw credentials in chat responses.
26617
- ${block(extraInstructions)}
26618
- `);
26619
- }
26620
-
26621
- /**
26622
- * Resolves disabled message for wallet runtime context.
26623
- *
26624
- * @private function of WalletCommitmentDefinition
26625
- */
26626
- function resolveWalletDisabledMessage(runtimeContext) {
26627
- if (runtimeContext.isPrivateMode) {
26628
- return 'Wallet is disabled because private mode is active.';
26629
- }
26630
- if (runtimeContext.isTeamConversation) {
26631
- return 'Wallet is disabled for TEAM conversations.';
26632
- }
26633
- if (!runtimeContext.enabled) {
26634
- return 'Wallet is disabled for unauthenticated users.';
26635
- }
26636
- return null;
26637
- }
26638
- /**
26639
- * Resolves runtime adapter for wallet tools or returns disabled payload when unavailable.
26640
- *
26641
- * @private function of WalletCommitmentDefinition
26642
- */
26643
- function getWalletToolRuntimeAdapterOrDisabledResult(action, runtimeContext) {
26644
- const disabledMessage = resolveWalletDisabledMessage(runtimeContext);
26645
- if (disabledMessage) {
26646
- return {
26647
- adapter: null,
26648
- disabledResult: {
26649
- action,
26650
- status: 'disabled',
26651
- records: action === 'retrieve' ? [] : undefined,
26652
- message: disabledMessage,
26653
- },
26654
- };
26655
- }
26656
- {
26657
- return {
26658
- adapter: null,
26659
- disabledResult: {
26660
- action,
26661
- status: 'disabled',
26662
- records: action === 'retrieve' ? [] : undefined,
26663
- message: 'Wallet runtime is not available in this environment.',
26664
- },
26665
- };
26666
- }
26667
- }
26668
-
26669
- /**
26670
- * Parses store/update wallet payload.
26671
- *
26672
- * @private function of WalletCommitmentDefinition
26673
- */
26674
- function parseWalletPayload(args) {
26675
- const recordType = parseWalletRecordType(args.recordType);
26676
- return {
26677
- recordType,
26678
- service: parseWalletService(args.service),
26679
- key: parseWalletKey(args.key),
26680
- isUserScoped: args.isUserScoped === true,
26681
- isGlobal: args.isGlobal === true,
26682
- ...parseWalletSecrets({
26683
- recordType,
26684
- username: args.username,
26685
- password: args.password,
26686
- secret: args.secret,
26687
- cookies: args.cookies,
26688
- }),
26689
- };
26690
- }
26691
- /**
26692
- * Parses text argument and returns trimmed text when available.
26693
- *
26694
- * @private function of WalletCommitmentDefinition
26695
- */
26696
- function normalizeOptionalText(value) {
26697
- if (typeof value !== 'string') {
26698
- return undefined;
26699
- }
26700
- const trimmed = value.trim();
26701
- return trimmed || undefined;
26702
- }
26703
- /**
26704
- * Parses wallet service argument.
26705
- *
26706
- * @private function of WalletCommitmentDefinition
26707
- */
26708
- function parseWalletService(value) {
26709
- return (normalizeOptionalText(value) || 'generic').toLowerCase();
26710
- }
26711
- /**
26712
- * Parses wallet key argument.
26713
- *
26714
- * @private function of WalletCommitmentDefinition
26715
- */
26716
- function parseWalletKey(value) {
26717
- return normalizeOptionalText(value) || 'default';
26718
- }
26719
- /**
26720
- * Parses one wallet record id argument.
26721
- *
26722
- * @private function of WalletCommitmentDefinition
26723
- */
26724
- function parseWalletId(value) {
26725
- const walletId = normalizeOptionalText(value);
26726
- if (!walletId) {
26727
- throw new Error('Wallet id is required.');
26728
- }
26729
- return walletId;
26730
- }
26731
- /**
26732
- * Parses wallet record type.
26733
- *
26734
- * @private function of WalletCommitmentDefinition
26735
- */
26736
- function parseWalletRecordType(value, fallback) {
26737
- var _a;
26738
- const normalizedType = (_a = normalizeOptionalText(value)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
26739
- if (normalizedType === 'USERNAME_PASSWORD') {
26740
- return 'USERNAME_PASSWORD';
26741
- }
26742
- if (normalizedType === 'SESSION_COOKIE') {
26743
- return 'SESSION_COOKIE';
26744
- }
26745
- if (normalizedType === 'ACCESS_TOKEN') {
26746
- return 'ACCESS_TOKEN';
26747
- }
26748
- if (fallback) {
26749
- return fallback;
26750
- }
26751
- throw new Error('Unsupported wallet recordType. Expected one of: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.');
26752
- }
26753
- /**
26754
- * Parses wallet secret fields according to record type.
26755
- *
26756
- * @private function of WalletCommitmentDefinition
26757
- */
26758
- function parseWalletSecrets(args) {
26759
- const username = normalizeOptionalText(args.username);
26760
- const password = normalizeOptionalText(args.password);
26761
- const secret = normalizeOptionalText(args.secret);
26762
- const cookies = normalizeOptionalText(args.cookies);
26763
- if (args.recordType === 'USERNAME_PASSWORD') {
26764
- if (!username || !password) {
26765
- throw new Error('Both username and password are required for USERNAME_PASSWORD.');
26766
- }
26767
- return { username, password };
26768
- }
26769
- if (args.recordType === 'SESSION_COOKIE') {
26770
- if (!cookies) {
26771
- throw new Error('Cookies are required for SESSION_COOKIE.');
26772
- }
26773
- return { cookies };
26774
- }
26775
- if (!secret) {
26776
- throw new Error('Secret is required for ACCESS_TOKEN.');
26777
- }
26778
- return { secret };
26779
- }
26780
- /**
26781
- * Collection of WALLET tool argument parsers.
26782
- *
26783
- * @private function of WalletCommitmentDefinition
26784
- */
26785
- const parseWalletToolArgs = {
26786
- /**
26787
- * Parses retrieve arguments.
26788
- */
26789
- retrieve(args) {
26790
- const limit = typeof args.limit === 'number' && Number.isFinite(args.limit) ? Math.floor(args.limit) : undefined;
26791
- return {
26792
- query: normalizeOptionalText(args.query),
26793
- recordType: normalizeOptionalText(args.recordType) ? parseWalletRecordType(args.recordType) : undefined,
26794
- service: normalizeOptionalText(args.service) ? parseWalletService(args.service) : undefined,
26795
- key: normalizeOptionalText(args.key) ? parseWalletKey(args.key) : undefined,
26796
- limit: limit && limit > 0 ? Math.min(limit, 20) : undefined,
26797
- };
26798
- },
26799
- /**
26800
- * Parses store payload.
26801
- */
26802
- store(args) {
26803
- return parseWalletPayload(args);
26804
- },
26805
- /**
26806
- * Parses update payload.
26807
- */
26808
- update(args) {
26809
- const walletId = parseWalletId(args.walletId);
26810
- const record = parseWalletPayload(args);
26811
- return {
26812
- ...record,
26813
- walletId,
26814
- };
26815
- },
26816
- /**
26817
- * Parses delete payload.
26818
- */
26819
- delete(args) {
26820
- return { walletId: parseWalletId(args.walletId) };
26821
- },
26822
- /**
26823
- * Parses request payload for user wallet input prompt.
26824
- */
26825
- request(args) {
26826
- return {
26827
- recordType: parseWalletRecordType(args.recordType, 'ACCESS_TOKEN'),
26828
- service: parseWalletService(args.service),
26829
- key: parseWalletKey(args.key),
26830
- message: normalizeOptionalText(args.message),
26831
- isUserScoped: args.isUserScoped === true,
26832
- isGlobal: args.isGlobal === true,
26833
- };
26834
- },
26835
- };
26836
-
26837
- /**
26838
- * Resolves runtime context from hidden tool arguments.
26839
- *
26840
- * @private function of WalletCommitmentDefinition
26841
- */
26842
- function resolveWalletRuntimeContext(args) {
26843
- const runtimeContext = readToolRuntimeContextFromToolArgs(args);
26844
- const memoryContext = runtimeContext === null || runtimeContext === void 0 ? void 0 : runtimeContext.memory;
26845
- return {
26846
- enabled: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.enabled) === true,
26847
- userId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.userId,
26848
- username: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.username,
26849
- agentId: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentId,
26850
- agentName: memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.agentName,
26851
- isTeamConversation: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isTeamConversation) === true,
26852
- isPrivateMode: (memoryContext === null || memoryContext === void 0 ? void 0 : memoryContext.isPrivateMode) === true,
26853
- };
26854
- }
26855
-
26856
- /**
26857
- * Creates runtime wallet tool function implementations.
26858
- *
26859
- * @private function of WalletCommitmentDefinition
26860
- */
26861
- function createWalletToolFunctions() {
26862
- return {
26863
- async [WalletToolNames.retrieve](args) {
26864
- const runtimeContext = resolveWalletRuntimeContext(args);
26865
- const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('retrieve', runtimeContext);
26866
- if (!adapter || disabledResult) {
26867
- return JSON.stringify(disabledResult);
26868
- }
26869
- try {
26870
- const parsedArgs = parseWalletToolArgs.retrieve(args);
26871
- const records = await adapter.retrieveWalletRecords(parsedArgs, runtimeContext);
26872
- return JSON.stringify({
26873
- action: 'retrieve',
26874
- status: 'ok',
26875
- query: parsedArgs.query,
26876
- records,
26877
- });
26878
- }
26879
- catch (error) {
26880
- return JSON.stringify({
26881
- action: 'retrieve',
26882
- status: 'error',
26883
- records: [],
26884
- message: error instanceof Error ? error.message : String(error),
26885
- });
26886
- }
26887
- },
26888
- async [WalletToolNames.store](args) {
26889
- const runtimeContext = resolveWalletRuntimeContext(args);
26890
- const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('store', runtimeContext);
26891
- if (!adapter || disabledResult) {
26892
- return JSON.stringify(disabledResult);
26893
- }
26894
- try {
26895
- const parsedArgs = parseWalletToolArgs.store(args);
26896
- const record = await adapter.storeWalletRecord(parsedArgs, runtimeContext);
26897
- return JSON.stringify({
26898
- action: 'store',
26899
- status: 'stored',
26900
- record,
26901
- });
26902
- }
26903
- catch (error) {
26904
- return JSON.stringify({
26905
- action: 'store',
26906
- status: 'error',
26907
- message: error instanceof Error ? error.message : String(error),
26908
- });
26909
- }
26910
- },
26911
- async [WalletToolNames.update](args) {
26912
- const runtimeContext = resolveWalletRuntimeContext(args);
26913
- const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('update', runtimeContext);
26914
- if (!adapter || disabledResult) {
26915
- return JSON.stringify(disabledResult);
26916
- }
26917
- try {
26918
- const parsedArgs = parseWalletToolArgs.update(args);
26919
- const record = await adapter.updateWalletRecord(parsedArgs, runtimeContext);
26920
- return JSON.stringify({
26921
- action: 'update',
26922
- status: 'updated',
26923
- record,
26924
- });
26925
- }
26926
- catch (error) {
26927
- return JSON.stringify({
26928
- action: 'update',
26929
- status: 'error',
26930
- message: error instanceof Error ? error.message : String(error),
26931
- });
26932
- }
26933
- },
26934
- async [WalletToolNames.delete](args) {
26935
- const runtimeContext = resolveWalletRuntimeContext(args);
26936
- const { adapter, disabledResult } = getWalletToolRuntimeAdapterOrDisabledResult('delete', runtimeContext);
26937
- if (!adapter || disabledResult) {
26938
- return JSON.stringify(disabledResult);
26939
- }
26940
- try {
26941
- const parsedArgs = parseWalletToolArgs.delete(args);
26942
- const deleted = await adapter.deleteWalletRecord(parsedArgs, runtimeContext);
26943
- return JSON.stringify({
26944
- action: 'delete',
26945
- status: 'deleted',
26946
- walletId: deleted.id,
26947
- });
26948
- }
26949
- catch (error) {
26950
- return JSON.stringify({
26951
- action: 'delete',
26952
- status: 'error',
26953
- message: error instanceof Error ? error.message : String(error),
26954
- });
26955
- }
26956
- },
26957
- async [WalletToolNames.request](args) {
26958
- const runtimeContext = resolveWalletRuntimeContext(args);
26959
- const disabledMessage = resolveWalletDisabledMessage(runtimeContext);
26960
- if (disabledMessage) {
26961
- return JSON.stringify({
26962
- action: 'request',
26963
- status: 'disabled',
26964
- message: disabledMessage,
26965
- });
26966
- }
26967
- const request = parseWalletToolArgs.request(args);
26968
- return JSON.stringify({
26969
- action: 'request',
26970
- status: 'requested',
26971
- request,
26972
- message: request.message ||
26973
- `Request user to provide ${request.recordType} credentials for service "${request.service}".`,
26974
- });
26975
- },
26976
- };
26977
- }
26978
-
26979
- /**
26980
- * Creates tool definitions required by WALLET commitment.
26981
- *
26982
- * @private function of WalletCommitmentDefinition
26983
- */
26984
- function createWalletTools(existingTools) {
26985
- const tools = [...(existingTools || [])];
26986
- addWalletToolIfMissing(tools, {
26987
- name: WalletToolNames.retrieve,
26988
- description: 'Retrieve wallet records relevant to the current task.',
26989
- parameters: {
26990
- type: 'object',
26991
- properties: {
26992
- query: { type: 'string', description: 'Optional text query used to filter wallet records.' },
26993
- recordType: {
26994
- type: 'string',
26995
- description: 'Optional record type filter (USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN).',
26996
- },
26997
- service: { type: 'string', description: 'Optional service filter, for example github.' },
26998
- key: { type: 'string', description: 'Optional wallet key filter.' },
26999
- limit: { type: 'integer', description: 'Optional maximum number of records (default 5, max 20).' },
27000
- },
27001
- required: [],
27002
- },
27003
- });
27004
- addWalletToolIfMissing(tools, {
27005
- name: WalletToolNames.store,
27006
- description: 'Store one wallet record.',
27007
- parameters: {
27008
- type: 'object',
27009
- properties: {
27010
- recordType: {
27011
- type: 'string',
27012
- description: 'Record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
27013
- },
27014
- service: { type: 'string', description: 'Service identifier, for example github.' },
27015
- key: { type: 'string', description: 'Logical credential key.' },
27016
- username: { type: 'string', description: 'Username for USERNAME_PASSWORD.' },
27017
- password: { type: 'string', description: 'Password for USERNAME_PASSWORD.' },
27018
- secret: { type: 'string', description: 'Token/API key for ACCESS_TOKEN.' },
27019
- cookies: { type: 'string', description: 'Cookie header/json for SESSION_COOKIE.' },
27020
- isUserScoped: { type: 'boolean', description: 'Set true to scope this record to current user.' },
27021
- isGlobal: { type: 'boolean', description: 'Set true to make this record global.' },
27022
- },
27023
- required: ['recordType', 'service'],
27024
- },
27025
- });
27026
- addWalletToolIfMissing(tools, {
27027
- name: WalletToolNames.update,
27028
- description: 'Update one existing wallet record.',
27029
- parameters: {
27030
- type: 'object',
27031
- properties: {
27032
- walletId: { type: 'string', description: 'Wallet record id to update.' },
27033
- recordType: {
27034
- type: 'string',
27035
- description: 'Record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
27036
- },
27037
- service: { type: 'string', description: 'Service identifier, for example github.' },
27038
- key: { type: 'string', description: 'Logical credential key.' },
27039
- username: { type: 'string', description: 'Username for USERNAME_PASSWORD.' },
27040
- password: { type: 'string', description: 'Password for USERNAME_PASSWORD.' },
27041
- secret: { type: 'string', description: 'Token/API key for ACCESS_TOKEN.' },
27042
- cookies: { type: 'string', description: 'Cookie header/json for SESSION_COOKIE.' },
27043
- isUserScoped: { type: 'boolean', description: 'Set true to scope this record to current user.' },
27044
- isGlobal: { type: 'boolean', description: 'Set true to make this record global.' },
27045
- },
27046
- required: ['walletId', 'recordType', 'service'],
27047
- },
27048
- });
27049
- addWalletToolIfMissing(tools, {
27050
- name: WalletToolNames.delete,
27051
- description: 'Delete one wallet record.',
27052
- parameters: {
27053
- type: 'object',
27054
- properties: {
27055
- walletId: { type: 'string', description: 'Wallet record id to delete.' },
27056
- },
27057
- required: ['walletId'],
27058
- },
27059
- });
27060
- addWalletToolIfMissing(tools, {
27061
- name: WalletToolNames.request,
27062
- description: 'Request missing credential from user via popup.',
27063
- parameters: {
27064
- type: 'object',
27065
- properties: {
27066
- recordType: {
27067
- type: 'string',
27068
- description: 'Requested record type: USERNAME_PASSWORD, SESSION_COOKIE, ACCESS_TOKEN.',
27069
- },
27070
- service: { type: 'string', description: 'Service identifier.' },
27071
- key: { type: 'string', description: 'Logical credential key.' },
27072
- message: { type: 'string', description: 'Optional UI message for user.' },
27073
- isUserScoped: {
27074
- type: 'boolean',
27075
- description: 'Set true when record should be scoped to current user.',
27076
- },
27077
- isGlobal: { type: 'boolean', description: 'Set true when record should be global.' },
27078
- },
27079
- required: [],
27080
- },
27081
- });
27082
- return tools;
27083
- }
27084
- /**
27085
- * Registers one wallet tool when missing in current tool list.
27086
- *
27087
- * @private function of WalletCommitmentDefinition
27088
- */
27089
- function addWalletToolIfMissing(tools, tool) {
27090
- if (!tools.some((existingTool) => existingTool.name === tool.name)) {
27091
- tools.push(tool);
27092
- }
27093
- }
27094
-
27095
- /**
27096
- * Gets markdown documentation for WALLET commitment.
27097
- *
27098
- * @private function of WalletCommitmentDefinition
27099
- */
27100
- function getWalletCommitmentDocumentation(type) {
27101
- return spaceTrim$1(`
27102
- # ${type}
27103
-
27104
- Enables private credential storage for tokens, usernames/passwords, and session cookies.
27105
- `);
27106
- }
27107
-
27108
- /**
27109
- * Gets human-readable titles for WALLET tool functions.
27110
- *
27111
- * @private function of WalletCommitmentDefinition
27112
- */
27113
- function getWalletToolTitles() {
27114
- return {
27115
- [WalletToolNames.retrieve]: 'Wallet',
27116
- [WalletToolNames.store]: 'Store wallet record',
27117
- [WalletToolNames.update]: 'Update wallet record',
27118
- [WalletToolNames.delete]: 'Delete wallet record',
27119
- [WalletToolNames.request]: 'Request wallet record',
27120
- };
27121
- }
27122
-
27123
- /**
27124
- * WALLET commitment definition.
27125
- *
27126
- * @private [🪔] Maybe export the commitments through some package
27127
- */
27128
- class WalletCommitmentDefinition extends BaseCommitmentDefinition {
27129
- constructor(type = 'WALLET') {
27130
- super(type);
27131
- }
27132
- get requiresContent() {
27133
- return false;
27134
- }
27135
- get description() {
27136
- return 'Enable persistent private credential storage (tokens, logins, cookies) scoped per agent or globally.';
27137
- }
27138
- get icon() {
27139
- return '👛';
27140
- }
27141
- get documentation() {
27142
- return getWalletCommitmentDocumentation(this.type);
27143
- }
27144
- applyToAgentModelRequirements(requirements, content) {
27145
- const extraInstructions = formatOptionalInstructionBlock('Wallet instructions', content);
27146
- return this.appendToSystemMessage({
27147
- ...requirements,
27148
- tools: createWalletTools(requirements.tools),
27149
- _metadata: {
27150
- ...requirements._metadata,
27151
- useWallet: content || true,
27152
- },
27153
- }, createWalletSystemMessage(extraInstructions));
27154
- }
27155
- getToolTitles() {
27156
- return getWalletToolTitles();
27157
- }
27158
- getToolFunctions() {
27159
- return createWalletToolFunctions();
27160
- }
27161
- }
27162
- // Note: [💞] Ignore a discrepancy between file name and entity name
27163
-
27164
23760
  /**
27165
23761
  * `WRITING RULES` commitment definition.
27166
23762
  *
@@ -27387,8 +23983,6 @@ const COMMITMENT_REGISTRY = [
27387
23983
  new PersonaCommitmentDefinition('PERSONA'),
27388
23984
  new PersonaCommitmentDefinition('PERSONAE'),
27389
23985
  new KnowledgeCommitmentDefinition(),
27390
- new MemoryCommitmentDefinition('MEMORY'),
27391
- new MemoryCommitmentDefinition('MEMORIES'),
27392
23986
  new StyleCommitmentDefinition('STYLE'),
27393
23987
  new StyleCommitmentDefinition('STYLES'),
27394
23988
  new RuleCommitmentDefinition('RULE'),
@@ -27410,7 +24004,6 @@ const COMMITMENT_REGISTRY = [
27410
24004
  new ModelCommitmentDefinition('MODELS'),
27411
24005
  new ActionCommitmentDefinition('ACTION'),
27412
24006
  new ActionCommitmentDefinition('ACTIONS'),
27413
- new ComponentCommitmentDefinition(),
27414
24007
  new MetaAvatarCommitmentDefinition(),
27415
24008
  new MetaAvatarCommitmentDefinition('META VISUAL'),
27416
24009
  new MetaImageCommitmentDefinition(),
@@ -27418,11 +24011,13 @@ const COMMITMENT_REGISTRY = [
27418
24011
  new MetaFontCommitmentDefinition(),
27419
24012
  new MetaLinkCommitmentDefinition(),
27420
24013
  new MetaDomainCommitmentDefinition(),
24014
+ new MetaDescriptionCommitmentDefinition(),
27421
24015
  new MetaDisclaimerCommitmentDefinition(),
24016
+ new MetaFullnameCommitmentDefinition(),
24017
+ new MetaIdCommitmentDefinition(),
27422
24018
  new MetaInputPlaceholderCommitmentDefinition(),
27423
24019
  new MetaThinkingMessageCommitmentDefinition(),
27424
24020
  new MetaVisibilityCommitmentDefinition(),
27425
- new MetaCommitmentDefinition(),
27426
24021
  new MetaVoiceCommitmentDefinition(),
27427
24022
  new NoteCommitmentDefinition('NOTE'),
27428
24023
  new NoteCommitmentDefinition('NOTES'),
@@ -27438,8 +24033,6 @@ const COMMITMENT_REGISTRY = [
27438
24033
  new MessageSuffixCommitmentDefinition(),
27439
24034
  new MessageCommitmentDefinition('MESSAGE'),
27440
24035
  new MessageCommitmentDefinition('MESSAGES'),
27441
- new WalletCommitmentDefinition('WALLET'),
27442
- new WalletCommitmentDefinition('WALLETS'),
27443
24036
  new ScenarioCommitmentDefinition('SCENARIO'),
27444
24037
  new ScenarioCommitmentDefinition('SCENARIOS'),
27445
24038
  new DeleteCommitmentDefinition('DELETE'),
@@ -27450,15 +24043,8 @@ const COMMITMENT_REGISTRY = [
27450
24043
  new OpenCommitmentDefinition(),
27451
24044
  new ClosedCommitmentDefinition(),
27452
24045
  new TeamCommitmentDefinition(),
27453
- new UseBrowserCommitmentDefinition(),
27454
- new UseDeepSearchCommitmentDefinition(),
27455
- new UseSearchEngineCommitmentDefinition(),
27456
- new UseSpawnCommitmentDefinition(),
27457
- new UseTimeoutCommitmentDefinition(),
27458
- new UseTimeCommitmentDefinition(),
27459
24046
  new UseUserLocationCommitmentDefinition(),
27460
24047
  new UseCalendarCommitmentDefinition(),
27461
- new UseEmailCommitmentDefinition(),
27462
24048
  new UsePopupCommitmentDefinition(),
27463
24049
  new UseImageGeneratorCommitmentDefinition('USE IMAGE GENERATOR'),
27464
24050
  new UseMcpCommitmentDefinition(),
@@ -28306,12 +24892,6 @@ const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
28306
24892
  ['GOAL', 'GOAL'],
28307
24893
  ['GOALS', 'GOAL'],
28308
24894
  ]);
28309
- /**
28310
- * Legacy commitments that should be parsed for compatibility but ignored by the model-requirements pipeline.
28311
- *
28312
- * @private internal constant of `filterCommitmentsForAgentModelRequirements`
28313
- */
28314
- const IGNORED_COMMITMENT_TYPES = new Set(['WALLET', 'WALLETS']);
28315
24895
  /**
28316
24896
  * Applies the commitment filtering rules used before commitment definitions are executed.
28317
24897
  *
@@ -28360,9 +24940,6 @@ function filterOverwrittenCommitments(commitments) {
28360
24940
  function filterDeletedCommitments(commitments) {
28361
24941
  const filteredCommitments = [];
28362
24942
  for (const commitment of commitments) {
28363
- if (isIgnoredCommitmentType(commitment.type)) {
28364
- continue;
28365
- }
28366
24943
  if (!isDeleteCommitmentType(commitment.type)) {
28367
24944
  filteredCommitments.push(commitment);
28368
24945
  continue;
@@ -28393,17 +24970,6 @@ function filterDeletedCommitments(commitments) {
28393
24970
  function isDeleteCommitmentType(commitmentType) {
28394
24971
  return DELETE_COMMITMENT_TYPES.has(commitmentType);
28395
24972
  }
28396
- /**
28397
- * Checks whether a parsed commitment is intentionally ignored by the current model compiler.
28398
- *
28399
- * @param commitmentType - Commitment type to check.
28400
- * @returns `true` when the commitment should not affect model requirements.
28401
- *
28402
- * @private internal utility of `filterDeletedCommitments`
28403
- */
28404
- function isIgnoredCommitmentType(commitmentType) {
28405
- return IGNORED_COMMITMENT_TYPES.has(commitmentType);
28406
- }
28407
24973
  /**
28408
24974
  * Extracts normalized parameter names used for DELETE-like invalidation matching.
28409
24975
  *
@@ -28537,7 +25103,6 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
28537
25103
  const filteredCommitments = filterCommitmentsForAgentModelRequirements(parseResult.commitments);
28538
25104
  let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
28539
25105
  requirements = await applyCommitmentsToAgentModelRequirements(requirements, filteredCommitments, options);
28540
- requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
28541
25106
  requirements = await augmentAgentModelRequirementsFromSource(requirements, parseResult, agentSource);
28542
25107
  requirements = await materializeInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
28543
25108
  return finalizeRequirements(requirements);
@@ -28660,59 +25225,6 @@ function extractInitialMessage(commitments) {
28660
25225
  return initialMessage;
28661
25226
  }
28662
25227
 
28663
- /**
28664
- * Normalizes a given text to camelCase format.
28665
- *
28666
- * Note: [🔂] This function is idempotent.
28667
- *
28668
- * @param text The text to be normalized.
28669
- * @param _isFirstLetterCapital Whether the first letter should be capitalized.
28670
- * @returns The camelCase formatted string.
28671
- * @example 'helloWorld'
28672
- * @example 'iLovePromptbook'
28673
- *
28674
- * @public exported from `@promptbook/utils`
28675
- */
28676
- function normalizeTo_camelCase(text, _isFirstLetterCapital = false) {
28677
- let charType;
28678
- let lastCharType = null;
28679
- let normalizedName = '';
28680
- for (const char of text) {
28681
- let normalizedChar;
28682
- if (/^[a-z]$/.test(char)) {
28683
- charType = 'LOWERCASE';
28684
- normalizedChar = char;
28685
- }
28686
- else if (/^[A-Z]$/.test(char)) {
28687
- charType = 'UPPERCASE';
28688
- normalizedChar = char.toLowerCase();
28689
- }
28690
- else if (/^[0-9]$/.test(char)) {
28691
- charType = 'NUMBER';
28692
- normalizedChar = char;
28693
- }
28694
- else {
28695
- charType = 'OTHER';
28696
- normalizedChar = '';
28697
- }
28698
- if (!lastCharType) {
28699
- if (_isFirstLetterCapital) {
28700
- normalizedChar = normalizedChar.toUpperCase(); //TODO: DRY
28701
- }
28702
- }
28703
- else if (charType !== lastCharType &&
28704
- !(charType === 'LOWERCASE' && lastCharType === 'UPPERCASE') &&
28705
- !(lastCharType === 'NUMBER') &&
28706
- !(charType === 'NUMBER')) {
28707
- normalizedChar = normalizedChar.toUpperCase(); //TODO: [🌺] DRY
28708
- }
28709
- normalizedName += normalizedChar;
28710
- lastCharType = charType;
28711
- }
28712
- return normalizedName;
28713
- }
28714
- // TODO: [🌺] Use some intermediate util splitWords
28715
-
28716
25228
  /**
28717
25229
  * Normalizes a domain-like string into a comparable hostname form.
28718
25230
  *
@@ -28762,6 +25274,8 @@ const META_COMMITMENT_APPLIERS = {
28762
25274
  'META IMAGE': applyMetaImageContent,
28763
25275
  'META DESCRIPTION': applyMetaDescriptionContent,
28764
25276
  'META DISCLAIMER': applyMetaDisclaimerContent,
25277
+ 'META FULLNAME': applyMetaFullnameContent,
25278
+ 'META ID': applyMetaIdContent,
28765
25279
  'META INPUT PLACEHOLDER': applyMetaInputPlaceholderContent,
28766
25280
  'META THINKING MESSAGE': applyMetaThinkingMessageContent,
28767
25281
  'MESSAGE SUFFIX': applyMessageSuffixContent,
@@ -28779,32 +25293,8 @@ function applyMetaCommitment(state, commitment) {
28779
25293
  const applyMetaContent = META_COMMITMENT_APPLIERS[commitment.type];
28780
25294
  if (applyMetaContent) {
28781
25295
  applyMetaContent(state, commitment.content);
28782
- return;
28783
- }
28784
- if (commitment.type === 'META') {
28785
- applyGenericMetaCommitment(state, commitment.content);
28786
25296
  }
28787
25297
  }
28788
- /**
28789
- * Applies the generic META commitment form (`META TYPE value`).
28790
- */
28791
- function applyGenericMetaCommitment(state, content) {
28792
- const metaTypeRaw = content.split(' ')[0] || 'NONE';
28793
- const metaValue = spaceTrim$1(content.substring(metaTypeRaw.length));
28794
- if (metaTypeRaw === 'LINK') {
28795
- state.links.push(metaValue);
28796
- }
28797
- if (metaTypeRaw.toUpperCase() === 'AVATAR') {
28798
- applyMetaAvatarContent(state, metaValue);
28799
- return;
28800
- }
28801
- if (metaTypeRaw.toUpperCase() === 'VISIBILITY') {
28802
- applyMetaVisibilityContent(state, metaValue);
28803
- return;
28804
- }
28805
- const metaType = normalizeTo_camelCase(metaTypeRaw);
28806
- state.meta[metaType] = metaValue;
28807
- }
28808
25298
  /**
28809
25299
  * Applies META AVATAR / META VISUAL content into the canonical `meta.avatar` field.
28810
25300
  */
@@ -28848,6 +25338,18 @@ function applyMetaDescriptionContent(state, content) {
28848
25338
  function applyMetaDisclaimerContent(state, content) {
28849
25339
  state.meta.disclaimer = content;
28850
25340
  }
25341
+ /**
25342
+ * Applies META FULLNAME content into the canonical `meta.fullname` field.
25343
+ */
25344
+ function applyMetaFullnameContent(state, content) {
25345
+ state.meta.fullname = spaceTrim$1(content);
25346
+ }
25347
+ /**
25348
+ * Applies META ID content into the canonical `meta.id` field.
25349
+ */
25350
+ function applyMetaIdContent(state, content) {
25351
+ state.meta.id = spaceTrim$1(content);
25352
+ }
28851
25353
  /**
28852
25354
  * Applies META INPUT PLACEHOLDER content into the canonical `meta.inputPlaceholder` field.
28853
25355
  */
@@ -28952,46 +25454,11 @@ function consumeConversationSampleCommitment(state, commitment) {
28952
25454
  * Static capability descriptors for commitments that map one-to-one to a visible capability.
28953
25455
  */
28954
25456
  const SIMPLE_CAPABILITY_BY_COMMITMENT_TYPE = {
28955
- 'USE BROWSER': {
28956
- type: 'browser',
28957
- label: 'Browser',
28958
- iconName: 'Globe',
28959
- },
28960
- 'USE SEARCH ENGINE': {
28961
- type: 'search-engine',
28962
- label: 'Internet',
28963
- iconName: 'Search',
28964
- },
28965
- 'USE SEARCH': {
28966
- type: 'search-engine',
28967
- label: 'Internet',
28968
- iconName: 'Search',
28969
- },
28970
- 'USE DEEPSEARCH': {
28971
- type: 'search-engine',
28972
- label: 'DeepSearch',
28973
- iconName: 'Search',
28974
- },
28975
- 'USE TIME': {
28976
- type: 'time',
28977
- label: 'Time',
28978
- iconName: 'Clock',
28979
- },
28980
- 'USE TIMEOUT': {
28981
- type: 'timeout',
28982
- label: 'Timers',
28983
- iconName: 'Clock',
28984
- },
28985
25457
  'USE USER LOCATION': {
28986
25458
  type: 'user-location',
28987
25459
  label: 'User location',
28988
25460
  iconName: 'MapPin',
28989
25461
  },
28990
- 'USE EMAIL': {
28991
- type: 'email',
28992
- label: 'Email',
28993
- iconName: 'Mail',
28994
- },
28995
25462
  'USE POPUP': {
28996
25463
  type: 'popup',
28997
25464
  label: 'Popup',
@@ -29635,19 +26102,6 @@ const bookLanguageDocumentationExamples = [
29635
26102
  CLOSED
29636
26103
  `),
29637
26104
  },
29638
- {
29639
- id: 'tool-using-browser-search-agent',
29640
- source: spaceTrim$1(`
29641
- Web Research Assistant
29642
-
29643
- GOAL Research topics using fresh and verifiable information.
29644
- USE SEARCH ENGINE Prefer official sources and recent publications.
29645
- USE BROWSER
29646
- RULE Verify important claims across multiple sources when possible.
29647
- RULE Include source links in your final answer.
29648
- INITIAL MESSAGE Ask me what topic you want to research and how deep the report should be.
29649
- `),
29650
- },
29651
26105
  {
29652
26106
  id: 'rule-and-knowledge-agent',
29653
26107
  source: spaceTrim$1(`
@@ -29661,18 +26115,6 @@ const bookLanguageDocumentationExamples = [
29661
26115
  INITIAL MESSAGE I can explain refund and support rules from provided knowledge.
29662
26116
  `),
29663
26117
  },
29664
- {
29665
- id: 'memory-agent-with-long-term-memory',
29666
- source: spaceTrim$1(`
29667
- Customer Success Memory Agent
29668
-
29669
- GOAL Support SaaS customers while remembering relevant setup and preference context.
29670
- MEMORY Remember product setup, user goals, and communication preferences.
29671
- RULE Store only user-approved preferences and project context.
29672
- RULE Never store secrets or sensitive data unless explicitly requested and allowed.
29673
- INITIAL MESSAGE I can remember your setup and preferences for future sessions.
29674
- `),
29675
- },
29676
26118
  {
29677
26119
  id: 'use-project-integration-agent',
29678
26120
  source: spaceTrim$1(`
@@ -29875,7 +26317,7 @@ const czechBookLanguageManualDictionary = {
29875
26317
  2. **Vrstva chování**:
29876
26318
  \`RULE\`, \`KNOWLEDGE\`, \`WRITING SAMPLE\`, \`WRITING RULES\`, \`LANGUAGE\`, \`GOAL\` a příbuzné commitmenty.
29877
26319
  3. **Vrstva schopností**:
29878
- \`USE*\`, \`MEMORY\` a další nástrojové commitmenty, které agentovi otevírají běhové schopnosti.
26320
+ \`USE*\` a další nástrojové commitmenty, které agentovi otevírají běhové schopnosti.
29879
26321
  4. **Vrstva skládání**:
29880
26322
  Dědičnost přes \`FROM\`, znovupoužití přes \`IMPORT\` a delegování přes \`TEAM\`.
29881
26323
  `),
@@ -29897,9 +26339,9 @@ const czechBookLanguageManualDictionary = {
29897
26339
  4. **Skládání místo jednoho velkého agenta**:
29898
26340
  Na specializované odpovědnosti použijte \`TEAM\` nebo \`IMPORT\`.
29899
26341
  Kompromis: režie s koordinací, výrazně lepší modularita a znovupoužitelnost.
29900
- 5. **Řízená paměť**:
29901
- Pokud používáte \`MEMORY\`, popište, co se pamatovat má a co v žádném případě ne.
29902
- Kompromis: přísnější návrh pravidel, lepší soukromí i kvalita zapamatovaného.
26342
+ 5. **Řízená práce s daty**:
26343
+ Pokud používáte \`USE PRIVACY\`, popište, co smí a co v žádném případě nesmí opustit konverzaci.
26344
+ Kompromis: přísnější návrh pravidel, lepší soukromí i kvalita odpovědí.
29903
26345
  `),
29904
26346
  },
29905
26347
  primitives: {
@@ -29930,7 +26372,7 @@ const czechBookLanguageManualDictionary = {
29930
26372
  3. **Přidejte oporu ve znalostech**
29931
26373
  Přidejte commitmenty \`KNOWLEDGE\` (přímý text, nebo lokální či importovatelné zdroje).
29932
26374
  4. **Přidejte schopnosti**
29933
- Přidejte jen ty commitmenty \`USE*\` a \`MEMORY\`, které agent opravdu potřebuje.
26375
+ Přidejte jen ty commitmenty \`USE*\`, které agent opravdu potřebuje.
29934
26376
  5. **Doplňte profilová metadata**
29935
26377
  Přidejte \`META DESCRIPTION\`, \`META AVATAR\` / \`META VISUAL\` nebo \`META IMAGE\`, \`META INPUT PLACEHOLDER\`, \`META THINKING MESSAGE\` a případná upozornění.
29936
26378
  6. **Připravte první interakci**
@@ -29983,7 +26425,7 @@ const czechBookLanguageManualDictionary = {
29983
26425
  capabilities: {
29984
26426
  title: 'Commitmenty USE',
29985
26427
  body: spaceTrim$1(`
29986
- Commitmenty \`USE*\` zapínají schopnosti (vyhledávání, prohlížeč, napojení na projekt, e-mail, generování obrázků a další).
26428
+ Commitmenty \`USE*\` zapínají schopnosti (napojení na projekt, kalendář, generování obrázků a další).
29987
26429
  Zpřístupňují běhové nástroje a doplňují pokyny do systémové zprávy.
29988
26430
  `),
29989
26431
  },
@@ -30037,16 +26479,6 @@ const czechBookLanguageManualDictionary = {
30037
26479
  '`CLOSED` brání tomu, aby se agent upravoval během konverzace.',
30038
26480
  ],
30039
26481
  },
30040
- 'tool-using-browser-search-agent': {
30041
- title: 'Agent s nástroji (prohlížeč a vyhledávač)',
30042
- goal: 'Umožnit rešerši na internetu s jasnou prací se zdroji.',
30043
- walkthrough: [
30044
- '`USE SEARCH ENGINE` zpřístupní vyhledávání na webu a volitelné pokyny k němu.',
30045
- '`USE BROWSER` zapne stahování adres a interaktivní procházení webu.',
30046
- 'Commitmenty `RULE` dělají požadavky na spolehlivost výslovnými a opakovatelnými.',
30047
- 'Tento vzor se hodí pro agenty na aktuální dění a ověřování faktů.',
30048
- ],
30049
- },
30050
26482
  'rule-and-knowledge-agent': {
30051
26483
  title: 'Agent s RULE a KNOWLEDGE',
30052
26484
  goal: 'Opřít odpovědi o výslovná omezení a připravené zdroje.',
@@ -30057,16 +26489,6 @@ const czechBookLanguageManualDictionary = {
30057
26489
  'Tento vzor použijte pro compliance, podporu a interní postupy.',
30058
26490
  ],
30059
26491
  },
30060
- 'memory-agent-with-long-term-memory': {
30061
- title: 'Agent s dlouhodobou pamětí (MEMORY)',
30062
- goal: 'Uchovat preference uživatele napříč konverzacemi.',
30063
- walkthrough: [
30064
- '`MEMORY` přidá běhové nástroje paměti a příslušné pokyny do systémové zprávy.',
30065
- 'Commitmenty `RULE` zúží, co se smí pamatovat, a snižují tak rizika pro soukromí.',
30066
- 'V Agents Serveru je paměť vedená za běhu a je vázaná na konkrétního uživatele.',
30067
- 'Hodí se pro asistenty, kteří si musí držet kontext v čase.',
30068
- ],
30069
- },
30070
26492
  'use-project-integration-agent': {
30071
26493
  title: 'Napojení na projekt (USE PROJECT)',
30072
26494
  goal: 'Pracovat s repozitářem na GitHubu přes připojení projektu.',
@@ -30111,7 +26533,7 @@ const czechBookLanguageManualDictionary = {
30111
26533
  {
30112
26534
  title: 'Neověřitelná tvrzení',
30113
26535
  dont: 'Agent odpovídá na otázky závislé na internetu bez nástrojů nebo bez uvedení zdrojů.',
30114
- doInstead: 'Přidejte `USE SEARCH ENGINE` / `USE BROWSER` a `RULE` zaměřené na citování.',
26536
+ doInstead: 'Přidejte zdroje `KNOWLEDGE` a `RULE` zaměřené na citování.',
30115
26537
  },
30116
26538
  {
30117
26539
  title: 'Chybějící mantinely',
@@ -30123,11 +26545,6 @@ const czechBookLanguageManualDictionary = {
30123
26545
  dont: 'Dlouhé řetězce `FROM` bez vysvětlení, proč je každý rodič potřeba.',
30124
26546
  doInstead: 'Držte dědičnost mělkou a pro znovupoužití sáhněte po cíleném IMPORT nebo TEAM.',
30125
26547
  },
30126
- {
30127
- title: 'Nebezpečné zacházení s pamětí',
30128
- dont: 'Ukládání každého detailu do paměti bez jakýchkoli hranic.',
30129
- doInstead: 'Doplňte `MEMORY` výslovnými pravidly, co se smí uchovávat.',
30130
- },
30131
26548
  ],
30132
26549
  tutorialSections: {
30133
26550
  serverAgentsHint: 'Vyjděte z některého z ukázkových agentů tohoto serveru výše a ponechte jen ty commitmenty, které nový agent potřebuje.',
@@ -30198,7 +26615,7 @@ const englishBookLanguageManualDictionary = {
30198
26615
  2. **Behavior layer**:
30199
26616
  \`RULE\`, \`KNOWLEDGE\`, \`WRITING SAMPLE\`, \`WRITING RULES\`, \`LANGUAGE\`, \`GOAL\`, and related commitments.
30200
26617
  3. **Capability layer**:
30201
- \`USE*\`, \`MEMORY\`, and other tooling commitments exposing runtime abilities.
26618
+ \`USE*\` and other tooling commitments exposing runtime abilities.
30202
26619
  4. **Composition layer**:
30203
26620
  \`FROM\` inheritance, \`IMPORT\` reuse, and \`TEAM\` delegation.
30204
26621
  `),
@@ -30220,8 +26637,8 @@ const englishBookLanguageManualDictionary = {
30220
26637
  4. **Composition over monoliths**:
30221
26638
  Use \`TEAM\`/\`IMPORT\` for specialized responsibilities.
30222
26639
  Tradeoff: orchestration overhead, stronger modularity and reuse.
30223
- 5. **Controlled memory**:
30224
- If using \`MEMORY\`, define what must and must not be remembered.
26640
+ 5. **Controlled data access**:
26641
+ If using \`USE PRIVACY\`, define what must and must not leave the conversation.
30225
26642
  Tradeoff: stricter policy design, better privacy and signal quality.
30226
26643
  `),
30227
26644
  },
@@ -30253,7 +26670,7 @@ const englishBookLanguageManualDictionary = {
30253
26670
  3. **Add grounding**
30254
26671
  Add \`KNOWLEDGE\` commitments (inline text or local/importable sources).
30255
26672
  4. **Add capabilities**
30256
- Add only necessary \`USE*\` and/or \`MEMORY\` commitments.
26673
+ Add only necessary \`USE*\` commitments.
30257
26674
  5. **Set profile metadata**
30258
26675
  Add \`META DESCRIPTION\`, \`META AVATAR\` / \`META VISUAL\` or \`META IMAGE\`, \`META INPUT PLACEHOLDER\`, \`META THINKING MESSAGE\`, and disclaimers if needed.
30259
26676
  6. **Add first interaction**
@@ -30306,7 +26723,7 @@ const englishBookLanguageManualDictionary = {
30306
26723
  capabilities: {
30307
26724
  title: 'USE commitments',
30308
26725
  body: spaceTrim$1(`
30309
- \`USE*\` commitments enable capabilities (search, browser, project integration, email, image generation, etc.).
26726
+ \`USE*\` commitments enable capabilities (project integration, calendar, image generation, etc.).
30310
26727
  They expose runtime tools and system-message guidance used during execution.
30311
26728
  `),
30312
26729
  },
@@ -30360,16 +26777,6 @@ const englishBookLanguageManualDictionary = {
30360
26777
  '`CLOSED` prevents conversational self-modification.',
30361
26778
  ],
30362
26779
  },
30363
- 'tool-using-browser-search-agent': {
30364
- title: 'Tool-using agent (Browser + Search engine)',
30365
- goal: 'Enable internet research with clear sourcing behavior.',
30366
- walkthrough: [
30367
- '`USE SEARCH ENGINE` provides web search tooling and optional search instructions.',
30368
- '`USE BROWSER` enables URL fetching and interactive browsing tools.',
30369
- '`RULE` commitments make reliability behavior explicit and repeatable.',
30370
- 'This pattern is ideal for current-events and fact-checking agents.',
30371
- ],
30372
- },
30373
26780
  'rule-and-knowledge-agent': {
30374
26781
  title: 'Agent with RULE and KNOWLEDGE',
30375
26782
  goal: 'Ground responses in explicit constraints and curated sources.',
@@ -30380,16 +26787,6 @@ const englishBookLanguageManualDictionary = {
30380
26787
  'Use this pattern for compliance, support, and internal procedures.',
30381
26788
  ],
30382
26789
  },
30383
- 'memory-agent-with-long-term-memory': {
30384
- title: 'MEMORY agent with long-term memory',
30385
- goal: 'Persist user preferences across conversations.',
30386
- walkthrough: [
30387
- '`MEMORY` adds runtime memory tools and memory-specific system guidance.',
30388
- '`RULE` commitments narrow what should be remembered to reduce privacy risks.',
30389
- 'In Agents Server, memory is runtime-backed and user-scoped.',
30390
- 'Use this for assistants that must preserve context over time.',
30391
- ],
30392
- },
30393
26790
  'use-project-integration-agent': {
30394
26791
  title: 'USE PROJECT external integration',
30395
26792
  goal: 'Work with a GitHub repository through a connected project integration.',
@@ -30434,7 +26831,7 @@ const englishBookLanguageManualDictionary = {
30434
26831
  {
30435
26832
  title: 'Unverifiable claims',
30436
26833
  dont: 'The agent answers internet-dependent questions without tools or without citing sources.',
30437
- doInstead: 'Add `USE SEARCH ENGINE` / `USE BROWSER` and a citation-oriented `RULE`.',
26834
+ doInstead: 'Add `KNOWLEDGE` sources and a citation-oriented `RULE`.',
30438
26835
  },
30439
26836
  {
30440
26837
  title: 'Missing guardrails',
@@ -30446,11 +26843,6 @@ const englishBookLanguageManualDictionary = {
30446
26843
  dont: 'Using deep `FROM` chains without documenting why each parent is needed.',
30447
26844
  doInstead: 'Keep inheritance shallow and use focused IMPORT/TEAM composition for reuse.',
30448
26845
  },
30449
- {
30450
- title: 'Unsafe memory usage',
30451
- dont: 'Storing every detail in memory without boundaries.',
30452
- doInstead: 'Pair `MEMORY` with explicit rules about what is allowed to persist.',
30453
- },
30454
26846
  ],
30455
26847
  tutorialSections: {
30456
26848
  serverAgentsHint: 'Use one of the selected server-agent examples above as your starting point, then retain only the commitments needed for the new agent.',
@@ -30928,22 +27320,13 @@ const COMPOSITION_COMMITMENT_TYPES = new Set(['FROM', 'IMPORT', 'IMPORTS', 'TEAM
30928
27320
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
30929
27321
  */
30930
27322
  const TOOLING_COMMITMENT_TYPES = new Set([
30931
- 'USE BROWSER',
30932
- 'USE DEEPSEARCH',
30933
- 'USE SEARCH ENGINE',
30934
- 'USE SEARCH',
30935
- 'USE SPAWN',
30936
- 'USE EMAIL',
30937
27323
  'USE POPUP',
30938
- 'USE TIME',
30939
27324
  'USE USER LOCATION',
30940
27325
  'USE PROJECT',
30941
27326
  'USE CALENDAR',
30942
27327
  'USE IMAGE GENERATOR',
30943
27328
  'USE MCP',
30944
27329
  'USE PRIVACY',
30945
- 'MEMORY',
30946
- 'MEMORIES',
30947
27330
  ]);
30948
27331
  /**
30949
27332
  * Commitment types that primarily define agent profile metadata.
@@ -30953,7 +27336,6 @@ const TOOLING_COMMITMENT_TYPES = new Set([
30953
27336
  const PROFILE_COMMITMENT_TYPES = new Set([
30954
27337
  'GOAL',
30955
27338
  'GOALS',
30956
- 'META',
30957
27339
  'META AVATAR',
30958
27340
  'META VISUAL',
30959
27341
  'META IMAGE',
@@ -30961,6 +27343,8 @@ const PROFILE_COMMITMENT_TYPES = new Set([
30961
27343
  'META DOMAIN',
30962
27344
  'META DESCRIPTION',
30963
27345
  'META DISCLAIMER',
27346
+ 'META FULLNAME',
27347
+ 'META ID',
30964
27348
  'META INPUT PLACEHOLDER',
30965
27349
  'META THINKING MESSAGE',
30966
27350
  'META VISIBILITY',
@@ -32803,6 +29187,59 @@ const expectCommandParser = {
32803
29187
  },
32804
29188
  };
32805
29189
 
29190
+ /**
29191
+ * Normalizes a given text to camelCase format.
29192
+ *
29193
+ * Note: [🔂] This function is idempotent.
29194
+ *
29195
+ * @param text The text to be normalized.
29196
+ * @param _isFirstLetterCapital Whether the first letter should be capitalized.
29197
+ * @returns The camelCase formatted string.
29198
+ * @example 'helloWorld'
29199
+ * @example 'iLovePromptbook'
29200
+ *
29201
+ * @public exported from `@promptbook/utils`
29202
+ */
29203
+ function normalizeTo_camelCase(text, _isFirstLetterCapital = false) {
29204
+ let charType;
29205
+ let lastCharType = null;
29206
+ let normalizedName = '';
29207
+ for (const char of text) {
29208
+ let normalizedChar;
29209
+ if (/^[a-z]$/.test(char)) {
29210
+ charType = 'LOWERCASE';
29211
+ normalizedChar = char;
29212
+ }
29213
+ else if (/^[A-Z]$/.test(char)) {
29214
+ charType = 'UPPERCASE';
29215
+ normalizedChar = char.toLowerCase();
29216
+ }
29217
+ else if (/^[0-9]$/.test(char)) {
29218
+ charType = 'NUMBER';
29219
+ normalizedChar = char;
29220
+ }
29221
+ else {
29222
+ charType = 'OTHER';
29223
+ normalizedChar = '';
29224
+ }
29225
+ if (!lastCharType) {
29226
+ if (_isFirstLetterCapital) {
29227
+ normalizedChar = normalizedChar.toUpperCase(); //TODO: DRY
29228
+ }
29229
+ }
29230
+ else if (charType !== lastCharType &&
29231
+ !(charType === 'LOWERCASE' && lastCharType === 'UPPERCASE') &&
29232
+ !(lastCharType === 'NUMBER') &&
29233
+ !(charType === 'NUMBER')) {
29234
+ normalizedChar = normalizedChar.toUpperCase(); //TODO: [🌺] DRY
29235
+ }
29236
+ normalizedName += normalizedChar;
29237
+ lastCharType = charType;
29238
+ }
29239
+ return normalizedName;
29240
+ }
29241
+ // TODO: [🌺] Use some intermediate util splitWords
29242
+
32806
29243
  /**
32807
29244
  * Removes quotes from a string
32808
29245
  *
@@ -38393,6 +34830,40 @@ class OpenAiAgentKitExecutionToolsOutputTypeMapper {
38393
34830
  }
38394
34831
  }
38395
34832
 
34833
+ /**
34834
+ * Marker property stored inside serialized tool-execution envelopes.
34835
+ *
34836
+ * @private internal tool-execution transport
34837
+ */
34838
+ const TOOL_EXECUTION_ENVELOPE_MARKER = '__promptbookToolExecutionEnvelope';
34839
+ /**
34840
+ * Parses one serialized tool-execution envelope when present.
34841
+ *
34842
+ * @private internal tool-execution transport
34843
+ */
34844
+ function parseToolExecutionEnvelope(rawValue) {
34845
+ if (typeof rawValue !== 'string') {
34846
+ return null;
34847
+ }
34848
+ try {
34849
+ const parsedValue = JSON.parse(rawValue);
34850
+ if (!parsedValue ||
34851
+ typeof parsedValue !== 'object' ||
34852
+ parsedValue[TOOL_EXECUTION_ENVELOPE_MARKER] !== true ||
34853
+ typeof parsedValue.assistantMessage !== 'string') {
34854
+ return null;
34855
+ }
34856
+ return {
34857
+ assistantMessage: parsedValue.assistantMessage,
34858
+ toolResult: parsedValue.toolResult,
34859
+ };
34860
+ }
34861
+ catch (_a) {
34862
+ return null;
34863
+ }
34864
+ }
34865
+ // Note: [💞] Ignore a discrepancy between file name and entity name
34866
+
38396
34867
  /**
38397
34868
  * Builds a tool invocation script that injects hidden runtime context into tool args.
38398
34869
  *
@@ -38464,7 +34935,7 @@ const loadOpenAiAgentsModule = createLazyModuleLoader(() => import('@openai/agen
38464
34935
  */
38465
34936
  const DEFAULT_DEEP_SEARCH_MODEL_NAME = 'o4-mini-deep-research';
38466
34937
  /**
38467
- * Tool name used by the Book commitment-backed DeepSearch capability.
34938
+ * Tool name used by the DeepSearch capability.
38468
34939
  */
38469
34940
  const DEEP_SEARCH_TOOL_NAME = 'deep_search';
38470
34941
  /**
@@ -38734,7 +35205,7 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
38734
35205
  };
38735
35206
  }
38736
35207
  /**
38737
- * Creates the native Agent SDK tool used for `USE DEEPSEARCH`.
35208
+ * Creates the native Agent SDK tool used for the DeepSearch capability.
38738
35209
  */
38739
35210
  async createDeepSearchAgentKitTool(toolDefinition) {
38740
35211
  const { Agent: AgentFromKit, webSearchTool } = await loadOpenAiAgentsModule();
@@ -46846,7 +43317,7 @@ class Agent extends AgentLlmExecutionTools {
46846
43317
  this.links = [];
46847
43318
  /**
46848
43319
  * Capabilities of the agent
46849
- * This is parsed from commitments like USE BROWSER, USE SEARCH ENGINE, KNOWLEDGE, etc.
43320
+ * This is parsed from commitments like USE CALENDAR, USE PROJECT, KNOWLEDGE, etc.
46850
43321
  */
46851
43322
  this.capabilities = [];
46852
43323
  /**