openfox 2.0.24 → 2.0.26

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.
Files changed (45) hide show
  1. package/dist/auto-config-FZFXOEEG.js +169 -0
  2. package/dist/backend-AGXWAU7A.js +9 -0
  3. package/dist/{chat-handler-4ATHDLH4.js → chat-handler-C4HZJNUN.js} +28 -47
  4. package/dist/{chunk-QK6TYNUN.js → chunk-7H4PYZMT.js} +6 -6
  5. package/dist/{chunk-RYHCYZQ7.js → chunk-DW55I7SI.js} +26 -24
  6. package/dist/{chunk-YVF3BLQS.js → chunk-GBUP7UDI.js} +36 -22
  7. package/dist/chunk-HNCM3D7Y.js +28 -0
  8. package/dist/chunk-IEDE6VK4.js +124 -0
  9. package/dist/chunk-J2GP3J3X.js +97 -0
  10. package/dist/{chunk-MDRNKI7D.js → chunk-K454WU7A.js} +62 -49
  11. package/dist/chunk-M3RB4IF6.js +114 -0
  12. package/dist/{chunk-XJ4SUDL7.js → chunk-QYP6MOB5.js} +33 -242
  13. package/dist/chunk-V4IE7HJY.js +175 -0
  14. package/dist/{chunk-GI24G4OW.js → chunk-VI236SOY.js} +79 -59
  15. package/dist/{chunk-CDIYCGCO.js → chunk-WEXW7ZXJ.js} +2 -2
  16. package/dist/{chunk-INRKWEOH.js → chunk-YBPRGUAE.js} +116 -65
  17. package/dist/{chunk-YUHODMKY.js → chunk-YGSBVKFU.js} +11 -5
  18. package/dist/{chunk-4EDH3ZXL.js → chunk-YRRUHP4T.js} +3 -3
  19. package/dist/chunk-Z4FMBCJO.js +52 -0
  20. package/dist/chunk-ZJ4FP6RS.js +200 -0
  21. package/dist/cli/dev.js +1 -1
  22. package/dist/cli/index.js +1 -1
  23. package/dist/client-X6BVH4Q4.js +13 -0
  24. package/dist/client-pure-5NOTSIRK.js +19 -0
  25. package/dist/{compactor-SEZEZSML.js → compactor-JMGSZ4DQ.js} +7 -4
  26. package/dist/http-client-SIPAW7IM.js +8 -0
  27. package/dist/{orchestrator-MFN7COWT.js → orchestrator-HZX3IETX.js} +16 -13
  28. package/dist/package.json +1 -1
  29. package/dist/{processor-W2ZSJVOJ.js → processor-AX2QQWUX.js} +30 -55
  30. package/dist/profiles-Q36ELWQF.js +9 -0
  31. package/dist/{provider-IMW3ITB7.js → provider-XRTIWMB6.js} +15 -9
  32. package/dist/provider-manager-4H4VGNYA.js +22 -0
  33. package/dist/{serve-ABSUHKT3.js → serve-NVFK3XHF.js} +23 -17
  34. package/dist/server/index.d.ts +9 -1
  35. package/dist/server/index.js +19 -13
  36. package/dist/{server-7EAYI7T4.js → server-7MFV467L.js} +18 -12
  37. package/dist/{tools-7CKTYL2G.js → tools-4KGLCQJL.js} +11 -8
  38. package/dist/url-utils-QWAHP54Q.js +15 -0
  39. package/dist/web/assets/{index-CkUCxzzC.css → index-BLOGpuPE.css} +1 -1
  40. package/dist/web/assets/{index-Bi5R_oF2.js → index-CtG8oo36.js} +66 -66
  41. package/dist/web/index.html +2 -2
  42. package/dist/web/sw.js +1 -1
  43. package/package.json +1 -1
  44. package/dist/chunk-UUFEE7VR.js +0 -505
  45. package/dist/provider-manager-DNBMBP4D.js +0 -16
