@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.
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.112.0-26`).
18
+ * It follows semantic versioning (e.g., `0.112.0-30`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.112.0-29",
3
+ "version": "0.112.0-31",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -98,7 +98,7 @@
98
98
  "module": "./esm/index.es.js",
99
99
  "typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
100
100
  "peerDependencies": {
101
- "@promptbook/core": "0.112.0-29"
101
+ "@promptbook/core": "0.112.0-31"
102
102
  },
103
103
  "dependencies": {
104
104
  "@mozilla/readability": "0.6.0",
package/umd/index.umd.js CHANGED
@@ -50,7 +50,7 @@
50
50
  * @generated
51
51
  * @see https://github.com/webgptorg/promptbook
52
52
  */
53
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-29';
53
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-31';
54
54
  /**
55
55
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
56
56
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -16263,7 +16263,11 @@
16263
16263
  *
16264
16264
  * @private internal constant for `aggregateUseCommitmentSystemMessages`
16265
16265
  */
16266
- const AGGREGATED_USE_COMMITMENT_TYPES = ['USE BROWSER', 'USE SEARCH ENGINE', 'USE TIME'];
16266
+ const AGGREGATED_USE_COMMITMENT_TYPES = [
16267
+ 'USE BROWSER',
16268
+ 'USE SEARCH ENGINE',
16269
+ 'USE TIME',
16270
+ ];
16267
16271
  /**
16268
16272
  * Prefix used for temporary in-system-message placeholders that preserve the first-occurrence position of aggregated `USE` sections.
16269
16273
  *
@@ -31225,6 +31229,7 @@
31225
31229
 
31226
31230
  - Decide what the agent should learn from this interaction.
31227
31231
  - Append new commitments at the end of the agent source.
31232
+ - Return only newly learned commitments, never repeat commitments that are already present.
31228
31233
  - Do not modify the current agent source, just return new commitments (KNOWLEDGE, RULE, etc.).
31229
31234
  - If there is nothing new to learn, return empty book code block
31230
31235
  - Wrap the commitments in a book code block.
@@ -31277,10 +31282,42 @@
31277
31282
  */
31278
31283
  appendToAgentSource(section) {
31279
31284
  const currentSource = this.options.getAgentSource();
31280
- const newSource = padBook(validateBook(_spaceTrim.spaceTrim(currentSource) + section));
31285
+ const normalizedSection = normalizeBookSection(section);
31286
+ if (!normalizedSection) {
31287
+ return;
31288
+ }
31289
+ if (containsNormalizedBookSection(currentSource, normalizedSection)) {
31290
+ return;
31291
+ }
31292
+ const newSource = padBook(validateBook(`${normalizeBookSection(currentSource)}\n\n${normalizedSection}`));
31281
31293
  this.options.updateAgentSource(newSource);
31282
31294
  }
31283
31295
  }
31296
+ /**
31297
+ * Normalizes one book fragment for deduplication and append composition.
31298
+ *
31299
+ * @param section Raw fragment from self-learning workflow.
31300
+ * @returns Trimmed fragment, or empty string when nothing remains.
31301
+ * @private function of Agent
31302
+ */
31303
+ function normalizeBookSection(section) {
31304
+ return _spaceTrim.spaceTrim(section).replace(/\r\n/g, '\n');
31305
+ }
31306
+ /**
31307
+ * Checks whether one normalized fragment already exists inside the current source.
31308
+ *
31309
+ * @param agentSource Current source.
31310
+ * @param normalizedSection Candidate fragment expected to be normalized first.
31311
+ * @returns True when appending would duplicate an existing fragment.
31312
+ * @private function of Agent
31313
+ */
31314
+ function containsNormalizedBookSection(agentSource, normalizedSection) {
31315
+ if (!normalizedSection) {
31316
+ return true;
31317
+ }
31318
+ const normalizedSource = normalizeBookSection(agentSource);
31319
+ return normalizedSource.includes(normalizedSection);
31320
+ }
31284
31321
  /**
31285
31322
  * Determines whether the interaction runs in OpenAI-compatible JSON schema mode.
31286
31323
  *