@smyslenny/agent-memory 4.2.0 → 4.3.1
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/README.md +1 -1
- package/dist/bin/agent-memory.js +66 -9
- package/dist/bin/agent-memory.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +65 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +66 -9
- package/dist/mcp/server.js.map +1 -1
- package/package.json +2 -2
- package/docs/design/.next-id +0 -1
- package/docs/design/0004-agent-memory-integration.md +0 -316
- package/docs/design/0005-reranker-api-integration.md +0 -276
- package/docs/design/0006-multi-provider-embedding.md +0 -196
- package/docs/design/0014-memory-core-dedup.md +0 -722
- package/docs/design/0015-v4-overhaul.md +0 -631
- package/docs/design/0016-v41-warm-boot-surface-emotion.md +0 -228
- package/docs/design/TEMPLATE.md +0 -67
- package/docs/roadmap/integration-plan-v1.md +0 -139
- package/docs/roadmap/memory-architecture.md +0 -168
- package/docs/roadmap/warm-boot.md +0 -135
package/dist/index.d.ts
CHANGED
|
@@ -550,7 +550,7 @@ declare function exportMemories(db: Database.Database, dirPath: string, opts?: {
|
|
|
550
550
|
agent_id?: string;
|
|
551
551
|
}): ExportResult;
|
|
552
552
|
|
|
553
|
-
type EmbeddingProviderKind = "openai-compatible" | "local-http";
|
|
553
|
+
type EmbeddingProviderKind = "openai-compatible" | "local-http" | "gemini";
|
|
554
554
|
interface EmbeddingProviderConfig {
|
|
555
555
|
provider: EmbeddingProviderKind;
|
|
556
556
|
baseUrl: string;
|
package/dist/index.js
CHANGED
|
@@ -676,6 +676,47 @@ function createLocalHttpEmbeddingProvider(opts) {
|
|
|
676
676
|
}
|
|
677
677
|
};
|
|
678
678
|
}
|
|
679
|
+
var GEMINI_DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com";
|
|
680
|
+
function createGeminiEmbeddingProvider(opts) {
|
|
681
|
+
const baseUrl = trimTrailingSlashes(opts.baseUrl || GEMINI_DEFAULT_BASE_URL);
|
|
682
|
+
const descriptorInput = `${baseUrl}|${opts.model}|${opts.dimension}`;
|
|
683
|
+
const id = stableProviderId(`gemini:${opts.model}`, descriptorInput);
|
|
684
|
+
return {
|
|
685
|
+
id,
|
|
686
|
+
model: opts.model,
|
|
687
|
+
dimension: opts.dimension,
|
|
688
|
+
async embed(texts) {
|
|
689
|
+
if (texts.length === 0) return [];
|
|
690
|
+
const fetchFn = getFetch(opts.fetchImpl);
|
|
691
|
+
const url = `${baseUrl}/v1beta/models/${opts.model}:batchEmbedContents?key=${opts.apiKey}`;
|
|
692
|
+
const requests = texts.map((text) => ({
|
|
693
|
+
model: `models/${opts.model}`,
|
|
694
|
+
content: { parts: [{ text }] },
|
|
695
|
+
outputDimensionality: opts.dimension
|
|
696
|
+
}));
|
|
697
|
+
const response = await fetchFn(url, {
|
|
698
|
+
method: "POST",
|
|
699
|
+
headers: { "content-type": "application/json" },
|
|
700
|
+
body: JSON.stringify({ requests })
|
|
701
|
+
});
|
|
702
|
+
if (!response.ok) {
|
|
703
|
+
const detail = await response.text().catch(() => "");
|
|
704
|
+
throw new Error(`Gemini embedding request failed: ${response.status} ${response.statusText}${detail ? ` \u2014 ${detail}` : ""}`);
|
|
705
|
+
}
|
|
706
|
+
const json2 = await response.json();
|
|
707
|
+
const embeddings = json2?.embeddings;
|
|
708
|
+
if (!Array.isArray(embeddings)) {
|
|
709
|
+
throw new Error("Gemini embedding response missing embeddings array");
|
|
710
|
+
}
|
|
711
|
+
return embeddings.map(
|
|
712
|
+
(entry, index) => assertEmbeddingVector(entry?.values, opts.dimension, `Gemini embedding item ${index}`)
|
|
713
|
+
);
|
|
714
|
+
},
|
|
715
|
+
async healthcheck() {
|
|
716
|
+
await this.embed(["healthcheck"]);
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
}
|
|
679
720
|
function normalizeEmbeddingBaseUrl(baseUrl) {
|
|
680
721
|
return trimTrailingSlashes(baseUrl);
|
|
681
722
|
}
|
|
@@ -688,7 +729,7 @@ function parseDimension(raw) {
|
|
|
688
729
|
}
|
|
689
730
|
function parseProvider(raw) {
|
|
690
731
|
if (!raw) return null;
|
|
691
|
-
if (raw === "openai-compatible" || raw === "local-http") {
|
|
732
|
+
if (raw === "openai-compatible" || raw === "local-http" || raw === "gemini") {
|
|
692
733
|
return raw;
|
|
693
734
|
}
|
|
694
735
|
throw new Error(`Unsupported embedding provider: ${raw}`);
|
|
@@ -699,8 +740,8 @@ function getEmbeddingProviderConfigFromEnv(env = process.env) {
|
|
|
699
740
|
const baseUrl = env.AGENT_MEMORY_EMBEDDING_BASE_URL;
|
|
700
741
|
const model = env.AGENT_MEMORY_EMBEDDING_MODEL;
|
|
701
742
|
const dimension = parseDimension(env.AGENT_MEMORY_EMBEDDING_DIMENSION);
|
|
702
|
-
if (!baseUrl) {
|
|
703
|
-
throw new Error("AGENT_MEMORY_EMBEDDING_BASE_URL is required when embeddings are enabled");
|
|
743
|
+
if (!baseUrl && provider !== "gemini") {
|
|
744
|
+
throw new Error("AGENT_MEMORY_EMBEDDING_BASE_URL is required when embeddings are enabled (not needed for gemini provider)");
|
|
704
745
|
}
|
|
705
746
|
if (!model) {
|
|
706
747
|
throw new Error("AGENT_MEMORY_EMBEDDING_MODEL is required when embeddings are enabled");
|
|
@@ -711,9 +752,12 @@ function getEmbeddingProviderConfigFromEnv(env = process.env) {
|
|
|
711
752
|
if (provider === "openai-compatible" && !env.AGENT_MEMORY_EMBEDDING_API_KEY) {
|
|
712
753
|
throw new Error("AGENT_MEMORY_EMBEDDING_API_KEY is required for openai-compatible providers");
|
|
713
754
|
}
|
|
755
|
+
if (provider === "gemini" && !env.AGENT_MEMORY_EMBEDDING_API_KEY) {
|
|
756
|
+
throw new Error("AGENT_MEMORY_EMBEDDING_API_KEY is required for gemini provider (Google AI API key)");
|
|
757
|
+
}
|
|
714
758
|
return {
|
|
715
759
|
provider,
|
|
716
|
-
baseUrl,
|
|
760
|
+
baseUrl: baseUrl ?? "",
|
|
717
761
|
model,
|
|
718
762
|
dimension,
|
|
719
763
|
apiKey: env.AGENT_MEMORY_EMBEDDING_API_KEY
|
|
@@ -722,8 +766,17 @@ function getEmbeddingProviderConfigFromEnv(env = process.env) {
|
|
|
722
766
|
function createEmbeddingProvider(input, opts) {
|
|
723
767
|
const normalized = {
|
|
724
768
|
...input,
|
|
725
|
-
baseUrl: normalizeEmbeddingBaseUrl(input.baseUrl)
|
|
769
|
+
baseUrl: input.baseUrl ? normalizeEmbeddingBaseUrl(input.baseUrl) : ""
|
|
726
770
|
};
|
|
771
|
+
if (normalized.provider === "gemini") {
|
|
772
|
+
return createGeminiEmbeddingProvider({
|
|
773
|
+
model: normalized.model,
|
|
774
|
+
dimension: normalized.dimension,
|
|
775
|
+
apiKey: normalized.apiKey,
|
|
776
|
+
baseUrl: normalized.baseUrl || void 0,
|
|
777
|
+
fetchImpl: opts?.fetchImpl
|
|
778
|
+
});
|
|
779
|
+
}
|
|
727
780
|
if (normalized.provider === "openai-compatible") {
|
|
728
781
|
return createOpenAICompatibleEmbeddingProvider({
|
|
729
782
|
baseUrl: normalized.baseUrl,
|
|
@@ -750,13 +803,16 @@ function resolveEmbeddingProviderConfig(opts) {
|
|
|
750
803
|
const model = opts?.config?.model ?? envConfig?.model;
|
|
751
804
|
const dimension = opts?.config?.dimension ?? envConfig?.dimension;
|
|
752
805
|
const apiKey = opts?.config?.apiKey ?? envConfig?.apiKey;
|
|
753
|
-
if (!provider || !
|
|
806
|
+
if (!provider || !model || !dimension) {
|
|
754
807
|
throw new Error("Incomplete embedding provider configuration");
|
|
755
808
|
}
|
|
756
|
-
if (provider
|
|
757
|
-
throw new Error("
|
|
809
|
+
if (provider !== "gemini" && !baseUrl) {
|
|
810
|
+
throw new Error("baseUrl is required for non-gemini embedding providers");
|
|
811
|
+
}
|
|
812
|
+
if ((provider === "openai-compatible" || provider === "gemini") && !apiKey) {
|
|
813
|
+
throw new Error(`${provider} embedding provider requires an API key`);
|
|
758
814
|
}
|
|
759
|
-
return { provider, baseUrl, model, dimension, apiKey };
|
|
815
|
+
return { provider, baseUrl: baseUrl ?? "", model, dimension, apiKey };
|
|
760
816
|
}
|
|
761
817
|
function getEmbeddingProvider(opts) {
|
|
762
818
|
const config = resolveEmbeddingProviderConfig({ config: opts?.config, env: opts?.env });
|