@agentmemory/agentmemory 0.9.16 → 0.9.17
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/AGENTS.md +5 -5
- package/README.md +27 -6
- package/dist/cli.mjs +5 -5
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +155 -6
- package/dist/index.mjs.map +1 -1
- package/dist/{src-3Oy_OOlF.mjs → src-TiNuQ3Ub.mjs} +146 -4
- package/dist/src-TiNuQ3Ub.mjs.map +1 -0
- package/dist/{standalone-BQOaGF4z.mjs → standalone-BIXq6S80.mjs} +3 -3
- package/dist/standalone-BIXq6S80.mjs.map +1 -0
- package/dist/standalone.mjs +2 -2
- package/dist/standalone.mjs.map +1 -1
- package/dist/{tools-registry-BF0pgZmI.mjs → tools-registry-BFKFKmYh.mjs} +11 -4
- package/dist/tools-registry-BFKFKmYh.mjs.map +1 -0
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/src-3Oy_OOlF.mjs.map +0 -1
- package/dist/standalone-BQOaGF4z.mjs.map +0 -1
- package/dist/tools-registry-BF0pgZmI.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as STREAM, c as jaccardSimilarity, i as KV, n as bootLog, o as fingerprintId, r as logger, s as generateId, t as VERSION } from "./cli.mjs";
|
|
2
2
|
import { a as isManagedImagePath, getImageRefCount, i as getMaxBytes, n as IMAGES_DIR, r as deleteImage, t as withKeyedLock } from "./image-refs-R3tin9MR.mjs";
|
|
3
|
-
import { _ as loadTeamConfig, a as getConsolidationDecayDays, c as isAutoCompressEnabled, d as isGraphExtractionEnabled, f as loadClaudeBridgeConfig, g as loadSnapshotConfig, h as loadFallbackConfig, i as detectLlmProviderKind, l as isConsolidationEnabled, m as loadEmbeddingConfig, n as getVisibleTools, o as getEnvVar, p as loadConfig, r as detectEmbeddingProvider, t as getAllTools, u as isContextInjectionEnabled } from "./tools-registry-
|
|
3
|
+
import { _ as loadTeamConfig, a as getConsolidationDecayDays, c as isAutoCompressEnabled, d as isGraphExtractionEnabled, f as loadClaudeBridgeConfig, g as loadSnapshotConfig, h as loadFallbackConfig, i as detectLlmProviderKind, l as isConsolidationEnabled, m as loadEmbeddingConfig, n as getVisibleTools, o as getEnvVar, p as loadConfig, r as detectEmbeddingProvider, t as getAllTools, u as isContextInjectionEnabled } from "./tools-registry-BFKFKmYh.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { execFile } from "node:child_process";
|
|
6
6
|
import { constants, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -184,6 +184,137 @@ var NoopProvider = class {
|
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
186
|
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/providers/openai.ts
|
|
189
|
+
const DEFAULT_BASE_URL$1 = "https://api.openai.com";
|
|
190
|
+
const DEFAULT_TIMEOUT_MS = 6e4;
|
|
191
|
+
const DEFAULT_AZURE_API_VERSION = "2024-08-01-preview";
|
|
192
|
+
/**
|
|
193
|
+
* OpenAI-compatible LLM provider.
|
|
194
|
+
*
|
|
195
|
+
* Uses raw fetch (no SDK) to support any OpenAI-compatible endpoint:
|
|
196
|
+
* - OpenAI official
|
|
197
|
+
* - Azure OpenAI (auto-detected from .openai.azure.com host)
|
|
198
|
+
* - DeepSeek
|
|
199
|
+
* - 硅基流动 (SiliconFlow)
|
|
200
|
+
* - vLLM / LM Studio / Ollama (with OpenAI compatibility layer)
|
|
201
|
+
* - Any other proxy implementing /v1/chat/completions
|
|
202
|
+
*
|
|
203
|
+
* Required env vars:
|
|
204
|
+
* OPENAI_API_KEY — API key
|
|
205
|
+
*
|
|
206
|
+
* Optional:
|
|
207
|
+
* OPENAI_BASE_URL — base URL without path (default: https://api.openai.com).
|
|
208
|
+
* Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
|
|
209
|
+
* OPENAI_MODEL — model name (default: gpt-4o-mini)
|
|
210
|
+
* OPENAI_API_VERSION — Azure api-version query param (default: 2024-08-01-preview)
|
|
211
|
+
* OPENAI_TIMEOUT_MS — outbound fetch timeout in ms (default: 60000)
|
|
212
|
+
* MAX_TOKENS — max output tokens (default: from config or 4096)
|
|
213
|
+
* OPENAI_REASONING_EFFORT — "low" | "medium" | "high" | "none"
|
|
214
|
+
* Passthrough for reasoning models (e.g. Ollama Cloud
|
|
215
|
+
* thinking models). Set to "none" to ensure
|
|
216
|
+
* message.content is populated instead of only
|
|
217
|
+
* message.reasoning.
|
|
218
|
+
*/
|
|
219
|
+
var OpenAIProvider = class {
|
|
220
|
+
name = "openai";
|
|
221
|
+
apiKey;
|
|
222
|
+
model;
|
|
223
|
+
maxTokens;
|
|
224
|
+
baseUrl;
|
|
225
|
+
reasoningEffort;
|
|
226
|
+
timeoutMs;
|
|
227
|
+
isAzure;
|
|
228
|
+
azureApiVersion;
|
|
229
|
+
constructor(apiKey, model, maxTokens, baseURL) {
|
|
230
|
+
this.apiKey = apiKey;
|
|
231
|
+
this.model = model;
|
|
232
|
+
this.maxTokens = maxTokens;
|
|
233
|
+
this.baseUrl = (baseURL || getEnvVar("OPENAI_BASE_URL") || DEFAULT_BASE_URL$1).replace(/\/+$/, "");
|
|
234
|
+
this.reasoningEffort = getEnvVar("OPENAI_REASONING_EFFORT") || void 0;
|
|
235
|
+
this.timeoutMs = parseTimeout(getEnvVar("OPENAI_TIMEOUT_MS"));
|
|
236
|
+
this.azureApiVersion = getEnvVar("OPENAI_API_VERSION") || DEFAULT_AZURE_API_VERSION;
|
|
237
|
+
this.isAzure = detectAzure(this.baseUrl);
|
|
238
|
+
}
|
|
239
|
+
async compress(systemPrompt, userPrompt) {
|
|
240
|
+
return this.call(systemPrompt, userPrompt);
|
|
241
|
+
}
|
|
242
|
+
async summarize(systemPrompt, userPrompt) {
|
|
243
|
+
return this.call(systemPrompt, userPrompt);
|
|
244
|
+
}
|
|
245
|
+
buildUrl() {
|
|
246
|
+
if (this.isAzure) {
|
|
247
|
+
const sep = this.baseUrl.includes("?") ? "&" : "?";
|
|
248
|
+
return `${this.baseUrl}/chat/completions${sep}api-version=${encodeURIComponent(this.azureApiVersion)}`;
|
|
249
|
+
}
|
|
250
|
+
return `${this.baseUrl}/v1/chat/completions`;
|
|
251
|
+
}
|
|
252
|
+
buildHeaders() {
|
|
253
|
+
if (this.isAzure) return {
|
|
254
|
+
"Content-Type": "application/json",
|
|
255
|
+
"api-key": this.apiKey
|
|
256
|
+
};
|
|
257
|
+
return {
|
|
258
|
+
"Content-Type": "application/json",
|
|
259
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
async call(systemPrompt, userPrompt) {
|
|
263
|
+
const url = this.buildUrl();
|
|
264
|
+
const body = {
|
|
265
|
+
model: this.model,
|
|
266
|
+
max_tokens: this.maxTokens,
|
|
267
|
+
messages: [{
|
|
268
|
+
role: "system",
|
|
269
|
+
content: systemPrompt
|
|
270
|
+
}, {
|
|
271
|
+
role: "user",
|
|
272
|
+
content: userPrompt
|
|
273
|
+
}]
|
|
274
|
+
};
|
|
275
|
+
if (this.reasoningEffort) body.reasoning_effort = this.reasoningEffort;
|
|
276
|
+
const ac = new AbortController();
|
|
277
|
+
const t = setTimeout(() => ac.abort(), this.timeoutMs);
|
|
278
|
+
let response;
|
|
279
|
+
try {
|
|
280
|
+
response = await fetch(url, {
|
|
281
|
+
method: "POST",
|
|
282
|
+
headers: this.buildHeaders(),
|
|
283
|
+
body: JSON.stringify(body),
|
|
284
|
+
signal: ac.signal
|
|
285
|
+
});
|
|
286
|
+
} catch (err) {
|
|
287
|
+
if (ac.signal.aborted || err instanceof Error && err.name === "AbortError") throw new Error(`OpenAI API request timed out after ${this.timeoutMs}ms — set OPENAI_TIMEOUT_MS to raise the bound or check the provider status.`);
|
|
288
|
+
throw err;
|
|
289
|
+
} finally {
|
|
290
|
+
clearTimeout(t);
|
|
291
|
+
}
|
|
292
|
+
if (!response.ok) {
|
|
293
|
+
const text = await response.text();
|
|
294
|
+
throw new Error(`OpenAI API error (${response.status}): ${text}`);
|
|
295
|
+
}
|
|
296
|
+
const data = await response.json();
|
|
297
|
+
const message = data.choices?.[0]?.message;
|
|
298
|
+
const content = message?.content;
|
|
299
|
+
if (content) return content;
|
|
300
|
+
const reasoning = message?.reasoning;
|
|
301
|
+
if (reasoning) return reasoning;
|
|
302
|
+
throw new Error(`OpenAI returned unexpected response: ${JSON.stringify(data).slice(0, 200)}`);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
function parseTimeout(raw) {
|
|
306
|
+
if (!raw) return DEFAULT_TIMEOUT_MS;
|
|
307
|
+
const n = parseInt(raw, 10);
|
|
308
|
+
return Number.isFinite(n) && n > 0 ? n : DEFAULT_TIMEOUT_MS;
|
|
309
|
+
}
|
|
310
|
+
function detectAzure(baseUrl) {
|
|
311
|
+
try {
|
|
312
|
+
return new URL(baseUrl).hostname.endsWith(".openai.azure.com");
|
|
313
|
+
} catch {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
187
318
|
//#endregion
|
|
188
319
|
//#region src/providers/openrouter.ts
|
|
189
320
|
var OpenRouterProvider = class {
|
|
@@ -769,6 +900,11 @@ function createBaseProvider(config) {
|
|
|
769
900
|
return new OpenRouterProvider(geminiKey, config.model, config.maxTokens, "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions");
|
|
770
901
|
}
|
|
771
902
|
case "openrouter": return new OpenRouterProvider(requireEnvVar("OPENROUTER_API_KEY"), config.model, config.maxTokens, "https://openrouter.ai/api/v1/chat/completions");
|
|
903
|
+
case "openai": {
|
|
904
|
+
const openaiKey = getEnvVar("OPENAI_API_KEY");
|
|
905
|
+
if (!openaiKey) throw new Error("OPENAI_API_KEY is required for the openai provider");
|
|
906
|
+
return new OpenAIProvider(openaiKey, config.model, config.maxTokens, config.baseURL);
|
|
907
|
+
}
|
|
772
908
|
case "noop": return new NoopProvider();
|
|
773
909
|
default: return new AgentSDKProvider();
|
|
774
910
|
}
|
|
@@ -5656,7 +5792,8 @@ function registerExportImportFunction(sdk, kv) {
|
|
|
5656
5792
|
"0.9.13",
|
|
5657
5793
|
"0.9.14",
|
|
5658
5794
|
"0.9.15",
|
|
5659
|
-
"0.9.16"
|
|
5795
|
+
"0.9.16",
|
|
5796
|
+
"0.9.17"
|
|
5660
5797
|
]).has(importData.version)) return {
|
|
5661
5798
|
success: false,
|
|
5662
5799
|
error: `Unsupported export version: ${importData.version}`
|
|
@@ -18158,6 +18295,11 @@ async function main() {
|
|
|
18158
18295
|
serviceName: OTEL_CONFIG.serviceName,
|
|
18159
18296
|
serviceVersion: OTEL_CONFIG.serviceVersion,
|
|
18160
18297
|
metricsExportIntervalMs: OTEL_CONFIG.metricsExportIntervalMs
|
|
18298
|
+
},
|
|
18299
|
+
telemetry: {
|
|
18300
|
+
project_name: "agentmemory",
|
|
18301
|
+
language: "node",
|
|
18302
|
+
framework: "iii-sdk"
|
|
18161
18303
|
}
|
|
18162
18304
|
});
|
|
18163
18305
|
const kv = new StateKV(sdk);
|
|
@@ -18317,7 +18459,7 @@ async function main() {
|
|
|
18317
18459
|
console.warn(`[agentmemory] Failed to backfill memories into BM25:`, err);
|
|
18318
18460
|
}
|
|
18319
18461
|
bootLog(`Ready. ${embeddingProvider ? "Triple-stream (BM25+Vector+Graph)" : "BM25+Graph"} search active.`);
|
|
18320
|
-
bootLog(`REST API:
|
|
18462
|
+
bootLog(`REST API: 121 endpoints at http://localhost:${config.restPort}/agentmemory/*`);
|
|
18321
18463
|
bootLog(`MCP surface (opt-in via \`npx @agentmemory/mcp\`): ${getAllTools().length} tools · 6 resources · 3 prompts`);
|
|
18322
18464
|
const viewerServer = startViewerServer(config.restPort + 2, kv, sdk, secret, config.restPort);
|
|
18323
18465
|
const autoForgetIntervalMs = parseInt(process.env.AUTO_FORGET_INTERVAL_MS || "3600000", 10);
|
|
@@ -18385,4 +18527,4 @@ main().catch((err) => {
|
|
|
18385
18527
|
|
|
18386
18528
|
//#endregion
|
|
18387
18529
|
export { };
|
|
18388
|
-
//# sourceMappingURL=src-
|
|
18530
|
+
//# sourceMappingURL=src-TiNuQ3Ub.mjs.map
|