@promptbook/node 0.112.0-30 → 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-29`).
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/node",
3
- "version": "0.112.0-30",
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,
@@ -96,7 +96,7 @@
96
96
  "module": "./esm/index.es.js",
97
97
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
98
98
  "peerDependencies": {
99
- "@promptbook/core": "0.112.0-30"
99
+ "@promptbook/core": "0.112.0-31"
100
100
  },
101
101
  "dependencies": {
102
102
  "@mozilla/readability": "0.6.0",
package/umd/index.umd.js CHANGED
@@ -48,7 +48,7 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-30';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-31';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -34128,6 +34128,7 @@
34128
34128
 
34129
34129
  - Decide what the agent should learn from this interaction.
34130
34130
  - Append new commitments at the end of the agent source.
34131
+ - Return only newly learned commitments, never repeat commitments that are already present.
34131
34132
  - Do not modify the current agent source, just return new commitments (KNOWLEDGE, RULE, etc.).
34132
34133
  - If there is nothing new to learn, return empty book code block
34133
34134
  - Wrap the commitments in a book code block.
@@ -34180,10 +34181,42 @@
34180
34181
  */
34181
34182
  appendToAgentSource(section) {
34182
34183
  const currentSource = this.options.getAgentSource();
34183
- const newSource = padBook(validateBook(_spaceTrim.spaceTrim(currentSource) + section));
34184
+ const normalizedSection = normalizeBookSection(section);
34185
+ if (!normalizedSection) {
34186
+ return;
34187
+ }
34188
+ if (containsNormalizedBookSection(currentSource, normalizedSection)) {
34189
+ return;
34190
+ }
34191
+ const newSource = padBook(validateBook(`${normalizeBookSection(currentSource)}\n\n${normalizedSection}`));
34184
34192
  this.options.updateAgentSource(newSource);
34185
34193
  }
34186
34194
  }
34195
+ /**
34196
+ * Normalizes one book fragment for deduplication and append composition.
34197
+ *
34198
+ * @param section Raw fragment from self-learning workflow.
34199
+ * @returns Trimmed fragment, or empty string when nothing remains.
34200
+ * @private function of Agent
34201
+ */
34202
+ function normalizeBookSection(section) {
34203
+ return _spaceTrim.spaceTrim(section).replace(/\r\n/g, '\n');
34204
+ }
34205
+ /**
34206
+ * Checks whether one normalized fragment already exists inside the current source.
34207
+ *
34208
+ * @param agentSource Current source.
34209
+ * @param normalizedSection Candidate fragment expected to be normalized first.
34210
+ * @returns True when appending would duplicate an existing fragment.
34211
+ * @private function of Agent
34212
+ */
34213
+ function containsNormalizedBookSection(agentSource, normalizedSection) {
34214
+ if (!normalizedSection) {
34215
+ return true;
34216
+ }
34217
+ const normalizedSource = normalizeBookSection(agentSource);
34218
+ return normalizedSource.includes(normalizedSection);
34219
+ }
34187
34220
  /**
34188
34221
  * Determines whether the interaction runs in OpenAI-compatible JSON schema mode.
34189
34222
  *