@@ -1,132 +1,25 @@
1
+ import {
2
+ getBackendCapabilities
3
+ } from "./chunk-Z4FMBCJO.js";
4
+ import {
5
+ ensureVersionPrefix
6
+ } from "./chunk-HNCM3D7Y.js";
1
7
  import {
2
8
  buildNonStreamingCreateParams,
3
9
  buildStreamingCreateParams,
4
- getBackendCapabilities,
5
- getModelProfile,
6
10
  getThinking,
7
11
  mapFinishReason
8
- } from "./chunk-UUFEE7VR.js";
12
+ } from "./chunk-ZJ4FP6RS.js";
13
+ import {
14
+ LLMError,
15
+ OpenAIHttpClient
16
+ } from "./chunk-IEDE6VK4.js";
9
17
  import {
10
18
  logger
11
19
  } from "./chunk-K44MW7JJ.js";
12
-
13
- // src/server/llm/url-utils.ts
14
- var VERSION_PREFIX_REGEX = /\/v\d+(\/|$)/;
15
- function hasVersionPrefix(url) {
16
- return VERSION_PREFIX_REGEX.test(url);
17
- }
18
- function ensureVersionPrefix(url, defaultVersion = "/v1") {
19
- if (hasVersionPrefix(url)) return url;
20
- return `${url.replace(/\/+$/, "")}${defaultVersion}`;
21
- }
22
- function stripVersionPrefix(url) {
23
- return url.replace(/\/v\d+\/?$/, "");
24
- }
25
- function buildModelsUrl(baseUrl) {
26
- return `${ensureVersionPrefix(baseUrl)}/models`;
27
- }
28
-
29
- // src/server/utils/errors.ts
30
- var OpenFoxError = class extends Error {
31
- constructor(message, code, details) {
32
- super(message);
33
- this.code = code;
34
- this.details = details;
35
- this.name = "OpenFoxError";
36
- }
37
- };
38
- var SessionNotFoundError = class extends OpenFoxError {
39
- constructor(sessionId) {
40
- super(`Session not found: ${sessionId}`, "SESSION_NOT_FOUND", { sessionId });
41
- this.name = "SessionNotFoundError";
42
- }
43
- };
44
- var LLMError = class extends OpenFoxError {
45
- constructor(message, details) {
46
- super(message, "LLM_ERROR", details);
47
- this.name = "LLMError";
48
- }
49
- };
50
-
51
- // src/server/llm/http-client.ts
52
- import { Agent, setGlobalDispatcher } from "undici";
53
- var agent = new Agent({ allowH2: true });
54
- setGlobalDispatcher(agent);
55
- var OpenAIHttpClient = class {
56
- baseURL;
57
- apiKey;
58
- constructor(options) {
59
- this.baseURL = options.baseURL;
60
- this.apiKey = options.apiKey;
61
- }
62
- async fetchChatCompletion(params, options) {
63
- const url = `${this.baseURL}/chat/completions`;
64
- const headers = {
65
- "Content-Type": "application/json",
66
- Authorization: `Bearer ${this.apiKey}`
67
- };
68
- const response = await fetch(url, {
69
- method: "POST",
70
- headers,
71
- body: JSON.stringify(params),
72
- signal: options?.signal ?? null
73
- });
74
- if (!response.ok) {
75
- const errorText = await response.text();
76
- throw new LLMError(`HTTP ${response.status}: ${errorText}`);
77
- }
78
- return response;
79
- }
80
- async createChatCompletion(params, options) {
81
- const response = await this.fetchChatCompletion(params, options);
82
- try {
83
- const data = await response.json();
84
- return data;
85
- } catch (error) {
86
- throw new LLMError(`Failed to parse response: ${error instanceof Error ? error.message : "Unknown error"}`);
87
- }
88
- }
89
- createChatCompletionStream(params, options) {
90
- const responsePromise = this.fetchChatCompletion(params, options);
91
- async function* generate() {
92
- const response = await responsePromise;
93
- if (!response.body) {
94
- throw new LLMError("No response body for streaming");
95
- }
96
- const reader = response.body.getReader();
97
- const decoder = new TextDecoder();
98
- let buffer = "";
99
- try {
100
- while (true) {
101
- const { done, value } = await reader.read();
102
- if (done) break;
103
- buffer += decoder.decode(value, { stream: true });
104
- const lines = buffer.split("\n");
105
- buffer = lines.pop() || "";
106
- for (const line of lines) {
107
- const trimmed = line.trim();
108
- if (!trimmed) continue;
109
- if (trimmed.startsWith("data: ")) {
110
- const data = trimmed.slice(6);
111
- if (data === "[DONE]") {
112
- return;
113
- }
114
- try {
115
- const chunk = JSON.parse(data);
116
- yield chunk;
117
- } catch (error) {
118
- logger.warn("Failed to parse SSE chunk", { data, error });
119
- }
120
- }
121
- }
122
- }
123
- } finally {
124
- reader.releaseLock();
125
- }
126
- }
127
- return generate();
128
- }
129
- };
20
+ import {
21
+ getModelProfile
22
+ } from "./chunk-V4IE7HJY.js";
130
23
 
