opencode-mem 2.3.6 → 2.3.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAyXA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;oBA0Bb,aAAa,GACb,kBAAkB,GAClB,WAAW;;;;;;;;;;;;;;;;;;;CAyBhB,CAAC;AAEF,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAyXA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;oBA4Bb,aAAa,GACb,kBAAkB,GAClB,WAAW;;;;;;;;;;;;;;;;;;;CAyBhB,CAAC;AAEF,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
package/dist/config.js CHANGED
@@ -316,7 +316,9 @@ export const CONFIG = {
316
316
  embeddingDimensions: fileConfig.embeddingDimensions ??
317
317
  getEmbeddingDimensions(fileConfig.embeddingModel ?? DEFAULTS.embeddingModel),
318
318
  embeddingApiUrl: fileConfig.embeddingApiUrl,
319
- embeddingApiKey: fileConfig.embeddingApiKey ?? process.env.OPENAI_API_KEY,
319
+ embeddingApiKey: fileConfig.embeddingApiUrl
320
+ ? (fileConfig.embeddingApiKey ?? process.env.OPENAI_API_KEY)
321
+ : undefined,
320
322
  similarityThreshold: fileConfig.similarityThreshold ?? DEFAULTS.similarityThreshold,
321
323
  maxMemories: fileConfig.maxMemories ?? DEFAULTS.maxMemories,
322
324
  maxProfileItems: fileConfig.maxProfileItems ?? DEFAULTS.maxProfileItems,
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/providers/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AA4BvF,qBAAa,yBAA0B,SAAQ,cAAc;IAC3D,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,gBAAgB;IAK3D,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,OAAO;IAIpB,eAAe,CACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,kBAAkB,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;IA2K1B,OAAO,CAAC,cAAc;CAavB"}
1
+ {"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/providers/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AA4BvF,qBAAa,yBAA0B,SAAQ,cAAc;IAC3D,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,gBAAgB;IAK3D,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,OAAO;IAIpB,eAAe,CACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,kBAAkB,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;IAiL1B,OAAO,CAAC,cAAc;CAavB"}
@@ -44,11 +44,12 @@ export class AnthropicMessagesProvider extends BaseAIProvider {
44
44
  });
45
45
  messages.push({ role: "user", content: userPrompt });
46
46
  let iterations = 0;
