@okhay-p/mivra 0.1.2 → 0.1.4

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 (48) hide show
  1. package/README.md +1 -0
  2. package/THIRD_PARTY_NOTICES.md +4 -0
  3. package/dist/chunk-KE5ZEREE.js +212 -0
  4. package/dist/chunk-KE5ZEREE.js.map +7 -0
  5. package/dist/chunk-KUKQU7EQ.js +755 -0
  6. package/dist/chunk-KUKQU7EQ.js.map +7 -0
  7. package/dist/chunk-ODFBAPPH.js +489 -0
  8. package/dist/chunk-ODFBAPPH.js.map +7 -0
  9. package/dist/chunk-PZ5AY32C.js +10 -0
  10. package/dist/chunk-PZ5AY32C.js.map +7 -0
  11. package/dist/chunk-TBAR47I6.js +32 -0
  12. package/dist/chunk-TBAR47I6.js.map +7 -0
  13. package/dist/chunk-YACRW47X.js +1203 -0
  14. package/dist/chunk-YACRW47X.js.map +7 -0
  15. package/dist/cli.js +256 -11188
  16. package/dist/cli.js.map +4 -4
  17. package/dist/client-5YDLS4KV.js +12 -0
  18. package/dist/client-5YDLS4KV.js.map +7 -0
  19. package/dist/extract-child.js +107 -173
  20. package/dist/extract-child.js.map +3 -3
  21. package/dist/key-check-WJ4CVZV5.js +8 -0
  22. package/dist/key-check-WJ4CVZV5.js.map +7 -0
  23. package/dist/start-76LKE3DL.js +13906 -0
  24. package/dist/start-76LKE3DL.js.map +7 -0
  25. package/drizzle/0012_overconfident_the_santerians.sql +66 -0
  26. package/drizzle/0013_next_dormammu.sql +1 -0
  27. package/drizzle/0014_furry_inertia.sql +1 -0
  28. package/drizzle/0015_spotty_warstar.sql +1 -0
  29. package/drizzle/0016_fresh_wiccan.sql +1 -0
  30. package/drizzle/0017_amusing_james_howlett.sql +28 -0
  31. package/drizzle/0018_happy_hairball.sql +43 -0
  32. package/drizzle/meta/0012_snapshot.json +1741 -0
  33. package/drizzle/meta/0013_snapshot.json +1749 -0
  34. package/drizzle/meta/0014_snapshot.json +1756 -0
  35. package/drizzle/meta/0015_snapshot.json +1763 -0
  36. package/drizzle/meta/0016_snapshot.json +1770 -0
  37. package/drizzle/meta/0017_snapshot.json +1956 -0
  38. package/drizzle/meta/0018_snapshot.json +2280 -0
  39. package/drizzle/meta/_journal.json +49 -0
  40. package/package.json +2 -1
  41. package/web/assets/index-C_DsRKCc.css +1 -0
  42. package/web/assets/index-DbKDW1xS.js +413 -0
  43. package/web/assets/notes-graph.worker-DaVQvftJ.js +1 -0
  44. package/web/assets/render.worker-BAfybD27.js +416 -0
  45. package/web/index.html +2 -2
  46. package/web/assets/index-BfT-sp3_.js +0 -406
  47. package/web/assets/index-FIC4B_yh.css +0 -1
  48. package/web/assets/render.worker-Bw6rO7Qu.js +0 -413
