diff options
| author | Clawd <ai@clawd.bot> | 2026-02-28 15:26:21 -0800 |
|---|---|---|
| committer | Clawd <ai@clawd.bot> | 2026-02-28 15:26:21 -0800 |
| commit | 5bd5da261732a1fce6a94ffa4d348dd6c80887cf (patch) | |
| tree | 7893aea50ba0d37ceff3ecddef4abc8b8784b822 /dist/main/db/sessions.js | |
| parent | 519d6b850e07a0387511a8f024dc394250b1a241 (diff) | |
Fix .gitignore: ignore dist/, .claude-flow/, and sync-conflict files
Remove accidentally committed build artifacts and working files.
Diffstat (limited to 'dist/main/db/sessions.js')
| -rw-r--r-- | dist/main/db/sessions.js | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/dist/main/db/sessions.js b/dist/main/db/sessions.js deleted file mode 100644 index b554898..0000000 --- a/dist/main/db/sessions.js +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 1 | "use strict"; | ||
| 2 | Object.defineProperty(exports, "__esModule", { value: true }); | ||
| 3 | exports.listSessions = listSessions; | ||
| 4 | exports.getSession = getSession; | ||
| 5 | exports.createSession = createSession; | ||
| 6 | exports.updateSession = updateSession; | ||
| 7 | exports.deleteSession = deleteSession; | ||
| 8 | exports.listMessages = listMessages; | ||
| 9 | exports.addMessage = addMessage; | ||
| 10 | const index_1 = require("./index"); | ||
| 11 | const uuid_1 = require("uuid"); | ||
| 12 | function listSessions(projectId) { | ||
| 13 | return (0, index_1.getDb)() | ||
| 14 | .prepare("SELECT * FROM sessions WHERE project_id = ? ORDER BY updated_at DESC") | ||
| 15 | .all(projectId); | ||
| 16 | } | ||
| 17 | function getSession(id) { | ||
| 18 | return (0, index_1.getDb)() | ||
| 19 | .prepare("SELECT * FROM sessions WHERE id = ?") | ||
| 20 | .get(id); | ||
| 21 | } | ||
| 22 | function createSession(projectId, name) { | ||
| 23 | const db = (0, index_1.getDb)(); | ||
| 24 | const id = (0, uuid_1.v4)(); | ||
| 25 | const now = Math.floor(Date.now() / 1000); | ||
| 26 | db.prepare(`INSERT INTO sessions (id, project_id, name, phase, permission_mode, created_at, updated_at) | ||
| 27 | VALUES (?, ?, ?, 'research', 'acceptEdits', ?, ?)`).run(id, projectId, name, now, now); | ||
| 28 | return { | ||
| 29 | id, | ||
| 30 | project_id: projectId, | ||
| 31 | name, | ||
| 32 | phase: "research", | ||
| 33 | claude_session_id: null, | ||
| 34 | permission_mode: "acceptEdits", | ||
| 35 | created_at: now, | ||
| 36 | updated_at: now, | ||
| 37 | }; | ||
| 38 | } | ||
| 39 | function updateSession(id, updates) { | ||
| 40 | const db = (0, index_1.getDb)(); | ||
| 41 | const sets = []; | ||
| 42 | const values = []; | ||
| 43 | for (const [key, value] of Object.entries(updates)) { | ||
| 44 | if (value !== undefined) { | ||
| 45 | sets.push(`${key} = ?`); | ||
| 46 | values.push(value); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | if (sets.length > 0) { | ||
| 50 | sets.push("updated_at = ?"); | ||
| 51 | values.push(Math.floor(Date.now() / 1000)); | ||
| 52 | values.push(id); | ||
| 53 | db.prepare(`UPDATE sessions SET ${sets.join(", ")} WHERE id = ?`).run(...values); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | function deleteSession(id) { | ||
| 57 | (0, index_1.getDb)().prepare("DELETE FROM sessions WHERE id = ?").run(id); | ||
| 58 | } | ||
| 59 | // Messages | ||
| 60 | function listMessages(sessionId) { | ||
| 61 | return (0, index_1.getDb)() | ||
| 62 | .prepare("SELECT * FROM messages WHERE session_id = ? ORDER BY created_at ASC") | ||
| 63 | .all(sessionId); | ||
| 64 | } | ||
| 65 | function addMessage(sessionId, role, content) { | ||
| 66 | const db = (0, index_1.getDb)(); | ||
| 67 | const id = (0, uuid_1.v4)(); | ||
| 68 | const now = Math.floor(Date.now() / 1000); | ||
| 69 | db.prepare("INSERT INTO messages (id, session_id, role, content, created_at) VALUES (?, ?, ?, ?, ?)").run(id, sessionId, role, content, now); | ||
| 70 | db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId); | ||
| 71 | return { id, session_id: sessionId, role, content, created_at: now }; | ||
| 72 | } | ||
