@okhay-p/mivra 0.1.3 → 0.1.5
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.
- package/README.md +1 -0
- package/dist/{chunk-3RMHLZ2Z.js → chunk-KUKQU7EQ.js} +24 -5
- package/dist/{chunk-3RMHLZ2Z.js.map → chunk-KUKQU7EQ.js.map} +2 -2
- package/dist/{chunk-EICBRY5M.js → chunk-ODFBAPPH.js} +113 -5
- package/dist/chunk-ODFBAPPH.js.map +7 -0
- package/dist/{chunk-FBDML53R.js → chunk-YACRW47X.js} +447 -177
- package/dist/chunk-YACRW47X.js.map +7 -0
- package/dist/cli.js +109 -23
- package/dist/cli.js.map +4 -4
- package/dist/{client-VU3KWV3U.js → client-5YDLS4KV.js} +2 -2
- package/dist/extract-child.js +1 -1
- package/dist/{start-3J3JSJEX.js → start-2RXX57ZZ.js} +3535 -518
- package/dist/start-2RXX57ZZ.js.map +7 -0
- package/drizzle/0013_next_dormammu.sql +1 -0
- package/drizzle/0014_furry_inertia.sql +1 -0
- package/drizzle/0015_spotty_warstar.sql +1 -0
- package/drizzle/0016_fresh_wiccan.sql +1 -0
- package/drizzle/0017_amusing_james_howlett.sql +28 -0
- package/drizzle/0018_happy_hairball.sql +43 -0
- package/drizzle/meta/0013_snapshot.json +1749 -0
- package/drizzle/meta/0014_snapshot.json +1756 -0
- package/drizzle/meta/0015_snapshot.json +1763 -0
- package/drizzle/meta/0016_snapshot.json +1770 -0
- package/drizzle/meta/0017_snapshot.json +1956 -0
- package/drizzle/meta/0018_snapshot.json +2280 -0
- package/drizzle/meta/_journal.json +42 -0
- package/package.json +2 -1
- package/web/assets/index-DJ2D5ZXo.css +1 -0
- package/web/assets/index-DcYzUL1W.js +413 -0
- package/web/assets/notes-graph.worker-DaVQvftJ.js +1 -0
- package/web/assets/render.worker-BAfybD27.js +416 -0
- package/web/index.html +8 -3
- package/dist/chunk-EICBRY5M.js.map +0 -7
- package/dist/chunk-FBDML53R.js.map +0 -7
- package/dist/start-3J3JSJEX.js.map +0 -7
- package/web/assets/index-BUYWW1Mc.js +0 -406
- package/web/assets/index-Cmq-m9fI.css +0 -1
- package/web/assets/render.worker-BEpv9w1x.js +0 -413
- /package/dist/{client-VU3KWV3U.js.map → client-5YDLS4KV.js.map} +0 -0
package/web/index.html
CHANGED
|
@@ -15,10 +15,15 @@
|
|
|
15
15
|
document.documentElement.classList.toggle("dark", dark);
|
|
16
16
|
})();
|
|
17
17
|
</script>
|
|
18
|
-
<script type="module" crossorigin src="/assets/index-
|
|
19
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
18
|
+
<script type="module" crossorigin src="/assets/index-DcYzUL1W.js"></script>
|
|
19
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DJ2D5ZXo.css">
|
|
20
20
|
</head>
|
|
21
21
|
<body>
|
|
22
|
-
<div id="root"
|
|
22
|
+
<div id="root">
|
|
23
|
+
<!-- Shown until the app's script arrives, which takes a while on a slow connection; React replaces it. -->
|
|
24
|
+
<p role="status" style="display: grid; place-items: center; min-height: 100dvh; margin: 0; font-family: system-ui, sans-serif; color: var(--muted-foreground)">
|
|
25
|
+
Loading Mivra…
|
|
26
|
+
</p>
|
|
27
|
+
</div>
|
|
23
28
|
</body>
|
|
24
29
|
</html>
|
|
@@ -1,7 +0,0 @@
|
|
|
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, 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 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 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\"] }).notNull(),\n text: text(\"text\").notNull(),\n concept: text(\"concept\"),\n basis: text(\"basis\", { enum: [\"wrong_answer\", \"chat\"] }).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 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)],\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 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\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 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 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"],
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,WAAW;AACpB,SAAS,OAAO,SAAS,YAAY,aAAa,MAAM,mBAAmB;AAEpE,IAAM,WAAW,YAAY,YAAY;AAAA,EAC9C,IAAI,KAAK,IAAI,EAAE,WAAW;AAAA,EAC1B,OAAO,KAAK,OAAO,EAAE,QAAQ;AAAA,EAC7B,WAAW,QAAQ,cAAc,EAAE,MAAM,eAAe,CAAC,EAAE,QAAQ;AAAA,EACnE,WAAW,QAAQ,cAAc,EAAE,MAAM,eAAe,CAAC,EAAE,QAAQ;AACrE,CAAC;AAMM,IAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,IACE,IAAI,KAAK,IAAI,EAAE,WAAW;AAAA,IAC1B,WAAW,KAAK,YAAY,EACzB,QAAQ,EACR,WAAW,MAAM,SAAS,IAAI,EAAE,UAAU,UAAU,CAAC;AAAA,IACxD,KAAK,QAAQ,KAAK,EAAE,QAAQ;AAAA,IAC5B,MAAM,KAAK,QAAQ,EAAE,MAAM,CAA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ts", "../../protocol/src/lesson.ts", "../../protocol/src/memory.ts", "../../protocol/src/document.ts", "../../protocol/src/vault.ts", "../../protocol/src/index.ts", "../../protocol/src/artifact-math-input.ts", "../../protocol/src/math-text.ts", "../../protocol/src/algorithm-trace.ts", "../../protocol/src/graph.ts", "../../protocol/src/multiple-choice.ts", "../../protocol/src/set-diagram.ts", "../../protocol/src/table.ts", "../../protocol/src/worked-steps.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from \"zod\";\n\n/**\n * Courses (ADR-011): one learning goal, a placement interview, then a syllabus of ordered topics\n * written by the AI. The learner never approves the syllabus; they change it later through the tutor.\n */\n\nexport const MAX_GOAL_CHARS = 300;\nexport const CourseGoal = z.string().trim().min(1).max(MAX_GOAL_CHARS);\n\n/** Body of POST /courses. */\nexport const StartCourse = z.object({ goal: CourseGoal }).strict();\nexport type StartCourse = z.infer<typeof StartCourse>;\n\nconst ConceptName = z.string().trim().min(1).max(80);\n\n// ---------------------------------------------------------------------------------------------\n// placement_question v1: one interview question. Multiple choice, true/false or yes/no, and the\n// learner can always answer \"Not sure\" or skip it. No confidence rating (owner decision on #1).\n// ---------------------------------------------------------------------------------------------\n\nexport const PlacementQuestionSpec = z\n .object({\n concept: ConceptName.describe('The single concept this question probes, e.g. \"chain rule\". Reuse the exact name from the learner\\'s record when it is there.'),\n question: z.string().trim().min(1).max(1000),\n options: z\n .array(z.object({ text: z.string().trim().min(1).max(300) }).strict())\n .min(2)\n .max(5)\n .describe('2-5 options with distinct text. For true/false or yes/no use two options, e.g. \"True\" and \"False\". Never add a \"Not sure\" option: the UI always offers one.'),\n correctOptionIndex: z.number().int().nonnegative().describe(\"0-based index of the single correct option.\"),\n explanation: z.string().trim().min(1).max(600).describe(\"One or two sentences shown after answering: why the correct option is correct.\"),\n })\n .strict()\n .superRefine((spec, ctx) => {\n if (spec.correctOptionIndex >= spec.options.length) {\n ctx.addIssue({ code: \"custom\", path: [\"correctOptionIndex\"], message: \"correctOptionIndex must point at one of the options\" });\n }\n const seen = new Map<string, number>();\n spec.options.forEach((option, i) => {\n const key = option.text.normalize(\"NFC\");\n const first = seen.get(key);\n if (first !== undefined) ctx.addIssue({ code: \"custom\", path: [\"options\", i, \"text\"], message: `duplicates option ${first}` });\n else seen.set(key, i);\n if (/^\\s*(not sure|i don'?t know|unsure|skip)\\W*$/i.test(option.text)) {\n ctx.addIssue({ code: \"custom\", path: [\"options\", i, \"text\"], message: \"Leave out Not sure / Skip: the UI always offers them\" });\n }\n });\n });\nexport type PlacementQuestionSpec = z.infer<typeof PlacementQuestionSpec>;\n\n/** What the client sees before answering. */\nexport const PlacementQuestionPublic = z\n .object({ concept: z.string(), question: z.string(), options: z.array(z.object({ text: z.string() }).strict()) })\n .strict();\nexport type PlacementQuestionPublic = z.infer<typeof PlacementQuestionPublic>;\n\nexport const toPlacementQuestionPublic = (spec: PlacementQuestionSpec): PlacementQuestionPublic => ({\n concept: spec.concept,\n question: spec.question,\n options: spec.options.map((o) => ({ text: o.text })),\n});\n\nexport const PlacementAnswer = z.union([\n z.object({ optionIndex: z.number().int().nonnegative() }).strict(),\n z.object({ unsure: z.literal(true) }).strict(),\n z.object({ skipped: z.literal(true) }).strict(),\n]);\nexport type PlacementAnswer = z.infer<typeof PlacementAnswer>;\n\nexport const PlacementResult = z.enum([\"correct\", \"incorrect\", \"unsure\", \"skipped\"]);\nexport type PlacementResult = z.infer<typeof PlacementResult>;\n\nexport const PlacementGrade = z\n .object({ result: PlacementResult, correctOptionIndex: z.number().int().nonnegative(), explanation: z.string() })\n .strict();\nexport type PlacementGrade = z.infer<typeof PlacementGrade>;\n\n/** Deterministic grader. \"Not sure\" counts as not knowing it; a skip is no evidence either way. */\nexport function gradePlacementQuestion(spec: PlacementQuestionSpec, answer: PlacementAnswer): PlacementGrade {\n let result: PlacementResult;\n if (\"optionIndex\" in answer) {\n if (!spec.options[answer.optionIndex]) throw new RangeError(`optionIndex ${answer.optionIndex} is not one of the ${spec.options.length} options`);\n result = answer.optionIndex === spec.correctOptionIndex ? \"correct\" : \"incorrect\";\n } else result = \"unsure\" in answer ? \"unsure\" : \"skipped\";\n return { result, correctOptionIndex: spec.correctOptionIndex, explanation: spec.explanation };\n}\n\n// ---------------------------------------------------------------------------------------------\n// Syllabus\n// ---------------------------------------------------------------------------------------------\n\nexport const KnownSource = z.enum([\"memory\", \"test\", \"guess\"]);\nexport type KnownSource = z.infer<typeof KnownSource>;\n\nexport const SyllabusTopicInput = z\n .object({\n title: z.string().trim().min(1).max(120),\n summary: z.string().trim().min(1).max(400).describe(\"What the lesson on this topic will cover, in one or two sentences.\"),\n reason: z.string().trim().min(1).max(300).describe('Why this topic is here for this learner, e.g. \"You missed the question on local minima\".'),\n requestedByLearner: z.boolean().describe(\"True if the learner explicitly asked for this topic. Such topics are never removed automatically.\"),\n concepts: z.array(ConceptName).min(1).max(8).describe(\"Concept names this topic teaches; reuse names from the learner's record and the placement questions.\"),\n })\n .strict();\n\n/** Input of the write_syllabus tool. The server adds ids, version and timestamps. */\nexport const SyllabusInput = z\n .object({\n topics: z.array(SyllabusTopicInput).min(1).max(20).describe(\"The ordered topics, first to learn first. Each topic gets one lesson.\"),\n known: z\n .array(\n z\n .object({\n concept: ConceptName,\n source: KnownSource.describe(\"memory = from their record or memories; test = from this placement interview; guess = your inference\"),\n note: z.string().trim().min(1).max(200),\n })\n .strict(),\n )\n .max(20)\n .describe(\"What the learner already knows or doesn't, each labelled with where that comes from. Shown to the learner.\"),\n })\n .strict()\n .superRefine((input, ctx) => {\n const seen = new Set<string>();\n input.topics.forEach((topic, i) => {\n const key = topic.title.trim().toLowerCase();\n if (seen.has(key)) ctx.addIssue({ code: \"custom\", path: [\"topics\", i, \"title\"], message: \"Topic titles must be distinct\" });\n seen.add(key);\n });\n });\nexport type SyllabusInput = z.infer<typeof SyllabusInput>;\n\nexport const SyllabusTopic = SyllabusTopicInput.extend({ id: z.string() }).strict();\nexport type SyllabusTopic = z.infer<typeof SyllabusTopic>;\n\nexport const SyllabusView = z\n .object({\n version: z.number().int().positive(),\n source: z.enum([\"interview\", \"tutor\", \"adaptive\", \"undo\"]),\n reason: z.string().nullable(),\n changedTopicIds: z.array(z.string()),\n /** Whether the learner can undo this version: an automatic change none of whose new topics has started. */\n canUndo: z.boolean(),\n topics: z.array(SyllabusTopic),\n known: SyllabusInput.shape.known,\n createdAt: z.string().datetime(),\n })\n .strict();\nexport type SyllabusView = z.infer<typeof SyllabusView>;\n\nexport const CourseStatus = z.enum([\"interviewing\", \"active\", \"complete\"]);\nexport type CourseStatus = z.infer<typeof CourseStatus>;\n\nexport const CourseView = z\n .object({\n id: z.string(),\n sessionId: z.string(),\n goal: z.string(),\n status: CourseStatus,\n syllabus: SyllabusView.nullable(),\n /** The tutor's reply that wrote the first syllabus, which ends the placement interview; null if unknown. */\n interviewMessageId: z.string().nullable(),\n createdAt: z.string().datetime(),\n })\n .strict();\nexport type CourseView = z.infer<typeof CourseView>;\n", "import { z } from \"zod\";\n\n/**\n * Lessons (ADR-011): one per syllabus topic, generated when the learner reaches it. The outline comes\n * first, then one tool call per section, so each section validates on its own and appears as soon as it\n * is written. A finished lesson is frozen.\n */\n\n/** Section kinds the outline can plan: prose, or an existing artifact kind by its tool's purpose. */\nexport const LessonSectionKind = z.enum([\"prose\", \"algorithm_trace\", \"graph\", \"multiple_choice\", \"set_diagram\", \"table\", \"worked_steps\"]);\nexport type LessonSectionKind = z.infer<typeof LessonSectionKind>;\n\nexport const MAX_LESSON_SECTIONS = 10;\n\nexport const LessonOutlineInput = z\n .object({\n title: z.string().trim().min(1).max(120),\n sections: z\n .array(\n z\n .object({\n title: z.string().trim().min(1).max(120),\n kind: LessonSectionKind.describe(\"prose = write_lesson_text; multiple_choice = ask_multiple_choice (a check); the others = the matching show_* tool.\"),\n purpose: z.string().trim().min(1).max(300).describe(\"What this section does for the learner, in one sentence.\"),\n })\n .strict(),\n )\n .min(2)\n .max(MAX_LESSON_SECTIONS)\n .describe(`2-${MAX_LESSON_SECTIONS} sections in reading order. Include at least one multiple_choice check, usually after the idea it checks.`),\n })\n .strict()\n .superRefine((outline, ctx) => {\n if (!outline.sections.some((s) => s.kind === \"multiple_choice\")) {\n ctx.addIssue({ code: \"custom\", path: [\"sections\"], message: \"Include at least one multiple_choice check\" });\n }\n });\nexport type LessonOutlineInput = z.infer<typeof LessonOutlineInput>;\n\nexport const LessonTextInput = z\n .object({\n markdown: z.string().trim().min(1).max(6000).describe(\"The section's prose, as markdown with $...$ and $$...$$ maths. Don't repeat the section title as a heading.\"),\n revisits: z\n .array(z.string().min(1))\n .max(5)\n .optional()\n .describe(\"sectionIds from <previous_lesson> this section revisits. The page links back to them, so don't write links yourself.\"),\n })\n .strict();\nexport type LessonTextInput = z.infer<typeof LessonTextInput>;\n\nexport const LessonStatus = z.enum([\"generating\", \"ready\", \"failed\", \"finished\"]);\nexport type LessonStatus = z.infer<typeof LessonStatus>;\n\nexport const LessonOutlineView = z\n .object({\n title: z.string(),\n sections: z.array(z.object({ title: z.string(), kind: LessonSectionKind }).strict()),\n })\n .strict();\n\n/** A lesson as the client sees it. `artifact` holds an ArtifactView, validated by the client's renderer. */\nexport const LessonView = z\n .object({\n id: z.string(),\n courseId: z.string(),\n topicId: z.string(),\n topicTitle: z.string(),\n position: z.number().int().nonnegative(),\n status: LessonStatus,\n version: z.number().int().positive().nullable(),\n outline: LessonOutlineView.nullable(),\n sections: z.array(\n z.discriminatedUnion(\"kind\", [\n z\n .object({\n id: z.string(),\n title: z.string(),\n kind: z.literal(\"prose\"),\n markdown: z.string(),\n /** Earlier sections this one revisits, for links back to exactly what the learner saw. */\n revisits: z.array(z.object({ lessonId: z.string(), sectionId: z.string(), title: z.string(), lessonTitle: z.string() }).strict()),\n })\n .strict(),\n z.object({ id: z.string(), title: z.string(), kind: z.literal(\"artifact\"), artifact: z.unknown() }).strict(),\n ]),\n ),\n checks: z.object({ total: z.number().int().nonnegative(), answered: z.number().int().nonnegative() }).strict(),\n /** The course's current syllabus version, so a page can notice a change made while it was open. */\n syllabusVersion: z.number().int().positive().nullable(),\n /** Sections the latest version added or changed, highlighted for the learner, and why. */\n changedSectionIds: z.array(z.string()),\n changeReason: z.string().nullable(),\n /** Whether the learner can finish it now: fully written and every check answered. */\n canFinish: z.boolean(),\n error: z.string().nullable(),\n createdAt: z.string().datetime(),\n finishedAt: z.string().datetime().nullable(),\n })\n .strict();\nexport type LessonView = z.infer<typeof LessonView>;\n\n/** One row per syllabus topic, in syllabus order, with its lesson if one exists. */\nexport const CourseLessonsView = z\n .object({\n topics: z.array(\n z\n .object({\n topicId: z.string(),\n title: z.string(),\n lesson: z.object({ id: z.string(), status: LessonStatus }).strict().nullable(),\n })\n .strict(),\n ),\n /** The lesson to show: the first unfinished one, or the last one once all are finished. */\n currentLessonId: z.string().nullable(),\n /** The next topic without a lesson, if the learner may start it now. */\n nextTopicId: z.string().nullable(),\n })\n .strict();\nexport type CourseLessonsView = z.infer<typeof CourseLessonsView>;\n\nconst SectionTitle = z.string().trim().min(1).max(120);\nconst SectionMarkdown = z.string().trim().min(1).max(6000);\nconst Reason = z.string().trim().min(1).max(300);\n\n/**\n * Input of change_lesson: the tutor's edit of the current lesson, on the learner's request (ADR-011).\n * One call makes one new version; the sections it adds or rewrites are highlighted.\n */\nexport const ChangeLessonInput = z\n .object({\n reason: Reason.describe('What the learner asked for, in a few words, e.g. \"Simpler intro with an example\".'),\n operations: z\n .array(\n z.discriminatedUnion(\"op\", [\n z.object({ op: z.literal(\"rewrite\"), sectionId: z.string().min(1), markdown: SectionMarkdown, title: SectionTitle.optional() }).strict()\n .describe(\"Replace a prose section's text (and optionally its title).\"),\n z.object({ op: z.literal(\"insert\"), afterSectionId: z.string().min(1).nullable(), title: SectionTitle, markdown: SectionMarkdown }).strict()\n .describe(\"Add a prose section after the given section, or first if null.\"),\n z.object({ op: z.literal(\"insert_artifact\"), afterSectionId: z.string().min(1).nullable(), title: SectionTitle, artifactId: z.string().min(1) }).strict()\n .describe(\"Add a card you created earlier in this reply (its artifactId) as a section.\"),\n z.object({ op: z.literal(\"remove\"), sectionId: z.string().min(1) }).strict(),\n z.object({ op: z.literal(\"move\"), sectionId: z.string().min(1), afterSectionId: z.string().min(1).nullable() }).strict(),\n ]),\n )\n .min(1)\n .max(10),\n })\n .strict();\nexport type ChangeLessonInput = z.infer<typeof ChangeLessonInput>;\n\n/** Input of change_syllabus: the tutor's edit of the course's future topics, on the learner's request. */\nexport const ChangeSyllabusInput = z\n .object({\n reason: Reason.describe('What the learner asked for, e.g. \"Add a topic on vectors before gradients\".'),\n operations: z\n .array(\n z.discriminatedUnion(\"op\", [\n z\n .object({\n op: z.literal(\"insert\"),\n afterTopicId: z.string().min(1).nullable().describe(\"Insert after this topic; null to insert before the first future topic.\"),\n title: SectionTitle,\n summary: z.string().trim().min(1).max(400),\n reason: Reason,\n concepts: z.array(z.string().trim().min(1).max(80)).min(1).max(8),\n })\n .strict(),\n z.object({ op: z.literal(\"edit\"), topicId: z.string().min(1), title: SectionTitle.optional(), summary: z.string().trim().min(1).max(400).optional() }).strict(),\n z.object({ op: z.literal(\"remove\"), topicId: z.string().min(1) }).strict(),\n z.object({ op: z.literal(\"move\"), topicId: z.string().min(1), afterTopicId: z.string().min(1).nullable() }).strict(),\n ]),\n )\n .min(1)\n .max(10),\n })\n .strict();\nexport type ChangeSyllabusInput = z.infer<typeof ChangeSyllabusInput>;\n\n/** Body of POST /lessons/{id}/sections: keep a tutor's Explain answer as a new section. */\nexport const AddToLesson = z\n .object({\n messageId: z.string().min(1).max(128),\n afterSectionId: z.string().min(1).max(128).nullable(),\n title: SectionTitle,\n })\n .strict();\nexport type AddToLesson = z.infer<typeof AddToLesson>;\n\nconst NewTopic = z\n .object({\n title: SectionTitle,\n summary: z.string().trim().min(1).max(400),\n concepts: z.array(z.string().trim().min(1).max(80)).min(1).max(8),\n })\n .strict();\n\n/**\n * Input of adapt_syllabus: lesson generation's own change to future topics when the learner struggled\n * (ADR-011). Insert, split or reorder only; never removes a topic. At most one per finished lesson.\n */\nexport const AdaptSyllabusInput = z\n .object({\n reason: Reason.describe('Shown to the learner, with the evidence, e.g. \"Added a chain rule refresher: you missed 3 of 4 checks on derivatives\".'),\n operation: z.discriminatedUnion(\"op\", [\n NewTopic.extend({ op: z.literal(\"insert\"), afterTopicId: z.string().min(1).nullable().describe(\"null = straight after this lesson's topic\") }).strict(),\n z.object({ op: z.literal(\"split\"), topicId: z.string().min(1), into: z.array(NewTopic).min(2).max(3) }).strict(),\n z.object({ op: z.literal(\"move\"), topicId: z.string().min(1), afterTopicId: z.string().min(1).nullable() }).strict(),\n ]),\n })\n .strict();\nexport type AdaptSyllabusInput = z.infer<typeof AdaptSyllabusInput>;\n", "import { z } from \"zod\";\n\n/** Memory entries are the model's inferences about the learner, kept apart from graded evidence (ADR-009). */\n\nexport const MemoryKind = z.enum([\"goal\", \"preference\", \"misconception\"]);\nexport type MemoryKind = z.infer<typeof MemoryKind>;\n\nconst MemoryText = z.string().trim().min(1).max(300);\n\n/** The input of the remember tool. Source, timestamps and basis are set by the server, not the model. */\nexport const RememberInput = z\n .object({\n kind: MemoryKind.describe(\"goal = what they want to learn or do; preference = how they like to learn; misconception = something they believe that is wrong.\"),\n text: MemoryText.describe(\"One short sentence about the learner. Never include the answer to a check they haven't answered.\"),\n concept: z.string().trim().min(1).max(80).optional().describe(\"Required for a misconception: the concept it is about. Use the exact name from the check or from their record, so it can be linked to their answers.\"),\n replaces: z.string().min(1).optional().describe(\"The id of a known memory this one corrects or updates.\"),\n })\n .strict()\n .superRefine((input, ctx) => {\n // Without a concept a misconception can't be linked to a wrong answer (ADR-009).\n if (input.kind === \"misconception\" && !input.concept) {\n ctx.addIssue({ code: \"custom\", path: [\"concept\"], message: \"A misconception needs a concept\" });\n }\n });\nexport type RememberInput = z.infer<typeof RememberInput>;\n\n/** How a memory is supported: a graded wrong answer, or only something said in chat. */\nexport const MemoryBasis = z.enum([\"wrong_answer\", \"chat\"]);\nexport type MemoryBasis = z.infer<typeof MemoryBasis>;\n\n/**\n * A memory as the learner sees it in the memory panel. A memory written while a check was unanswered\n * could give that check's answer away, so until the check is answered it is `held`, without its content.\n */\nexport const MemoryView = z\n .object({\n id: z.string(),\n kind: MemoryKind,\n held: z.boolean(),\n text: z.string().nullable(),\n concept: z.string().nullable(),\n basis: MemoryBasis.nullable(),\n createdAt: z.string().datetime(),\n editedAt: z.string().datetime().nullable(),\n })\n .strict();\nexport type MemoryView = z.infer<typeof MemoryView>;\n\nexport const MemoryEdit = z.object({ text: MemoryText }).strict();\n", "import { z } from \"zod\";\n\n/** The largest file the learner can upload (ADR-010). The server enforces it while reading. */\nexport const MAX_DOCUMENT_BYTES = 25 * 1024 * 1024;\n\n/** What a client sees of an uploaded document. Its text stays on the server. */\nexport const DocumentView = z.object({\n id: z.string(),\n sessionId: z.string(),\n messageId: z.string().nullable(),\n filename: z.string(),\n kind: z.enum([\"pdf\", \"pptx\"]),\n byteSize: z.number().int(),\n pageCount: z.number().int(),\n pagesWithText: z.number().int(),\n status: z.literal(\"ready\"),\n createdAt: z.string().datetime(),\n});\nexport type DocumentView = z.infer<typeof DocumentView>;\n", "import { z } from \"zod\";\n\n/**\n * Importing a learner's Obsidian vault (ADR-014). A vault is hostile input (ADR-010), so every size is capped.\n * Clients send only Markdown files; the server checks each path again and skips anything else.\n */\n\n/** Most files one import can send. */\nexport const MAX_VAULT_FILES = 10_000;\n/** Longest note, in characters. */\nexport const MAX_NOTE_CHARS = 1_000_000;\n/** Largest import request body. */\nexport const MAX_VAULT_BYTES = 64 * 1024 * 1024;\nconst MAX_PATH_CHARS = 512;\n\nexport const VaultFile = z\n .object({\n /** The file's path inside the vault, with `/` between folders, e.g. `Maths/Recursion.md`. */\n path: z.string().min(1).max(MAX_PATH_CHARS),\n text: z.string().max(MAX_NOTE_CHARS),\n })\n .strict();\nexport type VaultFile = z.infer<typeof VaultFile>;\n\nconst VaultFiles = z.array(VaultFile).max(MAX_VAULT_FILES);\nconst VaultName = z.string().trim().min(1).max(120);\n\n/** Starts a new import. The name tells imports apart, so it's unique; the CLI defaults it to the vault folder's name. */\nexport const VaultImportInput = z.object({ name: VaultName, files: VaultFiles }).strict();\nexport type VaultImportInput = z.infer<typeof VaultImportInput>;\n\n/** Replaces an import's files with a new snapshot of the vault. */\nexport const VaultSnapshotInput = z.object({ files: VaultFiles }).strict();\nexport type VaultSnapshotInput = z.infer<typeof VaultSnapshotInput>;\n\nexport const VaultImportView = z\n .object({\n id: z.string(),\n name: z.string(),\n source: z.literal(\"obsidian\"),\n noteCount: z.number().int(),\n createdAt: z.string().datetime(),\n updatedAt: z.string().datetime(),\n })\n .strict();\nexport type VaultImportView = z.infer<typeof VaultImportView>;\n\n/**\n * Why a file wasn't imported. `too_long` is a note over MAX_NOTE_CHARS and `symlink` a link inside a zipped\n * vault; both are reported by the zip upload and by clients that check sizes before sending.\n */\nexport const SkipReason = z.enum([\"not_markdown\", \"hidden\", \"bad_path\", \"duplicate\", \"too_long\", \"symlink\"]);\nexport type SkipReason = z.infer<typeof SkipReason>;\n\n/** What one import or re-import changed. `skipped` lists at most a few paths; `skippedCount` counts them all. */\nexport const VaultImportResult = z\n .object({\n import: VaultImportView,\n added: z.number().int(),\n updated: z.number().int(),\n removed: z.number().int(),\n unchanged: z.number().int(),\n skippedCount: z.number().int(),\n skipped: z.array(z.object({ path: z.string(), reason: SkipReason }).strict()),\n /** Links or tags left out because a note or the vault had more than the limit. */\n truncated: z.boolean(),\n })\n .strict();\nexport type VaultImportResult = z.infer<typeof VaultImportResult>;\n\nexport const NoteView = z\n .object({\n id: z.string(),\n importId: z.string(),\n path: z.string(),\n title: z.string(),\n aliases: z.array(z.string()),\n tags: z.array(z.string()),\n body: z.string(),\n updatedAt: z.string().datetime(),\n })\n .strict();\nexport type NoteView = z.infer<typeof NoteView>;\n\n/**\n * An import's notes and the links between them. A link whose target is no note in the vault has `to: null`\n * and keeps its `target`, so a client can draw it as an unresolved node, as Obsidian does.\n */\nexport const NoteGraph = z\n .object({\n notes: z.array(z.object({ id: z.string(), path: z.string(), title: z.string(), tags: z.array(z.string()) }).strict()),\n links: z.array(z.object({ from: z.string(), to: z.string().nullable(), target: z.string(), kind: z.enum([\"link\", \"embed\"]) }).strict()),\n })\n .strict();\nexport type NoteGraph = z.infer<typeof NoteGraph>;\n", "import { z } from \"zod\";\nimport { artifactMathInput, checkMathText } from \"./artifact-math-input.js\";\nimport { AlgorithmTraceSpec } from \"./algorithm-trace.js\";\nimport { PlacementAnswer, PlacementGrade, PlacementQuestionPublic, PlacementQuestionSpec } from \"./course.js\";\nimport { GraphSpec } from \"./graph.js\";\nimport { MultipleChoiceAnswer, MultipleChoiceGrade, MultipleChoicePublic, MultipleChoiceSpec } from \"./multiple-choice.js\";\nimport { SetDiagramSpec } from \"./set-diagram.js\";\nimport { TableSpec } from \"./table.js\";\nimport { WorkedStepsSpec } from \"./worked-steps.js\";\n\nexport * from \"./artifact-math-input.js\";\nexport * from \"./math-text.js\";\nexport * from \"./algorithm-trace.js\";\nexport * from \"./course.js\";\nexport * from \"./lesson.js\";\nexport * from \"./graph.js\";\nexport * from \"./multiple-choice.js\";\nexport * from \"./set-diagram.js\";\nexport * from \"./table.js\";\nexport * from \"./worked-steps.js\";\n\n/**\n * Every artifact kind the agent can produce, one tool per kind (ADR-006).\n * `input` adds current authoring checks to the stored `spec` schema, so old artifacts stay readable.\n * Bump `version` and keep the old schema when a spec changes incompatibly; stored artifacts record\n * the version they were created with.\n */\nexport const artifactKinds = {\n algorithm_trace: {\n version: 1,\n toolName: \"show_algorithm_trace\",\n description:\n \"Show the learner an interactive step-by-step trace of an algorithm running over a sequence (e.g. sliding window, two pointers, binary search, a simple sort). The learner steps through it with play/pause/step controls. Use it when watching state change step by step will make the idea click. Keep traces short (roughly 5-20 steps) and make each step's explanation say what changed and why.\",\n spec: AlgorithmTraceSpec,\n input: artifactMathInput(AlgorithmTraceSpec, [\"title\", \"steps.*.explanation\"]),\n },\n graph: {\n version: 1,\n toolName: \"show_graph\",\n description:\n \"Show the learner a graph or tree, drawn for you, optionally with steps they can walk through. Use it for graphs, trees, BFS, DFS, shortest paths, spanning trees and tree traversals, whenever seeing the structure or watching an algorithm move over it will help. Never give coordinates: the layout is automatic. For a binary search tree or binary tree traversal, set kind to tree and give every edge a side, so a lone left child and a lone right child are drawn differently. The automatic layout may draw crossing edges that mean nothing, even when the graph is planar, so don't use this to show whether a graph is planar. Keep it small enough to read (roughly 4-15 nodes, 5-20 steps) and make each step's explanation say what changed and why.\",\n spec: GraphSpec,\n input: artifactMathInput(GraphSpec, [\"title\", \"nodes.*.label\", \"edges.*.label\", \"steps.*.explanation\"], (spec, ctx) => {\n spec.nodes.forEach((node, i) => {\n if (node.label === undefined) checkMathText(node.id, [\"nodes\", i, \"id\"], ctx);\n });\n }),\n },\n multiple_choice: {\n version: 1,\n toolName: \"ask_multiple_choice\",\n description:\n \"Ask the learner one multiple-choice question to check understanding of a concept you just taught. Exactly one option is correct. Write plausible wrong options that reflect real misconceptions, and give per-option feedback where useful. The learner answers in the UI; the result is reported back to you on the next turn, so do not reveal the answer in your reply.\",\n spec: MultipleChoiceSpec,\n input: artifactMathInput(MultipleChoiceSpec, [\"question\", \"options.*.text\", \"options.*.feedback\", \"explanation\"]),\n },\n placement_question: {\n version: 1,\n toolName: \"ask_placement_question\",\n description:\n \"Course placement interview only: ask the learner one quick question to find out what they already know about one concept, before the syllabus is written. Use multiple choice, true/false or yes/no. The UI always adds \\\"Not sure\\\" and \\\"Skip\\\", so never include those as options. The learner answers in the UI and the result is reported back to you, so don't reveal the answer.\",\n spec: PlacementQuestionSpec,\n input: artifactMathInput(PlacementQuestionSpec, [\"question\", \"options.*.text\", \"explanation\"]),\n },\n set_diagram: {\n version: 1,\n toolName: \"show_set_diagram\",\n description:\n \"Show the learner a Venn diagram of 1 to 3 sets, with what each region contains. Use it for set operations (union, intersection, complement, difference) and inclusion-exclusion, not for more than 3 sets. Keep elements short, because they are drawn in their region. Add steps to walk through it: each step highlights exact regions (any of them, including outside every set, which needs `universe`) and says what changed and why.\",\n spec: SetDiagramSpec,\n input: artifactMathInput(SetDiagramSpec, [\"title\", \"universe\", \"sets.*.label\", \"regions.*.elements.*\", \"steps.*.explanation\", \"steps.*.variables.*.name\", \"steps.*.variables.*.value\"]),\n },\n table: {\n version: 1,\n toolName: \"show_table\",\n description:\n \"Show the learner a table: a truth table, a relation matrix or other tabular working. Use it whenever the content is really rows and columns. Add steps when filling it in or highlighting it one part at a time will help, such as working out a truth table column by column; leave them out for a table to read at a glance. Keep steps short and make each explanation say what changed and why.\",\n spec: TableSpec,\n input: artifactMathInput(TableSpec, [\"title\", \"columns.*\", \"rowHeaders.*\", \"rows.*.*\", \"steps.*.explanation\", \"steps.*.cells.*.value\"]),\n },\n worked_steps: {\n version: 1,\n toolName: \"show_worked_steps\",\n description:\n \"Show the learner a proof, an induction or combinatorics working as a sequence of steps they reveal one at a time, each a statement with its justification. Use it when the reasoning is the point and each line follows from the ones before. Use show_algorithm_trace instead for an algorithm's state changing over a sequence.\",\n spec: WorkedStepsSpec,\n input: artifactMathInput(WorkedStepsSpec, [\"title\", \"goal\", \"steps.*.label\", \"steps.*.statement\", \"steps.*.justification\"]),\n },\n} as const;\n\nexport type ArtifactKind = keyof typeof artifactKinds;\nexport const ArtifactKind = z.enum(Object.keys(artifactKinds) as [ArtifactKind, ...ArtifactKind[]]);\n\n/** Finds the kind registered for a tool name, if any. */\nexport function kindForTool(toolName: string): ArtifactKind | undefined {\n return (Object.keys(artifactKinds) as ArtifactKind[]).find((kind) => artifactKinds[kind].toolName === toolName);\n}\n\nconst ArtifactBase = { id: z.string(), createdAt: z.string().datetime() };\n\nexport const MultipleChoiceAttempt = z\n .object({ answer: MultipleChoiceAnswer, grade: MultipleChoiceGrade, createdAt: z.string().datetime() })\n .strict();\nexport type MultipleChoiceAttempt = z.infer<typeof MultipleChoiceAttempt>;\n\nexport const PlacementAttempt = z.object({ answer: PlacementAnswer, grade: PlacementGrade, createdAt: z.string().datetime() }).strict();\nexport type PlacementAttempt = z.infer<typeof PlacementAttempt>;\n\n/**\n * An artifact as the client receives it. Checks expose only their public view until answered;\n * after an attempt, the grade (with the correct answer and explanation) is included.\n */\nexport const ArtifactView = z.discriminatedUnion(\"kind\", [\n z\n .object({ ...ArtifactBase, kind: z.literal(\"algorithm_trace\"), version: z.literal(1), spec: AlgorithmTraceSpec })\n .strict(),\n z.object({ ...ArtifactBase, kind: z.literal(\"graph\"), version: z.literal(1), spec: GraphSpec }).strict(),\n z\n .object({\n ...ArtifactBase,\n kind: z.literal(\"multiple_choice\"),\n version: z.literal(1),\n spec: MultipleChoicePublic,\n latestAttempt: MultipleChoiceAttempt.optional(),\n })\n .strict(),\n z\n .object({\n ...ArtifactBase,\n kind: z.literal(\"placement_question\"),\n version: z.literal(1),\n spec: PlacementQuestionPublic,\n latestAttempt: PlacementAttempt.optional(),\n })\n .strict(),\n z.object({ ...ArtifactBase, kind: z.literal(\"set_diagram\"), version: z.literal(1), spec: SetDiagramSpec }).strict(),\n z.object({ ...ArtifactBase, kind: z.literal(\"table\"), version: z.literal(1), spec: TableSpec }).strict(),\n z.object({ ...ArtifactBase, kind: z.literal(\"worked_steps\"), version: z.literal(1), spec: WorkedStepsSpec }).strict(),\n]);\nexport type ArtifactView = z.infer<typeof ArtifactView>;\n\nexport * from \"./memory.js\";\nexport * from \"./document.js\";\nexport * from \"./vault.js\";\n\n/** ChatGPT's page for the learner's plan usage and per-app limits (ADR-015). */\nexport const CHATGPT_USAGE_URL = \"https://chatgpt.com/settings/usage\";\n/**\n * The reply error when the learner's ChatGPT plan has hit a usage limit. The UI recognises it and offers\n * \"Manage usage\", as OpenAI's guidelines ask (ADR-015).\n */\nexport const CHATGPT_USAGE_LIMIT_ERROR = \"ChatGPT usage limit reached. Review your plan or this app's limit in ChatGPT settings.\";\n", "import { z } from \"zod\";\nimport { splitMath } from \"./math-text.js\";\n\nconst REPAIR = String.raw`Wrap LaTeX commands in single-dollar math delimiters, with no spaces inside: $\\displaystyle\\sum_{i=1}^{n} i$. Put \\displaystyle inside the dollars. For literal backslashes followed by two or more letters (such as C:\\Users), use forward slashes, Unicode symbols such as \u2216, or describe them in words; backticks do not escape artifact math. Correct the affected field and retry this tool call.`;\n\n// Single-letter code escapes stay literal; longer literals such as C:\\Users are still rejected.\nexport function checkMathText(value: unknown, path: (string | number)[], ctx: z.RefinementCtx) {\n if (typeof value === \"string\" && splitMath(value).some((piece) => \"text\" in piece && /\\\\[a-zA-Z]{2,}/.test(piece.text))) {\n ctx.addIssue({ code: \"custom\", path, message: REPAIR });\n }\n}\n\n/** Input-only refinements: stored v1 specs and public views must continue to accept old text. */\nexport function artifactMathInput<T extends z.ZodType>(schema: T, fields: string[], extra?: (spec: z.output<T>, ctx: z.RefinementCtx) => void) {\n return schema.superRefine((spec, ctx) => {\n const visit = (value: unknown, parts: string[], path: (string | number)[]) => {\n if (parts.length === 0) return checkMathText(value, path, ctx);\n const [key, ...rest] = parts;\n if (key === \"*\" && Array.isArray(value)) value.forEach((item, i) => visit(item, rest, [...path, i]));\n else if (value && typeof value === \"object\" && key !== undefined) visit((value as Record<string, unknown>)[key], rest, [...path, key]);\n };\n for (const field of fields) visit(spec, field.split(\".\"), []);\n extra?.(spec, ctx);\n });\n}\n", "const isSpace = (char: string | undefined) => char !== undefined && /\\s/.test(char);\nconst isDigit = (char: string | undefined) => char !== undefined && char >= \"0\" && char <= \"9\";\n\nexport type MathPiece = { text: string } | { formula: string };\n\n/** For math mode: everything is literal except `$...$` formulas, and `\\$`, which is a literal dollar. */\nexport function splitMath(source: string): MathPiece[] {\n const pieces: MathPiece[] = [];\n let literal = \"\";\n let i = 0;\n while (i < source.length) {\n const char = source[i]!;\n if (char === \"\\\\\" && source[i + 1] === \"$\") {\n literal += \"$\";\n i += 2;\n } else if (char !== \"$\") {\n literal += char;\n i += 1;\n } else if (source[i + 1] === \"$\") {\n // A dollar next to another is never a delimiter here, so \"$$x$$\" stays as written.\n while (source[i] === \"$\") {\n literal += \"$\";\n i += 1;\n }\n } else {\n const close = closingDollar(source, i);\n if (close === undefined) {\n literal += \"$\";\n i += 1;\n } else {\n if (literal) pieces.push({ text: literal });\n literal = \"\";\n pieces.push({ formula: source.slice(i + 1, close) });\n i = close + 1;\n }\n }\n }\n if (literal) pieces.push({ text: literal });\n return pieces;\n}\n\nfunction closingDollar(source: string, open: number): number | undefined {\n let close = open + 1;\n while (close < source.length && source[close] !== \"$\") {\n close += source[close] === \"\\\\\" && (source[close + 1] === \"$\" || source[close + 1] === \"\\\\\") ? 2 : 1;\n }\n if (close >= source.length || close === open + 1 || source[close + 1] === \"$\") return undefined;\n if (isSpace(source[open + 1]) || isSpace(source[close - 1]) || isDigit(source[close + 1])) return undefined;\n return /`|\\n\\s*\\n/.test(source.slice(open, close)) ? undefined : close;\n}\n", "import { z } from \"zod\";\n\n/**\n * algorithm_trace v1: a step-through view of an algorithm running over a sequence.\n * Each step can move labelled pointers, highlight index ranges, update variables and\n * replace the sequence (for swaps/sorts). Covers sliding window, two pointers, binary\n * search and simple sorts.\n *\n * State rules (renderers must follow them):\n * - `values` persists: a step without `values` shows the previous step's sequence.\n * - `pointers`, `ranges` and `variables` do not persist: each step lists all of its own,\n * and omitting one means that step has none. So every step is fully described by itself\n * plus the current sequence, and bounds can be checked step by step.\n */\n\nconst MAX_VALUES = 64;\nconst MAX_STEPS = 200;\n\nconst Label = z.string().trim().min(1).max(40);\nconst Cell = z.union([z.number(), z.string().max(24)]);\nconst Index = z.number().int().nonnegative();\n\nexport const TracePointer = z\n .object({\n name: Label.describe('Pointer label shown under the cell, e.g. \"left\", \"right\", \"mid\", \"i\".'),\n index: Index.describe(\"0-based index into the sequence as it is at this step.\"),\n })\n .strict();\n\nexport const TraceRange = z\n .object({\n start: Index.describe(\"0-based start index, inclusive, within the sequence as it is at this step.\"),\n end: Index.describe(\"0-based end index, inclusive. Must be >= start and within the sequence.\"),\n label: Label.optional().describe('Optional label, e.g. \"window\".'),\n tone: z\n .enum([\"active\", \"done\", \"muted\"])\n .optional()\n .describe(\"active = current focus, done = finished/sorted, muted = ruled out. Defaults to active.\"),\n })\n .strict();\n\nexport const TraceVariable = z\n .object({\n name: Label,\n value: z.union([z.number(), z.string().max(80), z.boolean()]),\n })\n .strict();\n\nexport const TraceStep = z\n .object({\n explanation: z.string().trim().min(1).max(500).describe(\"What happens in this step, in one or two sentences.\"),\n values: z\n .array(Cell)\n .min(1)\n .max(MAX_VALUES)\n .optional()\n .describe(\"The whole sequence after this step. Omit unless the values changed (e.g. a swap); omitted means unchanged.\"),\n pointers: z\n .array(TracePointer)\n .max(8)\n .optional()\n .describe(\"All pointers to show at this step. Not carried over from earlier steps: repeat any that still apply.\"),\n ranges: z\n .array(TraceRange)\n .max(8)\n .optional()\n .describe(\"All highlighted ranges at this step. Not carried over from earlier steps.\"),\n variables: z\n .array(TraceVariable)\n .max(12)\n .optional()\n .describe(\"All running state at this step, e.g. current sum, best so far. Not carried over from earlier steps.\"),\n })\n .strict();\n\nexport const AlgorithmTraceSpec = z\n .object({\n title: z.string().trim().min(1).max(120),\n values: z.array(Cell).min(1).max(MAX_VALUES).describe(\"The input sequence before the first step.\"),\n steps: z.array(TraceStep).min(1).max(MAX_STEPS),\n })\n .strict()\n .superRefine((spec, ctx) => {\n // Every pointer and range must point inside the sequence as it is at that step.\n let length = spec.values.length;\n spec.steps.forEach((step, i) => {\n if (step.values) length = step.values.length;\n step.pointers?.forEach((p, j) => {\n if (p.index >= length) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"steps\", i, \"pointers\", j, \"index\"],\n message: `index ${p.index} is outside the sequence (length ${length})`,\n });\n }\n });\n step.ranges?.forEach((r, j) => {\n if (r.end >= length || r.start > r.end) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"steps\", i, \"ranges\", j],\n message: `range ${r.start}..${r.end} is invalid for a sequence of length ${length}`,\n });\n }\n });\n });\n });\n\nexport type AlgorithmTraceSpec = z.infer<typeof AlgorithmTraceSpec>;\nexport type TraceStep = z.infer<typeof TraceStep>;\n", "import { z } from \"zod\";\nimport { TraceVariable } from \"./algorithm-trace.js\";\n\n/**\n * graph v1: nodes and edges, optionally with steps that walk an algorithm over them. Covers BFS, DFS,\n * shortest paths, spanning trees and tree traversals. Self-loops and parallel edges are allowed and\n * drawn, because a multigraph is ordinary discrete maths. The model never picks coordinates: the\n * renderer computes one layout per graph, so nothing moves between steps.\n *\n * State rules (renderers must follow them):\n * - The graph itself never changes between steps.\n * - `nodeStates`, `edgeStates` and `variables` do not persist: each step lists all of its own, and\n * omitting one means that step has none. So every step is fully described by itself.\n */\n\nconst MAX_NODES = 60;\nconst MAX_EDGES = 200;\nconst MAX_STEPS = 200;\n\nconst Id = z.string().trim().min(1).max(24);\nconst Text = z.string().trim().min(1).max(24);\n\nexport const GraphTone = z.enum([\"active\", \"done\", \"muted\"]);\nexport type GraphTone = z.infer<typeof GraphTone>;\n\nconst ToneField = GraphTone.optional().describe(\n \"active = current focus, done = finished/visited, muted = ruled out. Defaults to active.\",\n);\n\nexport const GraphNode = z\n .object({\n id: Id.describe(\"Unique id, used by edges and steps. Shown on the node if it has no label.\"),\n label: Text.optional().describe(\"Short text on the node. Only $...$ is a formula, e.g. $v_1$.\"),\n })\n .strict();\n\nexport const GraphEdge = z\n .object({\n from: Id.describe(\"Id of a node. In a tree, the parent.\"),\n to: Id.describe(\"Id of a node, the same as `from` for a self-loop. In a tree, the child; children appear left to right in edge order unless they have a `side`.\"),\n side: z\n .enum([\"left\", \"right\"])\n .optional()\n .describe(\n \"Only when kind is tree: which child this is of `from`, its parent. Set it on every edge of a binary search tree or binary tree traversal, because a lone left child and a lone right child are different trees. A node has at most one child per side, and either all of its children have a side or none do.\",\n ),\n weight: z.number().optional().describe(\"Numeric weight shown on the edge. Give a weight or a label, not both.\"),\n label: Text.optional().describe(\"Text shown on the edge. Only $...$ is a formula.\"),\n })\n .strict();\n\nexport const GraphNodeState = z\n .object({ id: Id.describe(\"Id of a node.\"), tone: ToneField })\n .strict();\n\nexport const GraphEdgeState = z\n .object({\n from: Id,\n to: Id,\n nth: z\n .number()\n .int()\n .nonnegative()\n .optional()\n .describe(\"Only for parallel edges, and then required: which of the edges joining these nodes, 0-based in the order of `edges`.\"),\n tone: ToneField,\n })\n .strict()\n .describe(\"An edge of the graph. In an undirected graph, from and to may be in either order.\");\n\nexport const GraphStep = z\n .object({\n explanation: z.string().trim().min(1).max(500).describe(\"What happens in this step, in one or two sentences.\"),\n nodeStates: z\n .array(GraphNodeState)\n .max(MAX_NODES)\n .optional()\n .describe(\"The state of every node that has one at this step, at most one each. Not carried over from earlier steps: repeat any that still apply.\"),\n edgeStates: z\n .array(GraphEdgeState)\n .max(MAX_EDGES)\n .optional()\n .describe(\"The state of every edge that has one at this step, at most one each. Not carried over from earlier steps: repeat any that still apply.\"),\n variables: z\n .array(TraceVariable)\n .max(12)\n .optional()\n .describe(\"All running state at this step, e.g. the queue or current distances. Not carried over from earlier steps.\"),\n })\n .strict();\n\nconst pairKey = (from: string, to: string, directed: boolean) =>\n JSON.stringify(directed || from <= to ? [from, to] : [to, from]);\n\n/**\n * Finds which edge a step's edge state refers to, shared by the schema and renderers so they can't\n * disagree. Returns the index into `edges`, or why there isn't one.\n */\nexport function graphEdgeLookup(spec: { directed: boolean; edges: readonly { from: string; to: string }[] }) {\n const byPair = new Map<string, number[]>();\n spec.edges.forEach((edge, i) => {\n const key = pairKey(edge.from, edge.to, spec.directed);\n const indices = byPair.get(key);\n if (indices) indices.push(i);\n else byPair.set(key, [i]);\n });\n return (ref: { from: string; to: string; nth?: number | undefined }): { index: number } | { error: string } => {\n const name = `${ref.from} ${spec.directed ? \"->\" : \"--\"} ${ref.to}`;\n const indices = byPair.get(pairKey(ref.from, ref.to, spec.directed));\n if (!indices) return { error: `there is no edge ${name}` };\n if (ref.nth === undefined && indices.length > 1) return { error: `${indices.length} edges match ${name}: set nth to pick one` };\n const index = indices[ref.nth ?? 0];\n return index === undefined ? { error: `nth ${ref.nth} is out of range: ${indices.length} edges match ${name}` } : { index };\n };\n}\n\n/**\n * Each node's children in edge order, if the graph is a real tree: one root, connected, no cycles. Shared by\n * the schema and renderers so they can't disagree. Every edge must join nodes that exist.\n */\nexport function graphTreeShape(spec: {\n directed: boolean;\n nodes: readonly { id: string }[];\n edges: readonly { from: string; to: string }[];\n}): { root: string; children: Map<string, string[]> } | undefined {\n if (spec.edges.length !== spec.nodes.length - 1) return undefined;\n const ids = spec.nodes.map((node) => node.id);\n const adjacent = new Map<string, string[]>(ids.map((id) => [id, []]));\n for (const { from, to } of spec.edges) {\n adjacent.get(from)!.push(to);\n if (!spec.directed && from !== to) adjacent.get(to)!.push(from);\n }\n const roots = spec.directed ? ids.filter((id) => !spec.edges.some((edge) => edge.to === id)) : ids.slice(0, 1);\n const root = roots[0];\n if (roots.length !== 1 || root === undefined) return undefined;\n\n const children = new Map<string, string[]>();\n const pending = [root];\n while (pending.length) {\n const id = pending.pop()!;\n const next = adjacent.get(id)!.filter((other) => !children.has(other));\n children.set(id, next);\n pending.push(...next);\n }\n // With n - 1 edges, reaching all n nodes means there can't be a cycle.\n return children.size === ids.length ? { root, children } : undefined;\n}\n\n/** The rules for `side`, which only says anything about a tree that really gets drawn as one. */\nfunction checkSides(spec: Pick<GraphSpec, \"kind\" | \"directed\" | \"nodes\" | \"edges\">, ctx: z.RefinementCtx) {\n const sided = spec.edges.flatMap((edge, i) => (edge.side ? [{ edge, side: edge.side, path: [\"edges\", i, \"side\"] }] : []));\n const first = sided[0];\n if (!first) return;\n if (spec.kind !== \"tree\") {\n for (const { path } of sided) ctx.addIssue({ code: \"custom\", path, message: 'side only applies when kind is \"tree\": remove it, or set kind' });\n return;\n }\n const shape = graphTreeShape(spec);\n if (!shape) {\n ctx.addIssue({ code: \"custom\", path: first.path, message: \"side needs a real tree: connected with no cycles, and when directed, edges going parent to child from one root\" });\n return;\n }\n const sideOf = new Map<string, \"left\" | \"right\">();\n for (const { edge, side, path } of sided) {\n if (shape.children.get(edge.from)!.includes(edge.to)) sideOf.set(edge.to, side);\n else ctx.addIssue({ code: \"custom\", path, message: `side needs from to be the parent, but ${edge.to} is the parent of ${edge.from} here: swap them` });\n }\n for (const [parent, children] of shape.children) {\n const sides = children.flatMap((child) => sideOf.get(child) ?? []);\n if (sides.length > 0 && sides.length < children.length) {\n ctx.addIssue({ code: \"custom\", path: [\"edges\"], message: `node ${parent} mixes children with and without a side: give all of them one, or none` });\n }\n for (const side of [\"left\", \"right\"] as const) {\n if (sides.filter((s) => s === side).length > 1) ctx.addIssue({ code: \"custom\", path: [\"edges\"], message: `node ${parent} has two ${side} children` });\n }\n }\n}\n\nexport const GraphSpec = z\n .object({\n title: z.string().trim().min(1).max(120),\n directed: z.boolean().describe(\"True draws arrowheads from `from` to `to`.\"),\n kind: z\n .enum([\"tree\", \"graph\"])\n .optional()\n .describe(\n \"Layout hint. tree draws a rooted tree top-down, and needs a real tree: connected with no cycles, and when directed, edges going parent to child from one root. When undirected, the first node is the root. Anything else falls back to the general layout, unless an edge has a `side`, which is then an error. Defaults to graph.\",\n ),\n nodes: z.array(GraphNode).min(1).max(MAX_NODES),\n edges: z.array(GraphEdge).max(MAX_EDGES).describe(\"Self-loops and parallel edges are allowed.\"),\n steps: z.array(GraphStep).min(1).max(MAX_STEPS).optional().describe(\"Omit to show the graph without stepping through it.\"),\n })\n .strict()\n .superRefine((spec, ctx) => {\n const ids = new Set<string>();\n spec.nodes.forEach((node, i) => {\n if (ids.has(node.id)) ctx.addIssue({ code: \"custom\", path: [\"nodes\", i, \"id\"], message: `duplicate node id ${node.id}` });\n ids.add(node.id);\n });\n spec.edges.forEach((edge, i) => {\n for (const end of [\"from\", \"to\"] as const) {\n if (!ids.has(edge[end])) ctx.addIssue({ code: \"custom\", path: [\"edges\", i, end], message: `no node has id ${edge[end]}` });\n }\n if (edge.weight !== undefined && edge.label !== undefined) {\n ctx.addIssue({ code: \"custom\", path: [\"edges\", i], message: \"give a weight or a label, not both\" });\n }\n });\n if (spec.edges.every((edge) => ids.has(edge.from) && ids.has(edge.to))) checkSides(spec, ctx);\n const lookup = graphEdgeLookup(spec);\n spec.steps?.forEach((step, i) => {\n const seenNodes = new Set<string>();\n step.nodeStates?.forEach((state, j) => {\n const path = [\"steps\", i, \"nodeStates\", j];\n if (!ids.has(state.id)) ctx.addIssue({ code: \"custom\", path, message: `no node has id ${state.id}` });\n if (seenNodes.has(state.id)) ctx.addIssue({ code: \"custom\", path, message: `node ${state.id} has two states in one step` });\n seenNodes.add(state.id);\n });\n const seenEdges = new Set<number>();\n step.edgeStates?.forEach((state, j) => {\n const path = [\"steps\", i, \"edgeStates\", j];\n const found = lookup(state);\n if (\"error\" in found) return ctx.addIssue({ code: \"custom\", path, message: found.error });\n if (seenEdges.has(found.index)) ctx.addIssue({ code: \"custom\", path, message: `edge ${found.index} has two states in one step` });\n seenEdges.add(found.index);\n });\n });\n });\n\nexport type GraphSpec = z.infer<typeof GraphSpec>;\nexport type GraphStep = z.infer<typeof GraphStep>;\n", "import { z } from \"zod\";\n\n/**\n * multiple_choice v1: a comprehension check with exactly one correct option, graded by the\n * server without a model call (ADR-006). The full spec (with the answer) stays on the server;\n * the client gets the public view until the learner has answered.\n */\n\nexport const MultipleChoiceOption = z\n .object({\n text: z.string().trim().min(1).max(300),\n feedback: z\n .string()\n .trim()\n .min(1)\n .max(500)\n .optional()\n .describe(\"Shown if the learner picks this option: why it is right or what misconception it reflects.\"),\n })\n .strict();\n\nexport const MultipleChoiceSpec = z\n .object({\n concept: z\n .string()\n .trim()\n .min(1)\n .max(80)\n .describe('Short label for the concept being checked, e.g. \"sliding window invariant\". Used to track progress.'),\n question: z.string().trim().min(1).max(1000),\n options: z.array(MultipleChoiceOption).min(2).max(6).describe(\"2-6 options with distinct text.\"),\n correctOptionIndex: z\n .number()\n .int()\n .nonnegative()\n .describe(\"0-based index of the single correct option; must be less than the number of options.\"),\n explanation: z.string().trim().min(1).max(1000).describe(\"Shown after answering: why the correct option is correct.\"),\n })\n .strict()\n .superRefine((spec, ctx) => {\n if (spec.correctOptionIndex >= spec.options.length) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"correctOptionIndex\"],\n message: \"correctOptionIndex must point at one of the options\",\n });\n }\n // Two identical options can't be told apart, but only one would be graded correct. Compare the\n // trimmed text exactly: case and inner spacing can be the point of a question (\"A\" vs \"a\",\n // \"a b\" vs \"a b\"). NFC only merges Unicode spellings that render identically.\n const seen = new Map<string, number>();\n spec.options.forEach((option, i) => {\n const key = option.text.normalize(\"NFC\");\n const first = seen.get(key);\n if (first !== undefined) {\n ctx.addIssue({ code: \"custom\", path: [\"options\", i, \"text\"], message: `duplicates option ${first}` });\n } else {\n seen.set(key, i);\n }\n });\n });\n\nexport type MultipleChoiceSpec = z.infer<typeof MultipleChoiceSpec>;\n\n/** What the client sees before answering: no answer key, no feedback. */\nexport const MultipleChoicePublic = z\n .object({\n concept: z.string(),\n question: z.string(),\n options: z.array(z.object({ text: z.string() }).strict()),\n })\n .strict();\n\nexport type MultipleChoicePublic = z.infer<typeof MultipleChoicePublic>;\n\nexport function toMultipleChoicePublic(spec: MultipleChoiceSpec): MultipleChoicePublic {\n return {\n concept: spec.concept,\n question: spec.question,\n options: spec.options.map((o) => ({ text: o.text })),\n };\n}\n\nexport const MultipleChoiceAnswer = z.object({ optionIndex: z.number().int().nonnegative() }).strict();\nexport type MultipleChoiceAnswer = z.infer<typeof MultipleChoiceAnswer>;\n\nexport const MultipleChoiceGrade = z\n .object({\n correct: z.boolean(),\n correctOptionIndex: z.number().int().nonnegative(),\n explanation: z.string(),\n feedback: z.string().optional(),\n })\n .strict();\nexport type MultipleChoiceGrade = z.infer<typeof MultipleChoiceGrade>;\n\n/** Deterministic grader. Throws if the answer points outside the options. */\nexport function gradeMultipleChoice(spec: MultipleChoiceSpec, answer: MultipleChoiceAnswer): MultipleChoiceGrade {\n const chosen = spec.options[answer.optionIndex];\n if (!chosen) throw new RangeError(`optionIndex ${answer.optionIndex} is not one of the ${spec.options.length} options`);\n return {\n correct: answer.optionIndex === spec.correctOptionIndex,\n correctOptionIndex: spec.correctOptionIndex,\n explanation: spec.explanation,\n ...(chosen.feedback ? { feedback: chosen.feedback } : {}),\n };\n}\n", "import { z } from \"zod\";\nimport { TraceVariable } from \"./algorithm-trace.js\";\n\n/**\n * set_diagram v1: a Venn diagram of up to 3 sets, with what each region contains and optional steps\n * that highlight regions. Covers union, intersection, complement, difference and inclusion-exclusion.\n *\n * A region is named by the set ids it is inside and is outside every other set, so with sets a, b and c,\n * `[\"a\", \"b\"]` is \"in a and b, not c\", and `[\"b\", \"a\"]` is the same region. `[]` is outside every set.\n * A region that isn't listed has no contents shown; a listed region with no elements and no count is empty.\n *\n * Highlights and variables do not persist: each step lists all of its own.\n */\n\nconst MAX_SETS = 3;\n/** 2^3: every region of a 3-set diagram, including outside. */\nconst MAX_REGIONS = 8;\nconst MAX_ELEMENTS = 30;\nconst MAX_STEPS = 40;\n\nconst SetId = z.string().trim().min(1).max(24);\n/** Text drawn in a tight spot in the diagram, so it stays on one line. */\nconst ONE_LINE = /^[^\\n\\r\\v\\f\\u0085\\u2028\\u2029]*$/;\nconst oneLine = (max: number) => z.string().trim().min(1).max(max).regex(ONE_LINE, \"must not contain line breaks\");\nconst Element = z.union([z.number(), oneLine(24)]);\n\n/** The same string for any ordering of the same set ids, so a region can be compared and looked up. */\nexport function setRegionKey(ids: readonly string[]): string {\n return JSON.stringify([...ids].sort());\n}\n\nconst RegionIn = z.array(SetId).max(MAX_SETS);\n\nexport const SetDiagramSet = z\n .object({\n id: SetId.describe('Short id used to refer to this set, e.g. \"a\". Unique within the diagram.'),\n label: oneLine(32).describe('Shown next to the circle, e.g. \"$A$\" or \"Multiples of 3\", on one line. Only $...$ is a formula.'),\n })\n .strict();\n\nexport const SetDiagramRegion = z\n .object({\n in: RegionIn.describe('Ids of the sets this region is inside. It is outside all the others: with sets a, b, c, [\"a\",\"b\"] means in a and b, not c. [] means outside every set and needs `universe`. No id twice.'),\n elements: z.array(Element).max(MAX_ELEMENTS).describe(\"What the region contains, each short and on one line. No element may appear twice, in this list or across regions, and 1 and \\\"1\\\" count as the same element. Empty if you only know the count, or the region is empty.\"),\n count: z\n .number()\n .int()\n .nonnegative()\n .max(1_000_000)\n .optional()\n .describe(\"How many elements the region has, when that's more than you list, e.g. for inclusion-exclusion. At least the number of elements listed.\"),\n })\n .strict();\n\nexport const SetDiagramHighlight = z\n .object({\n in: RegionIn.describe(\"The region to highlight, named like a region's `in`, with no id twice. Any region of the diagram can be highlighted, listed or not.\"),\n tone: z.enum([\"active\", \"done\", \"muted\"]).optional().describe(\"active = current focus, done = finished, muted = ruled out. Defaults to active.\"),\n })\n .strict();\n\nexport const SetDiagramStep = z\n .object({\n explanation: z.string().trim().min(1).max(500).describe(\"What this step shows, in one or two sentences.\"),\n highlights: z\n .array(SetDiagramHighlight)\n .max(MAX_REGIONS)\n .optional()\n .describe(\"All regions highlighted at this step, each at most once. They apply to this step only, not carried over: repeat any that still apply.\"),\n variables: z.array(TraceVariable).max(12).optional().describe(\"All running state at this step, e.g. |A \u222A B| so far. Not carried over from earlier steps.\"),\n })\n .strict();\n\nexport const SetDiagramSpec = z\n .object({\n title: z.string().trim().min(1).max(120),\n sets: z.array(SetDiagramSet).min(1).max(MAX_SETS).describe(\"The circles, 1 to 3.\"),\n universe: oneLine(24).optional().describe('Label of the rectangle around the sets, e.g. \"$U$\", on one line. Needed to show or highlight the region outside every set, such as a complement.'),\n regions: z.array(SetDiagramRegion).max(MAX_REGIONS).describe(\"What each region contains, each region at most once.\"),\n steps: z.array(SetDiagramStep).min(1).max(MAX_STEPS).optional().describe(\"Optional walk through the diagram. Omit for a static diagram.\"),\n })\n .strict()\n .superRefine((spec, ctx) => {\n const ids = spec.sets.map((s) => s.id);\n spec.sets.forEach((set, i) => {\n if (ids.indexOf(set.id) !== i) ctx.addIssue({ code: \"custom\", path: [\"sets\", i, \"id\"], message: `duplicate set id \"${set.id}\"` });\n });\n\n /** Checks a list of region references, and reports any region named twice, whatever the order of its ids. */\n const checkRegions = (entries: readonly { in: string[] }[], path: (string | number)[]) => {\n const seen = new Set<string>();\n entries.forEach((entry, i) => {\n const at = [...path, i, \"in\"];\n entry.in.forEach((id, j) => {\n if (!ids.includes(id)) ctx.addIssue({ code: \"custom\", path: [...at, j], message: `unknown set \"${id}\"` });\n if (entry.in.indexOf(id) !== j) ctx.addIssue({ code: \"custom\", path: [...at, j], message: `set \"${id}\" is named twice` });\n });\n if (entry.in.length === 0 && spec.universe === undefined) {\n ctx.addIssue({ code: \"custom\", path: at, message: \"the region outside every set needs `universe`\" });\n }\n const key = setRegionKey(entry.in);\n if (seen.has(key)) ctx.addIssue({ code: \"custom\", path: at, message: `region ${key} appears more than once` });\n seen.add(key);\n });\n };\n checkRegions(spec.regions, [\"regions\"]);\n spec.steps?.forEach((step, i) => checkRegions(step.highlights ?? [], [\"steps\", i, \"highlights\"]));\n\n // Regions don't overlap, so an element in two of them would teach something false.\n const placed = new Set<string>();\n spec.regions.forEach((region, i) => {\n region.elements.forEach((element, j) => {\n if (placed.has(String(element))) {\n ctx.addIssue({ code: \"custom\", path: [\"regions\", i, \"elements\", j], message: `element \"${element}\" appears more than once; regions don't overlap` });\n }\n placed.add(String(element));\n });\n if (region.count !== undefined && region.count < region.elements.length) {\n ctx.addIssue({ code: \"custom\", path: [\"regions\", i, \"count\"], message: `count ${region.count} is less than the ${region.elements.length} elements listed` });\n }\n });\n });\n\nexport type SetDiagramSpec = z.infer<typeof SetDiagramSpec>;\nexport type SetDiagramStep = z.infer<typeof SetDiagramStep>;\nexport type SetDiagramHighlight = z.infer<typeof SetDiagramHighlight>;\n", "import { z } from \"zod\";\n\n/**\n * table v1: a truth table, relation matrix or other tabular working, optionally stepped through.\n *\n * State rules (renderers must follow them):\n * - `cells` persists: a changed cell keeps its new value on every later step.\n * - `highlight` does not persist: each step lists all of its own, and omitting it means that step has none.\n * The table's shape never changes, so every index can be checked against `rows` and `columns`.\n */\n\nconst MAX_COLUMNS = 16;\nconst MAX_ROWS = 64;\nconst MAX_STEPS = 100;\n\nconst Header = z.string().trim().min(1).max(80);\nconst CellValue = z.union([z.number(), z.boolean(), z.string().max(120)]);\nconst Index = z.number().int().nonnegative();\n\nexport const TableHighlight = z\n .object({\n row: Index.optional().describe(\"0-based data row, below the number of rows. With no column, highlights the whole row. A highlight must give a row, a column or both.\"),\n column: Index.optional().describe(\"0-based data column, below the number of columns. With no row, highlights the whole column. With both, highlights one cell.\"),\n tone: z\n .enum([\"active\", \"done\", \"muted\"])\n .optional()\n .describe(\"active = current focus, done = finished, muted = ruled out. Defaults to active. Where highlights overlap, the later one wins.\"),\n })\n .strict();\n\nexport const TableCellChange = z\n .object({\n row: Index.describe(\"0-based data row, below the number of rows.\"),\n column: Index.describe(\"0-based data column, below the number of columns.\"),\n value: CellValue.describe(\"The cell's value from this step on.\"),\n })\n .strict();\n\nexport const TableStep = z\n .object({\n explanation: z.string().trim().min(1).max(500).describe(\"What happens in this step, in one or two sentences.\"),\n highlight: z\n .array(TableHighlight)\n .max(32)\n .optional()\n .describe(\"All cells, rows and columns to highlight at this step. Not carried over from earlier steps.\"),\n cells: z\n .array(TableCellChange)\n .max(64)\n .optional()\n .describe('Cells this step fills in or changes. They keep the new value on later steps. To reveal working, start a cell as \"\" and set it here.'),\n })\n .strict();\n\nexport const TableSpec = z\n .object({\n title: z.string().trim().min(1).max(120),\n columns: z.array(Header).min(1).max(MAX_COLUMNS).describe(\"Column headers, one per data column. Don't include a header for rowHeaders.\"),\n rows: z\n .array(z.array(CellValue).min(1).max(MAX_COLUMNS))\n .min(1)\n .max(MAX_ROWS)\n .describe('Data rows, each with exactly one cell per column. A boolean shows as T or F; \"\" is a blank cell.'),\n rowHeaders: z.array(Header).max(MAX_ROWS).optional().describe(\"Optional label for each row, e.g. a relation matrix's elements. Exactly one per row.\"),\n steps: z.array(TableStep).min(1).max(MAX_STEPS).optional().describe(\"Omit for a static table. With steps, the learner steps through them.\"),\n })\n .strict()\n .superRefine((spec, ctx) => {\n const rowCount = spec.rows.length;\n const columnCount = spec.columns.length;\n spec.rows.forEach((row, i) => {\n if (row.length !== columnCount) {\n ctx.addIssue({ code: \"custom\", path: [\"rows\", i], message: `row has ${row.length} cells but there are ${columnCount} columns` });\n }\n });\n if (spec.rowHeaders && spec.rowHeaders.length !== rowCount) {\n ctx.addIssue({ code: \"custom\", path: [\"rowHeaders\"], message: `${spec.rowHeaders.length} row headers for ${rowCount} rows` });\n }\n const checkRow = (row: number, path: (string | number)[]) => {\n if (row >= rowCount) ctx.addIssue({ code: \"custom\", path, message: `row ${row} is outside the table (${rowCount} rows)` });\n };\n const checkColumn = (column: number, path: (string | number)[]) => {\n if (column >= columnCount) ctx.addIssue({ code: \"custom\", path, message: `column ${column} is outside the table (${columnCount} columns)` });\n };\n spec.steps?.forEach((step, i) => {\n step.highlight?.forEach((h, j) => {\n const path = [\"steps\", i, \"highlight\", j];\n if (h.row === undefined && h.column === undefined) ctx.addIssue({ code: \"custom\", path, message: \"a highlight needs a row, a column or both\" });\n if (h.row !== undefined) checkRow(h.row, [...path, \"row\"]);\n if (h.column !== undefined) checkColumn(h.column, [...path, \"column\"]);\n });\n step.cells?.forEach((c, j) => {\n checkRow(c.row, [\"steps\", i, \"cells\", j, \"row\"]);\n checkColumn(c.column, [\"steps\", i, \"cells\", j, \"column\"]);\n });\n });\n });\n\nexport type TableSpec = z.infer<typeof TableSpec>;\nexport type TableStep = z.infer<typeof TableStep>;\n", "import { z } from \"zod\";\n\n/**\n * worked_steps v1: a proof, induction or combinatorics working, revealed one step at a time.\n * Every step stays on screen once revealed, so later steps can be read against earlier ones.\n */\n\nconst MAX_STEPS = 50;\n\nexport const WorkedStep = z\n .object({\n label: z.string().trim().min(1).max(40).optional().describe('Optional heading for this part of the working, e.g. \"Base case\", \"Inductive step\".'),\n statement: z\n .string()\n .trim()\n .min(1)\n .max(1000)\n .describe(\"What this step establishes, mostly as a formula in $...$. For large sums and fractions, put \\\\displaystyle INSIDE the dollars, e.g. $\\\\displaystyle\\\\sum_{i=1}^{n} i$; $$ is not available.\"),\n justification: z.string().trim().min(1).max(500).describe('Why it follows, e.g. \"by the inductive hypothesis\".'),\n })\n .strict();\n\nexport const WorkedStepsSpec = z\n .object({\n title: z.string().trim().min(1).max(120),\n goal: z.string().trim().min(1).max(500).optional().describe(\"Optional statement of what is being shown, e.g. the claim to prove.\"),\n steps: z.array(WorkedStep).min(1).max(MAX_STEPS),\n })\n .strict();\n\nexport type WorkedStepsSpec = z.infer<typeof WorkedStepsSpec>;\nexport type WorkedStep = z.infer<typeof WorkedStep>;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,SAAS;AAOX,IAAM,iBAAiB;AACvB,IAAM,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,cAAc;AAG9D,IAAM,cAAc,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC,EAAE,OAAO;AAGjE,IAAM,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE;AAO5C,IAAM,wBAAwB,EAClC,OAAO;AAAA,EACN,SAAS,YAAY,SAAS,8HAA+H;AAAA,EAC7J,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAI;AAAA,EAC3C,SAAS,EACN,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,EACpE,IAAI,CAAC,EACL,IAAI,CAAC,EACL,SAAS,6JAA6J;AAAA,EACzK,oBAAoB,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,6CAA6C;AAAA,EACzG,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS,gFAAgF;AAC1I,CAAC,EACA,OAAO,EACP,YAAY,CAAC,MAAM,QAAQ;AAC1B,MAAI,KAAK,sBAAsB,KAAK,QAAQ,QAAQ;AAClD,QAA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