opencode-mem 2.3.5 → 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.
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -1
- package/dist/services/ai/providers/anthropic-messages.d.ts.map +1 -1
- package/dist/services/ai/providers/anthropic-messages.js +11 -7
- package/dist/services/ai/providers/base-provider.d.ts +3 -3
- package/dist/services/ai/providers/base-provider.d.ts.map +1 -1
- package/dist/services/ai/providers/openai-chat-completion.d.ts +2 -0
- package/dist/services/ai/providers/openai-chat-completion.d.ts.map +1 -1
- package/dist/services/ai/providers/openai-chat-completion.js +103 -38
- package/dist/services/ai/providers/openai-responses.d.ts.map +1 -1
- package/dist/services/ai/providers/openai-responses.js +4 -2
- package/dist/services/auto-capture.js +1 -1
- package/dist/services/logger.d.ts.map +1 -1
- package/dist/services/logger.js +3 -1
- package/dist/services/sqlite/connection-manager.d.ts.map +1 -1
- package/dist/services/sqlite/connection-manager.js +14 -2
- package/dist/services/user-memory-learning.js +6 -1
- package/dist/services/web-server.d.ts.map +1 -1
- package/dist/services/web-server.js +15 -2
- package/dist/web/app.js +5 -2
- package/package.json +1 -1
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAyXA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;
|
|
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.
|
|
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;
|
|
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(),
|
|
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
|
|
11
|
-
maxIterations
|
|
12
|
-
iterationTimeout
|
|
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;
|
|
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"}
|
|
@@ -6,6 +6,8 @@ export declare class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
6
6
|
constructor(config: any, aiSessionManager: AISessionManager);
|
|
7
7
|
getProviderName(): string;
|
|
8
8
|
supportsSession(): boolean;
|
|
9
|
+
private addToolResponse;
|
|
10
|
+
private filterIncompleteToolCallSequences;
|
|
9
11
|
executeToolCall(systemPrompt: string, userPrompt: string, toolSchema: ChatCompletionTool, sessionId: string): Promise<ToolCallResult>;
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=openai-chat-completion.d.ts.map
|
|
@@ -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;
|
|
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"}
|
|
@@ -14,6 +14,57 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
14
14
|
supportsSession() {
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
|
+
addToolResponse(sessionId, messages, toolCallId, content) {
|
|
18
|
+
const sequence = this.aiSessionManager.getLastSequence(sessionId) + 1;
|
|
19
|
+
this.aiSessionManager.addMessage({
|
|
20
|
+
aiSessionId: sessionId,
|
|
21
|
+
sequence,
|
|
22
|
+
role: "tool",
|
|
23
|
+
content,
|
|
24
|
+
toolCallId,
|
|
25
|
+
});
|
|
26
|
+
messages.push({
|
|
27
|
+
role: "tool",
|
|
28
|
+
tool_call_id: toolCallId,
|
|
29
|
+
content,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
filterIncompleteToolCallSequences(messages) {
|
|
33
|
+
const result = [];
|
|
34
|
+
let i = 0;
|
|
35
|
+
while (i < messages.length) {
|
|
36
|
+
const msg = messages[i];
|
|
37
|
+
if (msg.role === "assistant" && msg.toolCalls && msg.toolCalls.length > 0) {
|
|
38
|
+
const toolCallIds = new Set(msg.toolCalls.map((tc) => tc.id));
|
|
39
|
+
const toolResponses = [];
|
|
40
|
+
let j = i + 1;
|
|
41
|
+
while (j < messages.length && messages[j].role === "tool") {
|
|
42
|
+
if (toolCallIds.has(messages[j].toolCallId)) {
|
|
43
|
+
toolResponses.push(messages[j]);
|
|
44
|
+
toolCallIds.delete(messages[j].toolCallId);
|
|
45
|
+
}
|
|
46
|
+
j++;
|
|
47
|
+
}
|
|
48
|
+
if (toolCallIds.size === 0) {
|
|
49
|
+
result.push(msg);
|
|
50
|
+
toolResponses.forEach((tr) => result.push(tr));
|
|
51
|
+
i = j;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
log("Skipping incomplete tool call sequence", {
|
|
55
|
+
assistantMsgIndex: i,
|
|
56
|
+
missingToolCallIds: Array.from(toolCallIds),
|
|
57
|
+
});
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
result.push(msg);
|
|
63
|
+
i++;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
17
68
|
async executeToolCall(systemPrompt, userPrompt, toolSchema, sessionId) {
|
|
18
69
|
let session = this.aiSessionManager.getSession(sessionId, "openai-chat");
|
|
19
70
|
if (!session) {
|
|
@@ -24,7 +75,8 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
24
75
|
}
|
|
25
76
|
const existingMessages = this.aiSessionManager.getMessages(session.id);
|
|
26
77
|
const messages = [];
|
|
27
|
-
|
|
78
|
+
const validatedMessages = this.filterIncompleteToolCallSequences(existingMessages);
|
|
79
|
+
for (const msg of validatedMessages) {
|
|
28
80
|
const apiMsg = {
|
|
29
81
|
role: msg.role,
|
|
30
82
|
content: msg.content,
|
|
@@ -56,24 +108,29 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
56
108
|
});
|
|
57
109
|
messages.push({ role: "user", content: userPrompt });
|
|
58
110
|
let iterations = 0;
|
|
59
|
-
|
|
111
|
+
const maxIterations = this.config.maxIterations ?? 5;
|
|
112
|
+
const iterationTimeout = this.config.iterationTimeout ?? 30000;
|
|
113
|
+
while (iterations < maxIterations) {
|
|
60
114
|
iterations++;
|
|
61
115
|
const controller = new AbortController();
|
|
62
|
-
const timeout = setTimeout(() => controller.abort(),
|
|
116
|
+
const timeout = setTimeout(() => controller.abort(), iterationTimeout);
|
|
63
117
|
try {
|
|
64
118
|
const requestBody = {
|
|
65
119
|
model: this.config.model,
|
|
66
120
|
messages,
|
|
67
121
|
tools: [toolSchema],
|
|
68
|
-
tool_choice: { type: "function", name: toolSchema.function.name },
|
|
122
|
+
tool_choice: { type: "function", function: { name: toolSchema.function.name } },
|
|
69
123
|
temperature: 0.3,
|
|
70
124
|
};
|
|
125
|
+
const headers = {
|
|
126
|
+
"Content-Type": "application/json",
|
|
127
|
+
};
|
|
128
|
+
if (this.config.apiKey) {
|
|
129
|
+
headers.Authorization = `Bearer ${this.config.apiKey}`;
|
|
130
|
+
}
|
|
71
131
|
const response = await fetch(`${this.config.apiUrl}/chat/completions`, {
|
|
72
132
|
method: "POST",
|
|
73
|
-
headers
|
|
74
|
-
"Content-Type": "application/json",
|
|
75
|
-
Authorization: `Bearer ${this.config.apiKey}`,
|
|
76
|
-
},
|
|
133
|
+
headers,
|
|
77
134
|
body: JSON.stringify(requestBody),
|
|
78
135
|
signal: controller.signal,
|
|
79
136
|
});
|
|
@@ -113,38 +170,46 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
113
170
|
this.aiSessionManager.addMessage(assistantMsg);
|
|
114
171
|
messages.push(choice.message);
|
|
115
172
|
if (choice.message.tool_calls && choice.message.tool_calls.length > 0) {
|
|
116
|
-
const toolCall
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
173
|
+
for (const toolCall of choice.message.tool_calls) {
|
|
174
|
+
const toolCallId = toolCall.id;
|
|
175
|
+
if (toolCall.function.name === toolSchema.function.name) {
|
|
176
|
+
try {
|
|
177
|
+
const parsed = JSON.parse(toolCall.function.arguments);
|
|
178
|
+
const result = UserProfileValidator.validate(parsed);
|
|
179
|
+
if (!result.valid) {
|
|
180
|
+
throw new Error(result.errors.join(", "));
|
|
181
|
+
}
|
|
182
|
+
this.addToolResponse(session.id, messages, toolCallId, JSON.stringify({ success: true }));
|
|
183
|
+
return {
|
|
184
|
+
success: true,
|
|
185
|
+
data: result.data,
|
|
186
|
+
iterations,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
catch (validationError) {
|
|
190
|
+
const errorStack = validationError instanceof Error ? validationError.stack : undefined;
|
|
191
|
+
log("OpenAI tool response validation failed", {
|
|
192
|
+
error: String(validationError),
|
|
193
|
+
stack: errorStack,
|
|
194
|
+
errorType: validationError instanceof Error
|
|
195
|
+
? validationError.constructor.name
|
|
196
|
+
: typeof validationError,
|
|
197
|
+
toolName: toolSchema.function.name,
|
|
198
|
+
iteration: iterations,
|
|
199
|
+
rawArguments: toolCall.function.arguments.slice(0, 500),
|
|
200
|
+
});
|
|
201
|
+
const errorMessage = `Validation failed: ${String(validationError)}`;
|
|
202
|
+
this.addToolResponse(session.id, messages, toolCallId, JSON.stringify({ success: false, error: errorMessage }));
|
|
203
|
+
return {
|
|
204
|
+
success: false,
|
|
205
|
+
error: errorMessage,
|
|
206
|
+
iterations,
|
|
207
|
+
};
|
|
123
208
|
}
|
|
124
|
-
return {
|
|
125
|
-
success: true,
|
|
126
|
-
data: result.data,
|
|
127
|
-
iterations,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
catch (validationError) {
|
|
131
|
-
const errorStack = validationError instanceof Error ? validationError.stack : undefined;
|
|
132
|
-
log("OpenAI tool response validation failed", {
|
|
133
|
-
error: String(validationError),
|
|
134
|
-
stack: errorStack,
|
|
135
|
-
errorType: validationError instanceof Error
|
|
136
|
-
? validationError.constructor.name
|
|
137
|
-
: typeof validationError,
|
|
138
|
-
toolName: toolSchema.function.name,
|
|
139
|
-
iteration: iterations,
|
|
140
|
-
rawArguments: toolCall.function.arguments.slice(0, 500),
|
|
141
|
-
});
|
|
142
|
-
return {
|
|
143
|
-
success: false,
|
|
144
|
-
error: `Validation failed: ${String(validationError)}`,
|
|
145
|
-
iterations,
|
|
146
|
-
};
|
|
147
209
|
}
|
|
210
|
+
const wrongToolMessage = `Wrong tool called. Please use ${toolSchema.function.name} instead.`;
|
|
211
|
+
this.addToolResponse(session.id, messages, toolCallId, JSON.stringify({ success: false, error: wrongToolMessage }));
|
|
212
|
+
break;
|
|
148
213
|
}
|
|
149
214
|
}
|
|
150
215
|
const retrySequence = this.aiSessionManager.getLastSequence(session.id) + 1;
|
|
@@ -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;
|
|
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
|
-
|
|
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(),
|
|
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
|
|
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":"
|
|
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"}
|
package/dist/services/logger.js
CHANGED
|
@@ -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`, {
|
|
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;
|
|
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"}
|
|
@@ -24,7 +24,13 @@ export class ConnectionManager {
|
|
|
24
24
|
log("Using custom SQLite library", { path: customPath });
|
|
25
25
|
}
|
|
26
26
|
catch (error) {
|
|
27
|
-
|
|
27
|
+
const errorStr = String(error);
|
|
28
|
+
if (errorStr.includes("SQLite already loaded")) {
|
|
29
|
+
log("SQLite already loaded, skipping custom path configuration");
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw new Error(`Failed to load custom SQLite library: ${error}\n` + `Path: ${customPath}`);
|
|
33
|
+
}
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
else {
|
|
@@ -45,7 +51,13 @@ export class ConnectionManager {
|
|
|
45
51
|
log("Auto-detected and using Homebrew SQLite", { path: foundPath });
|
|
46
52
|
}
|
|
47
53
|
catch (error) {
|
|
48
|
-
|
|
54
|
+
const errorStr = String(error);
|
|
55
|
+
if (errorStr.includes("SQLite already loaded")) {
|
|
56
|
+
log("SQLite already loaded, skipping auto-detected path configuration");
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
throw new Error(`Failed to load Homebrew SQLite: ${error}\n` + `Path: ${foundPath}`);
|
|
60
|
+
}
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
63
|
else {
|
|
@@ -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
|
|
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");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-server.d.ts","sourceRoot":"","sources":["../../src/services/web-server.ts"],"names":[],"mappings":"AAOA,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAeD,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,YAAY,CAA8B;gBAEtC,MAAM,EAAE,eAAe;IAI7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YASd,MAAM;
|
|
1
|
+
{"version":3,"file":"web-server.d.ts","sourceRoot":"","sources":["../../src/services/web-server.ts"],"names":[],"mappings":"AAOA,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAeD,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,YAAY,CAA8B;gBAEtC,MAAM,EAAE,eAAe;IAI7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YASd,MAAM;IA0Ed,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiC3B,SAAS,IAAI,OAAO;IAIpB,aAAa,IAAI,OAAO;IAIxB,MAAM,IAAI,MAAM;IAIV,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;CAW/C;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAIhF"}
|
|
@@ -51,8 +51,21 @@ export class WebServer {
|
|
|
51
51
|
};
|
|
52
52
|
this.worker.onerror = (error) => {
|
|
53
53
|
clearTimeout(timeout);
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const errorDetails = {
|
|
55
|
+
message: error.message || "Unknown error",
|
|
56
|
+
filename: error.filename || "unknown",
|
|
57
|
+
lineno: error.lineno || 0,
|
|
58
|
+
colno: error.colno || 0,
|
|
59
|
+
error: error.error ? String(error.error) : "no error object",
|
|
60
|
+
type: error.type || "error",
|
|
61
|
+
};
|
|
62
|
+
log("Web server worker error (detailed)", errorDetails);
|
|
63
|
+
const errorMsg = error.message
|
|
64
|
+
? `${error.message} (at ${error.filename}:${error.lineno}:${error.colno})`
|
|
65
|
+
: error.error
|
|
66
|
+
? String(error.error)
|
|
67
|
+
: `Worker failed: ${JSON.stringify(errorDetails)}`;
|
|
68
|
+
reject(new Error(errorMsg));
|
|
56
69
|
};
|
|
57
70
|
});
|
|
58
71
|
this.worker.postMessage({
|
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
|
|
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
|
|