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
@@ -0,0 +1,97 @@
1
+ // src/server/llm/streaming.ts
2
+ async function* streamWithSegments(client, request) {
3
+ let content = "";
4
+ let thinkingContent = "";
5
+ let response = null;
6
+ const segments = [];
7
+ let currentTextSegment = "";
8
+ let currentThinkingSegment = "";
9
+ const startTime = performance.now();
10
+ let firstTokenTime = null;
11
+ const flushText = () => {
12
+ if (currentTextSegment.trim()) {
13
+ segments.push({ type: "text", content: currentTextSegment });
14
+ }
15
+ currentTextSegment = "";
16
+ };
17
+ const flushThinking = () => {
18
+ if (currentThinkingSegment.trim()) {
19
+ segments.push({ type: "thinking", content: currentThinkingSegment });
20
+ }
21
+ currentThinkingSegment = "";
22
+ };
23
+ try {
24
+ for await (const event of client.stream(request)) {
25
+ switch (event.type) {
26
+ case "text_delta":
27
+ if (firstTokenTime === null) {
28
+ firstTokenTime = performance.now();
29
+ }
30
+ flushThinking();
31
+ content += event.content;
32
+ currentTextSegment += event.content;
33
+ yield { type: "text_delta", content: event.content };
34
+ break;
35
+ case "thinking_delta":
36
+ if (firstTokenTime === null) {
37
+ firstTokenTime = performance.now();
38
+ }
39
+ flushText();
40
+ thinkingContent += event.content;
41
+ currentThinkingSegment += event.content;
42
+ yield { type: "thinking_delta", content: event.content };
43
+ break;
44
+ case "tool_call_delta":
45
+ yield {
46
+ type: "tool_call_delta",
47
+ index: event.index,
48
+ ...event.id !== void 0 ? { id: event.id } : {},
49
+ ...event.name !== void 0 ? { name: event.name } : {},
50
+ ...event.arguments !== void 0 ? { arguments: event.arguments } : {}
51
+ };
52
+ break;
53
+ case "done":
54
+ flushThinking();
55
+ flushText();
56
+ response = event.response;
57
+ yield { type: "done", response: event.response };
58
+ break;
59
+ case "error":
60
+ yield { type: "error", error: event.error };
61
+ return null;
62
+ }
63
+ }
64
+ } catch (error) {
65
+ yield { type: "error", error: error instanceof Error ? error.message : "Unknown error" };
66
+ return null;
67
+ }
68
+ if (!response) {
69
+ return null;
70
+ }
71
+ const toolCalls = response.toolCalls ?? [];
72
+ for (const tc of toolCalls) {
73
+ segments.push({ type: "tool_call", toolCallId: tc.id });
74
+ }
75
+ const endTime = performance.now();
76
+ const ttft = ((firstTokenTime ?? endTime) - startTime) / 1e3;
77
+ const completionTime = (endTime - (firstTokenTime ?? startTime)) / 1e3;
78
+ const { promptTokens, completionTokens } = response.usage;
79
+ return {
80
+ content,
81
+ thinkingContent,
82
+ toolCalls,
83
+ response,
84
+ segments,
85
+ timing: {
86
+ ttft,
87
+ completionTime,
88
+ tps: completionTime > 0 ? completionTokens / completionTime : 0,
89
+ prefillTps: ttft > 0 ? promptTokens / ttft : 0
90
+ }
91
+ };
92
+ }
93
+
94
+ export {
95
+ streamWithSegments
96
+ };
97
+ //# sourceMappingURL=chunk-J2GP3J3X.js.map
@@ -1,21 +1,3 @@
1
- import {
2
- getProject
3
- } from "./chunk-O4TED6AJ.js";
4
- import {
5
- COMPACTION_PROMPT,
6
- TurnMetrics,
7
- buildBasePrompt,
8
- buildSubAgentSystemPrompt,
9
- buildTopLevelSystemPrompt,
10
- computeEffectiveTools,
11
- consumeStreamGenerator,
12
- createChatDoneEvent,
13
- createMessageDoneEvent,
14
- createMessageStartEvent,
15
- createToolCallEvent,
16
- createToolResultEvent,
17
- streamLLMPure
18
- } from "./chunk-YUHODMKY.js";
19
1
  import {
20
2
  startInspectProxy
21
3
  } from "./chunk-DL6ZILAF.js";
