openfox 2.0.76 → 2.0.78

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 (76) hide show
  1. package/dist/{chat-handler-3BZ4PDL2.js → chat-handler-5ZHPYU24.js} +21 -20
  2. package/dist/{chunk-MF3UW36X.js → chunk-37WF2Z3T.js} +84 -17
  3. package/dist/{chunk-OBQPXUXI.js → chunk-5CQRB7AD.js} +2 -2
  4. package/dist/chunk-64TKWWNF.js +7 -0
  5. package/dist/{chunk-LXFLRM7M.js → chunk-6AE3JPDJ.js} +2 -2
  6. package/dist/chunk-AANVMTYU.js +327 -0
  7. package/dist/{chunk-YMFCFMMB.js → chunk-AFJLY43Z.js} +8 -3
  8. package/dist/{chunk-OCVRIPQP.js → chunk-CJDYSUU5.js} +3 -3
  9. package/dist/{chunk-OMWVB2XC.js → chunk-DI4SIPFT.js} +46 -27
  10. package/dist/{chunk-7772ENZN.js → chunk-EHVDAVYG.js} +4 -3
  11. package/dist/{chunk-DH3SSBZN.js → chunk-EYIWUONA.js} +2 -2
  12. package/dist/{chunk-NGJ5XJ7D.js → chunk-M7EFXRDS.js} +57 -290
  13. package/dist/{chunk-4QHDQP2N.js → chunk-MTUYDBSL.js} +2 -2
  14. package/dist/{chunk-HHUIXHHX.js → chunk-NUR2B4RU.js} +7 -7
  15. package/dist/{chunk-46RORSKU.js → chunk-NZIYELSQ.js} +9 -7
  16. package/dist/{chunk-7QXRQ5ZL.js → chunk-RGUUZD5B.js} +5 -1
  17. package/dist/{chunk-EZK7CGJ7.js → chunk-RMXPVQP4.js} +315 -45
  18. package/dist/{chunk-D6CI2B7B.js → chunk-SGBXBP3S.js} +253 -110
  19. package/dist/{chunk-O3NUNU4H.js → chunk-SJTG56CH.js} +5 -4
  20. package/dist/{chunk-DJASQ2ZB.js → chunk-TSVFRWSG.js} +24 -5
  21. package/dist/{chunk-XTK6E2QR.js → chunk-UIU7OGHP.js} +26 -10
  22. package/dist/{chunk-J7VCI5EX.js → chunk-UMX7MMNW.js} +652 -248
  23. package/dist/{chunk-HLHGNHMV.js → chunk-VGWJFXPR.js} +23 -11
  24. package/dist/{chunk-KVRSAC4Z.js → chunk-VPFUXGMM.js} +6 -1
  25. package/dist/{chunk-W4ZEG3LX.js → chunk-WL2WEJAK.js} +2 -2
  26. package/dist/{chunk-HAQV6AJP.js → chunk-WUSWNLTV.js} +3 -3
  27. package/dist/{chunk-5GOOSZX7.js → chunk-X6BXZFO7.js} +1 -1
  28. package/dist/{chunk-WGAAQASA.js → chunk-YFVSSMA3.js} +3 -2
  29. package/dist/cli/dev.js +1 -1
  30. package/dist/cli/index.js +1 -1
  31. package/dist/{client-TDPQVBQ7.js → client-V5DZRO2D.js} +3 -3
  32. package/dist/{client-pure-NMLDKRDN.js → client-pure-5YE5WFJP.js} +2 -2
  33. package/dist/compactor-G7B3V24F.js +24 -0
  34. package/dist/{config-EUMVEFHU.js → config-MD74ETY5.js} +2 -2
  35. package/dist/{events-FLWRLM6V.js → events-KNOZX7YG.js} +7 -4
  36. package/dist/{folding-ONH3D4OK.js → folding-OPP2BVUB.js} +2 -2
  37. package/dist/{inspect-proxy-JHZV34QR.js → inspect-proxy-DRYIIH4O.js} +4 -4
  38. package/dist/{manager-OPMCSYN2.js → manager-ATWZUL3O.js} +5 -5
  39. package/dist/{orchestrator-5IMCWX5P.js → orchestrator-L6LX5BV7.js} +20 -19
  40. package/dist/package.json +6 -1
  41. package/dist/{path-security-ZROWNL22.js → path-security-HUXQHEQ5.js} +10 -7
  42. package/dist/{platform-QGXO3CNR.js → platform-VBNNMTR5.js} +4 -4
  43. package/dist/{processor-3R4GS6VB.js → processor-UQX5KL56.js} +21 -20
  44. package/dist/{project-creator-C22J43BC.js → project-creator-NNUITNUI.js} +3 -3
  45. package/dist/{projects-WSVINK2C.js → projects-ZGJGICGT.js} +3 -3
  46. package/dist/{protocol-Sr6Jr4ZS.d.ts → protocol-BXxJmsOW.d.ts} +2 -1
  47. package/dist/{protocol-EWEVW65B.js → protocol-Q7X4NEME.js} +3 -3
  48. package/dist/provider/index.d.ts +4 -4
  49. package/dist/{provider-G2YC2IC4.js → provider-PI3RDDE4.js} +6 -6
  50. package/dist/{provider-manager-SQIELYLK.js → provider-manager-PD3BXUHY.js} +4 -4
  51. package/dist/{serve-MXKMKZYY.js → serve-QWC3U5MB.js} +26 -25
  52. package/dist/server/index.d.ts +27 -4
  53. package/dist/server/index.js +25 -24
  54. package/dist/server-3XUD2NB7.js +40 -0
  55. package/dist/sessions-SFG42M4W.js +42 -0
  56. package/dist/{settings-7XDMSPIC.js → settings-6M55N4Q2.js} +5 -3
  57. package/dist/shared/index.d.ts +3 -3
  58. package/dist/shared/index.js +1 -1
  59. package/dist/{tools-JRCUWPJO.js → tools-HGKUD327.js} +26 -23
  60. package/dist/{types-C4cG9CtC.d.ts → types-C308SU4B.d.ts} +3 -0
  61. package/dist/{types-DSZhFA8O.d.ts → types-o07LJcLI.d.ts} +1 -1
  62. package/dist/{update-OXDQ75M7.js → update-NWZALB5M.js} +2 -2
  63. package/dist/{update-server-4MTM7M5P.js → update-server-V6GJ43WH.js} +2 -2
  64. package/dist/web/assets/index-7_xKqeJc.js +305 -0
  65. package/dist/web/assets/index-DRkTjPo3.css +32 -0
  66. package/dist/web/index.html +4 -4
  67. package/dist/web/manifest.webmanifest +1 -1
  68. package/dist/web/registerSW.js +1 -1
  69. package/dist/web/sw.js +1 -1
  70. package/dist/{workspace-6QTTUMMW.js → workspace-J74ZMSOJ.js} +14 -2
  71. package/package.json +6 -1
  72. package/dist/chunk-KQEVAO2Q.js +0 -7
  73. package/dist/compactor-BB3YYVRP.js +0 -23
  74. package/dist/server-SPYFMFQE.js +0 -39
  75. package/dist/web/assets/index-BNVBxKnB.css +0 -32
  76. package/dist/web/assets/index-ghDkIdlf.js +0 -305