@@ -0,0 +1,489 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-PZ5AY32C.js";
4
+
5
+ // ../server/src/db/client.ts
6
+ import { chmodSync, mkdirSync, readdirSync, rmSync } from "node:fs";
7
+ import { basename, dirname, join } from "node:path";
8
+ import { fileURLToPath } from "node:url";
9
+ import Database from "better-sqlite3";
10
+ import { drizzle } from "drizzle-orm/better-sqlite3";
11
+ import { migrate } from "drizzle-orm/better-sqlite3/migrator";
12
+ import { readMigrationFiles } from "drizzle-orm/migrator";
13
+
14
+ // ../server/src/db/schema.ts
15
+ var schema_exports = {};
16
+ __export(schema_exports, {
17
+ artifacts: () => artifacts,
18
+ attempts: () => attempts,
19
+ conceptEdgeKinds: () => conceptEdgeKinds,
20
+ conceptEdges: () => conceptEdges,
21
+ conceptSources: () => conceptSources,
22
+ concepts: () => concepts,
23
+ courseStatuses: () => courseStatuses,
24
+ courses: () => courses,
25
+ documentChunks: () => documentChunks,
26
+ documentKinds: () => documentKinds,
27
+ documents: () => documents,
28
+ lessonErrorActions: () => lessonErrorActions,
29
+ lessonSections: () => lessonSections,
30
+ lessonStatuses: () => lessonStatuses,
31
+ lessonVersions: () => lessonVersions,
32
+ lessons: () => lessons,
33
+ memories: () => memories,
34
+ memorySources: () => memorySources,
35
+ memoryStatuses: () => memoryStatuses,
36
+ messages: () => messages,
37
+ noteChunks: () => noteChunks,
38
+ noteLinks: () => noteLinks,
39
+ noteTags: () => noteTags,
40
+ notes: () => notes,
41
+ runStatuses: () => runStatuses,
42
+ runs: () => runs,
43
+ sessions: () => sessions,
44
+ settings: () => settings,
45
+ syllabusVersions: () => syllabusVersions,
46
+ usageBillings: () => usageBillings,
47
+ usageKinds: () => usageKinds,
48
+ usageRecords: () => usageRecords,
49
+ usageStatuses: () => usageStatuses,
50
+ vaultImports: () => vaultImports
51
+ });
52
+ import { sql } from "drizzle-orm";
53
+ import { index, integer, primaryKey, real, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
54
+ var sessions = sqliteTable("sessions", {
55
+ id: text("id").primaryKey(),
56
+ title: text("title").notNull(),
57
+ /** The learner renamed it, so automatic titling (a first message, the tutor's course title) leaves it alone. */
58
+ titleSetByLearner: integer("title_set_by_learner", { mode: "boolean" }).notNull().default(false),
59
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
60
+ updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
61
+ });
62
+ var messages = sqliteTable(
63
+ "messages",
64
+ {
65
+ id: text("id").primaryKey(),
66
+ sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
67
+ seq: integer("seq").notNull(),
68
+ role: text("role", { enum: ["system", "user", "assistant"] }).notNull(),
69
+ parts: text("parts", { mode: "json" }).notNull(),
70
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
71
+ },
72
+ (t) => [uniqueIndex("messages_session_seq_idx").on(t.sessionId, t.seq)]
73
+ );
74
+ var runStatuses = ["running", "completed", "cancelled", "failed"];
75
+ var runs = sqliteTable(
76
+ "runs",
77
+ {
78
+ id: text("id").primaryKey(),
79
+ sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
80
+ userMessageId: text("user_message_id").notNull().references(() => messages.id, { onDelete: "cascade" }),
81
+ /** A unique claim on the quiz reply this automatic run continues. No synthetic user message. */
82
+ continuationOf: text("continuation_of"),
83
+ assistantMessageId: text("assistant_message_id").references(() => messages.id, { onDelete: "set null" }),
84
+ status: text("status", { enum: runStatuses }).notNull(),
85
+ /** The model that ran, as "<provider>:<model-id>" (ADR-012). Null for runs before it was recorded. */
86
+ model: text("model"),
87
+ /** The reasoning effort it ran with; null leaves it to the model's default. */
88
+ effort: text("effort"),
89
+ /**
90
+ * For a custom provider's model (issue #69), a fingerprint of the endpoint it ran against, so private
91
+ * reasoning metadata never replays to a different destination under the same model id. Null otherwise.
92
+ */
93
+ endpoint: text("endpoint"),
94
+ error: text("error"),
95
+ startedAt: integer("started_at", { mode: "timestamp_ms" }).notNull(),
96
+ endedAt: integer("ended_at", { mode: "timestamp_ms" })
97
+ },
98
+ (t) => [
99
+ uniqueIndex("runs_continuation_once_idx").on(t.continuationOf),
100
+ index("runs_session_idx").on(t.sessionId, t.startedAt),
101
+ uniqueIndex("runs_one_running_per_session_idx").on(t.sessionId).where(sql`${t.status} = 'running'`)
102
+ ]
103
+ );
104
+ var artifacts = sqliteTable(
105
+ "artifacts",
106
+ {
107
+ id: text("id").primaryKey(),
108
+ sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
109
+ runId: text("run_id").notNull().references(() => runs.id, { onDelete: "cascade" }),
110
+ toolCallId: text("tool_call_id").notNull(),
111
+ kind: text("kind").notNull(),
112
+ version: integer("version").notNull(),
113
+ spec: text("spec", { mode: "json" }).notNull(),
114
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
115
+ },
116
+ (t) => [index("artifacts_session_idx").on(t.sessionId, t.createdAt), uniqueIndex("artifacts_tool_call_idx").on(t.runId, t.toolCallId)]
117
+ );
118
+ var attempts = sqliteTable(
119
+ "attempts",
120
+ {
121
+ id: text("id").primaryKey(),
122
+ artifactId: text("artifact_id").notNull().references(() => artifacts.id, { onDelete: "cascade" }),
123
+ sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
124
+ answer: text("answer", { mode: "json" }).notNull(),
125
+ grade: text("grade", { mode: "json" }).notNull(),
126
+ correct: integer("correct", { mode: "boolean" }).notNull(),
127
+ concept: text("concept"),
128
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
129
+ },
130
+ (t) => [uniqueIndex("attempts_one_per_artifact_idx").on(t.artifactId), index("attempts_session_idx").on(t.sessionId, t.createdAt), index("attempts_created_idx").on(t.createdAt)]
131
+ );
132
+ var memoryStatuses = ["pending", "active", "superseded"];
133
+ var memories = sqliteTable(
134
+ "memories",
135
+ {
136
+ id: text("id").primaryKey(),
137
+ kind: text("kind", { enum: ["goal", "preference", "misconception", "known"] }).notNull(),
138
+ text: text("text").notNull(),
139
+ concept: text("concept"),
140
+ basis: text("basis", { enum: ["wrong_answer", "chat", "import"] }).notNull(),
141
+ attemptId: text("attempt_id").references(() => attempts.id, { onDelete: "set null" }),
142
+ sessionId: text("session_id").references(() => sessions.id, { onDelete: "set null" }),
143
+ runId: text("run_id").references(() => runs.id, { onDelete: "set null" }),
144
+ status: text("status", { enum: memoryStatuses }).notNull(),
145
+ /** The memory this one corrects, kept until this one is deleted. */
146
+ replacesId: text("replaces_id"),
147
+ /** For basis `import`, the imported note it was drawn from (ADR-014): deleting the note deletes the memory. */
148
+ noteId: text("note_id").references(() => notes.id, { onDelete: "cascade" }),
149
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
150
+ editedAt: integer("edited_at", { mode: "timestamp_ms" })
151
+ },
152
+ (t) => [index("memories_status_idx").on(t.status, t.createdAt), index("memories_run_idx").on(t.runId), index("memories_note_idx").on(t.noteId)]
153
+ );
154
+ var documentKinds = ["pdf", "pptx"];
155
+ var documents = sqliteTable(
156
+ "documents",
157
+ {
158
+ id: text("id").primaryKey(),
159
+ sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
160
+ messageId: text("message_id").references(() => messages.id, { onDelete: "set null" }),
161
+ filename: text("filename").notNull(),
162
+ kind: text("kind", { enum: documentKinds }).notNull(),
163
+ byteSize: integer("byte_size").notNull(),
164
+ textChars: integer("text_chars").notNull(),
165
+ pageCount: integer("page_count").notNull(),
166
+ pagesWithText: integer("pages_with_text").notNull(),
167
+ status: text("status", { enum: ["ready"] }).notNull(),
168
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
169
+ },
170
+ (t) => [index("documents_session_idx").on(t.sessionId, t.createdAt)]
171
+ );
172
+ var documentChunks = sqliteTable(
173
+ "document_chunks",
174
+ {
175
+ id: integer("id").primaryKey({ autoIncrement: true }),
176
+ documentId: text("document_id").notNull().references(() => documents.id, { onDelete: "cascade" }),
177
+ page: integer("page").notNull(),
178
+ seq: integer("seq").notNull(),
179
+ text: text("text").notNull()
180
+ },
181
+ (t) => [uniqueIndex("document_chunks_document_seq_idx").on(t.documentId, t.seq)]
182
+ );
183
+ var courseStatuses = ["interviewing", "active", "complete"];
184
+ var courses = sqliteTable(
185
+ "courses",
186
+ {
187
+ id: text("id").primaryKey(),
188
+ sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
189
+ goal: text("goal").notNull(),
190
+ status: text("status", { enum: courseStatuses }).notNull(),
191
+ /** The subject icon's Lucide name, from protocol's `courseIcons`, chosen by the tutor with the first syllabus; null until then. */
192
+ icon: text("icon"),
193
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
194
+ updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
195
+ },
196
+ (t) => [uniqueIndex("courses_session_idx").on(t.sessionId)]
197
+ );
198
+ var syllabusVersions = sqliteTable(
199
+ "syllabus_versions",
200
+ {
201
+ id: text("id").primaryKey(),
202
+ courseId: text("course_id").notNull().references(() => courses.id, { onDelete: "cascade" }),
203
+ version: integer("version").notNull(),
204
+ topics: text("topics", { mode: "json" }).notNull(),
205
+ known: text("known", { mode: "json" }).notNull(),
206
+ /** Who made this version: the interview, the tutor on request (Change), or adaptive generation (ADR-011). */
207
+ source: text("source", { enum: ["interview", "tutor", "adaptive", "undo"] }).notNull().default("interview"),
208
+ /** For an adaptive change, the finished lesson whose results prompted it: at most one change per lesson. */
209
+ triggerLessonId: text("trigger_lesson_id"),
210
+ /** Why it changed, shown to the learner. Null for the first version. */
211
+ reason: text("reason"),
212
+ /** Ids of the topics this version added or changed, for highlighting. */
213
+ changedTopicIds: text("changed_topic_ids", { mode: "json" }).notNull().default(sql`'[]'`),
214
+ runId: text("run_id").references(() => runs.id, { onDelete: "set null" }),
215
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
216
+ },
217
+ (t) => [uniqueIndex("syllabus_versions_course_version_idx").on(t.courseId, t.version)]
218
+ );
219
+ var lessonStatuses = ["generating", "ready", "failed", "finished"];
220
+ var lessonErrorActions = ["lesson-model"];
221
+ var lessons = sqliteTable(
222
+ "lessons",
223
+ {
224
+ id: text("id").primaryKey(),
225
+ courseId: text("course_id").notNull().references(() => courses.id, { onDelete: "cascade" }),
226
+ topicId: text("topic_id").notNull(),
227
+ topicTitle: text("topic_title").notNull(),
228
+ /** The topic's position in the syllabus when the lesson started. */
229
+ position: integer("position").notNull(),
230
+ sessionId: text("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
231
+ status: text("status", { enum: lessonStatuses }).notNull(),
232
+ error: text("error"),
233
+ /** Set with `error` when that message is Mivra's own and names a fix; the lesson then shows it. */
234
+ errorAction: text("error_action", { enum: lessonErrorActions }),
235
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
236
+ finishedAt: integer("finished_at", { mode: "timestamp_ms" })
237
+ },
238
+ (t) => [uniqueIndex("lessons_course_topic_idx").on(t.courseId, t.topicId), uniqueIndex("lessons_session_idx").on(t.sessionId)]
239
+ );
240
+ var lessonSections = sqliteTable(
241
+ "lesson_sections",
242
+ {
243
+ id: text("id").primaryKey(),
244
+ lessonId: text("lesson_id").notNull().references(() => lessons.id, { onDelete: "cascade" }),
245
+ kind: text("kind", { enum: ["prose", "artifact"] }).notNull(),
246
+ title: text("title").notNull(),
247
+ markdown: text("markdown"),
248
+ artifactId: text("artifact_id").references(() => artifacts.id, { onDelete: "cascade" }),
249
+ /** Sections of the previous lesson this one revisits, by id, so the page can link back to them. */
250
+ revisits: text("revisits", { mode: "json" }).notNull().default(sql`'[]'`),
251
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
252
+ },
253
+ (t) => [index("lesson_sections_lesson_idx").on(t.lessonId), uniqueIndex("lesson_sections_artifact_idx").on(t.artifactId)]
254
+ );
255
+ var lessonVersions = sqliteTable(
256
+ "lesson_versions",
257
+ {
258
+ id: text("id").primaryKey(),
259
+ lessonId: text("lesson_id").notNull().references(() => lessons.id, { onDelete: "cascade" }),
260
+ version: integer("version").notNull(),
261
+ outline: text("outline", { mode: "json" }).notNull(),
262
+ sectionIds: text("section_ids", { mode: "json" }).notNull(),
263
+ /** Ids of the sections this version added or changed, for highlighting. Empty for version 1. */
264
+ changedSectionIds: text("changed_section_ids", { mode: "json" }).notNull().default(sql`'[]'`),
265
+ /** Why the tutor changed it. Null for version 1. */
266
+ reason: text("reason"),
267
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
268
+ },
269
+ (t) => [uniqueIndex("lesson_versions_lesson_version_idx").on(t.lessonId, t.version)]
270
+ );
271
+ var settings = sqliteTable("settings", {
272
+ key: text("key").primaryKey(),
273
+ value: text("value", { mode: "json" }).notNull(),
274
+ updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
275
+ });
276
+ var vaultImports = sqliteTable(
277
+ "vault_imports",
278
+ {
279
+ id: text("id").primaryKey(),
280
+ name: text("name").notNull(),
281
+ source: text("source", { enum: ["obsidian"] }).notNull(),
282
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
283
+ updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
284
+ },
285
+ (t) => [uniqueIndex("vault_imports_name_idx").on(t.name)]
286
+ );
287
+ var notes = sqliteTable(
288
+ "notes",
289
+ {
290
+ id: text("id").primaryKey(),
291
+ importId: text("import_id").notNull().references(() => vaultImports.id, { onDelete: "cascade" }),
292
+ path: text("path").notNull(),
293
+ title: text("title").notNull(),
294
+ titleKey: text("title_key").notNull(),
295
+ aliases: text("aliases", { mode: "json" }).$type().notNull(),
296
+ body: text("body").notNull(),
297
+ hash: text("hash").notNull(),
298
+ /** The hash this note had when it was last distilled, or null if it never was. Differing from `hash` means it's waiting. */
299
+ distilledHash: text("distilled_hash"),
300
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
301
+ updatedAt: integer("updated_at", { mode: "timestamp_ms" }).notNull()
302
+ },
303
+ (t) => [uniqueIndex("notes_import_path_idx").on(t.importId, t.path), index("notes_import_title_idx").on(t.importId, t.titleKey)]
304
+ );
305
+ var noteChunks = sqliteTable(
306
+ "note_chunks",
307
+ {
308
+ id: integer("id").primaryKey({ autoIncrement: true }),
309
+ noteId: text("note_id").notNull().references(() => notes.id, { onDelete: "cascade" }),
310
+ seq: integer("seq").notNull(),
311
+ heading: text("heading"),
312
+ text: text("text").notNull()
313
+ },
314
+ (t) => [uniqueIndex("note_chunks_note_seq_idx").on(t.noteId, t.seq)]
315
+ );
316
+ var noteLinks = sqliteTable(
317
+ "note_links",
318
+ {
319
+ noteId: text("note_id").notNull().references(() => notes.id, { onDelete: "cascade" }),
320
+ target: text("target").notNull(),
321
+ kind: text("kind", { enum: ["link", "embed"] }).notNull()
322
+ },
323
+ (t) => [primaryKey({ columns: [t.noteId, t.target, t.kind] })]
324
+ );
325
+ var noteTags = sqliteTable(
326
+ "note_tags",
327
+ {
328
+ noteId: text("note_id").notNull().references(() => notes.id, { onDelete: "cascade" }),
329
+ tag: text("tag").notNull()
330
+ },
331
+ (t) => [primaryKey({ columns: [t.noteId, t.tag] }), index("note_tags_tag_idx").on(t.tag)]
332
+ );
333
+ var usageKinds = ["chat", "continuation", "lesson", "distillation", "test"];
334
+ var usageStatuses = ["completed", "failed", "cancelled"];
335
+ var usageBillings = ["api", "subscription"];
336
+ var usageRecords = sqliteTable(
337
+ "usage_records",
338
+ {
339
+ id: text("id").primaryKey(),
340
+ kind: text("kind", { enum: usageKinds }).notNull(),
341
+ status: text("status", { enum: usageStatuses }).notNull(),
342
+ sessionId: text("session_id"),
343
+ runId: text("run_id"),
344
+ /** The call's position within its run (or test), from 0. Each tool-call step, and each retry, is its own call. */
345
+ seq: integer("seq").notNull(),
346
+ /** "openrouter", "anthropic", "openai", "chatgpt" or "custom:<provider id>". */
347
+ provider: text("provider").notNull(),
348
+ providerLabel: text("provider_label").notNull(),
349
+ model: text("model").notNull(),
350
+ modelLabel: text("model_label"),
351
+ effort: text("effort"),
352
+ billing: text("billing", { enum: usageBillings }).notNull(),
353
+ /** All input tokens, cached ones included. */
354
+ inputTokens: integer("input_tokens"),
355
+ inputNoCacheTokens: integer("input_no_cache_tokens"),
356
+ inputCacheReadTokens: integer("input_cache_read_tokens"),
357
+ inputCacheWriteTokens: integer("input_cache_write_tokens"),
358
+ /** All output tokens, reasoning included. */
359
+ outputTokens: integer("output_tokens"),
360
+ outputReasoningTokens: integer("output_reasoning_tokens"),
361
+ /** US dollars the provider reported for this call (OpenRouter does). */
362
+ reportedCost: real("reported_cost"),
363
+ price: text("price", { mode: "json" }),
364
+ /** US dollars at `price`, or null when the price or a needed token count is unknown. */
365
+ estimatedCost: real("estimated_cost"),
366
+ startedAt: integer("started_at", { mode: "timestamp_ms" }).notNull(),
367
+ endedAt: integer("ended_at", { mode: "timestamp_ms" }).notNull()
368
+ },
369
+ (t) => [index("usage_records_started_idx").on(t.startedAt), index("usage_records_run_idx").on(t.runId)]
370
+ );
371
+ var concepts = sqliteTable(
372
+ "concepts",
373
+ {
374
+ id: text("id").primaryKey(),
375
+ key: text("key").notNull(),
376
+ name: text("name").notNull(),
377
+ createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull()
378
+ },
379
+ (t) => [uniqueIndex("concepts_key_idx").on(t.key)]
380
+ );
381
+ var conceptSources = sqliteTable(
382
+ "concept_sources",
383
+ {
384
+ conceptId: text("concept_id").notNull().references(() => concepts.id, { onDelete: "cascade" }),
385
+ noteId: text("note_id").notNull().references(() => notes.id, { onDelete: "cascade" })
386
+ },
387
+ (t) => [primaryKey({ columns: [t.conceptId, t.noteId] }), index("concept_sources_note_idx").on(t.noteId)]
388
+ );
389
+ var conceptEdgeKinds = ["prerequisite", "related"];
390
+ var conceptEdges = sqliteTable(
391
+ "concept_edges",
392
+ {
393
+ fromId: text("from_id").notNull().references(() => concepts.id, { onDelete: "cascade" }),
394
+ toId: text("to_id").notNull().references(() => concepts.id, { onDelete: "cascade" }),
395
+ kind: text("kind", { enum: conceptEdgeKinds }).notNull(),
396
+ noteId: text("note_id").notNull().references(() => notes.id, { onDelete: "cascade" })
397
+ },
398
+ (t) => [primaryKey({ columns: [t.fromId, t.toId, t.kind, t.noteId] }), index("concept_edges_note_idx").on(t.noteId), index("concept_edges_to_idx").on(t.toId)]
399
+ );
400
+ var memorySources = sqliteTable(
401
+ "memory_sources",
402
+ {
403
+ memoryId: text("memory_id").notNull().references(() => memories.id, { onDelete: "cascade" }),
404
+ noteId: text("note_id").notNull().references(() => notes.id, { onDelete: "cascade" }),
405
+ /** What this note said, as the model put it: the memory's text if it moves to this note. */
406
+ text: text("text").notNull()
407
+ },
408
+ (t) => [primaryKey({ columns: [t.memoryId, t.noteId] }), index("memory_sources_note_idx").on(t.noteId)]
409
+ );
410
+
411
+ // ../server/src/db/client.ts
412
+ var defaultMigrations = fileURLToPath(new URL("../../drizzle", import.meta.url));
413
+ var KEEP_BACKUPS = 5;
414
+ var NewerDatabaseError = class extends Error {
415
+ constructor(path) {
416
+ super(`${path} was last used by a newer version of Mivra. Update Mivra, or restore an older copy from the backups folder next to it.`);
417
+ }
418
+ };
419
+ function backupBeforeMigrating(sqlite, path, migrationsFolder, clock) {
420
+ const hasTable = sqlite.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = '__drizzle_migrations'").get();
421
+ if (!hasTable) return void 0;
422
+ const last = sqlite.prepare("SELECT created_at FROM __drizzle_migrations ORDER BY created_at DESC LIMIT 1").get();
423
+ if (!last) return void 0;
424
+ const lastApplied = Number(last.created_at);
425
+ const known = readMigrationFiles({ migrationsFolder });
426
+ const newestKnown = Math.max(0, ...known.map((m) => m.folderMillis));
427
+ if (lastApplied > newestKnown) throw new NewerDatabaseError(path);
428
+ if (!known.some((m) => m.folderMillis > lastApplied)) return void 0;
429
+ const dir = join(dirname(path), "backups");
430
+ mkdirSync(dir, { recursive: true, mode: 448 });
431
+ chmodSync(dir, 448);
432
+ const name = basename(path, ".db");
433
+ const target = join(dir, `${name}-${clock().toISOString().replace(/[:.]/g, "-")}.db`);
434
+ sqlite.prepare("VACUUM INTO ?").run(target);
435
+ chmodSync(target, 384);
436
+ const generated = new RegExp(`^${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}-\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}-\\d{3}Z\\.db$`);
437
+ const older = readdirSync(dir).filter((f) => generated.test(f) && f !== basename(target)).sort();
438
+ for (const old of older.slice(0, Math.max(0, older.length - (KEEP_BACKUPS - 1)))) rmSync(join(dir, old), { force: true });
439
+ return target;
440
+ }
441
+ function openDb(path, { migrationsFolder = defaultMigrations, onBackup, clock = () => /* @__PURE__ */ new Date() } = {}) {
442
+ if (path !== ":memory:") mkdirSync(dirname(path), { recursive: true });
443
+ const sqlite = new Database(path);
444
+ try {
445
+ sqlite.pragma("journal_mode = WAL");
446
+ sqlite.pragma("foreign_keys = ON");
447
+ if (path !== ":memory:") {
448
+ const backup = backupBeforeMigrating(sqlite, path, migrationsFolder, clock);
449
+ if (backup) onBackup?.(backup);
450
+ }
451
+ const db = drizzle(sqlite, { schema: schema_exports });
452
+ migrate(db, { migrationsFolder });
453
+ return db;
454
+ } catch (error) {
455
+ sqlite.close();
456
+ throw error;
457
+ }
458
+ }
459
+
460
+ export {
461
+ sessions,
462
+ messages,
463
+ runs,
464
+ artifacts,
465
+ attempts,
466
+ memories,
467
+ documents,
468
+ documentChunks,
469
+ courses,
470
+ syllabusVersions,
471
+ lessons,
472
+ lessonSections,
473
+ lessonVersions,
474
+ settings,
475
+ vaultImports,
476
+ notes,
477
+ noteChunks,
478
+ noteLinks,
479
+ noteTags,
480
+ usageRecords,
481
+ concepts,
482
+ conceptSources,
483
+ conceptEdges,
484
+ memorySources,
485
+ KEEP_BACKUPS,
486
+ NewerDatabaseError,
487
+ openDb
488
+ };
489
+ //# sourceMappingURL=chunk-ODFBAPPH.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../server/src/db/client.ts", "../../server/src/db/schema.ts"],
4
+ "sourcesContent": ["import { chmodSync, mkdirSync, readdirSync, rmSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport Database from \"better-sqlite3\";\nimport { drizzle } from \"drizzle-orm/better-sqlite3\";\nimport { migrate } from \"drizzle-orm/better-sqlite3/migrator\";\nimport { readMigrationFiles } from \"drizzle-orm/migrator\";\nimport * as schema from \"./schema.js\";\n\nconst defaultMigrations = fileURLToPath(new URL(\"../../drizzle\", import.meta.url));\n\n/** Backups kept in `backups/` next to the database; older ones are deleted after a new one is made. */\nexport const KEEP_BACKUPS = 5;\n\n/** The database was migrated by a newer Mivra than this one, which can't safely use it. */\nexport class NewerDatabaseError extends Error {\n constructor(path: string) {\n super(`${path} was last used by a newer version of Mivra. Update Mivra, or restore an older copy from the backups folder next to it.`);\n }\n}\n\n/**\n * When the database already holds data and migrations are pending, copies it to `backups/` first (ADR-013), so an\n * upgrade that goes wrong never costs the learner their history. Drizzle applies every migration newer than the\n * last one recorded, so that's what counts as pending. A database a newer Mivra migrated is refused instead.\n */\nfunction backupBeforeMigrating(sqlite: Database.Database, path: string, migrationsFolder: string, clock: () => Date): string | undefined {\n const hasTable = sqlite.prepare(\"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = '__drizzle_migrations'\").get();\n // A new database has nothing to lose.\n if (!hasTable) return undefined;\n const last = sqlite.prepare(\"SELECT created_at FROM __drizzle_migrations ORDER BY created_at DESC LIMIT 1\").get() as { created_at: number | string } | undefined;\n if (!last) return undefined;\n const lastApplied = Number(last.created_at);\n const known = readMigrationFiles({ migrationsFolder });\n const newestKnown = Math.max(0, ...known.map((m) => m.folderMillis));\n if (lastApplied > newestKnown) throw new NewerDatabaseError(path);\n if (!known.some((m) => m.folderMillis > lastApplied)) return undefined;\n\n // Private from the start: the folder is 0700, so a copy is never readable by other users, even before its chmod.\n const dir = join(dirname(path), \"backups\");\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n chmodSync(dir, 0o700);\n const name = basename(path, \".db\");\n const target = join(dir, `${name}-${clock().toISOString().replace(/[:.]/g, \"-\")}.db`);\n // VACUUM INTO writes a consistent copy, WAL included, in one statement. If it fails, nothing is migrated.\n sqlite.prepare(\"VACUUM INTO ?\").run(target);\n chmodSync(target, 0o600);\n\n // Only Mivra's own backups (exactly its timestamped names) are ever deleted, never the one just made, and never a\n // copy the learner put here. Names sort by time.\n const generated = new RegExp(`^${name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}-\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}-\\\\d{2}-\\\\d{2}-\\\\d{3}Z\\\\.db$`);\n const older = readdirSync(dir).filter((f) => generated.test(f) && f !== basename(target)).sort();\n for (const old of older.slice(0, Math.max(0, older.length - (KEEP_BACKUPS - 1)))) rmSync(join(dir, old), { force: true });\n return target;\n}\n\nexport interface OpenDbOptions {\n /** Where the migrations are; a bundled build (the `@okhay-p/mivra` package) passes where it ships them. */\n migrationsFolder?: string;\n /** Told the backup's path when one is made before migrating. */\n onBackup?: (path: string) => void;\n clock?: () => Date;\n}\n\n/**\n * Opens (or creates) the SQLite database and applies pending migrations, backing it up first when it holds data\n * (ADR-013). Pass \":memory:\" for tests.\n */\nexport function openDb(path: string, { migrationsFolder = defaultMigrations, onBackup, clock = () => new Date() }: OpenDbOptions = {}) {\n if (path !== \":memory:\") mkdirSync(dirname(path), { recursive: true });\n const sqlite = new Database(path);\n try {\n sqlite.pragma(\"journal_mode = WAL\");\n sqlite.pragma(\"foreign_keys = ON\");\n if (path !== \":memory:\") {\n const backup = backupBeforeMigrating(sqlite, path, migrationsFolder, clock);\n if (backup) onBackup?.(backup);\n }\n const db = drizzle(sqlite, { schema });\n migrate(db, { migrationsFolder });\n return db;\n } catch (error) {\n sqlite.close();\n throw error;\n }\n}\n\nexport type Db = ReturnType<typeof openDb>;\n", "import { sql } from \"drizzle-orm\";\nimport { index, integer, primaryKey, real, sqliteTable, text, uniqueIndex } from \"drizzle-orm/sqlite-core\";\n\nexport const sessions = sqliteTable(\"sessions\", {\n id: text(\"id\").primaryKey(),\n title: text(\"title\").notNull(),\n /** The learner renamed it, so automatic titling (a first message, the tutor's course title) leaves it alone. */\n titleSetByLearner: integer(\"title_set_by_learner\", { mode: \"boolean\" }).notNull().default(false),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" }).notNull(),\n});\n\n/**\n * One row per AI SDK UIMessage; `parts` holds the message parts as JSON.\n * `seq` is the message's position within its session and defines conversation order.\n */\nexport const messages = sqliteTable(\n \"messages\",\n {\n id: text(\"id\").primaryKey(),\n sessionId: text(\"session_id\")\n .notNull()\n .references(() => sessions.id, { onDelete: \"cascade\" }),\n seq: integer(\"seq\").notNull(),\n role: text(\"role\", { enum: [\"system\", \"user\", \"assistant\"] }).notNull(),\n parts: text(\"parts\", { mode: \"json\" }).notNull(),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [uniqueIndex(\"messages_session_seq_idx\").on(t.sessionId, t.seq)],\n);\n\nexport const runStatuses = [\"running\", \"completed\", \"cancelled\", \"failed\"] as const;\nexport type RunStatus = (typeof runStatuses)[number];\n\n/**\n * One row per model generation. A session has at most one running run at a time,\n * enforced by the partial unique index. Cancelled runs may save display-only partial text.\n */\nexport const runs = sqliteTable(\n \"runs\",\n {\n id: text(\"id\").primaryKey(),\n sessionId: text(\"session_id\")\n .notNull()\n .references(() => sessions.id, { onDelete: \"cascade\" }),\n userMessageId: text(\"user_message_id\")\n .notNull()\n .references(() => messages.id, { onDelete: \"cascade\" }),\n /** A unique claim on the quiz reply this automatic run continues. No synthetic user message. */\n continuationOf: text(\"continuation_of\"),\n assistantMessageId: text(\"assistant_message_id\").references(() => messages.id, { onDelete: \"set null\" }),\n status: text(\"status\", { enum: runStatuses }).notNull(),\n /** The model that ran, as \"<provider>:<model-id>\" (ADR-012). Null for runs before it was recorded. */\n model: text(\"model\"),\n /** The reasoning effort it ran with; null leaves it to the model's default. */\n effort: text(\"effort\"),\n /**\n * For a custom provider's model (issue #69), a fingerprint of the endpoint it ran against, so private\n * reasoning metadata never replays to a different destination under the same model id. Null otherwise.\n */\n endpoint: text(\"endpoint\"),\n error: text(\"error\"),\n startedAt: integer(\"started_at\", { mode: \"timestamp_ms\" }).notNull(),\n endedAt: integer(\"ended_at\", { mode: \"timestamp_ms\" }),\n },\n (t) => [\n uniqueIndex(\"runs_continuation_once_idx\").on(t.continuationOf),\n index(\"runs_session_idx\").on(t.sessionId, t.startedAt),\n uniqueIndex(\"runs_one_running_per_session_idx\")\n .on(t.sessionId)\n .where(sql`${t.status} = 'running'`),\n ],\n);\n\n/**\n * A learning artifact produced by an agent tool call (ADR-006). `spec` is the full, validated tool\n * input, including private fields such as a check's answer key; clients only ever see a view of it.\n */\nexport const artifacts = sqliteTable(\n \"artifacts\",\n {\n id: text(\"id\").primaryKey(),\n sessionId: text(\"session_id\")\n .notNull()\n .references(() => sessions.id, { onDelete: \"cascade\" }),\n runId: text(\"run_id\")\n .notNull()\n .references(() => runs.id, { onDelete: \"cascade\" }),\n toolCallId: text(\"tool_call_id\").notNull(),\n kind: text(\"kind\").notNull(),\n version: integer(\"version\").notNull(),\n spec: text(\"spec\", { mode: \"json\" }).notNull(),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [index(\"artifacts_session_idx\").on(t.sessionId, t.createdAt), uniqueIndex(\"artifacts_tool_call_idx\").on(t.runId, t.toolCallId)],\n);\n\n/**\n * A learner's graded answer to a check artifact. One attempt per artifact (the grade reveals the\n * answer). `concept` and `correct` double as the first progress evidence (ADR-006).\n */\nexport const attempts = sqliteTable(\n \"attempts\",\n {\n id: text(\"id\").primaryKey(),\n artifactId: text(\"artifact_id\")\n .notNull()\n .references(() => artifacts.id, { onDelete: \"cascade\" }),\n sessionId: text(\"session_id\")\n .notNull()\n .references(() => sessions.id, { onDelete: \"cascade\" }),\n answer: text(\"answer\", { mode: \"json\" }).notNull(),\n grade: text(\"grade\", { mode: \"json\" }).notNull(),\n correct: integer(\"correct\", { mode: \"boolean\" }).notNull(),\n concept: text(\"concept\"),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [uniqueIndex(\"attempts_one_per_artifact_idx\").on(t.artifactId), index(\"attempts_session_idx\").on(t.sessionId, t.createdAt), index(\"attempts_created_idx\").on(t.createdAt)],\n);\n\nexport const memoryStatuses = [\"pending\", \"active\", \"superseded\"] as const;\n\n/** The model's inferences about the learner (ADR-009). Pending until the reply that wrote them completes. */\nexport const memories = sqliteTable(\n \"memories\",\n {\n id: text(\"id\").primaryKey(),\n kind: text(\"kind\", { enum: [\"goal\", \"preference\", \"misconception\", \"known\"] }).notNull(),\n text: text(\"text\").notNull(),\n concept: text(\"concept\"),\n basis: text(\"basis\", { enum: [\"wrong_answer\", \"chat\", \"import\"] }).notNull(),\n attemptId: text(\"attempt_id\").references(() => attempts.id, { onDelete: \"set null\" }),\n sessionId: text(\"session_id\").references(() => sessions.id, { onDelete: \"set null\" }),\n runId: text(\"run_id\").references(() => runs.id, { onDelete: \"set null\" }),\n status: text(\"status\", { enum: memoryStatuses }).notNull(),\n /** The memory this one corrects, kept until this one is deleted. */\n replacesId: text(\"replaces_id\"),\n /** For basis `import`, the imported note it was drawn from (ADR-014): deleting the note deletes the memory. */\n noteId: text(\"note_id\").references(() => notes.id, { onDelete: \"cascade\" }),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n editedAt: integer(\"edited_at\", { mode: \"timestamp_ms\" }),\n },\n (t) => [index(\"memories_status_idx\").on(t.status, t.createdAt), index(\"memories_run_idx\").on(t.runId), index(\"memories_note_idx\").on(t.noteId)],\n);\n\nexport const documentKinds = [\"pdf\", \"pptx\"] as const;\n\n/**\n * A file the learner attached to a session (ADR-010). Only its extracted text is kept, never the file.\n * Extraction finishes before the row is written, so `status` is always \"ready\" for now.\n */\nexport const documents = sqliteTable(\n \"documents\",\n {\n id: text(\"id\").primaryKey(),\n sessionId: text(\"session_id\")\n .notNull()\n .references(() => sessions.id, { onDelete: \"cascade\" }),\n messageId: text(\"message_id\").references(() => messages.id, { onDelete: \"set null\" }),\n filename: text(\"filename\").notNull(),\n kind: text(\"kind\", { enum: documentKinds }).notNull(),\n byteSize: integer(\"byte_size\").notNull(),\n textChars: integer(\"text_chars\").notNull(),\n pageCount: integer(\"page_count\").notNull(),\n pagesWithText: integer(\"pages_with_text\").notNull(),\n status: text(\"status\", { enum: [\"ready\"] }).notNull(),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [index(\"documents_session_idx\").on(t.sessionId, t.createdAt)],\n);\n\n/**\n * A piece of a document's text; `page` is its page or slide number and `seq` its position in the document.\n * The migration adds the document_chunks_fts FTS5 table, which triggers keep in sync with this one and\n * which relies on `id` being a stable rowid. Drizzle doesn't model it, so SessionStore queries it in SQL.\n */\nexport const documentChunks = sqliteTable(\n \"document_chunks\",\n {\n id: integer(\"id\").primaryKey({ autoIncrement: true }),\n documentId: text(\"document_id\")\n .notNull()\n .references(() => documents.id, { onDelete: \"cascade\" }),\n page: integer(\"page\").notNull(),\n seq: integer(\"seq\").notNull(),\n text: text(\"text\").notNull(),\n },\n (t) => [uniqueIndex(\"document_chunks_document_seq_idx\").on(t.documentId, t.seq)],\n);\n\nexport const courseStatuses = [\"interviewing\", \"active\", \"complete\"] as const;\n\n/**\n * A course (ADR-011): one learning goal, taught in its own chat session. It starts with a placement\n * interview and becomes active once the AI has written its syllabus.\n */\nexport const courses = sqliteTable(\n \"courses\",\n {\n id: text(\"id\").primaryKey(),\n sessionId: text(\"session_id\")\n .notNull()\n .references(() => sessions.id, { onDelete: \"cascade\" }),\n goal: text(\"goal\").notNull(),\n status: text(\"status\", { enum: courseStatuses }).notNull(),\n /** The subject icon's Lucide name, from protocol's `courseIcons`, chosen by the tutor with the first syllabus; null until then. */\n icon: text(\"icon\"),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [uniqueIndex(\"courses_session_idx\").on(t.sessionId)],\n);\n\n/**\n * One immutable version of a course's syllabus. `topics` is the ordered list of topics, each with a\n * server-assigned id that stays the same across versions, so lessons can refer to their topic.\n * `known` is what the AI said the learner already knows, labelled by source.\n */\nexport const syllabusVersions = sqliteTable(\n \"syllabus_versions\",\n {\n id: text(\"id\").primaryKey(),\n courseId: text(\"course_id\")\n .notNull()\n .references(() => courses.id, { onDelete: \"cascade\" }),\n version: integer(\"version\").notNull(),\n topics: text(\"topics\", { mode: \"json\" }).notNull(),\n known: text(\"known\", { mode: \"json\" }).notNull(),\n /** Who made this version: the interview, the tutor on request (Change), or adaptive generation (ADR-011). */\n source: text(\"source\", { enum: [\"interview\", \"tutor\", \"adaptive\", \"undo\"] }).notNull().default(\"interview\"),\n /** For an adaptive change, the finished lesson whose results prompted it: at most one change per lesson. */\n triggerLessonId: text(\"trigger_lesson_id\"),\n /** Why it changed, shown to the learner. Null for the first version. */\n reason: text(\"reason\"),\n /** Ids of the topics this version added or changed, for highlighting. */\n changedTopicIds: text(\"changed_topic_ids\", { mode: \"json\" }).notNull().default(sql`'[]'`),\n runId: text(\"run_id\").references(() => runs.id, { onDelete: \"set null\" }),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [uniqueIndex(\"syllabus_versions_course_version_idx\").on(t.courseId, t.version)],\n);\n\nexport const lessonStatuses = [\"generating\", \"ready\", \"failed\", \"finished\"] as const;\n/** What the learner can do about a failed lesson, when it's more than retrying: fix the lesson model's override (issue #71). */\nexport const lessonErrorActions = [\"lesson-model\"] as const;\n\n/**\n * One lesson per syllabus topic (ADR-011). Generation runs in the lesson's own hidden session, so its\n * artifacts, attempts and model transcript use the existing tables. A finished lesson is frozen.\n */\nexport const lessons = sqliteTable(\n \"lessons\",\n {\n id: text(\"id\").primaryKey(),\n courseId: text(\"course_id\")\n .notNull()\n .references(() => courses.id, { onDelete: \"cascade\" }),\n topicId: text(\"topic_id\").notNull(),\n topicTitle: text(\"topic_title\").notNull(),\n /** The topic's position in the syllabus when the lesson started. */\n position: integer(\"position\").notNull(),\n sessionId: text(\"session_id\")\n .notNull()\n .references(() => sessions.id, { onDelete: \"cascade\" }),\n status: text(\"status\", { enum: lessonStatuses }).notNull(),\n error: text(\"error\"),\n /** Set with `error` when that message is Mivra's own and names a fix; the lesson then shows it. */\n errorAction: text(\"error_action\", { enum: lessonErrorActions }),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n finishedAt: integer(\"finished_at\", { mode: \"timestamp_ms\" }),\n },\n (t) => [uniqueIndex(\"lessons_course_topic_idx\").on(t.courseId, t.topicId), uniqueIndex(\"lessons_session_idx\").on(t.sessionId)],\n);\n\n/** An immutable lesson section: prose, or a reference to an artifact. Versions list sections by id. */\nexport const lessonSections = sqliteTable(\n \"lesson_sections\",\n {\n id: text(\"id\").primaryKey(),\n lessonId: text(\"lesson_id\")\n .notNull()\n .references(() => lessons.id, { onDelete: \"cascade\" }),\n kind: text(\"kind\", { enum: [\"prose\", \"artifact\"] }).notNull(),\n title: text(\"title\").notNull(),\n markdown: text(\"markdown\"),\n artifactId: text(\"artifact_id\").references(() => artifacts.id, { onDelete: \"cascade\" }),\n /** Sections of the previous lesson this one revisits, by id, so the page can link back to them. */\n revisits: text(\"revisits\", { mode: \"json\" }).notNull().default(sql`'[]'`),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [index(\"lesson_sections_lesson_idx\").on(t.lessonId), uniqueIndex(\"lesson_sections_artifact_idx\").on(t.artifactId)],\n);\n\n/**\n * A version of a lesson: its outline and the ordered ids of its sections. Version 1 grows while it is\n * generated; later versions (Change, ADR-011) are new rows, so attempts stay with what the learner saw.\n */\nexport const lessonVersions = sqliteTable(\n \"lesson_versions\",\n {\n id: text(\"id\").primaryKey(),\n lessonId: text(\"lesson_id\")\n .notNull()\n .references(() => lessons.id, { onDelete: \"cascade\" }),\n version: integer(\"version\").notNull(),\n outline: text(\"outline\", { mode: \"json\" }).notNull(),\n sectionIds: text(\"section_ids\", { mode: \"json\" }).notNull(),\n /** Ids of the sections this version added or changed, for highlighting. Empty for version 1. */\n changedSectionIds: text(\"changed_section_ids\", { mode: \"json\" }).notNull().default(sql`'[]'`),\n /** Why the tutor changed it. Null for version 1. */\n reason: text(\"reason\"),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [uniqueIndex(\"lesson_versions_lesson_version_idx\").on(t.lessonId, t.version)],\n);\n\n/** App-wide settings as JSON values by key, such as the current model selection (ADR-012). */\nexport const settings = sqliteTable(\"settings\", {\n key: text(\"key\").primaryKey(),\n value: text(\"value\", { mode: \"json\" }).notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" }).notNull(),\n});\n\n/** One imported Obsidian vault (ADR-014). Importing again replaces its notes with the new snapshot. */\nexport const vaultImports = sqliteTable(\n \"vault_imports\",\n {\n id: text(\"id\").primaryKey(),\n name: text(\"name\").notNull(),\n source: text(\"source\", { enum: [\"obsidian\"] }).notNull(),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [uniqueIndex(\"vault_imports_name_idx\").on(t.name)],\n);\n\n/**\n * A Markdown note from an imported vault, written only by the import (ADR-014). `hash` is the SHA-256 of its text,\n * so a re-import skips unchanged files. `titleKey` and `aliases` (already normalised) resolve `[[links]]`.\n */\nexport const notes = sqliteTable(\n \"notes\",\n {\n id: text(\"id\").primaryKey(),\n importId: text(\"import_id\")\n .notNull()\n .references(() => vaultImports.id, { onDelete: \"cascade\" }),\n path: text(\"path\").notNull(),\n title: text(\"title\").notNull(),\n titleKey: text(\"title_key\").notNull(),\n aliases: text(\"aliases\", { mode: \"json\" }).$type<string[]>().notNull(),\n body: text(\"body\").notNull(),\n hash: text(\"hash\").notNull(),\n /** The hash this note had when it was last distilled, or null if it never was. Differing from `hash` means it's waiting. */\n distilledHash: text(\"distilled_hash\"),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n updatedAt: integer(\"updated_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [uniqueIndex(\"notes_import_path_idx\").on(t.importId, t.path), index(\"notes_import_title_idx\").on(t.importId, t.titleKey)],\n);\n\n/**\n * A piece of a note's text under its heading path (`Heading > Subheading`). The migration adds the note_chunks_fts\n * FTS5 table, kept in sync by triggers, which relies on `id` being a stable rowid, as for document chunks.\n */\nexport const noteChunks = sqliteTable(\n \"note_chunks\",\n {\n id: integer(\"id\").primaryKey({ autoIncrement: true }),\n noteId: text(\"note_id\")\n .notNull()\n .references(() => notes.id, { onDelete: \"cascade\" }),\n seq: integer(\"seq\").notNull(),\n heading: text(\"heading\"),\n text: text(\"text\").notNull(),\n },\n (t) => [uniqueIndex(\"note_chunks_note_seq_idx\").on(t.noteId, t.seq)],\n);\n\n/** A `[[link]]` or `![[embed]]` as written, without its heading or display text. Resolved to a note when read. */\nexport const noteLinks = sqliteTable(\n \"note_links\",\n {\n noteId: text(\"note_id\")\n .notNull()\n .references(() => notes.id, { onDelete: \"cascade\" }),\n target: text(\"target\").notNull(),\n kind: text(\"kind\", { enum: [\"link\", \"embed\"] }).notNull(),\n },\n (t) => [primaryKey({ columns: [t.noteId, t.target, t.kind] })],\n);\n\n/** A tag from a note's text or frontmatter, lower-cased and without its `#`. */\nexport const noteTags = sqliteTable(\n \"note_tags\",\n {\n noteId: text(\"note_id\")\n .notNull()\n .references(() => notes.id, { onDelete: \"cascade\" }),\n tag: text(\"tag\").notNull(),\n },\n (t) => [primaryKey({ columns: [t.noteId, t.tag] }), index(\"note_tags_tag_idx\").on(t.tag)],\n);\n\nexport const usageKinds = [\"chat\", \"continuation\", \"lesson\", \"distillation\", \"test\"] as const;\nexport const usageStatuses = [\"completed\", \"failed\", \"cancelled\"] as const;\nexport const usageBillings = [\"api\", \"subscription\"] as const;\n\n/**\n * One model call's accounting (issue #70): a provider call, so a tutor run with several tool-call steps has one row\n * per step. Content-free by design: no prompt, reply, error text or credential, only what the Usage page needs.\n * `session_id` and `run_id` are plain ids with no foreign key, so deleting a chat keeps its rows and totals; labels\n * are snapshots, so a renamed or removed provider stays readable. A null token count was not reported (unknown),\n * never zero. `price` is the per-million-token price known when the call ended, kept so later price changes never\n * rewrite history; `estimated_cost` was computed from it then. For a subscription call that estimate is only an\n * API-price comparison, never a charge.\n */\nexport const usageRecords = sqliteTable(\n \"usage_records\",\n {\n id: text(\"id\").primaryKey(),\n kind: text(\"kind\", { enum: usageKinds }).notNull(),\n status: text(\"status\", { enum: usageStatuses }).notNull(),\n sessionId: text(\"session_id\"),\n runId: text(\"run_id\"),\n /** The call's position within its run (or test), from 0. Each tool-call step, and each retry, is its own call. */\n seq: integer(\"seq\").notNull(),\n /** \"openrouter\", \"anthropic\", \"openai\", \"chatgpt\" or \"custom:<provider id>\". */\n provider: text(\"provider\").notNull(),\n providerLabel: text(\"provider_label\").notNull(),\n model: text(\"model\").notNull(),\n modelLabel: text(\"model_label\"),\n effort: text(\"effort\"),\n billing: text(\"billing\", { enum: usageBillings }).notNull(),\n /** All input tokens, cached ones included. */\n inputTokens: integer(\"input_tokens\"),\n inputNoCacheTokens: integer(\"input_no_cache_tokens\"),\n inputCacheReadTokens: integer(\"input_cache_read_tokens\"),\n inputCacheWriteTokens: integer(\"input_cache_write_tokens\"),\n /** All output tokens, reasoning included. */\n outputTokens: integer(\"output_tokens\"),\n outputReasoningTokens: integer(\"output_reasoning_tokens\"),\n /** US dollars the provider reported for this call (OpenRouter does). */\n reportedCost: real(\"reported_cost\"),\n price: text(\"price\", { mode: \"json\" }),\n /** US dollars at `price`, or null when the price or a needed token count is unknown. */\n estimatedCost: real(\"estimated_cost\"),\n startedAt: integer(\"started_at\", { mode: \"timestamp_ms\" }).notNull(),\n endedAt: integer(\"ended_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [index(\"usage_records_started_idx\").on(t.startedAt), index(\"usage_records_run_idx\").on(t.runId)],\n);\n\n/**\n * A node of the knowledge graph (ADR-014), drawn from imported notes. `key` is the name's `conceptKey` (ADR-009), so\n * one concept has one node however its name is written. A concept lives as long as at least one note supports it.\n */\nexport const concepts = sqliteTable(\n \"concepts\",\n {\n id: text(\"id\").primaryKey(),\n key: text(\"key\").notNull(),\n name: text(\"name\").notNull(),\n createdAt: integer(\"created_at\", { mode: \"timestamp_ms\" }).notNull(),\n },\n (t) => [uniqueIndex(\"concepts_key_idx\").on(t.key)],\n);\n\n/** Which notes a concept was drawn from. */\nexport const conceptSources = sqliteTable(\n \"concept_sources\",\n {\n conceptId: text(\"concept_id\")\n .notNull()\n .references(() => concepts.id, { onDelete: \"cascade\" }),\n noteId: text(\"note_id\")\n .notNull()\n .references(() => notes.id, { onDelete: \"cascade\" }),\n },\n (t) => [primaryKey({ columns: [t.conceptId, t.noteId] }), index(\"concept_sources_note_idx\").on(t.noteId)],\n);\n\nexport const conceptEdgeKinds = [\"prerequisite\", \"related\"] as const;\n\n/**\n * An edge between two concepts, one row per note that supports it. `prerequisite` reads \"from is a prerequisite of\n * to\"; a `related` edge is stored once, with the smaller id as `from`.\n */\nexport const conceptEdges = sqliteTable(\n \"concept_edges\",\n {\n fromId: text(\"from_id\")\n .notNull()\n .references(() => concepts.id, { onDelete: \"cascade\" }),\n toId: text(\"to_id\")\n .notNull()\n .references(() => concepts.id, { onDelete: \"cascade\" }),\n kind: text(\"kind\", { enum: conceptEdgeKinds }).notNull(),\n noteId: text(\"note_id\")\n .notNull()\n .references(() => notes.id, { onDelete: \"cascade\" }),\n },\n (t) => [primaryKey({ columns: [t.fromId, t.toId, t.kind, t.noteId] }), index(\"concept_edges_note_idx\").on(t.noteId), index(\"concept_edges_to_idx\").on(t.toId)],\n);\n\n/**\n * Every note that supports a memory drawn from notes, its own `note_id` among them, with the text that note gave.\n * Repeats aren't saved twice (one `known` memory per concept per import), so a memory can stand on several notes; it\n * moves to another when its note goes, taking that note's text unless the learner edited it, and goes only with the\n * last.\n */\nexport const memorySources = sqliteTable(\n \"memory_sources\",\n {\n memoryId: text(\"memory_id\")\n .notNull()\n .references(() => memories.id, { onDelete: \"cascade\" }),\n noteId: text(\"note_id\")\n .notNull()\n .references(() => notes.id, { onDelete: \"cascade\" }),\n /** What this note said, as the model put it: the memory's text if it moves to this note. */\n text: text(\"text\").notNull(),\n },\n (t) => [primaryKey({ columns: [t.memoryId, t.noteId] }), index(\"memory_sources_note_idx\").on(t.noteId)],\n);\n"],
5
+ "mappings": ";;;;;AAAA,SAAS,WAAW,WAAW,aAAa,cAAc;AAC1D,SAAS,UAAU,SAAS,YAAY;AACxC,SAAS,qBAAqB;AAC9B,OAAO,cAAc;AACrB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,0BAA0B;;;ACNnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AK,GAAG,GAAG,EAAE,OAAO,KAAK,CAAC;AACxH,SAAO;AACT;AAcO,SAAS,OAAO,MAAc,EAAE,mBAAmB,mBAAmB,UAAU,QAAQ,MAAM,oBAAI,KAAK,EAAE,IAAmB,CAAC,GAAG;AACrI,MAAI,SAAS,WAAY,WAAU,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AACrE,QAAM,SAAS,IAAI,SAAS,IAAI;AAChC,MAAI;AACF,WAAO,OAAO,oBAAoB;AAClC,WAAO,OAAO,mBAAmB;AACjC,QAAI,SAAS,YAAY;AACvB,YAAM,SAAS,sBAAsB,QAAQ,MAAM,kBAAkB,KAAK;AAC1E,UAAI,OAAQ,YAAW,MAAM;AAAA,IAC/B;AACA,UAAM,KAAK,QAAQ,QAAQ,EAAE,uBAAO,CAAC;AACrC,YAAQ,IAAI,EAAE,iBAAiB,CAAC;AAChC,WAAO;AAAA,EACT,SAAS,OAAO;AACd,WAAO,MAAM;AACb,UAAM;AAAA,EACR;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export {
8
+ __export
9
+ };
10
+ //# sourceMappingURL=chunk-PZ5AY32C.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }