@agenr/agenr-plugin 2.1.0 → 3.1.0

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.
@@ -7,10 +7,12 @@ import {
7
7
  BEFORE_TURN_DEBUG_ARTIFACT_DEFAULT_TOP_K,
8
8
  BEFORE_TURN_DEBUG_ARTIFACT_MAX_TOP_K,
9
9
  RECALL_DEBUG_ARTIFACT_DEFAULT_TOP_K,
10
- RECALL_DEBUG_ARTIFACT_MAX_TOP_K,
10
+ RECALL_DEBUG_ARTIFACT_MAX_TOP_K
11
+ } from "./chunk-GELCEVFA.js";
12
+ import {
11
13
  formatAgenrBeforeTurnRecall,
12
14
  runBeforeTurn
13
- } from "./chunk-IMQIJPIP.js";
15
+ } from "./chunk-V5CDMHRN.js";
14
16
  import {
15
17
  CLAIM_KEY_SOURCES,
16
18
  CLAIM_KEY_STATUSES,
@@ -39,10 +41,10 @@ import {
39
41
  resolveEmbeddingModel,
40
42
  resolveModel,
41
43
  runUnifiedRecall
42
- } from "./chunk-7TDALVPY.js";
44
+ } from "./chunk-NNO2V4GH.js";
43
45
  import {
44
46
  recall
45
- } from "./chunk-6T5RXGIR.js";
47
+ } from "./chunk-5LADPJ4C.js";
46
48
 
47
49
  // src/internal-eval-server.ts
48
50
  import process from "process";
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  projectClaimCentricRecallEntry,
3
- runProcedureRecall
4
- } from "./chunk-7TDALVPY.js";
3
+ runProcedureRecall,
4
+ truncate
5
+ } from "./chunk-NNO2V4GH.js";
5
6
  import {
6
7
  recall
7
- } from "./chunk-6T5RXGIR.js";
8
+ } from "./chunk-5LADPJ4C.js";
8
9
 
9
10
  // src/app/before-turn/service.ts
10
11
  var DEFAULT_MAX_DURABLE_ENTRIES = 1;
@@ -355,7 +356,7 @@ function buildCurrentTurnOnlyQuery(currentTurnText, maxChars) {
355
356
  if (maxChars <= 0) {
356
357
  return void 0;
357
358
  }
358
- const query = truncate(normalizeWhitespace(currentTurnText), maxChars);
359
+ const query = truncate2(normalizeWhitespace(currentTurnText), maxChars);
359
360
  return query.length > 0 ? query : void 0;
360
361
  }