@@ -2,41 +2,42 @@ import {
2
2
  buildRunChatTurnParams,
3
3
  finalizeTurnCompletion,
4
4
  generateSessionNameForSession
5
- } from "./chunk-XTK6E2QR.js";
5
+ } from "./chunk-UIU7OGHP.js";
6
6
  import {
7
7
  runChatTurn
8
- } from "./chunk-HLHGNHMV.js";
9
- import "./chunk-D6CI2B7B.js";
8
+ } from "./chunk-VGWJFXPR.js";
9
+ import "./chunk-SGBXBP3S.js";
10
+ import "./chunk-5CQRB7AD.js";
10
11
  import "./chunk-NWO6GRYE.js";
11
- import "./chunk-KVRSAC4Z.js";
12
- import "./chunk-MF3UW36X.js";
12
+ import "./chunk-VPFUXGMM.js";
13
+ import "./chunk-37WF2Z3T.js";
13
14
  import "./chunk-WGMJCFCE.js";
15
+ import "./chunk-NZIYELSQ.js";
14
16
  import "./chunk-EU3WWTFH.js";
15
- import "./chunk-7772ENZN.js";
16
- import "./chunk-DH3SSBZN.js";
17
- import "./chunk-LXFLRM7M.js";
18
- import "./chunk-OBQPXUXI.js";
19
- import "./chunk-4QHDQP2N.js";
20
- import "./chunk-YMFCFMMB.js";
17
+ import "./chunk-EHVDAVYG.js";
18
+ import "./chunk-MTUYDBSL.js";
19
+ import "./chunk-AFJLY43Z.js";
20
+ import "./chunk-EYIWUONA.js";
21
+ import "./chunk-6AE3JPDJ.js";
21
22
  import "./chunk-I72ACQ6R.js";
