@promptbook/remote-server 0.112.0-29 → 0.112.0-31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.es.js CHANGED
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
40
40
  * @generated
41
41
  * @see https://github.com/webgptorg/promptbook
42
42
  */
43
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-29';
43
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-31';
44
44
  /**
45
45
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
46
46
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -16253,7 +16253,11 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
16253
16253
  *
16254
16254
  * @private internal constant for `aggregateUseCommitmentSystemMessages`
16255
16255
  */
16256
- const AGGREGATED_USE_COMMITMENT_TYPES = ['USE BROWSER', 'USE SEARCH ENGINE', 'USE TIME'];
16256
+ const AGGREGATED_USE_COMMITMENT_TYPES = [
16257
+ 'USE BROWSER',
16258
+ 'USE SEARCH ENGINE',
16259
+ 'USE TIME',
16260
+ ];
16257
16261
  /**
16258
16262
  * Prefix used for temporary in-system-message placeholders that preserve the first-occurrence position of aggregated `USE` sections.
16259
16263
  *
@@ -31215,6 +31219,7 @@ class SelfLearningManager {
31215
31219
 
31216
31220
  - Decide what the agent should learn from this interaction.
31217
31221
  - Append new commitments at the end of the agent source.
31222
+ - Return only newly learned commitments, never repeat commitments that are already present.
31218
31223
  - Do not modify the current agent source, just return new commitments (KNOWLEDGE, RULE, etc.).
31219
31224
  - If there is nothing new to learn, return empty book code block
31220
31225
  - Wrap the commitments in a book code block.
@@ -31267,10 +31272,42 @@ class SelfLearningManager {
31267
31272
  */
31268
31273
  appendToAgentSource(section) {
31269
31274
  const currentSource = this.options.getAgentSource();
31270
- const newSource = padBook(validateBook(spaceTrim$1(currentSource) + section));
31275
+ const normalizedSection = normalizeBookSection(section);
31276
+ if (!normalizedSection) {
31277
+ return;
31278
+ }
31279
+ if (containsNormalizedBookSection(currentSource, normalizedSection)) {
31280
+ return;
31281
+ }
31282
+ const newSource = padBook(validateBook(`${normalizeBookSection(currentSource)}\n\n${normalizedSection}`));
31271
31283
  this.options.updateAgentSource(newSource);
31272
31284
  }
31273
31285
  }
31286
+ /**
31287
+ * Normalizes one book fragment for deduplication and append composition.
31288
+ *
31289
+ * @param section Raw fragment from self-learning workflow.
31290
+ * @returns Trimmed fragment, or empty string when nothing remains.
31291
+ * @private function of Agent
31292
+ */
31293
+ function normalizeBookSection(section) {
31294
+ return spaceTrim$1(section).replace(/\r\n/g, '\n');
31295
+ }
31296
+ /**
31297
+ * Checks whether one normalized fragment already exists inside the current source.
31298
+ *
31299
+ * @param agentSource Current source.
31300
+ * @param normalizedSection Candidate fragment expected to be normalized first.
31301
+ * @returns True when appending would duplicate an existing fragment.
31302
+ * @private function of Agent
31303
+ */
31304
+ function containsNormalizedBookSection(agentSource, normalizedSection) {
31305
+ if (!normalizedSection) {
31306
+ return true;
31307
+ }
31308
+ const normalizedSource = normalizeBookSection(agentSource);
31309
+ return normalizedSource.includes(normalizedSection);
31310
+ }
31274
31311
  /**
31275
31312
  * Determines whether the interaction runs in OpenAI-compatible JSON schema mode.
31276
31313
  *