agenr 3.0.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.
- package/CHANGELOG.md +31 -0
- package/LICENSE +21 -661
- package/README.md +48 -25
- package/dist/adapters/openclaw/index.js +192 -164
- package/dist/adapters/skeln/index.js +177 -112
- package/dist/{chunk-MYZ2CWY6.js → chunk-E2DHUFZK.js} +464 -542
- package/dist/{chunk-LAXNNWHM.js → chunk-EEEL53X4.js} +191 -12
- package/dist/{chunk-TBFAARM5.js → chunk-JSVQILB3.js} +12 -1
- package/dist/{chunk-ELR2HSVC.js → chunk-NNO2V4GH.js} +243 -0
- package/dist/{chunk-P5SB75FK.js → chunk-NOIZQRQV.js} +2 -2
- package/dist/{chunk-575MUIW5.js → chunk-V5CDMHRN.js} +14 -179
- package/dist/cli.js +3 -3
- package/dist/internal-eval-server.js +3 -3
- package/dist/internal-recall-eval-server.js +3 -3
- package/package.json +2 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
projectClaimCentricRecallEntry,
|
|
3
|
-
runProcedureRecall
|
|
4
|
-
|
|
3
|
+
runProcedureRecall,
|
|
4
|
+
truncate
|
|
5
|
+
} from "./chunk-NNO2V4GH.js";
|
|
5
6
|
import {
|
|
6
7
|
recall
|
|
7
8
|
} from "./chunk-5LADPJ4C.js";
|
|
@@ -355,7 +356,7 @@ function buildCurrentTurnOnlyQuery(currentTurnText, maxChars) {
|
|
|
355
356
|
if (maxChars <= 0) {
|
|
356
357
|
return void 0;
|
|
357
358
|
}
|
|
358
|
-
const query =
|
|
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}${
|
|
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 ?
|
|
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
|
|
405
|
+
return truncate2(normalizedCurrentTurn, maxChars);
|
|
405
406
|
}
|
|
406
407
|
const recentUserTurn = [...recentTurns].reverse().find((turn) => turn.role === "user");
|
|
407
|
-
return recentUserTurn ?
|
|
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
|
|
752
|
+
function truncate2(value, maxChars) {
|
|
752
753
|
if (maxChars <= 0) {
|
|
753
754
|
return "";
|
|
754
755
|
}
|
|
@@ -764,166 +765,6 @@ function formatErrorMessage(error) {
|
|
|
764
765
|
return String(error);
|
|
765
766
|
}
|
|
766
767
|
|
|
767
|
-
// src/adapters/shared/memory-tool-format.ts
|
|
768
|
-
var DEFAULT_RECALL_LIMIT = 10;
|
|
769
|
-
var RESULT_SUBJECT_LOG_LIMIT = 5;
|
|
770
|
-
function truncate2(value, maxChars) {
|
|
771
|
-
if (value.length <= maxChars) {
|
|
772
|
-
return value;
|
|
773
|
-
}
|
|
774
|
-
return `${value.slice(0, maxChars - 3).trimEnd()}...`;
|
|
775
|
-
}
|
|
776
|
-
function sanitizeStoreToolParams(params) {
|
|
777
|
-
return {
|
|
778
|
-
type: params.type,
|
|
779
|
-
subject: params.subject,
|
|
780
|
-
...params.importance !== void 0 ? { importance: params.importance } : {},
|
|
781
|
-
...params.expiry !== void 0 ? { expiry: params.expiry } : {},
|
|
782
|
-
...params.tags.length > 0 ? { tags: params.tags } : {},
|
|
783
|
-
contentLength: params.content.length,
|
|
784
|
-
...params.sourceContext !== void 0 ? { sourceContextLength: params.sourceContext.length } : {},
|
|
785
|
-
...params.supersedes !== void 0 ? { hasSupersedes: true } : {},
|
|
786
|
-
...params.claimKey !== void 0 ? { hasClaimKey: true } : {},
|
|
787
|
-
...params.validFrom !== void 0 ? { hasValidFrom: true } : {},
|
|
788
|
-
...params.validTo !== void 0 ? { hasValidTo: true } : {}
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
function formatRecallToolSummary(params) {
|
|
792
|
-
const parts = [`query=${JSON.stringify(truncate2(params.query, 80))}`];
|
|
793
|
-
if (params.mode) {
|
|
794
|
-
parts.push(`mode=${params.mode}`);
|
|
795
|
-
}
|
|
796
|
-
if (params.limit !== void 0 && params.limit !== DEFAULT_RECALL_LIMIT) {
|
|
797
|
-
parts.push(`limit=${params.limit}`);
|
|
798
|
-
}
|
|
799
|
-
if (params.types.length > 0) {
|
|
800
|
-
parts.push(`types=${JSON.stringify(params.types)}`);
|
|
801
|
-
}
|
|
802
|
-
if (params.tags.length > 0) {
|
|
803
|
-
parts.push(`tags=${JSON.stringify(params.tags)}`);
|
|
804
|
-
}
|
|
805
|
-
if (params.asOf) {
|
|
806
|
-
parts.push(`as_of=${JSON.stringify(params.asOf)}`);
|
|
807
|
-
}
|
|
808
|
-
return parts.join(" ");
|
|
809
|
-
}
|
|
810
|
-
function sanitizeRecallToolParams(params) {
|
|
811
|
-
return {
|
|
812
|
-
query: params.query,
|
|
813
|
-
...params.mode ? { mode: params.mode } : {},
|
|
814
|
-
...params.limit !== void 0 ? { limit: params.limit } : {},
|
|
815
|
-
...params.threshold !== void 0 ? { threshold: params.threshold } : {},
|
|
816
|
-
...params.types.length > 0 ? { types: params.types } : {},
|
|
817
|
-
...params.tags.length > 0 ? { tags: params.tags } : {},
|
|
818
|
-
...params.asOf ? { asOf: params.asOf } : {}
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
function formatUnifiedRecallLogSummary(result) {
|
|
822
|
-
const procedureCount = result.procedureCandidates.length;
|
|
823
|
-
const procedureSummary = result.procedure ? ` [procedure: ${JSON.stringify(truncate2(result.procedure.title, 80))}]` : "";
|
|
824
|
-
const entrySubjects = result.entries.map((entry) => entry.entry.subject.trim()).filter((subject) => subject.length > 0);
|
|
825
|
-
const displayed = entrySubjects.slice(0, RESULT_SUBJECT_LOG_LIMIT).map((subject) => JSON.stringify(truncate2(subject, 80)));
|
|
826
|
-
const remaining = entrySubjects.length - RESULT_SUBJECT_LOG_LIMIT;
|
|
827
|
-
const suffix = displayed.length === 0 ? "" : ` [entry subjects: ${displayed.join(", ")}${remaining > 0 ? `, ... and ${remaining} more` : ""}]`;
|
|
828
|
-
const entryEpisodeSummary = `${result.episodes.length} episode${result.episodes.length === 1 ? "" : "s"}, ${result.entries.length} entr${result.entries.length === 1 ? "y" : "ies"}`;
|
|
829
|
-
if (procedureCount === 0 && !result.procedure) {
|
|
830
|
-
return `${entryEpisodeSummary}${suffix}`;
|
|
831
|
-
}
|
|
832
|
-
return `${procedureCount} procedure candidate${procedureCount === 1 ? "" : "s"}, ${entryEpisodeSummary}${procedureSummary}${suffix}`;
|
|
833
|
-
}
|
|
834
|
-
function buildRecallToolDetails(result, extraDetails = {}) {
|
|
835
|
-
return {
|
|
836
|
-
status: "ok",
|
|
837
|
-
count: result.count,
|
|
838
|
-
...extraDetails,
|
|
839
|
-
routing: {
|
|
840
|
-
requested: result.routing.requested,
|
|
841
|
-
detectedIntent: result.routing.detectedIntent,
|
|
842
|
-
queried: result.routing.queried,
|
|
843
|
-
reason: result.routing.reason
|
|
844
|
-
},
|
|
845
|
-
...result.asOf ? { asOf: result.asOf } : {},
|
|
846
|
-
...result.timeWindow ? { timeWindow: result.timeWindow } : {},
|
|
847
|
-
...result.procedure ? {
|
|
848
|
-
procedure: {
|
|
849
|
-
id: result.procedure.id,
|
|
850
|
-
procedureKey: result.procedure.procedure_key,
|
|
851
|
-
title: result.procedure.title,
|
|
852
|
-
goal: result.procedure.goal
|
|
853
|
-
}
|
|
854
|
-
} : {},
|
|
855
|
-
procedures: result.procedureCandidates.map((candidate) => ({
|
|
856
|
-
id: candidate.procedure.id,
|
|
857
|
-
procedureKey: candidate.procedure.procedure_key,
|
|
858
|
-
title: candidate.procedure.title,
|
|
859
|
-
goal: candidate.procedure.goal,
|
|
860
|
-
score: candidate.score,
|
|
861
|
-
lexicalScore: candidate.scores.lexical,
|
|
862
|
-
vectorScore: candidate.scores.vector
|
|
863
|
-
})),
|
|
864
|
-
procedureNotices: result.procedureNotices,
|
|
865
|
-
episodes: result.episodes.map((episode) => ({
|
|
866
|
-
id: episode.episode.id,
|
|
867
|
-
source: episode.episode.source,
|
|
868
|
-
sourceId: episode.episode.sourceId,
|
|
869
|
-
startedAt: episode.episode.startedAt,
|
|
870
|
-
endedAt: episode.episode.endedAt,
|
|
871
|
-
tags: episode.episode.tags,
|
|
872
|
-
score: episode.score,
|
|
873
|
-
activityLevel: episode.episode.activityLevel,
|
|
874
|
-
summary: episode.episode.summary,
|
|
875
|
-
whyMatched: describeEpisodeWhyMatched(episode.scores.semantic, episode.scores.temporal)
|
|
876
|
-
})),
|
|
877
|
-
entries: result.entries.map((entry) => ({
|
|
878
|
-
id: entry.entry.id,
|
|
879
|
-
subject: entry.entry.subject,
|
|
880
|
-
type: entry.entry.type,
|
|
881
|
-
expiry: entry.entry.expiry,
|
|
882
|
-
importance: entry.entry.importance,
|
|
883
|
-
score: entry.score,
|
|
884
|
-
tags: entry.entry.tags,
|
|
885
|
-
content: entry.entry.content
|
|
886
|
-
})),
|
|
887
|
-
projectedEntries: result.projectedEntries.map((entry) => ({
|
|
888
|
-
id: entry.entryId,
|
|
889
|
-
familyKey: entry.familyKey,
|
|
890
|
-
claimKey: entry.claimKey,
|
|
891
|
-
slotPolicy: entry.slotPolicy,
|
|
892
|
-
memoryState: entry.memoryState,
|
|
893
|
-
claimStatus: entry.claimStatus,
|
|
894
|
-
freshness: entry.freshness,
|
|
895
|
-
provenance: entry.provenance,
|
|
896
|
-
whySurfaced: entry.whySurfaced
|
|
897
|
-
})),
|
|
898
|
-
entryFamilies: result.entryFamilies.map((family) => ({
|
|
899
|
-
familyKey: family.familyKey,
|
|
900
|
-
claimKey: family.claimKey,
|
|
901
|
-
slotPolicy: family.slotPolicy,
|
|
902
|
-
subject: family.subject,
|
|
903
|
-
primaryEntryId: family.primary.entryId,
|
|
904
|
-
entries: family.entries.map((entry) => ({
|
|
905
|
-
id: entry.entryId,
|
|
906
|
-
memoryState: entry.memoryState,
|
|
907
|
-
claimStatus: entry.claimStatus
|
|
908
|
-
}))
|
|
909
|
-
})),
|
|
910
|
-
claimTransitions: result.claimTransitions,
|
|
911
|
-
notices: result.notices
|
|
912
|
-
};
|
|
913
|
-
}
|
|
914
|
-
function describeEpisodeWhyMatched(semanticScore, temporalScore) {
|
|
915
|
-
if (semanticScore > 0 && temporalScore > 0) {
|
|
916
|
-
return "Semantic match within the resolved time window.";
|
|
917
|
-
}
|
|
918
|
-
if (semanticScore > 0) {
|
|
919
|
-
return "Semantic match to the episode summary.";
|
|
920
|
-
}
|
|
921
|
-
if (temporalScore > 0) {
|
|
922
|
-
return "Session overlaps the resolved time window.";
|
|
923
|
-
}
|
|
924
|
-
return "Matched episodic recall ranking.";
|
|
925
|
-
}
|
|
926
|
-
|
|
927
768
|
// src/adapters/shared/injection/entry-lines.ts
|
|
928
769
|
var MAX_CONTENT_CHARS = 220;
|
|
929
770
|
function formatInjectionEntryHeader(item) {
|
|
@@ -938,12 +779,12 @@ function formatInjectionEntryHeader(item) {
|
|
|
938
779
|
return `- [${metadata.join(" | ")}] ${item.entry.subject}`;
|
|
939
780
|
}
|
|
940
781
|
function formatInjectionEntryBodyLines(item) {
|
|
941
|
-
const lines = [` ${
|
|
782
|
+
const lines = [` ${truncate(item.entry.content.trim(), MAX_CONTENT_CHARS)}`];
|
|
942
783
|
lines.push(` why: ${item.whySurfaced.summary}`);
|
|
943
784
|
const metadata = [
|
|
944
785
|
item.entry.tags.length > 0 ? `tags: ${item.entry.tags.join(", ")}` : void 0,
|
|
945
786
|
item.freshnessLabel ? `freshness: ${item.freshnessLabel}` : void 0,
|
|
946
|
-
item.provenanceSummary ? `provenance: ${
|
|
787
|
+
item.provenanceSummary ? `provenance: ${truncate(item.provenanceSummary, MAX_CONTENT_CHARS)}` : void 0
|
|
947
788
|
].filter((value) => value !== void 0);
|
|
948
789
|
if (metadata.length > 0) {
|
|
949
790
|
lines.push(` ${metadata.join(" | ")}`);
|
|
@@ -1011,25 +852,19 @@ function formatProcedureHeader(suggestion) {
|
|
|
1011
852
|
return `- [${metadata.join(" | ")}] ${suggestion.procedure.title}`;
|
|
1012
853
|
}
|
|
1013
854
|
function formatProcedureBodyLines(suggestion) {
|
|
1014
|
-
const lines = [` goal: ${
|
|
855
|
+
const lines = [` goal: ${truncate(suggestion.procedure.goal.trim(), MAX_CONTENT_CHARS2)}`];
|
|
1015
856
|
lines.push(` why: ${suggestion.whySurfaced.summary}`);
|
|
1016
857
|
if (suggestion.procedure.when_to_use.length > 0) {
|
|
1017
|
-
lines.push(` when to use: ${
|
|
858
|
+
lines.push(` when to use: ${truncate(suggestion.procedure.when_to_use.join("; "), MAX_CONTENT_CHARS2)}`);
|
|
1018
859
|
}
|
|
1019
860
|
if (suggestion.procedure.verification.length > 0) {
|
|
1020
|
-
lines.push(` verification: ${
|
|
861
|
+
lines.push(` verification: ${truncate(suggestion.procedure.verification.join("; "), MAX_CONTENT_CHARS2)}`);
|
|
1021
862
|
}
|
|
1022
863
|
return lines;
|
|
1023
864
|
}
|
|
1024
865
|
|
|
1025
866
|
export {
|
|
1026
867
|
runBeforeTurn,
|
|
1027
|
-
truncate2 as truncate,
|
|
1028
|
-
sanitizeStoreToolParams,
|
|
1029
|
-
formatRecallToolSummary,
|
|
1030
|
-
sanitizeRecallToolParams,
|
|
1031
|
-
formatUnifiedRecallLogSummary,
|
|
1032
|
-
buildRecallToolDetails,
|
|
1033
868
|
formatInjectionEntryHeader,
|
|
1034
869
|
formatInjectionEntryBodyLines,
|
|
1035
870
|
wrapAgenrMemoryContext,
|
package/dist/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
openClawTranscriptParser,
|
|
10
10
|
parseTuiSessionKey,
|
|
11
11
|
readOpenClawSessionsStore
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-JSVQILB3.js";
|
|
13
13
|
import {
|
|
14
14
|
applyClaimExtractionResultToEntry,
|
|
15
15
|
backfillEpisodeEmbeddings,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
tokenizeGroundingText,
|
|
34
34
|
validateEntriesWithIndexes,
|
|
35
35
|
validateSupersessionRules
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-EEEL53X4.js";
|
|
37
37
|
import {
|
|
38
38
|
DEFAULT_CLAIM_EXTRACTION_CONCURRENCY,
|
|
39
39
|
DEFAULT_SURGEON_CONTEXT_LIMIT,
|
|
@@ -100,7 +100,7 @@ import {
|
|
|
100
100
|
updateEntry,
|
|
101
101
|
validateTemporalValidityRange,
|
|
102
102
|
writeConfig
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-NNO2V4GH.js";
|
|
104
104
|
import {
|
|
105
105
|
compactClaimKey,
|
|
106
106
|
describeClaimKeyNormalizationFailure,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-NOIZQRQV.js";
|
|
3
3
|
import "./chunk-ZYADFKX3.js";
|
|
4
4
|
import "./chunk-GELCEVFA.js";
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-V5CDMHRN.js";
|
|
6
|
+
import "./chunk-NNO2V4GH.js";
|
|
7
7
|
import "./chunk-5LADPJ4C.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-NOIZQRQV.js";
|
|
3
3
|
import "./chunk-ZYADFKX3.js";
|
|
4
4
|
import "./chunk-GELCEVFA.js";
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-V5CDMHRN.js";
|
|
6
|
+
import "./chunk-NNO2V4GH.js";
|
|
7
7
|
import "./chunk-5LADPJ4C.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agenr",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Agent memory - local-first knowledge infrastructure for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=24"
|
|
42
42
|
},
|
|
43
|
-
"license": "
|
|
43
|
+
"license": "MIT",
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "pnpm run build:root && pnpm run build:plugin",
|
|
46
46
|
"build:root": "tsup",
|