22
- import "./chunk-46RORSKU.js";
23
23
  import {
24
24
  getEventStore
25
- } from "./chunk-NGJ5XJ7D.js";
26
- import "./chunk-7QXRQ5ZL.js";
27
- import "./chunk-DJASQ2ZB.js";
25
+ } from "./chunk-M7EFXRDS.js";
26
+ import "./chunk-TSVFRWSG.js";
27
+ import "./chunk-AANVMTYU.js";
28
+ import "./chunk-RGUUZD5B.js";
28
29
  import {
29
30
  createChatMessageMessage,
30
31
  createPhaseChangedMessage,
31
32
  createSessionRunningMessage
32
- } from "./chunk-O3NUNU4H.js";
33
+ } from "./chunk-SJTG56CH.js";
33
34
  import "./chunk-J2GP3J3X.js";
34
35
  import "./chunk-V4IE7HJY.js";
35
36
  import "./chunk-YHEQTVFV.js";
36
- import "./chunk-EZK7CGJ7.js";
37
+ import "./chunk-RMXPVQP4.js";
37
38
  import "./chunk-K44MW7JJ.js";
38
- import "./chunk-5GOOSZX7.js";
39
- import "./chunk-WGAAQASA.js";
39
+ import "./chunk-X6BXZFO7.js";
40
+ import "./chunk-YFVSSMA3.js";
40
41
  import "./chunk-CQGTEGKL.js";
41
42
  import "./chunk-5WRI5ZAA.js";
42
43
 
@@ -159,4 +160,4 @@ export {
159
160
  startChatSession,
160
161
  stopSessionExecution
161
162
  };
162
- //# sourceMappingURL=chat-handler-3BZ4PDL2.js.map
163
+ //# sourceMappingURL=chat-handler-5ZHPYU24.js.map
@@ -23,8 +23,10 @@ async function loadWorkspaceConfig(workdir) {
23
23
  const configPath = getConfigPath(workdir);
24
24
  const raw = await readFile(configPath, "utf-8");
25
25
  const parsed = JSON.parse(raw);
26
- if (!parsed.setup) return null;
27
- return { setup: parsed.setup };
26
+ const config = {};
27
+ if (parsed.setup) config.setup = parsed.setup;
28
+ if (parsed.rootDir) config.rootDir = parsed.rootDir;
29
+ return Object.keys(config).length > 0 ? config : null;
28
30
  } catch {
29
31
  return null;
30
32
  }
@@ -79,7 +81,14 @@ function getGlobalDataDir() {
79
81
  return join2(process.env["XDG_DATA_HOME"] ?? join2(home, ".local", "share"), `openfox${suffix}`);
80
82
  }
81
83
  }
82
- function getWorkspacesDir(projectName) {
84
+ async function getWorkspacesDir(projectName, projectDir) {
85
+ const config = await loadWorkspaceConfig(projectDir);
86
+ if (config?.rootDir) {
87
+ return isAbsolute(config.rootDir) ? config.rootDir : resolve2(projectDir, config.rootDir);
88
+ }
89
+ return join2(getGlobalDataDir(), "workspaces", projectName);
90
+ }
91
+ function getDefaultGlobalWorkspacesDir(projectName) {
83
92
  return join2(getGlobalDataDir(), "workspaces", projectName);
84
93
  }
85
94
  function getGitBranch(cwd) {
@@ -97,6 +106,12 @@ function listBranches(cwd) {
97
106
  return branches;
98
107
  });
99
108
  }