47
- const maxIterations = this.config.maxIterations;
47
+ const maxIterations = this.config.maxIterations ?? 5;
48
+ const iterationTimeout = this.config.iterationTimeout ?? 30000;
48
49
  while (iterations < maxIterations) {
49
50
  iterations++;
50
51
  const controller = new AbortController();
51
- const timeout = setTimeout(() => controller.abort(), this.config.iterationTimeout);
52
+ const timeout = setTimeout(() => controller.abort(), iterationTimeout);
52
53
  try {
53
54
  const tool = ToolSchemaConverter.toAnthropic(toolSchema);
54
55
  const requestBody = {
@@ -57,13 +58,16 @@ export class AnthropicMessagesProvider extends BaseAIProvider {
57
58
  messages,
58
59
  tools: [tool],
59
60
  };
61
+ const headers = {
62
+ "Content-Type": "application/json",
63
+ "anthropic-version": "2023-06-01",
64
+ };
65
+ if (this.config.apiKey) {
66
+ headers["x-api-key"] = this.config.apiKey;
67
+ }
60
68
  const response = await fetch(`${this.config.apiUrl}/messages`, {
61
69
  method: "POST",
62
- headers: {
63
- "Content-Type": "application/json",
64
- "x-api-key": this.config.apiKey,
65
- "anthropic-version": "2023-06-01",
66
- },
70
+ headers,
67
71
  body: JSON.stringify(requestBody),
68
72
  signal: controller.signal,
69
73
  });
@@ -7,9 +7,9 @@ export interface ToolCallResult {
7
7
  export interface ProviderConfig {
8
8
  model: string;
9
9
  apiUrl: string;
10
- apiKey: string;
11
- maxIterations: number;
12
- iterationTimeout: number;
10
+ apiKey?: string;
11
+ maxIterations?: number;
12
+ iterationTimeout?: number;
13
13
  }
14
14
  export declare abstract class BaseAIProvider {
15
15
  protected config: ProviderConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"base-provider.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/providers/base-provider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,8BAAsB,cAAc;IAClC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC;gBAErB,MAAM,EAAE,cAAc;IAIlC,QAAQ,CAAC,eAAe,CACtB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,GAAG,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;IAE1B,QAAQ,CAAC,eAAe,IAAI,MAAM;IAElC,QAAQ,CAAC,eAAe,IAAI,OAAO;CACpC"}
1
+ {"version":3,"file":"base-provider.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/providers/base-provider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,8BAAsB,cAAc;IAClC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC;gBAErB,MAAM,EAAE,cAAc;IAIlC,QAAQ,CAAC,eAAe,CACtB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,GAAG,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;IAE1B,QAAQ,CAAC,eAAe,IAAI,MAAM;IAElC,QAAQ,CAAC,eAAe,IAAI,OAAO;CACpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"openai-chat-completion.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/providers/openai-chat-completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAqBlE,qBAAa,4BAA6B,SAAQ,cAAc;IAC9D,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,gBAAgB;IAK3D,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,OAAO;IAI1B,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,iCAAiC;IAwCnC,eAAe,CACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,kBAAkB,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;CAkO3B"}
1
+ {"version":3,"file":"openai-chat-completion.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/providers/openai-chat-completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAqBlE,qBAAa,4BAA6B,SAAQ,cAAc;IAC9D,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,gBAAgB;IAK3D,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,OAAO;IAI1B,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,iCAAiC;IAwCnC,eAAe,CACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,kBAAkB,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;CAyO3B"}
@@ -108,10 +108,12 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
108
108
  });
109
109
  messages.push({ role: "user", content: userPrompt });
110
110
  let iterations = 0;
111
- while (iterations < this.config.maxIterations) {
111
+ const maxIterations = this.config.maxIterations ?? 5;
112
+ const iterationTimeout = this.config.iterationTimeout ?? 30000;
113
+ while (iterations < maxIterations) {
112
114
  iterations++;
113
115
  const controller = new AbortController();
114
- const timeout = setTimeout(() => controller.abort(), this.config.iterationTimeout);
116
+ const timeout = setTimeout(() => controller.abort(), iterationTimeout);
115
117
  try {
116
118
  const requestBody = {
117
119
  model: this.config.model,
@@ -120,12 +122,15 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
120
122
  tool_choice: { type: "function", function: { name: toolSchema.function.name } },
121
123
  temperature: 0.3,
122
124
  };
125
+ const headers = {
126
+ "Content-Type": "application/json",
127
+ };
128
+ if (this.config.apiKey) {
129
+ headers.Authorization = `Bearer ${this.config.apiKey}`;
130
+ }
123
131
  const response = await fetch(`${this.config.apiUrl}/chat/completions`, {
124
132
  method: "POST",
125
- headers: {
126
- "Content-Type": "application/json",
127
- Authorization: `Bearer ${this.config.apiKey}`,
128
- },
133
+ headers,
129
134
  body: JSON.stringify(requestBody),
130
135
  signal: controller.signal,
131
136
  });
@@ -1 +1 @@
1
- {"version":3,"file":"openai-responses.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/providers/openai-responses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAsBvF,qBAAa,uBAAwB,SAAQ,cAAc;IACzD,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,gBAAgB;IAK3D,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,OAAO;IAIpB,eAAe,CACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,kBAAkB,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;IAuH1B,OAAO,CAAC,eAAe;IAsCvB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,gBAAgB;CAsBzB"}
1
+ {"version":3,"file":"openai-responses.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/providers/openai-responses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAsBvF,qBAAa,uBAAwB,SAAQ,cAAc;IACzD,OAAO,CAAC,gBAAgB,CAAmB;gBAE/B,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,gBAAgB;IAK3D,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,OAAO;IAIpB,eAAe,CACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,kBAAkB,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;IAyH1B,OAAO,CAAC,eAAe;IAsCvB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,gBAAgB;CAsBzB"}
@@ -25,10 +25,12 @@ export class OpenAIResponsesProvider extends BaseAIProvider {
25
25
  let conversationId = session.conversationId;
26
26
  let currentPrompt = userPrompt;
27
27
  let iterations = 0;
28
- while (iterations < this.config.maxIterations) {
28
+ const maxIterations = this.config.maxIterations ?? 5;
29
+ const iterationTimeout = this.config.iterationTimeout ?? 30000;
30
+ while (iterations < maxIterations) {
29
31
  iterations++;
30
32
  const controller = new AbortController();
31
- const timeout = setTimeout(() => controller.abort(), this.config.iterationTimeout);
33
+ const timeout = setTimeout(() => controller.abort(), iterationTimeout);
32
34
  try {
33
35
  const tool = ToolSchemaConverter.toResponsesAPI(toolSchema);
34
36
  const requestBody = {
@@ -181,7 +181,7 @@ function buildMarkdownContext(userPrompt, textResponses, toolCalls, latestMemory
181
181
  return sections.join("\n");
182
182
  }
183
183
  async function generateSummary(context, sessionID) {
184
- if (!CONFIG.memoryModel || !CONFIG.memoryApiUrl || !CONFIG.memoryApiKey) {
184
+ if (!CONFIG.memoryModel || !CONFIG.memoryApiUrl) {
185
185
  throw new Error("External API not configured for auto-capture");
186
186
  }
187
187
  const { AIProviderFactory } = await import("./ai/ai-provider-factory.js");
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/services/logger.ts"],"names":[],"mappings":"AAkBA,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,QAOlD"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/services/logger.ts"],"names":[],"mappings":"AAoBA,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,QAOlD"}
@@ -10,7 +10,9 @@ function ensureLoggerInitialized() {
10
10
  if (!existsSync(LOG_DIR)) {
11
11
  mkdirSync(LOG_DIR, { recursive: true });
12
12
  }
13
- writeFileSync(LOG_FILE, `\n--- Session started: ${new Date().toISOString()} ---\n`, { flag: "a" });
13
+ writeFileSync(LOG_FILE, `\n--- Session started: ${new Date().toISOString()} ---\n`, {
14
+ flag: "a",
15
+ });
14
16
  globalThis[GLOBAL_LOGGER_KEY] = true;
15
17
  }
16
18
  export function log(message, data) {
@@ -1 +1 @@
1
- {"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/connection-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,eAAe;IA+EzB,OAAO,CAAC,YAAY;IAqBlB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ;IAmBvC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IASrC,QAAQ,IAAI,IAAI;CAWjB;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}
1
+ {"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../src/services/sqlite/connection-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,eAAe;IA+EvB,OAAO,CAAC,YAAY;IAqBpB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ;IAmBvC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IASrC,QAAQ,IAAI,IAAI;CAWjB;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}
@@ -119,7 +119,12 @@ Identify and ${existingProfile ? "update" : "create"}:
119
119
  ${existingProfile ? "Merge with existing profile, incrementing frequencies and updating confidence scores." : "Create initial profile with conservative confidence scores."}`;
120
120
  }
121
121
  async function analyzeUserProfile(context, existingProfile) {
122
- if (!CONFIG.memoryModel || !CONFIG.memoryApiUrl || !CONFIG.memoryApiKey) {
122
+ if (!CONFIG.memoryModel || !CONFIG.memoryApiUrl) {
123
+ log("User Profile Config Check Failed:", {
124
+ memoryModel: CONFIG.memoryModel,
125
+ memoryApiUrl: CONFIG.memoryApiUrl,
126
+ memoryApiKey: CONFIG.memoryApiKey,
127
+ });
123
128
  throw new Error("External API not configured for user memory learning");
124
129
  }
125
130
  const { AIProviderFactory } = await import("./ai/ai-provider-factory.js");
package/dist/web/app.js CHANGED
@@ -166,14 +166,17 @@ function renderMemoryCard(memory) {
166
166
  const isSelected = state.selectedMemories.has(memory.id);
167
167
  const isPinned = memory.isPinned || false;
168
168
  const isLinked = !!memory.linkedPromptId;
169
- const similarityHtml =
169
+ const similarityHtml =
170
170
  memory.similarity !== undefined
171
171
  ? `<span class="similarity-score">${memory.similarity}%</span>`
172
172
  : "";
173
173
 
174
174
  let displayInfo = memory.displayName || memory.id;
175
175
  if (memory.projectPath) {
176
- const pathParts = memory.projectPath.replace(/\\/g, "/").split("/").filter((p) => p);
176
+ const pathParts = memory.projectPath
177
+ .replace(/\\/g, "/")
178
+ .split("/")
179
+ .filter((p) => p);
177
180
  displayInfo = pathParts[pathParts.length - 1] || memory.projectPath;
178
181
  }
179
182
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-mem",
3
- "version": "2.3.6",
3
+ "version": "2.3.7",
4
4
  "description": "OpenCode plugin that gives coding agents persistent memory using local vector database",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",