@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/mcp/server.js
CHANGED
|
@@ -690,12 +690,54 @@ function createLocalHttpEmbeddingProvider(opts) {
|
|
|
690
690
|
}
|
|
691
691
|
};
|
|
692
692
|
}
|
|
693
|
+
function createGeminiEmbeddingProvider(opts) {
|
|
694
|
+
const baseUrl = trimTrailingSlashes(opts.baseUrl || GEMINI_DEFAULT_BASE_URL);
|
|
695
|
+
const descriptorInput = `${baseUrl}|${opts.model}|${opts.dimension}`;
|
|
696
|
+
const id = stableProviderId(`gemini:${opts.model}`, descriptorInput);
|
|
697
|
+
return {
|
|
698
|
+
id,
|
|
699
|
+
model: opts.model,
|
|
700
|
+
dimension: opts.dimension,
|
|
701
|
+
async embed(texts) {
|
|
702
|
+
if (texts.length === 0) return [];
|
|
703
|
+
const fetchFn = getFetch(opts.fetchImpl);
|
|
704
|
+
const url2 = `${baseUrl}/v1beta/models/${opts.model}:batchEmbedContents?key=${opts.apiKey}`;
|
|
705
|
+
const requests = texts.map((text) => ({
|
|
706
|
+
model: `models/${opts.model}`,
|
|
707
|
+
content: { parts: [{ text }] },
|
|
708
|
+
outputDimensionality: opts.dimension
|
|
709
|
+
}));
|
|
710
|
+
const response = await fetchFn(url2, {
|
|
711
|
+
method: "POST",
|
|
712
|
+
headers: { "content-type": "application/json" },
|
|
713
|
+
body: JSON.stringify({ requests })
|
|
714
|
+
});
|
|
715
|
+
if (!response.ok) {
|
|
716
|
+
const detail = await response.text().catch(() => "");
|
|
717
|
+
throw new Error(`Gemini embedding request failed: ${response.status} ${response.statusText}${detail ? ` \u2014 ${detail}` : ""}`);
|
|
718
|
+
}
|
|
719
|
+
const json2 = await response.json();
|
|
720
|
+
const embeddings = json2?.embeddings;
|
|
721
|
+
if (!Array.isArray(embeddings)) {
|
|
722
|
+
throw new Error("Gemini embedding response missing embeddings array");
|
|
723
|
+
}
|
|
724
|
+
return embeddings.map(
|
|
725
|
+
(entry, index) => assertEmbeddingVector(entry?.values, opts.dimension, `Gemini embedding item ${index}`)
|
|
726
|
+
);
|
|
727
|
+
},
|
|
728
|
+
async healthcheck() {
|
|
729
|
+
await this.embed(["healthcheck"]);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
}
|
|
693
733
|
function normalizeEmbeddingBaseUrl(baseUrl) {
|
|
694
734
|
return trimTrailingSlashes(baseUrl);
|
|
695
735
|
}
|
|
736
|
+
var GEMINI_DEFAULT_BASE_URL;
|
|
696
737
|
var init_embedding = __esm({
|
|
697
738
|
"src/search/embedding.ts"() {
|
|
698
739
|
"use strict";
|
|
740
|
+
GEMINI_DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com";
|
|
699
741
|
}
|
|
700
742
|
});
|
|
701
743
|
|
|
@@ -707,7 +749,7 @@ function parseDimension(raw) {
|
|
|
707
749
|
}
|
|
708
750
|
function parseProvider(raw) {
|
|
709
751
|
if (!raw) return null;
|
|
710
|
-
if (raw === "openai-compatible" || raw === "local-http") {
|
|
752
|
+
if (raw === "openai-compatible" || raw === "local-http" || raw === "gemini") {
|
|
711
753
|
return raw;
|
|
712
754
|
}
|
|
713
755
|
throw new Error(`Unsupported embedding provider: ${raw}`);
|
|
@@ -718,8 +760,8 @@ function getEmbeddingProviderConfigFromEnv(env = process.env) {
|
|
|
718
760
|
const baseUrl = env.AGENT_MEMORY_EMBEDDING_BASE_URL;
|
|
719
761
|
const model = env.AGENT_MEMORY_EMBEDDING_MODEL;
|
|
720
762
|
const dimension = parseDimension(env.AGENT_MEMORY_EMBEDDING_DIMENSION);
|
|
721
|
-
if (!baseUrl) {
|
|
722
|
-
throw new Error("AGENT_MEMORY_EMBEDDING_BASE_URL is required when embeddings are enabled");
|
|
763
|
+
if (!baseUrl && provider !== "gemini") {
|
|
764
|
+
throw new Error("AGENT_MEMORY_EMBEDDING_BASE_URL is required when embeddings are enabled (not needed for gemini provider)");
|
|
723
765
|
}
|
|
724
766
|
if (!model) {
|
|
725
767
|
throw new Error("AGENT_MEMORY_EMBEDDING_MODEL is required when embeddings are enabled");
|
|
@@ -730,9 +772,12 @@ function getEmbeddingProviderConfigFromEnv(env = process.env) {
|
|
|
730
772
|
if (provider === "openai-compatible" && !env.AGENT_MEMORY_EMBEDDING_API_KEY) {
|
|
731
773
|
throw new Error("AGENT_MEMORY_EMBEDDING_API_KEY is required for openai-compatible providers");
|
|
732
774
|
}
|
|
775
|
+
if (provider === "gemini" && !env.AGENT_MEMORY_EMBEDDING_API_KEY) {
|
|
776
|
+
throw new Error("AGENT_MEMORY_EMBEDDING_API_KEY is required for gemini provider (Google AI API key)");
|
|
777
|
+
}
|
|
733
778
|
return {
|
|
734
779
|
provider,
|
|
735
|
-
baseUrl,
|
|
780
|
+
baseUrl: baseUrl ?? "",
|
|
736
781
|
model,
|
|
737
782
|
dimension,
|
|
738
783
|
apiKey: env.AGENT_MEMORY_EMBEDDING_API_KEY
|
|
@@ -741,8 +786,17 @@ function getEmbeddingProviderConfigFromEnv(env = process.env) {
|
|
|
741
786
|
function createEmbeddingProvider(input, opts) {
|
|
742
787
|
const normalized = {
|
|
743
788
|
...input,
|
|
744
|
-
baseUrl: normalizeEmbeddingBaseUrl(input.baseUrl)
|
|
789
|
+
baseUrl: input.baseUrl ? normalizeEmbeddingBaseUrl(input.baseUrl) : ""
|
|
745
790
|
};
|
|
791
|
+
if (normalized.provider === "gemini") {
|
|
792
|
+
return createGeminiEmbeddingProvider({
|
|
793
|
+
model: normalized.model,
|
|
794
|
+
dimension: normalized.dimension,
|
|
795
|
+
apiKey: normalized.apiKey,
|
|
796
|
+
baseUrl: normalized.baseUrl || void 0,
|
|
797
|
+
fetchImpl: opts?.fetchImpl
|
|
798
|
+
});
|
|
799
|
+
}
|
|
746
800
|
if (normalized.provider === "openai-compatible") {
|
|
747
801
|
return createOpenAICompatibleEmbeddingProvider({
|
|
748
802
|
baseUrl: normalized.baseUrl,
|
|
@@ -769,13 +823,16 @@ function resolveEmbeddingProviderConfig(opts) {
|
|
|
769
823
|
const model = opts?.config?.model ?? envConfig?.model;
|
|
770
824
|
const dimension = opts?.config?.dimension ?? envConfig?.dimension;
|
|
771
825
|
const apiKey = opts?.config?.apiKey ?? envConfig?.apiKey;
|
|
772
|
-
if (!provider || !
|
|
826
|
+
if (!provider || !model || !dimension) {
|
|
773
827
|
throw new Error("Incomplete embedding provider configuration");
|
|
774
828
|
}
|
|
775
|
-
if (provider
|
|
776
|
-
throw new Error("
|
|
829
|
+
if (provider !== "gemini" && !baseUrl) {
|
|
830
|
+
throw new Error("baseUrl is required for non-gemini embedding providers");
|
|
831
|
+
}
|
|
832
|
+
if ((provider === "openai-compatible" || provider === "gemini") && !apiKey) {
|
|
833
|
+
throw new Error(`${provider} embedding provider requires an API key`);
|
|
777
834
|
}
|
|
778
|
-
return { provider, baseUrl, model, dimension, apiKey };
|
|
835
|
+
return { provider, baseUrl: baseUrl ?? "", model, dimension, apiKey };
|
|
779
836
|
}
|
|
780
837
|
function getEmbeddingProvider(opts) {
|
|
781
838
|
const config2 = resolveEmbeddingProviderConfig({ config: opts?.config, env: opts?.env });
|