opencode-mem 2.13.0 → 2.14.0
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 +13 -3
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +43 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -20
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +3 -1
- package/dist/services/ai/opencode-provider.d.ts +31 -25
- package/dist/services/ai/opencode-provider.d.ts.map +1 -1
- package/dist/services/ai/opencode-provider.js +76 -222
- package/dist/services/ai/providers/openai-chat-completion.d.ts +6 -5
- package/dist/services/ai/providers/openai-chat-completion.d.ts.map +1 -1
- package/dist/services/ai/providers/openai-chat-completion.js +56 -15
- package/dist/services/api-handlers.d.ts.map +1 -1
- package/dist/services/api-handlers.js +8 -3
- package/dist/services/auto-capture.js +8 -5
- package/dist/services/client.d.ts +3 -2
- package/dist/services/client.d.ts.map +1 -1
- package/dist/services/client.js +14 -8
- package/dist/services/embedding.d.ts.map +1 -1
- package/dist/services/embedding.js +28 -6
- package/dist/services/language-detector.d.ts.map +1 -1
- package/dist/services/language-detector.js +20 -3
- package/dist/services/sqlite/vector-search.d.ts.map +1 -1
- package/dist/services/sqlite/vector-search.js +15 -4
- package/dist/services/user-memory-learning.js +8 -5
- package/package.json +2 -5
|
@@ -1,238 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return _statePath;
|
|
17
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* SDK-based structured output via opencode v2 session.prompt.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the old auth.json/OAuth-juggling flow. Instead of forging requests
|
|
5
|
+
* to provider HTTP endpoints ourselves, we delegate to the running opencode
|
|
6
|
+
* server: it already owns the user's auth (any provider, including
|
|
7
|
+
* github-copilot personal/business), token refresh, and provider routing.
|
|
8
|
+
*
|
|
9
|
+
* Per call we create a transient session, prompt with a JSON schema, then
|
|
10
|
+
* delete the session so it does not pollute the user's TUI session list.
|
|
11
|
+
*/
|
|
12
|
+
import { createOpencodeClient } from "@opencode-ai/sdk/v2/client";
|
|
13
|
+
let _connectedProviders = new Set();
|
|
14
|
+
let _v2Client;
|
|
18
15
|
export function setConnectedProviders(providers) {
|
|
19
|
-
_connectedProviders = providers;
|
|
16
|
+
_connectedProviders = new Set(providers);
|
|
20
17
|
}
|
|
21
18
|
export function isProviderConnected(providerName) {
|
|
22
|
-
return _connectedProviders.
|
|
19
|
+
return _connectedProviders.has(providerName);
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const candidates = [
|
|
27
|
-
join(statePath, "auth.json"),
|
|
28
|
-
join(dirname(statePath), "share", "opencode", "auth.json"),
|
|
29
|
-
join(statePath.replace("/state/", "/share/"), "auth.json"),
|
|
30
|
-
];
|
|
31
|
-
return candidates.find(existsSync);
|
|
21
|
+
export function setV2Client(client) {
|
|
22
|
+
_v2Client = client;
|
|
32
23
|
}
|
|
33
|
-
export function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
export function getV2Client() {
|
|
25
|
+
return _v2Client;
|
|
26
|
+
}
|
|
27
|
+
export function createV2Client(serverUrl) {
|
|
28
|
+
const baseUrl = typeof serverUrl === "string" ? serverUrl : serverUrl.toString();
|
|
29
|
+
return createOpencodeClient({ baseUrl });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generate one structured-output completion via opencode's v2 API.
|
|
33
|
+
* Throws on: session.create failure, prompt failure, AssistantMessage.error
|
|
34
|
+
* (StructuredOutputError / ApiError / ...), missing `info.structured`,
|
|
35
|
+
* or final Zod validation failure.
|
|
36
|
+
*/
|
|
37
|
+
export async function generateStructuredOutput(opts) {
|
|
38
|
+
const { client, providerID, modelID, systemPrompt, userPrompt, schema, directory, retryCount } = opts;
|
|
39
|
+
// zod v4 exposes JSON Schema export natively (instance `.toJSONSchema()`
|
|
40
|
+
// and global `z.toJSONSchema()`); we prefer instance, fall back to global.
|
|
41
|
+
// This avoids pulling in a separate `zod-to-json-schema` dependency.
|
|
42
|
+
const jsonSchema = schema.toJSONSchema?.() ?? (await import("zod")).z.toJSONSchema(schema);
|
|
43
|
+
const created = await client.session.create({
|
|
44
|
+
title: "opencode-mem capture",
|
|
45
|
+
...(directory ? { directory } : {}),
|
|
46
|
+
});
|
|
47
|
+
const sessionID = created?.data?.id;
|
|
48
|
+
if (!sessionID) {
|
|
49
|
+
throw new Error("opencode-mem: session.create returned no session id; cannot generate structured output");
|
|
44
50
|
}
|
|
45
|
-
let parsed;
|
|
46
51
|
try {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export function createOAuthFetch(statePath, providerName) {
|
|
65
|
-
return async (input, init) => {
|
|
66
|
-
let auth = readOpencodeAuth(statePath, providerName);
|
|
67
|
-
// Refresh token if expired
|
|
68
|
-
if (!auth.access || auth.expires < Date.now()) {
|
|
69
|
-
const refreshResponse = await fetch(OAUTH_TOKEN_URL, {
|
|
70
|
-
method: "POST",
|
|
71
|
-
headers: { "Content-Type": "application/json" },
|
|
72
|
-
body: JSON.stringify({
|
|
73
|
-
grant_type: "refresh_token",
|
|
74
|
-
refresh_token: auth.refresh,
|
|
75
|
-
client_id: OAUTH_CLIENT_ID,
|
|
76
|
-
}),
|
|
77
|
-
});
|
|
78
|
-
if (!refreshResponse.ok) {
|
|
79
|
-
throw new Error(`OAuth token refresh failed: ${refreshResponse.status}`);
|
|
80
|
-
}
|
|
81
|
-
const json = (await refreshResponse.json());
|
|
82
|
-
auth = {
|
|
83
|
-
type: "oauth",
|
|
84
|
-
refresh: json.refresh_token,
|
|
85
|
-
access: json.access_token,
|
|
86
|
-
expires: Date.now() + json.expires_in * 1000,
|
|
87
|
-
};
|
|
88
|
-
const authPath = findAuthJsonPath(statePath);
|
|
89
|
-
if (authPath) {
|
|
90
|
-
try {
|
|
91
|
-
const allAuth = JSON.parse(readFileSync(authPath, "utf-8"));
|
|
92
|
-
allAuth[providerName] = auth;
|
|
93
|
-
writeFileSync(authPath, JSON.stringify(allAuth));
|
|
94
|
-
}
|
|
95
|
-
catch { }
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// Build headers
|
|
99
|
-
const requestInit = init ?? {};
|
|
100
|
-
const requestHeaders = new Headers();
|
|
101
|
-
if (input instanceof Request) {
|
|
102
|
-
input.headers.forEach((value, key) => requestHeaders.set(key, value));
|
|
52
|
+
const promptResult = await client.session.prompt({
|
|
53
|
+
sessionID,
|
|
54
|
+
...(directory ? { directory } : {}),
|
|
55
|
+
model: { providerID, modelID },
|
|
56
|
+
system: systemPrompt,
|
|
57
|
+
parts: [{ type: "text", text: userPrompt }],
|
|
58
|
+
format: {
|
|
59
|
+
type: "json_schema",
|
|
60
|
+
schema: jsonSchema,
|
|
61
|
+
...(retryCount !== undefined ? { retryCount } : {}),
|
|
62
|
+
},
|
|
63
|
+
noReply: true,
|
|
64
|
+
});
|
|
65
|
+
const data = promptResult.data;
|
|
66
|
+
const info = data?.info;
|
|
67
|
+
if (!info) {
|
|
68
|
+
throw new Error("opencode-mem: prompt response missing `info`");
|
|
103
69
|
}
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
else if (Array.isArray(requestInit.headers)) {
|
|
109
|
-
for (const pair of requestInit.headers) {
|
|
110
|
-
const [key, value] = pair;
|
|
111
|
-
if (typeof value !== "undefined")
|
|
112
|
-
requestHeaders.set(key, value);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
for (const [key, value] of Object.entries(requestInit.headers)) {
|
|
117
|
-
if (typeof value !== "undefined")
|
|
118
|
-
requestHeaders.set(key, String(value));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
70
|
+
if (info.error) {
|
|
71
|
+
const msg = info.error.data?.message ?? info.error.name;
|
|
72
|
+
throw new Error(`opencode-mem: opencode reported ${info.error.name}: ${msg}`);
|
|
121
73
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const incomingBetas = incomingBeta
|
|
125
|
-
.split(",")
|
|
126
|
-
.map((b) => b.trim())
|
|
127
|
-
.filter(Boolean);
|
|
128
|
-
const mergedBetas = [...new Set([...OAUTH_REQUIRED_BETAS, ...incomingBetas])].join(",");
|
|
129
|
-
requestHeaders.set("authorization", `Bearer ${auth.access}`);
|
|
130
|
-
requestHeaders.set("anthropic-beta", mergedBetas);
|
|
131
|
-
requestHeaders.set("user-agent", "claude-cli/2.1.2 (external, cli)");
|
|
132
|
-
requestHeaders.delete("x-api-key");
|
|
133
|
-
// Prefix tool names in request body
|
|
134
|
-
let body = requestInit.body;
|
|
135
|
-
if (body && typeof body === "string") {
|
|
136
|
-
try {
|
|
137
|
-
const parsed = JSON.parse(body);
|
|
138
|
-
if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
139
|
-
parsed.tools = parsed.tools.map((tool) => ({
|
|
140
|
-
...tool,
|
|
141
|
-
name: tool.name ? `${MCP_TOOL_PREFIX}${tool.name}` : tool.name,
|
|
142
|
-
}));
|
|
143
|
-
}
|
|
144
|
-
if (parsed.messages && Array.isArray(parsed.messages)) {
|
|
145
|
-
parsed.messages = parsed.messages.map((msg) => {
|
|
146
|
-
if (msg.content && Array.isArray(msg.content)) {
|
|
147
|
-
msg.content = msg.content.map((block) => {
|
|
148
|
-
if (block.type === "tool_use" && block.name) {
|
|
149
|
-
return { ...block, name: `${MCP_TOOL_PREFIX}${block.name}` };
|
|
150
|
-
}
|
|
151
|
-
return block;
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return msg;
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
body = JSON.stringify(parsed);
|
|
158
|
-
}
|
|
159
|
-
catch { }
|
|
74
|
+
if (info.structured === undefined || info.structured === null) {
|
|
75
|
+
throw new Error("opencode-mem: opencode returned no structured output (info.structured was empty)");
|
|
160
76
|
}
|
|
161
|
-
|
|
162
|
-
|
|
77
|
+
return schema.parse(info.structured);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
// Best-effort: leaving a transient session behind is cosmetic, not
|
|
81
|
+
// worth failing a successful capture if cleanup itself errors.
|
|
163
82
|
try {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
else if (input instanceof Request) {
|
|
169
|
-
requestUrl = new URL(input.url);
|
|
170
|
-
}
|
|
171
|
-
if (requestUrl?.pathname === "/v1/messages" && !requestUrl.searchParams.has("beta")) {
|
|
172
|
-
requestUrl.searchParams.set("beta", "true");
|
|
173
|
-
requestInput =
|
|
174
|
-
input instanceof Request ? new Request(requestUrl.toString(), input) : requestUrl;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
catch { }
|
|
178
|
-
const response = await fetch(requestInput, { ...requestInit, body, headers: requestHeaders });
|
|
179
|
-
// Strip mcp_ prefix from tool names in streaming response
|
|
180
|
-
if (response.body) {
|
|
181
|
-
const reader = response.body.getReader();
|
|
182
|
-
const decoder = new TextDecoder();
|
|
183
|
-
const encoder = new TextEncoder();
|
|
184
|
-
const stream = new ReadableStream({
|
|
185
|
-
async pull(controller) {
|
|
186
|
-
const { done, value } = await reader.read();
|
|
187
|
-
if (done) {
|
|
188
|
-
controller.close();
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
let text = decoder.decode(value, { stream: true });
|
|
192
|
-
text = text.replace(/"name"\s*:\s*"mcp_([^"]+)"/g, '"name": "$1"');
|
|
193
|
-
controller.enqueue(encoder.encode(text));
|
|
194
|
-
},
|
|
195
|
-
});
|
|
196
|
-
return new Response(stream, {
|
|
197
|
-
status: response.status,
|
|
198
|
-
statusText: response.statusText,
|
|
199
|
-
headers: response.headers,
|
|
83
|
+
await client.session.delete({
|
|
84
|
+
sessionID,
|
|
85
|
+
...(directory ? { directory } : {}),
|
|
200
86
|
});
|
|
201
87
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
// --- Provider ---
|
|
206
|
-
export function createOpencodeAIProvider(providerName, auth, statePath) {
|
|
207
|
-
if (providerName === "anthropic") {
|
|
208
|
-
if (auth.type === "oauth") {
|
|
209
|
-
if (!statePath)
|
|
210
|
-
throw new Error("statePath is required for OAuth authentication");
|
|
211
|
-
return createAnthropic({
|
|
212
|
-
apiKey: "",
|
|
213
|
-
fetch: createOAuthFetch(statePath, providerName),
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
return createAnthropic({ apiKey: auth.key });
|
|
217
|
-
}
|
|
218
|
-
if (providerName === "openai") {
|
|
219
|
-
if (auth.type === "oauth") {
|
|
220
|
-
throw new Error("OpenAI does not support OAuth authentication. Use an API key instead.");
|
|
88
|
+
catch {
|
|
89
|
+
// intentionally swallowed
|
|
221
90
|
}
|
|
222
|
-
return createOpenAI({ apiKey: auth.key });
|
|
223
91
|
}
|
|
224
|
-
throw new Error(`Unsupported opencode provider: '${providerName}'. Supported providers: anthropic, openai`);
|
|
225
|
-
}
|
|
226
|
-
// --- Structured Output ---
|
|
227
|
-
export async function generateStructuredOutput(options) {
|
|
228
|
-
const auth = readOpencodeAuth(options.statePath, options.providerName);
|
|
229
|
-
const provider = createOpencodeAIProvider(options.providerName, auth, options.statePath);
|
|
230
|
-
const result = await generateText({
|
|
231
|
-
model: provider(options.modelId),
|
|
232
|
-
system: options.systemPrompt,
|
|
233
|
-
prompt: options.userPrompt,
|
|
234
|
-
output: Output.object({ schema: options.schema }),
|
|
235
|
-
temperature: options.temperature ?? 0.3,
|
|
236
|
-
});
|
|
237
|
-
return result.output;
|
|
238
92
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { BaseAIProvider, type ToolCallResult } from "./base-provider.js";
|
|
2
|
-
import { AISessionManager } from "../session/ai-session-manager.js";
|
|
1
|
+
import { BaseAIProvider, type ProviderConfig, type ToolCallResult } from "./base-provider.js";
|
|
2
|
+
import type { AISessionManager } from "../session/ai-session-manager.js";
|
|
3
|
+
import type { AIMessage } from "../session/session-types.js";
|
|
3
4
|
import type { ChatCompletionTool } from "../tools/tool-schema.js";
|
|
4
5
|
export declare class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
5
|
-
private aiSessionManager;
|
|
6
|
-
constructor(config:
|
|
6
|
+
private readonly aiSessionManager;
|
|
7
|
+
constructor(config: ProviderConfig, aiSessionManager: AISessionManager);
|
|
7
8
|
getProviderName(): string;
|
|
8
9
|
supportsSession(): boolean;
|
|
9
10
|
private addToolResponse;
|
|
10
|
-
|
|
11
|
+
protected filterIncompleteToolCallSequences(messages: AIMessage[]): AIMessage[];
|
|
11
12
|
executeToolCall(systemPrompt: string, userPrompt: string, toolSchema: ChatCompletionTool, sessionId: string): Promise<ToolCallResult>;
|
|
12
13
|
}
|
|
13
14
|
//# 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,
|
|
1
|
+
{"version":3,"file":"openai-chat-completion.d.ts","sourceRoot":"","sources":["../../../../src/services/ai/providers/openai-chat-completion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAgElE,qBAAa,4BAA6B,SAAQ,cAAc;IAC9D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;gBAExC,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB;IAKtE,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,OAAO;IAI1B,OAAO,CAAC,eAAe;IAqBvB,SAAS,CAAC,iCAAiC,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE;IAwCzE,eAAe,CACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,kBAAkB,EAC9B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;CAmS3B"}
|
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import { BaseAIProvider, applySafeExtraParams } from "./base-provider.js";
|
|
2
|
-
import { AISessionManager } from "../session/ai-session-manager.js";
|
|
1
|
+
import { BaseAIProvider, applySafeExtraParams, } from "./base-provider.js";
|
|
3
2
|
import { log } from "../../logger.js";
|
|
4
3
|
import { UserProfileValidator } from "../validators/user-profile-validator.js";
|
|
4
|
+
function isErrorResponseBody(data) {
|
|
5
|
+
return (typeof data === "object" &&
|
|
6
|
+
data !== null &&
|
|
7
|
+
typeof data.status === "string" &&
|
|
8
|
+
typeof data.msg === "string");
|
|
9
|
+
}
|
|
10
|
+
function hasNonEmptyChoices(data) {
|
|
11
|
+
if (typeof data !== "object" || data === null)
|
|
12
|
+
return false;
|
|
13
|
+
const { choices } = data;
|
|
14
|
+
if (!Array.isArray(choices) || choices.length === 0)
|
|
15
|
+
return false;
|
|
16
|
+
const first = choices[0];
|
|
17
|
+
if (typeof first !== "object" || first === null)
|
|
18
|
+
return false;
|
|
19
|
+
if (typeof first.message !== "object" || first.message === null)
|
|
20
|
+
return false;
|
|
21
|
+
const { content, tool_calls } = first.message;
|
|
22
|
+
if (content !== undefined && content !== null && typeof content !== "string")
|
|
23
|
+
return false;
|
|
24
|
+
if (tool_calls !== undefined && !Array.isArray(tool_calls))
|
|
25
|
+
return false;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
5
28
|
export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
6
29
|
aiSessionManager;
|
|
7
30
|
constructor(config, aiSessionManager) {
|
|
@@ -34,14 +57,18 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
34
57
|
let i = 0;
|
|
35
58
|
while (i < messages.length) {
|
|
36
59
|
const msg = messages[i];
|
|
60
|
+
if (!msg) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
37
63
|
if (msg.role === "assistant" && msg.toolCalls && msg.toolCalls.length > 0) {
|
|
38
64
|
const toolCallIds = new Set(msg.toolCalls.map((tc) => tc.id));
|
|
39
65
|
const toolResponses = [];
|
|
40
66
|
let j = i + 1;
|
|
41
|
-
while (j < messages.length && messages[j]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
while (j < messages.length && messages[j]?.role === "tool") {
|
|
68
|
+
const toolMessage = messages[j];
|
|
69
|
+
if (toolMessage?.toolCallId && toolCallIds.has(toolMessage.toolCallId)) {
|
|
70
|
+
toolResponses.push(toolMessage);
|
|
71
|
+
toolCallIds.delete(toolMessage.toolCallId);
|
|
45
72
|
}
|
|
46
73
|
j++;
|
|
47
74
|
}
|
|
@@ -158,8 +185,8 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
158
185
|
iterations,
|
|
159
186
|
};
|
|
160
187
|
}
|
|
161
|
-
const data =
|
|
162
|
-
if (data
|
|
188
|
+
const data = await response.json();
|
|
189
|
+
if (isErrorResponseBody(data)) {
|
|
163
190
|
log("API returned error in response body", {
|
|
164
191
|
provider: this.getProviderName(),
|
|
165
192
|
model: this.config.model,
|
|
@@ -172,13 +199,16 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
172
199
|
iterations,
|
|
173
200
|
};
|
|
174
201
|
}
|
|
175
|
-
if (!data
|
|
202
|
+
if (!hasNonEmptyChoices(data)) {
|
|
203
|
+
const choices = typeof data === "object" && data !== null
|
|
204
|
+
? data.choices
|
|
205
|
+
: undefined;
|
|
176
206
|
log("Invalid API response format", {
|
|
177
207
|
provider: this.getProviderName(),
|
|
178
208
|
model: this.config.model,
|
|
179
209
|
response: JSON.stringify(data).slice(0, 1000),
|
|
180
|
-
hasChoices:
|
|
181
|
-
choicesLength:
|
|
210
|
+
hasChoices: Array.isArray(choices),
|
|
211
|
+
choicesLength: Array.isArray(choices) ? choices.length : undefined,
|
|
182
212
|
});
|
|
183
213
|
return {
|
|
184
214
|
success: false,
|
|
@@ -187,18 +217,29 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
187
217
|
};
|
|
188
218
|
}
|
|
189
219
|
const choice = data.choices[0];
|
|
220
|
+
if (!choice) {
|
|
221
|
+
return {
|
|
222
|
+
success: false,
|
|
223
|
+
error: "Invalid API response format",
|
|
224
|
+
iterations,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
190
227
|
const assistantSequence = this.aiSessionManager.getLastSequence(session.id) + 1;
|
|
191
228
|
const assistantMsg = {
|
|
192
229
|
aiSessionId: session.id,
|
|
193
230
|
sequence: assistantSequence,
|
|
194
231
|
role: "assistant",
|
|
195
|
-
content: choice.message.content
|
|
232
|
+
content: choice.message.content ?? "",
|
|
196
233
|
};
|
|
197
234
|
if (choice.message.tool_calls) {
|
|
198
235
|
assistantMsg.toolCalls = choice.message.tool_calls;
|
|
199
236
|
}
|
|
200
237
|
this.aiSessionManager.addMessage(assistantMsg);
|
|
201
|
-
messages.push(
|
|
238
|
+
messages.push({
|
|
239
|
+
role: "assistant",
|
|
240
|
+
content: choice.message.content ?? null,
|
|
241
|
+
tool_calls: choice.message.tool_calls,
|
|
242
|
+
});
|
|
202
243
|
if (choice.message.tool_calls && choice.message.tool_calls.length > 0) {
|
|
203
244
|
for (const toolCall of choice.message.tool_calls) {
|
|
204
245
|
const toolCallId = toolCall.id;
|
|
@@ -257,7 +298,7 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
257
298
|
if (error instanceof Error && error.name === "AbortError") {
|
|
258
299
|
return {
|
|
259
300
|
success: false,
|
|
260
|
-
error: `API request timeout (${
|
|
301
|
+
error: `API request timeout (${iterationTimeout}ms)`,
|
|
261
302
|
iterations,
|
|
262
303
|
};
|
|
263
304
|
}
|
|
@@ -270,7 +311,7 @@ export class OpenAIChatCompletionProvider extends BaseAIProvider {
|
|
|
270
311
|
}
|
|
271
312
|
return {
|
|
272
313
|
success: false,
|
|
273
|
-
error: `Max iterations (${
|
|
314
|
+
error: `Max iterations (${maxIterations}) reached without tool call`,
|
|
274
315
|
iterations,
|
|
275
316
|
};
|
|
276
317
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-handlers.d.ts","sourceRoot":"","sources":["../../src/services/api-handlers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,UAAU,WAAW,CAAC,CAAC,GAAG,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,MAAM;IACd,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAA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AAC,CAE7F;AAED,wBAAsB,0BAA0B,CAC9C,SAAS,GAAE,MAAU,GACpB,OAAO,CAAC,WAAW,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,CA6G9E"}
|
|
@@ -54,7 +54,10 @@ function getProjectPathFromTag(tag) {
|
|
|
54
54
|
}
|
|
55
55
|
export async function handleListTags() {
|
|
56
56
|
try {
|
|
57
|
-
|
|
57
|
+
// Tags are stored as SQLite metadata; embedding model is not needed.
|
|
58
|
+
// Calling warmup() here would block on @huggingface/transformers init in
|
|
59
|
+
// the worker thread and hang every read API. Only handlers that compute
|
|
60
|
+
// similarity (e.g. handleSearch) should warm up the embedding service.
|
|
58
61
|
const projectShards = shardManager.getAllShards("project", "");
|
|
59
62
|
const tagsMap = new Map();
|
|
60
63
|
for (const shard of projectShards) {
|
|
@@ -89,7 +92,8 @@ export async function handleListTags() {
|
|
|
89
92
|
}
|
|
90
93
|
export async function handleListMemories(tag, page = 1, pageSize = 20, includePrompts = true) {
|
|
91
94
|
try {
|
|
92
|
-
|
|
95
|
+
// Listing only reads SQLite rows; no vector ops happen here.
|
|
96
|
+
// See handleListTags comment - keep embedding init out of read paths.
|
|
93
97
|
let allMemories = [];
|
|
94
98
|
if (tag) {
|
|
95
99
|
const { scope: tagScope, hash } = extractScopeFromTag(tag);
|
|
@@ -520,7 +524,8 @@ export async function handleSearch(query, tag, page = 1, pageSize = 20) {
|
|
|
520
524
|
}
|
|
521
525
|
export async function handleStats() {
|
|
522
526
|
try {
|
|
523
|
-
|
|
527
|
+
// Stats only counts SQLite rows; no embedding needed.
|
|
528
|
+
// See handleListTags comment - keep embedding init out of read paths.
|
|
524
529
|
const projectShards = shardManager.getAllShards("project", "");
|
|
525
530
|
let userCount = 0, projectCount = 0;
|
|
526
531
|
const typeCount = {};
|
|
@@ -181,10 +181,14 @@ async function generateSummary(context, sessionID, userPrompt) {
|
|
|
181
181
|
if (CONFIG.memoryModel) {
|
|
182
182
|
log("opencodeProvider takes precedence over memoryModel for auto-capture");
|
|
183
183
|
}
|
|
184
|
-
const { isProviderConnected,
|
|
184
|
+
const { isProviderConnected, getV2Client, generateStructuredOutput } = await import("./ai/opencode-provider.js");
|
|
185
185
|
if (!isProviderConnected(CONFIG.opencodeProvider)) {
|
|
186
186
|
throw new Error(`opencode provider '${CONFIG.opencodeProvider}' is not connected. Check your opencode provider configuration.`);
|
|
187
187
|
}
|
|
188
|
+
const v2Client = getV2Client();
|
|
189
|
+
if (!v2Client) {
|
|
190
|
+
throw new Error("opencode-mem: v2 client not initialized; cannot perform structured-output capture");
|
|
191
|
+
}
|
|
188
192
|
const { detectLanguage, getLanguageName } = await import("./language-detector.js");
|
|
189
193
|
const targetLang = CONFIG.autoCaptureLanguage === "auto" || !CONFIG.autoCaptureLanguage
|
|
190
194
|
? detectLanguage(userPrompt)
|
|
@@ -219,13 +223,12 @@ Analyze this conversation. If it contains technical work (code, bugs, features,
|
|
|
219
223
|
tags: z.array(z.string()),
|
|
220
224
|
});
|
|
221
225
|
const result = await generateStructuredOutput({
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
226
|
+
client: v2Client,
|
|
227
|
+
providerID: CONFIG.opencodeProvider,
|
|
228
|
+
modelID: CONFIG.opencodeModel,
|
|
225
229
|
systemPrompt,
|
|
226
230
|
userPrompt: aiPrompt,
|
|
227
231
|
schema,
|
|
228
|
-
temperature: CONFIG.memoryTemperature === false ? undefined : (CONFIG.memoryTemperature ?? 0.3),
|
|
229
232
|
});
|
|
230
233
|
return {
|
|
231
234
|
summary: result.summary,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MemoryType } from "../types/index.js";
|
|
2
|
+
export type MemoryScope = "project" | "all-projects";
|
|
2
3
|
export declare class LocalMemoryClient {
|
|
3
4
|
private initPromise;
|
|
4
5
|
private isInitialized;
|
|
@@ -12,7 +13,7 @@ export declare class LocalMemoryClient {
|
|
|
12
13
|
ready: boolean;
|
|
13
14
|
};
|
|
14
15
|
close(): void;
|
|
15
|
-
searchMemories(query: string, containerTag: string): Promise<{
|
|
16
|
+
searchMemories(query: string, containerTag: string, scope?: MemoryScope): Promise<{
|
|
16
17
|
success: true;
|
|
17
18
|
results: import("./sqlite/types.js").SearchResult[];
|
|
18
19
|
total: number;
|
|
@@ -56,7 +57,7 @@ export declare class LocalMemoryClient {
|
|
|
56
57
|
success: boolean;
|
|
57
58
|
error: string;
|
|
58
59
|
}>;
|
|
59
|
-
listMemories(containerTag: string, limit?: number): Promise<{
|
|
60
|
+
listMemories(containerTag: string, limit?: number, scope?: MemoryScope): Promise<{
|
|
60
61
|
success: true;
|
|
61
62
|
memories: {
|
|
62
63
|
id: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/services/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/services/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,cAAc,CAAC;AAqDrD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,aAAa,CAAkB;;YAIzB,UAAU;IAiBlB,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjE,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAIjC,SAAS,IAAI;QACX,WAAW,EAAE,OAAO,CAAC;QACrB,WAAW,EAAE,OAAO,CAAC;QACrB,KAAK,EAAE,OAAO,CAAC;KAChB;IAQD,KAAK,IAAI,IAAI;IAIP,cAA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