361
362
  function buildContextualAnchorQuery(currentTurnQuery, recentTurns, maxChars) {
@@ -369,7 +370,7 @@ function buildContextualAnchorQuery(currentTurnQuery, recentTurns, maxChars) {
369
370
  if (remaining <= 0) {
370
371
  return void 0;
371
372
  }
372
- return `${currentTurnQuery}${separator}${prefix}${truncate(anchor, remaining)}`;
373
+ return `${currentTurnQuery}${separator}${prefix}${truncate2(anchor, remaining)}`;
373
374
  }
374
375
  function buildCompactContextAnchor(recentTurns) {
375
376
  const recentTurn = recentTurns[recentTurns.length - 1];
@@ -377,7 +378,7 @@ function buildCompactContextAnchor(recentTurns) {
377
378
  return void 0;
378
379
  }
379
380
  const normalized = normalizeWhitespace(recentTurn.text);
380
- return normalized.length > 0 ? truncate(normalized, MAX_CONTEXT_ANCHOR_CHARS) : void 0;
381
+ return normalized.length > 0 ? truncate2(normalized, MAX_CONTEXT_ANCHOR_CHARS) : void 0;
381
382
  }
382
383
  function requiresContextualQuery(currentTurnText) {
383
384
  const normalizedTurn = normalizeWhitespace(currentTurnText);
@@ -401,10 +402,10 @@ function shouldAllowContextualFallback(currentTurnText, recentTurns) {
401
402
  function buildProcedureQuery(currentTurnText, recentTurns, maxChars) {
402
403
  const normalizedCurrentTurn = normalizeWhitespace(currentTurnText);
403
404
  if (normalizedCurrentTurn.length > 0) {
404
- return truncate(normalizedCurrentTurn, maxChars);
405
+ return truncate2(normalizedCurrentTurn, maxChars);
405
406
  }
406
407
  const recentUserTurn = [...recentTurns].reverse().find((turn) => turn.role === "user");
407
- return recentUserTurn ? truncate(normalizeWhitespace(recentUserTurn.text), maxChars) : void 0;
408
+ return recentUserTurn ? truncate2(normalizeWhitespace(recentUserTurn.text), maxChars) : void 0;
408
409
  }
409
410
  function applyDirectnessSelection(currentTurnText, items) {
410
411
  if (items.length === 0) {
@@ -748,7 +749,7 @@ function normalizeOptionalString(value) {
748
749
  function normalizeWhitespace(value) {
749
750
  return value.replace(/\s+/g, " ").trim();
750
751
  }
751
- function truncate(value, maxChars) {
752
+ function truncate2(value, maxChars) {
752
753
  if (maxChars <= 0) {
753
754
  return "";
754
755
  }
@@ -764,7 +765,34 @@ function formatErrorMessage(error) {
764
765
  return String(error);
765
766
  }
766
767
 
767
- // src/adapters/openclaw/format/memory-context.ts
768
+ // src/adapters/shared/injection/entry-lines.ts
769
+ var MAX_CONTENT_CHARS = 220;
770
+ function formatInjectionEntryHeader(item) {
771
+ const metadata = [
772
+ `rank ${item.rank}`,
773
+ item.entry.id,
774
+ item.entry.type,
775
+ item.entry.expiry,
776
+ `importance ${item.entry.importance}`,
777
+ item.score !== void 0 ? `score ${item.score.toFixed(2)}` : void 0
778
+ ].filter((value) => value !== void 0);
779
+ return `- [${metadata.join(" | ")}] ${item.entry.subject}`;
780
+ }
781
+ function formatInjectionEntryBodyLines(item) {
782
+ const lines = [` ${truncate(item.entry.content.trim(), MAX_CONTENT_CHARS)}`];
783
+ lines.push(` why: ${item.whySurfaced.summary}`);
784
+ const metadata = [
785
+ item.entry.tags.length > 0 ? `tags: ${item.entry.tags.join(", ")}` : void 0,
786
+ item.freshnessLabel ? `freshness: ${item.freshnessLabel}` : void 0,
787
+ item.provenanceSummary ? `provenance: ${truncate(item.provenanceSummary, MAX_CONTENT_CHARS)}` : void 0
788
+ ].filter((value) => value !== void 0);
789
+ if (metadata.length > 0) {
790
+ lines.push(` ${metadata.join(" | ")}`);
791
+ }
792
+ return lines;
793
+ }
794
+
795
+ // src/adapters/shared/injection/memory-context.ts
768
796
  var AGENR_MEMORY_CONTEXT_BLOCK_RE = /<agenr-memory-context>[\s\S]*?<\/agenr-memory-context>/giu;
769
797
  var AGENR_MEMORY_CONTEXT_OPEN_RE = /<agenr-memory-context>/giu;
770
798
  var AGENR_MEMORY_CONTEXT_CLOSE_RE = /<\/agenr-memory-context>/giu;
@@ -786,8 +814,8 @@ function stripAgenrMemoryContext(content) {
786
814
  return content.replace(AGENR_MEMORY_CONTEXT_BLOCK_RE, " ").replace(AGENR_MEMORY_CONTEXT_OPEN_RE, " ").replace(AGENR_MEMORY_CONTEXT_CLOSE_RE, " ").replace(AGENR_MEMORY_CONTEXT_NOTE_RE, " ");
787
815
  }
788
816
 
789
- // src/adapters/openclaw/format/before-turn-format.ts
790
- var MAX_CONTENT_CHARS = 220;
817
+ // src/adapters/shared/injection/before-turn-format.ts
818
+ var MAX_CONTENT_CHARS2 = 220;
791
819
  function formatAgenrBeforeTurnRecall(patch) {
792
820
  if (patch.durableMemory.length === 0 && !patch.procedure) {
793
821
  return "";
@@ -800,8 +828,8 @@ function formatAgenrBeforeTurnRecall(patch) {
800
828
  if (patch.durableMemory.length > 0) {
801
829
  lines.push("### Relevant Durable Memory");
802
830
  for (const item of patch.durableMemory) {
803
- lines.push(formatEntryHeader(item));
804
- lines.push(...formatEntryBodyLines(item));
831
+ lines.push(formatInjectionEntryHeader(item));
832
+ lines.push(...formatInjectionEntryBodyLines(item));
805
833
  }
806
834
  lines.push("");
807
835
  }
@@ -813,30 +841,6 @@ function formatAgenrBeforeTurnRecall(patch) {
813
841
  }
814
842
  return wrapAgenrMemoryContext(lines.join("\n").trim());
815
843
  }
816
- function formatEntryHeader(item) {
817
- const metadata = [
818
- `rank ${item.rank}`,
819
- item.entry.id,
820
- item.entry.type,
821
- item.entry.expiry,
822
- `importance ${item.entry.importance}`,
823
- `score ${item.score.toFixed(2)}`
824
- ];
825
- return `- [${metadata.join(" | ")}] ${item.entry.subject}`;
826
- }
827
- function formatEntryBodyLines(item) {
828
- const lines = [` ${truncate2(item.entry.content.trim(), MAX_CONTENT_CHARS)}`];
829
- lines.push(` why: ${item.whySurfaced.summary}`);
830
- const metadata = [
831
- item.entry.tags.length > 0 ? `tags: ${item.entry.tags.join(", ")}` : void 0,
832
- item.freshnessLabel ? `freshness: ${item.freshnessLabel}` : void 0,
833
- item.provenanceSummary ? `provenance: ${truncate2(item.provenanceSummary, MAX_CONTENT_CHARS)}` : void 0
834
- ].filter((value) => value !== void 0);
835
- if (metadata.length > 0) {
836
- lines.push(` ${metadata.join(" | ")}`);
837
- }
838
- return lines;
839
- }
840
844
  function formatProcedureHeader(suggestion) {
841
845
  const metadata = [
842
846
  suggestion.procedure.id,
@@ -848,39 +852,23 @@ function formatProcedureHeader(suggestion) {
848
852
  return `- [${metadata.join(" | ")}] ${suggestion.procedure.title}`;
849
853
  }
850
854
  function formatProcedureBodyLines(suggestion) {
851
- const lines = [` goal: ${truncate2(suggestion.procedure.goal.trim(), MAX_CONTENT_CHARS)}`];
855
+ const lines = [` goal: ${truncate(suggestion.procedure.goal.trim(), MAX_CONTENT_CHARS2)}`];
852
856
  lines.push(` why: ${suggestion.whySurfaced.summary}`);
853
857
  if (suggestion.procedure.when_to_use.length > 0) {
854
- lines.push(` when to use: ${truncate2(suggestion.procedure.when_to_use.join("; "), MAX_CONTENT_CHARS)}`);
858
+ lines.push(` when to use: ${truncate(suggestion.procedure.when_to_use.join("; "), MAX_CONTENT_CHARS2)}`);
855
859
  }
856
860
  if (suggestion.procedure.verification.length > 0) {
857
- lines.push(` verification: ${truncate2(suggestion.procedure.verification.join("; "), MAX_CONTENT_CHARS)}`);
861
+ lines.push(` verification: ${truncate(suggestion.procedure.verification.join("; "), MAX_CONTENT_CHARS2)}`);
858
862
  }
859
863
  return lines;
860
864
  }
861
- function truncate2(value, maxChars) {
862
- if (value.length <= maxChars) {
863
- return value;
864
- }
865
- return `${value.slice(0, maxChars - 3).trimEnd()}...`;
866
- }
867
-
868
- // src/app/debug-artifacts/before-turn.ts
869
- var BEFORE_TURN_DEBUG_ARTIFACT_DEFAULT_TOP_K = 10;
870
- var BEFORE_TURN_DEBUG_ARTIFACT_MAX_TOP_K = 25;
871
-
872
- // src/app/debug-artifacts/recall.ts
873
- var RECALL_DEBUG_ARTIFACT_DEFAULT_TOP_K = 10;
874
- var RECALL_DEBUG_ARTIFACT_MAX_TOP_K = 25;
875
865
 
876
866
  export {
877
867
  runBeforeTurn,
868
+ formatInjectionEntryHeader,
869
+ formatInjectionEntryBodyLines,
878
870
  wrapAgenrMemoryContext,
879
871
  containsAgenrMemoryContext,
880
872
  stripAgenrMemoryContext,
881
- formatAgenrBeforeTurnRecall,
882
- BEFORE_TURN_DEBUG_ARTIFACT_DEFAULT_TOP_K,
883
- BEFORE_TURN_DEBUG_ARTIFACT_MAX_TOP_K,
884
- RECALL_DEBUG_ARTIFACT_DEFAULT_TOP_K,
885
- RECALL_DEBUG_ARTIFACT_MAX_TOP_K
873
+ formatAgenrBeforeTurnRecall
886
874
  };