109
+ function listRemoteBranches(cwd) {
110
+ return captureStdout(cwd, ["branch", "-r", "--format", "%(refname:short)"]).then((out) => {
111
+ if (!out) return [];
112
+ return out.trim().split("\n").filter(Boolean).map((b) => b.trim());
113
+ });
114
+ }
100
115
  async function getCommitsBehind(cwd, branch) {
101
116
  const out = await captureStdout(cwd, ["rev-list", "--count", "HEAD..origin/" + branch, "--"]);
102
117
  if (out === null) return null;
@@ -106,6 +121,46 @@ async function getCommitsBehind(cwd, branch) {
106
121
  function validateRef(cwd, name) {
107
122
  return runGit(cwd, ["check-ref-format", `refs/heads/${name}`]);
108
123
  }
124
+ async function getDefaultBranch(projectDir) {
125
+ await runGit(projectDir, ["fetch", "origin", "--no-tags", "--quiet"]).catch(() => {
126
+ });
127
+ const originHead = await captureStdout(projectDir, ["symbolic-ref", "refs/remotes/origin/HEAD"]);
128
+ if (originHead) {
129
+ const branch = originHead.trim().replace("refs/remotes/origin/", "");
130
+ if (branch) return branch;
131
+ }
132
+ const current = await getGitBranch(projectDir);
133
+ if (current) return current;
134
+ return "main";
135
+ }
136
+ async function resolveAndValidateSourceBranch(cwd, sourceBranch, projectDir) {
137
+ await validateRef(cwd, sourceBranch.replace(/^origin\//, ""));
138
+ await runGit(cwd, ["fetch", "origin", "--no-tags", "--quiet"]).catch(() => {
139
+ });
140
+ const branchName = sourceBranch.replace(/^origin\//, "");
141
+ const localRef = await captureStdout(cwd, ["rev-parse", "--verify", "--quiet", "refs/heads/" + branchName]);
142
+ if (localRef !== null) return branchName;
143
+ const remoteRef = await captureStdout(cwd, ["rev-parse", "--verify", "--quiet", "refs/remotes/origin/" + branchName]);
144
+ if (remoteRef !== null) {
145
+ await runGit(cwd, ["branch", "--track", branchName, "origin/" + branchName]);
146
+ return branchName;
147
+ }
148
+ if (projectDir) {
149
+ const remoteExists = await captureStdout(projectDir, ["ls-remote", "--heads", "origin", branchName]);
150
+ if (remoteExists !== null && remoteExists.trim() !== "") {
151
+ await runGit(cwd, ["fetch", projectDir, "refs/remotes/origin/" + branchName + ":refs/heads/" + branchName]).catch(
152
+ async () => {
153
+ await runGit(projectDir, ["fetch", "origin", branchName]);
154
+ await runGit(cwd, ["fetch", projectDir, "refs/remotes/origin/" + branchName + ":refs/heads/" + branchName]);
155
+ }
156
+ );
157
+ return branchName;
158
+ }
159
+ }
160
+ throw new Error(
161
+ `Source branch "${sourceBranch}" not found locally or on origin. Use a valid branch name like "main" or "origin/main".`
162
+ );
163
+ }
109
164
  function validateWorkspaceName(name) {
110
165
  if (!name || typeof name !== "string") throw new Error("Workspace name is required");
111
166
  if (name.includes("/") || name.includes("\\")) throw new Error("Workspace name cannot contain path separators");
@@ -116,11 +171,12 @@ function validateWorkspaceName(name) {
116
171
  function checkoutBranch(cwd, name) {
117
172
  return runGit(cwd, ["checkout", name]);
118
173
  }
119
- function createBranch(cwd, name) {
120
- return runGit(cwd, ["checkout", "-b", name]);
174
+ function createBranch(cwd, name, sourceBranch) {
175
+ const args = sourceBranch ? ["checkout", "-b", name, sourceBranch] : ["checkout", "-b", name];
176
+ return runGit(cwd, args);
121
177
  }
122
- async function workspaceExists(projectName, name) {
123
- const dir = getWorkspacesDir(projectName);
178
+ async function workspaceExists(projectName, name, projectDir) {
179
+ const dir = await getWorkspacesDir(projectName, projectDir);
124
180
  const wsPath = resolve2(dir, name);
125
181
  const st = await statSafe(wsPath);
126
182
  if (!st?.isDirectory()) return false;
@@ -128,8 +184,8 @@ async function workspaceExists(projectName, name) {
128
184
  const gitSt = await statSafe(gitDir);
129
185
  return gitSt?.isDirectory() ?? false;
130
186
  }
131
- async function listWorkspaces(projectName) {
132
- const dir = getWorkspacesDir(projectName);
187
+ async function listWorkspaces(projectName, projectDir) {
188
+ const dir = await getWorkspacesDir(projectName, projectDir);
133
189
  try {
134
190
  const { readdir } = await import("fs/promises");
135
191
  const entries = await readdir(dir, { withFileTypes: true });
@@ -146,8 +202,8 @@ async function listWorkspaces(projectName) {
146
202
  return [];
147
203
  }
148
204
  }
149
- async function ensureWorkspace(projectDir, name, projectName, branch) {
150
- const workspacesDir = getWorkspacesDir(projectName);
205
+ async function ensureWorkspace(projectDir, name, projectName, branch, sourceBranch) {
206
+ const workspacesDir = await getWorkspacesDir(projectName, projectDir);
151
207
  const wsPath = resolve2(workspacesDir, name);
152
208
  await mkdir2(workspacesDir, { recursive: true });
153
209
  const existing = await statSafe(wsPath);
@@ -166,9 +222,10 @@ async function ensureWorkspace(projectDir, name, projectName, branch) {
166
222
  throw new Error("Failed to clone workspace");
167
223
  }
168
224
  if (branch) {
225
+ await validateRef(wsPath, branch);
169
226
  await runGit(wsPath, ["checkout", branch]).catch(async () => {
170
- const sourceBranch = await getGitBranch(projectDir) ?? "main";
171
- await runGit(wsPath, ["checkout", "-b", branch, sourceBranch]);
227
+ const sb = sourceBranch ? await resolveAndValidateSourceBranch(wsPath, sourceBranch, projectDir) : await getDefaultBranch(projectDir);
228
+ await runGit(wsPath, ["checkout", "-b", branch, sb]);
172
229
  });
173
230
  }
174
231
  const config = await loadWorkspaceConfig(projectDir);
@@ -184,15 +241,19 @@ async function ensureWorkspace(projectDir, name, projectName, branch) {
184
241
  }
185
242
  return { path: wsPath, name };
186
243
  }
187
- async function deleteWorkspace(projectName, name) {
188
- const dir = getWorkspacesDir(projectName);
244
+ async function deleteWorkspace(projectName, name, projectDir) {
245
+ const dir = await getWorkspacesDir(projectName, projectDir);
189
246
  const wsPath = resolve2(dir, name);
190
247
  const st = await statSafe(wsPath);
191
248
  if (!st?.isDirectory()) {
192
249
  throw new Error(`Workspace "${name}" does not exist`);
193
250
  }
194
251
  const { rm } = await import("fs/promises");
195
- await rm(wsPath, { recursive: true, force: true });
252
+ try {
253
+ execSync(`rm -rf "${wsPath}"`, { stdio: "ignore", timeout: 1e4 });
254
+ } catch {
255
+ await rm(wsPath, { recursive: true, force: true });
256
+ }
196
257
  logger.info("Deleted workspace", { projectName, name, path: wsPath });
197
258
  }
198
259
  async function statSafe(p) {
@@ -208,11 +269,17 @@ export {
208
269
  loadWorkspaceConfig,
209
270
  saveWorkspaceConfig,
210
271
  runGit,
272
+ getServerMode,
273
+ getGlobalDataDir,
211
274
  getWorkspacesDir,
275
+ getDefaultGlobalWorkspacesDir,
212
276
  getGitBranch,
213
277
  listBranches,
278
+ listRemoteBranches,
214
279
  getCommitsBehind,
215
280
  validateRef,
281
+ getDefaultBranch,
282
+ resolveAndValidateSourceBranch,
216
283
  validateWorkspaceName,
217
284
  checkoutBranch,
218
285
  createBranch,
@@ -221,4 +288,4 @@ export {
221
288
  ensureWorkspace,
222
289
  deleteWorkspace
223
290
  };
224
- //# sourceMappingURL=chunk-MF3UW36X.js.map
291
+ //# sourceMappingURL=chunk-37WF2Z3T.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getPlatformShell
3
- } from "./chunk-4QHDQP2N.js";
3
+ } from "./chunk-MTUYDBSL.js";
4
4
  import {
5
5
  appendLog,
6
6
  createProcess,
@@ -153,4 +153,4 @@ export {
153
153
  getSessionProcesses2 as getSessionProcesses,
154
154
  getProcessLogs
155
155
  };
156
- //# sourceMappingURL=chunk-OBQPXUXI.js.map
156
+ //# sourceMappingURL=chunk-5CQRB7AD.js.map
@@ -0,0 +1,7 @@
1
+ // src/constants.ts
2
+ var VERSION = "2.0.78";
3
+
4
+ export {
5
+ VERSION
6
+ };
7
+ //# sourceMappingURL=chunk-64TKWWNF.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getDatabase
3
- } from "./chunk-7QXRQ5ZL.js";
3
+ } from "./chunk-RGUUZD5B.js";
4
4
 
5
5
  // src/server/db/projects.ts
6
6
  function createProject(name, workdir) {
@@ -117,4 +117,4 @@ export {
117
117
  deleteProject,
118
118
  toggleStar
119
119
  };
120
- //# sourceMappingURL=chunk-LXFLRM7M.js.map
120
+ //# sourceMappingURL=chunk-6AE3JPDJ.js.map
@@ -0,0 +1,327 @@
1
+ import {
2
+ getDatabase
3
+ } from "./chunk-RGUUZD5B.js";
4
+
5
+ // src/server/db/sessions.ts
6
+ function getProjectDangerLevel(projectId) {
7
+ try {
8
+ const db = getDatabase();
9
+ const row = db.prepare("SELECT danger_level FROM projects WHERE id = ?").get(projectId);
10
+ return row?.danger_level ?? "normal";
11
+ } catch {
12
+ return "normal";
13
+ }
14
+ }
15
+ function createSession(projectId, workdir, title, providerId, providerModel, workspace, branch) {
16
+ const db = getDatabase();
17
+ const now = (/* @__PURE__ */ new Date()).toISOString();
18
+ const id = crypto.randomUUID();
19
+ const dangerLevel = getProjectDangerLevel(projectId);
20
+ db.prepare(
21
+ `
22
+ INSERT INTO sessions (id, project_id, workdir, workspace, branch, phase, mode, workflow_phase, is_running, created_at, updated_at, title, provider_id, provider_model, danger_level)
23
+ VALUES (?, ?, ?, ?, ?, 'idle', 'planner', 'plan', 0, ?, ?, ?, ?, ?, ?)
24
+ `
25
+ ).run(
26
+ id,
27
+ projectId,
28
+ workdir,
29
+ workspace ?? null,
30
+ branch ?? null,
31
+ now,
32
+ now,
33
+ title ?? null,
34
+ providerId ?? null,
35
+ providerModel ?? null,
36
+ dangerLevel
37
+ );
38
+ return {
39
+ id,
40
+ projectId,
41
+ workdir,
42
+ ...workspace ? { workspace } : {},
43
+ ...branch ? { branch } : {},
44
+ mode: "planner",
45
+ phase: "plan",
46
+ isRunning: false,
47
+ providerId: providerId ?? null,
48
+ providerModel: providerModel ?? null,
49
+ createdAt: now,
50
+ updatedAt: now,
51
+ messages: [],
52
+ criteria: [],
53
+ contextWindows: [],
54
+ executionState: null,
55
+ metadata: {
56
+ ...title ? { title } : {},
57
+ totalTokensUsed: 0,
58
+ totalToolCalls: 0,
59
+ iterationCount: 0
60
+ },
61
+ metadataEntries: {},
62
+ dangerLevel
63
+ };
64
+ }
65
+ function getSession(id) {
66
+ const db = getDatabase();
67
+ const row = db.prepare(
68
+ `
69
+ SELECT * FROM sessions WHERE id = ?
70
+ `
71
+ ).get(id);
72
+ if (!row) {
73
+ return null;
74
+ }
75
+ return {
76
+ ...mapSessionBase(row),
77
+ ...row.branch ? { branch: row.branch } : {},
78
+ messages: [],
79
+ criteria: [],
80
+ contextWindows: [],
81
+ executionState: null,
82
+ metadata: {
83
+ ...row.title ? { title: row.title } : {},
84
+ totalTokensUsed: row.total_tokens_used,
85
+ totalToolCalls: row.total_tool_calls,
86
+ iterationCount: row.iteration_count
87
+ },
88
+ metadataEntries: {},
89
+ dangerLevel: row.danger_level ?? "normal"
90
+ };
91
+ }
92
+ function updateSessionProvider(id, providerId, providerModel) {
93
+ const db = getDatabase();
94
+ const now = (/* @__PURE__ */ new Date()).toISOString();
95
+ db.prepare(
96
+ `
97
+ UPDATE sessions SET provider_id = ?, provider_model = ?, updated_at = ? WHERE id = ?
98
+ `
99
+ ).run(providerId, providerModel, now, id);
100
+ }
101
+ function updateSessionMode(id, mode) {
102
+ const db = getDatabase();
103
+ const now = (/* @__PURE__ */ new Date()).toISOString();
104
+ db.prepare(
105
+ `
106
+ UPDATE sessions SET mode = ?, updated_at = ? WHERE id = ?
107
+ `
108
+ ).run(mode, now, id);
109
+ }
110
+ function updateSessionDangerLevel(id, dangerLevel) {
111
+ const db = getDatabase();
112
+ const now = (/* @__PURE__ */ new Date()).toISOString();
113
+ db.prepare(
114
+ `
115
+ UPDATE sessions SET danger_level = ?, updated_at = ? WHERE id = ?
116
+ `
117
+ ).run(dangerLevel, now, id);
118
+ }
119
+ function updateSessionPhase(id, phase) {
120
+ const db = getDatabase();
121
+ const now = (/* @__PURE__ */ new Date()).toISOString();
122
+ db.prepare(
123
+ `
124
+ UPDATE sessions SET workflow_phase = ?, updated_at = ? WHERE id = ?
125
+ `
126
+ ).run(phase, now, id);
127
+ }
128
+ function updateSessionRunning(id, isRunning) {
129
+ const db = getDatabase();
130
+ const now = (/* @__PURE__ */ new Date()).toISOString();
131
+ db.prepare(
132
+ `
133
+ UPDATE sessions SET is_running = ?, updated_at = ? WHERE id = ?
134
+ `
135
+ ).run(isRunning ? 1 : 0, now, id);
136
+ }
137
+ function updateSessionMetadata(id, metadata) {
138
+ const db = getDatabase();
139
+ const now = (/* @__PURE__ */ new Date()).toISOString();
140
+ const updates = ["updated_at = ?"];
141
+ const values = [now];
142
+ if (metadata.title !== void 0) {
143
+ updates.push("title = ?");
144
+ values.push(metadata.title ?? "");
145
+ }
146
+ if (metadata.totalTokensUsed !== void 0) {
147
+ updates.push("total_tokens_used = ?");
148
+ values.push(metadata.totalTokensUsed);
149
+ }
150
+ if (metadata.totalToolCalls !== void 0) {
151
+ updates.push("total_tool_calls = ?");
152
+ values.push(metadata.totalToolCalls);
153
+ }
154
+ if (metadata.iterationCount !== void 0) {
155
+ updates.push("iteration_count = ?");
156
+ values.push(metadata.iterationCount);
157
+ }
158
+ values.push(id);
159
+ db.prepare(
160
+ `
161
+ UPDATE sessions SET ${updates.join(", ")} WHERE id = ?
162
+ `
163
+ ).run(...values);
164
+ }
165
+ function updateSessionCachedPrompt(id, systemPrompt, tools, hash) {
166
+ const db = getDatabase();
167
+ const now = (/* @__PURE__ */ new Date()).toISOString();
168
+ db.prepare(
169
+ `
170
+ UPDATE sessions SET cached_system_prompt = ?, cached_tools = ?, cached_hash = ?, updated_at = ? WHERE id = ?
171
+ `
172
+ ).run(systemPrompt, JSON.stringify(tools), hash, now, id);
173
+ }
174
+ function getSessionCachedPrompt(id) {
175
+ const db = getDatabase();
176
+ const row = db.prepare(
177
+ `
178
+ SELECT cached_system_prompt, cached_tools, cached_hash FROM sessions WHERE id = ?
179
+ `
180
+ ).get(id);
181
+ if (!row || !row.cached_system_prompt || !row.cached_tools || !row.cached_hash) {
182
+ return null;
183
+ }
184
+ try {
185
+ const tools = JSON.parse(row.cached_tools);
186
+ return { systemPrompt: row.cached_system_prompt, tools, hash: row.cached_hash };
187
+ } catch {
188
+ return null;
189
+ }
190
+ }
191
+ function updateSessionMessageCount(id, delta) {
192
+ try {
193
+ const db = getDatabase();
194
+ const now = (/* @__PURE__ */ new Date()).toISOString();
195
+ db.prepare(
196
+ `
197
+ UPDATE sessions SET message_count = message_count + ?, updated_at = ? WHERE id = ?
198
+ `
199
+ ).run(delta, now, id);
200
+ } catch {
201
+ }
202
+ }
203
+ function getSessionMessageCount(id) {
204
+ try {
205
+ const db = getDatabase();
206
+ const row = db.prepare(`SELECT message_count FROM sessions WHERE id = ?`).get(id);
207
+ return row?.message_count ?? 0;
208
+ } catch {
209
+ return 0;
210
+ }
211
+ }
212
+ function listSessions() {
213
+ const db = getDatabase();
214
+ const rows = db.prepare(
215
+ `
216
+ SELECT
217
+ s.id,
218
+ s.project_id,
219
+ s.workdir,
220
+ s.workspace,
221
+ s.branch,
222
+ s.mode,
223
+ s.workflow_phase,
224
+ s.is_running,
225
+ s.created_at,
226
+ s.updated_at,
227
+ s.title,
228
+ s.provider_id,
229
+ s.provider_model,
230
+ s.message_count
231
+ FROM sessions s
232
+ ORDER BY s.updated_at DESC
233
+ `
234
+ ).all();
235
+ return rows.map(mapSessionSummaryRow);
236
+ }
237
+ function listSessionsByProject(projectId, limit = 20, offset = 0) {
238
+ const db = getDatabase();
239
+ const rows = db.prepare(
240
+ `
241
+ SELECT
242
+ s.id,
243
+ s.project_id,
244
+ s.workdir,
245
+ s.workspace,
246
+ s.branch,
247
+ s.mode,
248
+ s.workflow_phase,
249
+ s.is_running,
250
+ s.created_at,
251
+ s.updated_at,
252
+ s.title,
253
+ s.provider_id,
254
+ s.provider_model,
255
+ s.message_count
256
+ FROM sessions s
257
+ WHERE s.project_id = ?
258
+ ORDER BY s.updated_at DESC
259
+ LIMIT ? OFFSET ?
260
+ `
261
+ ).all(projectId, limit + 1, offset);
262
+ const hasMore = rows.length > limit;
263
+ const sessions = rows.slice(0, limit).map(mapSessionSummaryRow);
264
+ return { sessions, hasMore };
265
+ }
266
+ function updateSessionWorkdir(id, workdir, workspace, branch) {
267
+ const db = getDatabase();
268
+ const now = (/* @__PURE__ */ new Date()).toISOString();
269
+ db.prepare(
270
+ branch !== void 0 ? "UPDATE sessions SET workdir = ?, workspace = ?, branch = ?, updated_at = ? WHERE id = ?" : "UPDATE sessions SET workdir = ?, workspace = ?, updated_at = ? WHERE id = ?"
271
+ ).run(workdir, workspace, ...branch !== void 0 ? [branch, now, id] : [now, id]);
272
+ }
273
+ function updateSessionBranch(id, branch) {
274
+ const db = getDatabase();
275
+ const now = (/* @__PURE__ */ new Date()).toISOString();
276
+ db.prepare("UPDATE sessions SET branch = ?, updated_at = ? WHERE id = ?").run(branch, now, id);
277
+ }
278
+ function deleteSession(id) {
279
+ const db = getDatabase();
280
+ db.prepare("DELETE FROM sessions WHERE id = ?").run(id);
281
+ }
282
+ function mapSessionBase(row) {
283
+ return {
284
+ id: row.id,
285
+ projectId: row.project_id,
286
+ workdir: row.workdir,
287
+ ...row.workspace ? { workspace: row.workspace } : {},
288
+ ...row.branch ? { branch: row.branch } : {},
289
+ mode: row.mode ?? "planner",
290
+ phase: row.workflow_phase ?? "plan",
291
+ isRunning: Boolean(row.is_running),
292
+ providerId: row.provider_id ?? null,
293
+ providerModel: row.provider_model ?? null,
294
+ createdAt: row.created_at,
295
+ updatedAt: row.updated_at
296
+ };
297
+ }
298
+ function mapSessionSummaryRow(row) {
299
+ return {
300
+ ...mapSessionBase(row),
301
+ ...row.title ? { title: row.title } : {},
302
+ criteriaCount: 0,
303
+ criteriaCompleted: 0,
304
+ messageCount: row.message_count
305
+ };
306
+ }
307
+
308
+ export {
309
+ createSession,
310
+ getSession,
311
+ updateSessionProvider,
312
+ updateSessionMode,
313
+ updateSessionDangerLevel,
314
+ updateSessionPhase,
315
+ updateSessionRunning,
316
+ updateSessionMetadata,
317
+ updateSessionCachedPrompt,
318
+ getSessionCachedPrompt,
319
+ updateSessionMessageCount,
320
+ getSessionMessageCount,
321
+ listSessions,
322
+ listSessionsByProject,
323
+ updateSessionWorkdir,
324
+ updateSessionBranch,
325
+ deleteSession
326
+ };
327
+ //# sourceMappingURL=chunk-AANVMTYU.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getDatabase
3
- } from "./chunk-7QXRQ5ZL.js";
3
+ } from "./chunk-RGUUZD5B.js";
4
4
 
5
5
  // src/server/db/settings.ts
6
6
  var SETTINGS_KEYS = {
@@ -92,6 +92,10 @@ function getAllSettings() {
92
92
  }
93
93
  return result;
94
94
  }
95
+ function getMaxVisibleItems() {
96
+ const setting = getSetting(SETTINGS_KEYS.DISPLAY_MAX_VISIBLE_ITEMS);
97
+ return setting ? parseInt(setting, 10) : 0;
98
+ }
95
99
 
96
100
  export {
97
101
  SETTINGS_KEYS,
@@ -99,6 +103,7 @@ export {
99
103
  getSetting,
100
104
  setSetting,
101
105
  deleteSetting,
102
- getAllSettings
106
+ getAllSettings,
107
+ getMaxVisibleItems
103
108
  };
104
- //# sourceMappingURL=chunk-YMFCFMMB.js.map
109
+ //# sourceMappingURL=chunk-AFJLY43Z.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createLLMClient
3
- } from "./chunk-W4ZEG3LX.js";
3
+ } from "./chunk-WL2WEJAK.js";
4
4
  import {
5
5
  getModelProfile
6
6
  } from "./chunk-V4IE7HJY.js";
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-HNCM3D7Y.js";
15
15
  import {
16
16
  resolveAttachmentsInMessages
17
- } from "./chunk-EZK7CGJ7.js";
17
+ } from "./chunk-RMXPVQP4.js";
18
18
  import {
19
19
  logger
20
20
  } from "./chunk-K44MW7JJ.js";
@@ -807,4 +807,4 @@ export {
807
807
  parseDefaultModelSelection,
808
808
  createProviderManager
809
809
  };
810
- //# sourceMappingURL=chunk-OCVRIPQP.js.map
810
+ //# sourceMappingURL=chunk-CJDYSUU5.js.map