Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Initial g1t: services, event bus, intents and attempts | 1 | import type { |
| 2 | Attempt, | |
| 3 | AttemptRuntime, | |
| 4 | AttemptStatus, | |
| 5 | Intent, | |
| 6 | IntentStatus, | |
| 7 | SessionEntry, | |
| 8 | SessionEntryKind, | |
| 9 | } from "@g1t/contracts"; | |
| 10 | ||
| 11 | export type IntentRow = { | |
| 12 | id: string; | |
| 13 | repo_id: string; | |
| 14 | number: number; | |
| 15 | title: string; | |
| 16 | brief: string; | |
| 17 | checks: string; | |
| 18 | status: IntentStatus; | |
| 19 | author_id: string; | |
| 20 | author_name: string; | |
| 21 | created_at: number; | |
| 22 | attempt_count: number; | |
| 23 | }; | |
| 24 | ||
| 25 | export type AttemptRow = { | |
| 26 | id: string; | |
| 27 | intent_id: string; | |
| 28 | repo_id: string; | |
| 29 | number: number; | |
| 30 | agent: string; | |
| 31 | runtime: AttemptRuntime; | |
| 32 | status: AttemptStatus; | |
| 33 | summary: string | null; | |
| 34 | fork_repo_id: string; | |
| 35 | fork_namespace: string; | |
| 36 | fork_name: string; | |
| 37 | head_commit: string | null; | |
| 38 | started_by_id: string; | |
| 39 | started_by_name: string; | |
| 40 | created_at: number; | |
| 41 | updated_at: number; | |
| 42 | }; | |
| 43 | ||
| 44 | export type SessionRow = { | |
| 45 | attempt_id: string; | |
| 46 | seq: number; | |
| 47 | kind: SessionEntryKind; | |
| 48 | text: string; | |
| 49 | tool: string | null; | |
| 50 | commit: string | null; | |
| 51 | at: number; | |
| 52 | }; | |
| 53 | ||
| 54 | export function toIntent(row: IntentRow): Intent { | |
| 55 | return { | |
| 56 | id: row.id, | |
| 57 | repoId: row.repo_id, | |
| 58 | number: row.number, | |
| 59 | title: row.title, | |
| 60 | brief: row.brief, | |
| 61 | checks: JSON.parse(row.checks), | |
| 62 | status: row.status, | |
| 63 | author: { id: row.author_id, username: row.author_name }, | |
| 64 | createdAt: row.created_at, | |
| 65 | attemptCount: row.attempt_count, | |
| 66 | }; | |
| 67 | } | |
| 68 | ||
| 69 | export function toAttempt(row: AttemptRow): Attempt { | |
| 70 | return { | |
| 71 | id: row.id, | |
| 72 | intentId: row.intent_id, | |
| 73 | repoId: row.repo_id, | |
| 74 | number: row.number, | |
| 75 | agent: row.agent, | |
| 76 | runtime: row.runtime, | |
| 77 | status: row.status, | |
| 78 | summary: row.summary, | |
| 79 | fork: { namespace: row.fork_namespace, name: row.fork_name }, | |
| 80 | headCommit: row.head_commit, | |
| 81 | startedBy: { id: row.started_by_id, username: row.started_by_name }, | |
| 82 | createdAt: row.created_at, | |
| 83 | updatedAt: row.updated_at, | |
| 84 | }; | |
| 85 | } | |
| 86 | ||
| 87 | export function toSessionEntry(row: SessionRow): SessionEntry { | |
| 88 | return { | |
| 89 | seq: row.seq, | |
| 90 | kind: row.kind, | |
| 91 | text: row.text, | |
| 92 | tool: row.tool, | |
| 93 | commit: row.commit, | |
| 94 | at: row.at, | |
| 95 | }; | |
| 96 | } |