@@ -35,21 +17,6 @@ import {
35
17
  import {
36
18
  createMcpTools
37
19
  } from "./chunk-NWO6GRYE.js";
38
- import {
39
- getCurrentContextWindowId,
40
- getCurrentWindowMessageOptions,
41
- getEventStore,
42
- getRuntimeConfig
43
- } from "./chunk-YBWY4DKY.js";
44
- import {
45
- buildContextMessagesFromEventHistory,
46
- foldContextState,
47
- handleMessageDelta,
48
- handleMessageThinking,
49
- handleToolCall,
50
- handleToolResult,
51
- stripOrphanedToolCalls
52
- } from "./chunk-6PLAWCHQ.js";
53
20
  import {
54
21
  createChatDoneMessage,
55
22
  createChatMessageMessage,
@@ -66,6 +33,42 @@ import {
66
33
  deleteSetting,
67
34
  getSetting
68
35
  } from "./chunk-RFNEDBVO.js";
36
+ import {
37
+ getProject
38
+ } from "./chunk-O4TED6AJ.js";
39
+ import {
40
+ COMPACTION_PROMPT,
41
+ TurnMetrics,
42
+ buildBasePrompt,
43
+ buildSubAgentSystemPrompt,
44
+ buildTopLevelSystemPrompt,
45
+ computeEffectiveTools,
46
+ consumeStreamGenerator,
47
+ createChatDoneEvent,
48
+ createMessageDoneEvent,
49
+ createMessageStartEvent,
50
+ createToolCallEvent,
51
+ createToolResultEvent,
52
+ streamLLMPure
53
+ } from "./chunk-YGSBVKFU.js";
54
+ import {
55
+ getCurrentContextWindowId,
56
+ getCurrentWindowMessageOptions,
57
+ getEventStore,
58
+ getRuntimeConfig
59
+ } from "./chunk-YBWY4DKY.js";
60
+ import {
61
+ buildContextMessagesFromEventHistory,
62
+ foldContextState,
63
+ handleMessageDelta,
64
+ handleMessageThinking,
65
+ handleToolCall,
66
+ handleToolResult,
67
+ stripOrphanedToolCalls
68
+ } from "./chunk-6PLAWCHQ.js";
69
+ import {
70
+ logger
71
+ } from "./chunk-K44MW7JJ.js";
69
72
  import {
70
73
  loadGlobalConfig,
71
74
  saveGlobalConfig
@@ -75,10 +78,7 @@ import {
75
78
  } from "./chunk-CQGTEGKL.js";
76
79
  import {
77
80
  modelSupportsVision
78
- } from "./chunk-UUFEE7VR.js";
79
- import {
80
- logger
81
- } from "./chunk-K44MW7JJ.js";
81
+ } from "./chunk-V4IE7HJY.js";
82
82
 
83
83
  // src/server/tools/read.ts
84
84
  import { readFile as readFile2, stat, readdir } from "fs/promises";
@@ -205,6 +205,9 @@ async function isPathWithinSandbox(path, workdir, sessionId) {
205
205
  }
206
206
  return { allowed: false, resolvedPath };
207
207
  }
208
+ function looksLikeRegex(str) {
209
+ return /[*?+[\]\\]/.test(str);
210
+ }
208
211
  function extractAbsolutePathsFromCommand(command) {
209
212
  if (!command.trim()) {
210
213
  return [];
@@ -239,6 +242,9 @@ function extractAbsolutePathsFromCommand(command) {
239
242
  if (content.startsWith("/") && content.endsWith("/")) {
240
243
  continue;
241
244
  }
245
+ if (content.startsWith("/") && looksLikeRegex(content)) {
246
+ continue;
247
+ }
242
248
  if (content.startsWith("/")) {
243
249
  const resolved = normalize(content);
244
250
  if (!isSafePath(resolved)) {
@@ -259,7 +265,7 @@ function extractAbsolutePathsFromCommand(command) {
259
265
  if (pathCandidate.includes("__URL__") || pathCandidate.includes("__FILEURL__")) {
260
266
  continue;
261
267
  }
262
- if (pathCandidate.endsWith("/") && pathCandidate.split("/").length <= 2) {
268
+ if (looksLikeRegex(pathCandidate)) {
263
269
  continue;
264
270
  }
265
271
  const resolved = normalize(pathCandidate);
@@ -2482,8 +2488,15 @@ ${CONTINUE_PROMPT}` : CONTINUE_PROMPT;
2482
2488
  ...config.subAgentMetadata ? { subAgentId: config.subAgentMetadata.subAgentId, subAgentType: config.subAgentMetadata.subAgentType } : {}
2483
2489
  })
2484
2490
  );
2485
- const previousContextTokens = sessionManager.getContextState(sessionId).currentTokens;
2486
- const modelSettings = currentMaxTokensOverride !== void 0 ? { ...sessionManager.getCurrentModelSettings(), maxTokens: currentMaxTokensOverride } : sessionManager.getCurrentModelSettings();
2491
+ const contextState = sessionManager.getContextState(sessionId);
2492
+ const previousContextTokens = contextState.currentTokens;
2493
+ const contextWindow = sessionManager.getCurrentModelContext();
2494
+ const availableForOutput = Math.max(256, contextWindow - contextState.currentTokens);
2495
+ let modelSettings = currentMaxTokensOverride !== void 0 ? { ...sessionManager.getCurrentModelSettings(), maxTokens: currentMaxTokensOverride } : sessionManager.getCurrentModelSettings();
2496
+ if (modelSettings) {
2497
+ const requestedMaxTokens = modelSettings.maxTokens ?? 16384;
2498
+ modelSettings = { ...modelSettings, maxTokens: Math.min(requestedMaxTokens, availableForOutput) };
2499
+ }
2487
2500
  const streamGen = streamLLMPure({
2488
2501
  messageId: assistantMsgId,
2489
2502
  systemPrompt: assembledRequest.systemPrompt,
@@ -2549,9 +2562,9 @@ ${CONTINUE_PROMPT}` : CONTINUE_PROMPT;
2549
2562
  );
2550
2563
  sessionManager.setCurrentContextSize(sessionId, result.usage.promptTokens);
2551
2564
  if (!compacting) {
2552
- const contextState = sessionManager.getContextState(sessionId);
2553
- const { shouldCompact, appendCompactionPrompt } = await import("./compactor-SEZEZSML.js");
2554
- if (shouldCompact(contextState.currentTokens, contextState.maxTokens, runtimeConfig.context.compactionThreshold)) {
2565
+ const contextState2 = sessionManager.getContextState(sessionId);
2566
+ const { shouldCompact, appendCompactionPrompt } = await import("./compactor-JMGSZ4DQ.js");
2567
+ if (shouldCompact(contextState2.currentTokens, contextState2.maxTokens, runtimeConfig.context.compactionThreshold)) {
2555
2568
  appendCompactionPrompt(sessionId, append);
2556
2569
  compacting = true;
2557
2570
  continue;
@@ -2562,8 +2575,8 @@ ${CONTINUE_PROMPT}` : CONTINUE_PROMPT;
2562
2575
  truncationRetryCount += 1;
2563
2576
  const currentMaxTokens = result.modelParams?.maxTokens ?? 16384;
2564
2577
  const promptTokens = result.usage.promptTokens;
2565
- const contextWindow = sessionManager.getCurrentModelContext();
2566
- const newMaxTokens = Math.min(Math.floor(currentMaxTokens * 1.5), contextWindow - promptTokens - 2048);
2578
+ const contextWindow2 = sessionManager.getCurrentModelContext();
2579
+ const newMaxTokens = Math.min(Math.floor(currentMaxTokens * 1.5), contextWindow2 - promptTokens - 2048);
2567
2580
  currentMaxTokensOverride = newMaxTokens;
2568
2581
  const interimStats = turnMetrics.buildStats(statsIdentity, mode);
2569
2582
  append(
@@ -3355,7 +3368,7 @@ var callSubAgentTool = {
3355
3368
  };
3356
3369
  }
3357
3370
  try {
3358
- const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-7CKTYL2G.js");
3371
+ const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-4KGLCQJL.js");
3359
3372
  const toolRegistry = getToolRegistryForAgent2(agentDef);
3360
3373
  const turnMetrics = new TurnMetrics();
3361
3374
  const result = await executeSubAgent({
@@ -4161,7 +4174,7 @@ async function computeContextHash(sessionManager, sessionId) {
4161
4174
  const runtimeConfig = getRuntimeConfig();
4162
4175
  const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
4163
4176
  const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
4164
- const { createToolRegistry: createToolRegistry2 } = await import("./tools-7CKTYL2G.js");
4177
+ const { createToolRegistry: createToolRegistry2 } = await import("./tools-4KGLCQJL.js");
4165
4178
  const allTools = createToolRegistry2().definitions;
4166
4179
  const toolFingerprint = getToolFingerprint(allTools);
4167
4180
  const hash = computeDynamicContextHash(instructionContent, skills, toolFingerprint);
@@ -4274,7 +4287,7 @@ var mcpConfigTool = createTool(
4274
4287
  await saveGlobalConfig(mcpConfigMode, { ...globalConfig, mcpServers: updated });
4275
4288
  }
4276
4289
  async function rebuildTools() {
4277
- const { setMcpTools: setMcpTools2 } = await import("./tools-7CKTYL2G.js");
4290
+ const { setMcpTools: setMcpTools2 } = await import("./tools-4KGLCQJL.js");
4278
4291
  const mcpTools = createMcpTools(mcpManagerForTools);
4279
4292
  setMcpTools2(mcpTools);
4280
4293
  }
@@ -4678,4 +4691,4 @@ export {
4678
4691
  getToolRegistryForAgent,
4679
4692
  createToolRegistry
4680
4693
  };
4681
- //# sourceMappingURL=chunk-MDRNKI7D.js.map
4694
+ //# sourceMappingURL=chunk-K454WU7A.js.map
@@ -0,0 +1,114 @@
1
+ import {
2
+ buildModelsUrl,
3
+ stripVersionPrefix
4
+ } from "./chunk-HNCM3D7Y.js";
5
+ import {
6
+ logger
7
+ } from "./chunk-K44MW7JJ.js";
8
+
9
+ // src/server/llm/models.ts
10
+ var modelCache = /* @__PURE__ */ new Map();
11
+ var llmStatus = "unknown";
12
+ var lastActiveUrl = null;
13
+ var CACHE_TTL_MS = 3e4;
14
+ function getCacheKey(url) {
15
+ return stripVersionPrefix(url);
16
+ }
17
+ async function detectModel(llmBaseUrl, retries = 3, silent = false) {
18
+ const cacheKey = getCacheKey(llmBaseUrl);
19
+ const now = Date.now();
20
+ const cached = modelCache.get(cacheKey);
21
+ if (cached && now - cached.timestamp < CACHE_TTL_MS) {
22
+ lastActiveUrl = cacheKey;
23
+ llmStatus = "connected";
24
+ return cached.model;
25
+ }
26
+ const url = buildModelsUrl(llmBaseUrl);
27
+ for (let attempt = 1; attempt <= retries; attempt++) {
28
+ try {
29
+ if (silent) {
30
+ logger.debug("Fetching models from LLM server", { url, attempt });
31
+ }
32
+ const response = await fetch(url, {
33
+ signal: AbortSignal.timeout(1e4)
34
+ });
35
+ if (!response.ok) {
36
+ if (silent) {
37
+ logger.debug("Failed to fetch models from LLM server", { status: response.status, attempt });
38
+ } else {
39
+ logger.warn("Failed to fetch models from LLM server", { status: response.status, attempt });
40
+ }
41
+ if (attempt < retries) {
42
+ await new Promise((r) => setTimeout(r, 1e3 * attempt));
43
+ continue;
44
+ }
45
+ llmStatus = "disconnected";
46
+ return cached?.model ?? null;
47
+ }
48
+ const data = await response.json();
49
+ if (data.data && data.data.length > 0) {
50
+ const modelData = data.data[0];
51
+ const modelId = modelData.id;
52
+ modelCache.set(cacheKey, {
53
+ model: modelId,
54
+ modelInfo: modelData,
55
+ timestamp: now
56
+ });
57
+ lastActiveUrl = cacheKey;
58
+ llmStatus = "connected";
59
+ if (silent) {
60
+ logger.debug("Detected LLM model", {
61
+ model: modelId,
62
+ maxLen: modelData.max_model_len,
63
+ root: modelData.root
64
+ });
65
+ } else {
66
+ logger.info("Detected LLM model", {
67
+ model: modelId,
68
+ maxLen: modelData.max_model_len,
69
+ root: modelData.root
70
+ });
71
+ }
72
+ return modelId;
73
+ }
74
+ if (silent) {
75
+ logger.debug("LLM server returned empty models list");
76
+ } else {
77
+ logger.warn("LLM server returned empty models list");
78
+ }
79
+ llmStatus = "disconnected";
80
+ return null;
81
+ } catch (error) {
82
+ const errMsg = error instanceof Error ? error.message : String(error);
83
+ if (silent) {
84
+ logger.debug("Could not detect model from LLM server", { error: errMsg, attempt });
85
+ } else {
86
+ logger.warn("Could not detect model from LLM server", { error: errMsg, attempt });
87
+ }
88
+ if (attempt < retries) {
89
+ await new Promise((r) => setTimeout(r, 1e3 * attempt));
90
+ continue;
91
+ }
92
+ }
93
+ }
94
+ llmStatus = "disconnected";
95
+ return cached?.model ?? null;
96
+ }
97
+ function getLlmStatus() {
98
+ return llmStatus;
99
+ }
100
+ function clearModelCache(url) {
101
+ if (url) {
102
+ modelCache.delete(getCacheKey(url));
103
+ } else {
104
+ modelCache.clear();
105
+ }
106
+ llmStatus = "unknown";
107
+ }
108
+
109
+ export {
110
+ detectModel,
111
+ getLlmStatus,
112
+ clearModelCache
113
+ };
114
+ //# sourceMappingURL=chunk-M3RB4IF6.js.map