| 42 | } |
| 43 | |
| 44 | function sessionRow(info: SessionV1.SessionInfo): typeof SessionTable.$inferInsert { |
| 45 | return { |
| 46 | id: info.id, |
| 47 | project_id: info.projectID, |
| 48 | workspace_id: info.workspaceID ?? null, |
| 49 | parent_id: info.parentID, |
| 50 | slug: info.slug, |
| 51 | directory: info.directory, |
| 52 | path: info.path, |
| 53 | title: info.title, |
| 54 | agent: info.agent, |
| 55 | model: info.model, |
| 56 | version: info.version, |
| 57 | share_url: info.share?.url, |
| 58 | summary_additions: info.summary?.additions, |
| 59 | summary_deletions: info.summary?.deletions, |
| 60 | summary_files: info.summary?.files, |
| 61 | summary_diffs: info.summary?.diffs ? [...info.summary.diffs] : undefined, |
| 62 | metadata: info.metadata, |
| 63 | cost: info.cost ?? 0, |
| 64 | tokens_input: (info.tokens ?? { input: 0 }).input, |
| 65 | tokens_output: (info.tokens ?? { output: 0 }).output, |
| 66 | tokens_reasoning: (info.tokens ?? { reasoning: 0 }).reasoning, |
| 67 | tokens_cache_read: (info.tokens ?? { cache: { read: 0 } }).cache.read, |
| 68 | tokens_cache_write: (info.tokens ?? { cache: { write: 0 } }).cache.write, |
| 69 | revert: info.revert ? { ...info.revert, messageID: SessionMessage.ID.make(info.revert.messageID) } : null, |
| 70 | permission: info.permission ? [...info.permission] : undefined, |
| 71 | time_created: info.time.created, |
| 72 | time_updated: info.time.updated, |
| 73 | time_compacting: info.time.compacting, |
| 74 | time_archived: info.time.archived, |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | function messageData( |
| 79 | info: (typeof SessionV1.Event.MessageUpdated.Type)["data"]["info"], |