131
24
  // src/server/llm/client.ts
132
25
  function createLLMClient(config, initialBackend = "unknown") {
@@ -141,7 +34,7 @@ function createLLMClient(config, initialBackend = "unknown") {
141
34
  let capabilities = getBackendCapabilities(backend);
142
35
  const reasoningEffort = config.llm.reasoningEffort;
143
36
  const thinkingField = config.llm.thinkingField;
144
- const idleTimeout = config.llm.idleTimeout ?? 3e4;
37
+ const idleTimeout = config.llm.idleTimeout ?? 12e4;
145
38
  return {
146
39
  getModel() {
147
40
  return model;
@@ -176,7 +69,7 @@ function createLLMClient(config, initialBackend = "unknown") {
176
69
  reasoningEffort: request.reasoningEffort ?? reasoningEffort
177
70
  });
178
71
  try {
179
- const resolvedEffort = request.reasoningEffort ?? reasoningEffort;
72
+ const resolvedEffort = request.skipClientReasoningEffort ? void 0 : request.reasoningEffort ?? reasoningEffort;
180
73
  const { params: createParams } = await buildNonStreamingCreateParams({
181
74
  model,
182
75
  request,
@@ -185,10 +78,14 @@ function createLLMClient(config, initialBackend = "unknown") {
185
78
  ...resolvedEffort ? { reasoningEffort: resolvedEffort } : {},
186
79
  ...thinkingField ? { thinkingField } : {}
187
80
  });
188
- const response = await httpClient.createChatCompletion(createParams, {
189
- signal: request.signal
190
- });
191
- const choice = response.choices[0];
81
+ const httpResponse = await httpClient.createChatCompletion(
82
+ createParams,
83
+ {
84
+ signal: request.signal
85
+ },
86
+ request.returnRaw
87
+ );
88
+ const choice = httpResponse.choices[0];
192
89
  if (!choice) {
193
90
  throw new LLMError("No completion choice returned");
194
91
  }
@@ -201,16 +98,17 @@ function createLLMClient(config, initialBackend = "unknown") {
201
98
  arguments: JSON.parse(tc.function.arguments)
202
99
  }));
203
100
  return {
204
- id: response.id,
101
+ id: httpResponse.id,
205
102
  content,
206
103
  ...thinkingContent ? { thinkingContent } : {},
207
104
  ...toolCalls && toolCalls.length > 0 ? { toolCalls } : {},
208
105
  finishReason: mapFinishReason(choice.finish_reason),
209
106
  usage: {
210
- promptTokens: response.usage?.prompt_tokens ?? 0,
211
- completionTokens: response.usage?.completion_tokens ?? 0,
212
- totalTokens: response.usage?.total_tokens ?? 0
213
- }
107
+ promptTokens: httpResponse.usage?.prompt_tokens ?? 0,
108
+ completionTokens: httpResponse.usage?.completion_tokens ?? 0,
109
+ totalTokens: httpResponse.usage?.total_tokens ?? 0
110
+ },
111
+ ...httpResponse.raw ? { raw: httpResponse.raw } : {}
214
112
  };
215
113
  } catch (error) {
216
114
  logger.error("LLM complete error", { error: String(error) });
@@ -220,7 +118,7 @@ function createLLMClient(config, initialBackend = "unknown") {
220
118
  }
221
119
  },
222
120
  async *stream(request) {
223
- const resolvedEffort = request.reasoningEffort ?? reasoningEffort;
121
+ const resolvedEffort = request.skipClientReasoningEffort ? void 0 : request.reasoningEffort ?? reasoningEffort;
224
122
  logger.debug("LLM stream request", {
225
123
  messageCount: request.messages.length,
226
124
  hasTools: !!request.tools?.length,
@@ -358,114 +256,7 @@ function createLLMClient(config, initialBackend = "unknown") {
358
256
  };
359
257
  }
360
258
 
361
- // src/server/llm/models.ts
362
- var modelCache = /* @__PURE__ */ new Map();
363
- var llmStatus = "unknown";
364
- var lastActiveUrl = null;
365
- var CACHE_TTL_MS = 3e4;
366
- function getCacheKey(url) {
367
- return stripVersionPrefix(url);
368
- }
369
- async function detectModel(llmBaseUrl, retries = 3, silent = false) {
370
- const cacheKey = getCacheKey(llmBaseUrl);
371
- const now = Date.now();
372
- const cached = modelCache.get(cacheKey);
373
- if (cached && now - cached.timestamp < CACHE_TTL_MS) {
374
- lastActiveUrl = cacheKey;
375
- llmStatus = "connected";
376
- return cached.model;
377
- }
378
- const url = buildModelsUrl(llmBaseUrl);
379
- for (let attempt = 1; attempt <= retries; attempt++) {
380
- try {
381
- if (silent) {
382
- logger.debug("Fetching models from LLM server", { url, attempt });
383
- }
384
- const response = await fetch(url, {
385
- signal: AbortSignal.timeout(1e4)
386
- });
387
- if (!response.ok) {
388
- if (silent) {
389
- logger.debug("Failed to fetch models from LLM server", { status: response.status, attempt });
390
- } else {
391
- logger.warn("Failed to fetch models from LLM server", { status: response.status, attempt });
392
- }
393
- if (attempt < retries) {
394
- await new Promise((r) => setTimeout(r, 1e3 * attempt));
395
- continue;
396
- }
397
- llmStatus = "disconnected";
398
- return cached?.model ?? null;
399
- }
400
- const data = await response.json();
401
- if (data.data && data.data.length > 0) {
402
- const modelData = data.data[0];
403
- const modelId = modelData.id;
404
- modelCache.set(cacheKey, {
405
- model: modelId,
406
- modelInfo: modelData,
407
- timestamp: now
408
- });
409
- lastActiveUrl = cacheKey;
410
- llmStatus = "connected";
411
- if (silent) {
412
- logger.debug("Detected LLM model", {
413
- model: modelId,
414
- maxLen: modelData.max_model_len,
415
- root: modelData.root
416
- });
417
- } else {
418
- logger.info("Detected LLM model", {
419
- model: modelId,
420
- maxLen: modelData.max_model_len,
421
- root: modelData.root
422
- });
423
- }
424
- return modelId;
425
- }
426
- if (silent) {
427
- logger.debug("LLM server returned empty models list");
428
- } else {
429
- logger.warn("LLM server returned empty models list");
430
- }
431
- llmStatus = "disconnected";
432
- return null;
433
- } catch (error) {
434
- const errMsg = error instanceof Error ? error.message : String(error);
435
- if (silent) {
436
- logger.debug("Could not detect model from LLM server", { error: errMsg, attempt });
437
- } else {
438
- logger.warn("Could not detect model from LLM server", { error: errMsg, attempt });
439
- }
440
- if (attempt < retries) {
441
- await new Promise((r) => setTimeout(r, 1e3 * attempt));
442
- continue;
443
- }
444
- }
445
- }
446
- llmStatus = "disconnected";
447
- return cached?.model ?? null;
448
- }
449
- function getLlmStatus() {
450
- return llmStatus;
451
- }
452
- function clearModelCache(url) {
453
- if (url) {
454
- modelCache.delete(getCacheKey(url));
455
- } else {
456
- modelCache.clear();
457
- }
458
- llmStatus = "unknown";
459
- }
460
-
461
259
  export {
462
- SessionNotFoundError,
463
- ensureVersionPrefix,
464
- stripVersionPrefix,
465
- buildModelsUrl,
466
- createLLMClient,
467
- detectModel,
468
- getLlmStatus,
469
- clearModelCache
260
+ createLLMClient
470
261
  };
471
- //# sourceMappingURL=chunk-XJ4SUDL7.js.map
262
+ //# sourceMappingURL=chunk-QYP6MOB5.js.map
@@ -0,0 +1,175 @@
1
+ // src/server/llm/profiles.ts
2
+ var DEFAULT_PROFILE = {
3
+ name: "default",
4
+ temperature: 0.7,
5
+ topP: 0.9,
6
+ defaultMaxTokens: 4096,
7
+ supportsVision: true
8
+ };
9
+ var MOCK_PROFILE = {
10
+ name: "mock",
11
+ temperature: 0.7,
12
+ topP: 0.9,
13
+ defaultMaxTokens: 1024,
14
+ supportsVision: false
15
+ };
16
+ var MODEL_PROFILES = [
17
+ {
18
+ pattern: "mistral",
19
+ profile: {
20
+ name: "Mistral",
21
+ temperature: 0.7,
22
+ topP: 0.9,
23
+ defaultMaxTokens: 16384,
24
+ supportsVision: false
25
+ }
26
+ },
27
+ {
28
+ pattern: "qwen3-coder-next",
29
+ profile: {
30
+ name: "Qwen3-Coder-Next",
31
+ // Per Qwen docs: "temperature=1.0, top_p=0.95, top_k=40"
32
+ temperature: 1,
33
+ topP: 0.95,
34
+ topK: 40,
35
+ // "This model supports only non-thinking mode and does not generate <think></think> blocks"
36
+ defaultMaxTokens: 16384,
37
+ supportsVision: false
38
+ }
39
+ },
40
+ {
41
+ pattern: "qwen3",
42
+ profile: {
43
+ name: "Qwen3",
44
+ temperature: 0.7,
45
+ topP: 0.9,
46
+ defaultMaxTokens: 16384,
47
+ supportsVision: false
48
+ }
49
+ },
50
+ {
51
+ pattern: "qwen3-vl",
52
+ profile: {
53
+ name: "Qwen3-VL",
54
+ temperature: 0.7,
55
+ topP: 0.9,
56
+ defaultMaxTokens: 16384,
57
+ supportsVision: true
58
+ }
59
+ },
60
+ {
61
+ pattern: "deepseek",
62
+ profile: {
63
+ name: "DeepSeek",
64
+ temperature: 0.6,
65
+ topP: 0.95,
66
+ defaultMaxTokens: 16384,
67
+ supportsVision: false
68
+ }
69
+ },
70
+ {
71
+ pattern: "minimax-m2.5",
72
+ profile: {
73
+ name: "MiniMax-M2.5",
74
+ temperature: 1,
75
+ topP: 0.95,
76
+ topK: 40,
77
+ defaultMaxTokens: 16384,
78
+ supportsVision: false
79
+ }
80
+ },
81
+ {
82
+ pattern: "minimax-m2.7",
83
+ profile: {
84
+ name: "MiniMax-M2.7",
85
+ temperature: 1,
86
+ topP: 0.95,
87
+ topK: 40,
88
+ defaultMaxTokens: 16384,
89
+ supportsVision: false
90
+ }
91
+ },
92
+ {
93
+ pattern: "minimax",
94
+ profile: {
95
+ name: "MiniMax",
96
+ temperature: 1,
97
+ topP: 0.95,
98
+ topK: 40,
99
+ defaultMaxTokens: 16384,
100
+ supportsVision: false
101
+ }
102
+ },
103
+ {
104
+ pattern: "minimax-m3",
105
+ profile: {
106
+ name: "MiniMax-M3",
107
+ temperature: 1,
108
+ topP: 0.95,
109
+ topK: 40,
110
+ defaultMaxTokens: 16384,
111
+ supportsVision: true
112
+ }
113
+ },
114
+ {
115
+ pattern: "llava",
116
+ profile: {
117
+ name: "LLaVA",
118
+ temperature: 0.7,
119
+ topP: 0.9,
120
+ defaultMaxTokens: 16384,
121
+ supportsVision: true
122
+ }
123
+ },
124
+ {
125
+ pattern: "llama",
126
+ profile: {
127
+ name: "Llama",
128
+ temperature: 0.7,
129
+ topP: 0.9,
130
+ defaultMaxTokens: 16384,
131
+ supportsVision: false
132
+ }
133
+ },
134
+ {
135
+ pattern: "claude",
136
+ profile: {
137
+ name: "Claude",
138
+ temperature: 0.7,
139
+ topP: 0.9,
140
+ defaultMaxTokens: 16384,
141
+ supportsVision: false
142
+ }
143
+ },
144
+ {
145
+ pattern: "gemma-4",
146
+ profile: {
147
+ name: "Gemma 4",
148
+ temperature: 0.7,
149
+ topP: 0.9,
150
+ defaultMaxTokens: 16384,
151
+ supportsVision: true
152
+ }
153
+ }
154
+ ];
155
+ function getModelProfile(modelName) {
156
+ const lowerName = modelName.toLowerCase();
157
+ if (lowerName.includes("mock")) {
158
+ return MOCK_PROFILE;
159
+ }
160
+ for (const { pattern, profile } of MODEL_PROFILES) {
161
+ if (lowerName.includes(pattern.toLowerCase())) {
162
+ return profile;
163
+ }
164
+ }
165
+ return DEFAULT_PROFILE;
166
+ }
167
+ function modelSupportsVision(modelName) {
168
+ return getModelProfile(modelName).supportsVision;
169
+ }
170
+
171
+ export {
172
+ getModelProfile,
173
+ modelSupportsVision
174
+ };
175
+ //# sourceMappingURL=chunk-V4IE7HJY.js.map
@@ -1,3 +1,10 @@
1
+ import {
2
+ createContextStateMessage,
3
+ createSessionStateMessage
4
+ } from "./chunk-F4PMNP7S.js";
5
+ import {
6
+ getPendingQuestionsForSession
7
+ } from "./chunk-EU3WWTFH.js";
1
8
  import {
2
9
  getEventStore,
3
10
  updateSessionMetadata
@@ -6,13 +13,6 @@ import {
6
13
  buildMessagesFromStoredEvents,
7
14
  foldPendingConfirmations
8
15
  } from "./chunk-6PLAWCHQ.js";
9
- import {
10
- createContextStateMessage,
11
- createSessionStateMessage
12
- } from "./chunk-F4PMNP7S.js";
13
- import {
14
- getPendingQuestionsForSession
15
- } from "./chunk-EU3WWTFH.js";
16
16
  import {
17
17
  logger
18
18
  } from "./chunk-K44MW7JJ.js";
@@ -58,53 +58,6 @@ Example inputs and outputs:
58
58
  - "Add unit tests for the API" \u2192 "Add API unit tests"
59
59
 
60
60
  User message: {message}`;
61
- async function generateSessionName(options) {
62
- const { userMessage, llmClient, signal, modelSettings, nonThinkingEnabled } = options;
63
- try {
64
- logger.debug("Generating session name", { messagePreview: userMessage.slice(0, 50) });
65
- const prompt = SESSION_NAME_PROMPT.replace("{message}", userMessage);
66
- const messages = [
67
- {
68
- role: "user",
69
- content: prompt
70
- }
71
- ];
72
- const timeoutSignal = AbortSignal.timeout(6e4);
73
- const composedSignal = signal ? AbortSignal.any([timeoutSignal, signal]) : timeoutSignal;
74
- const response = await llmClient.complete({
75
- messages,
76
- tools: [],
77
- signal: composedSignal,
78
- // Default to non-thinking (reasoningEffort: 'none') when not explicitly configured
79
- // to prevent thinking output in session names. Only skip when user explicitly
80
- // set nonThinkingEnabled to false.
81
- ...nonThinkingEnabled !== false ? { reasoningEffort: "none" } : {},
82
- ...modelSettings ? { modelSettings } : {}
83
- });
84
- let name = (response.content || response.thinkingContent || "").trim();
85
- if (name.length > 50) {
86
- name = name.substring(0, 47) + "...";
87
- }
88
- if (!name || name.length < 3) {
89
- return {
90
- success: false,
91
- error: "Generated name is too short or empty"
92
- };
93
- }
94
- logger.debug("Session name generated successfully", { name });
95
- return {
96
- success: true,
97
- name
98
- };
99
- } catch (error) {
100
- const errorMessage = error instanceof Error ? error.message : "Unknown error generating session name";
101
- logger.debug("Session name generation error", { error: errorMessage });
102
- return {
103
- success: false,
104
- error: errorMessage
105
- };
106
- }
107
- }
108
61
  function needsNameGeneration(sessionTitle, messageCount) {
109
62
  if (messageCount > 1) {
110
63
  return false;
@@ -145,13 +98,80 @@ function applyGeneratedSessionName(sessionId, name, deps) {
145
98
  );
146
99
  }
147
100
  }
101
+ function resolveSessionProvider(session, providerManager) {
102
+ const providers = providerManager.getProviders();
103
+ const effectiveModel = session.providerModel ?? providerManager.getCurrentModel();
104
+ if (!effectiveModel) return void 0;
105
+ const provider = session.providerId ? providers.find((p) => p.id === session.providerId) : providers.find((p) => p.isActive);
106
+ if (!provider) return void 0;
107
+ return {
108
+ baseUrl: provider.url,
109
+ ...provider.apiKey ? { apiKey: provider.apiKey } : {},
110
+ model: effectiveModel
111
+ };
112
+ }
113
+ async function generateSessionNameForSession(sessionId, userMessage, deps, signal) {
114
+ const { sessionManager, providerManager, broadcastForSession, eventStore } = deps;
115
+ const session = sessionManager.getSession(sessionId);
116
+ if (!session) return;
117
+ const messageCount = getSessionMessageCount(sessionId);
118
+ if (!needsNameGenerationCheck(sessionId, session.metadata.title, messageCount)) return;
119
+ const providerConfig = resolveSessionProvider(session, providerManager);
120
+ const modelSettings = providerConfig ? providerManager.getModelSettings(providerConfig.model, "non-thinking") : void 0;
121
+ const prompt = SESSION_NAME_PROMPT.replace("{message}", userMessage);
122
+ try {
123
+ let client;
124
+ if (deps.getLLMClient && providerConfig) {
125
+ client = deps.getLLMClient();
126
+ client.setModel(providerConfig.model);
127
+ } else if (providerConfig) {
128
+ const { createLLMClient } = await import("./client-X6BVH4Q4.js");
129
+ client = createLLMClient({
130
+ llm: {
131
+ baseUrl: providerConfig.baseUrl,
132
+ model: providerConfig.model,
133
+ ...providerConfig.apiKey ? { apiKey: providerConfig.apiKey } : {}
134
+ }
135
+ });
136
+ } else if (deps.getLLMClient) {
137
+ client = deps.getLLMClient();
138
+ } else {
139
+ logger.debug("Session name generation skipped: no LLM client available", { sessionId });
140
+ return;
141
+ }
142
+ const timeoutSignal = AbortSignal.timeout(12e4);
143
+ const composedSignal = signal ? AbortSignal.any([timeoutSignal, signal]) : timeoutSignal;
144
+ const response = await client.complete({
145
+ messages: [{ role: "user", content: prompt }],
146
+ tools: [],
147
+ ...modelSettings ? { modelSettings } : {},
148
+ signal: composedSignal,
149
+ skipClientReasoningEffort: true
150
+ });
151
+ let name = (response.content || response.thinkingContent || "").trim();
152
+ if (name.length > 50) {
153
+ name = name.substring(0, 47) + "...";
154
+ }
155
+ if (name.length >= 3) {
156
+ applyGeneratedSessionName(sessionId, name, {
157
+ sessionManager,
158
+ eventStore,
159
+ broadcastForSession
160
+ });
161
+ } else {
162
+ logger.debug("Session name too short", { sessionId, name });
163
+ }
164
+ } catch (error) {
165
+ logger.error("Session name generation error", {
166
+ sessionId,
167
+ error: error instanceof Error ? error.message : String(error)
168
+ });
169
+ }
170
+ }
148
171
 
149
172
  export {
150
- getSessionMessageCount,
151
173
  finalizeTurnCompletion,
152
174
  buildRunChatTurnParams,
153
- generateSessionName,
154
- needsNameGenerationCheck,
155
- applyGeneratedSessionName
175
+ generateSessionNameForSession
156
176
  };
157
- //# sourceMappingURL=chunk-GI24G4OW.js.map
177
+ //# sourceMappingURL=chunk-VI236SOY.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  COMPACTION_PROMPT,
3
3
  createMessageStartEvent
4
- } from "./chunk-YUHODMKY.js";
4
+ } from "./chunk-YGSBVKFU.js";
5
5
  import {
6
6
  getCurrentWindowMessageOptions
7
7
  } from "./chunk-YBWY4DKY.js";
@@ -31,4 +31,4 @@ export {
31
31
  shouldCompact,
32
32
  getCompactionTarget
33
33
  };
34
- //# sourceMappingURL=chunk-CDIYCGCO.js.map
34
+ //# sourceMappingURL=chunk-WEXW7ZXJ.js.map