diff --git a/AGENTS.md b/AGENTS.md index 7f6363c..22e5f66 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,12 +16,12 @@ a Tauri 2 shell (planned). Status: Phase 0, pre-alpha. See | `crates/rupok-ink` | Pen input pipeline, wasm-safe | `StrokeBuilder` (wet ink), `filter::OneEuro2`, `pressure::PressureCurve`, `simplify`, `codec::{encode_points, decode_points}` (point codec v1), `MIN_WIDTH_RATIO`, `point_radius`, `math` (handwritten maths → LaTeX), `write` (text + LaTeX → timed handwriting strokes) | | `crates/rupok-core` | Lesson document on Loro | `Lesson` (`doc.rs`: all mutations), model types (`model.rs`: `ItemData`, `StrokeData`, `ObjectData`, `PageSpec`…), `Scene` (`scene.rs`: R*-tree hit-test, eraser, lasso), `DOC_FORMAT` | | `crates/rupok-format` | `.rpk` package and Smart Object bundles (Apache-2.0) | `Package::{read, write, from_lesson, add_asset, content_markdown}`, `readable` (derived `README.md`/`content.md`/`content.json`), `ObjectBundle::{from_single_html, from_files, from_dir, validate}`, `LIBS`, `safe_path`, `FORMAT_VERSION`, `MIMETYPE`, `media` (embed allowlist, `parse_link`, `embed_url`, `prepare`), `model3d` (3D viewer object) | -| `crates/rupok-live` | Live agent bridge shared by the board and `rupok mcp --live` | `protocol.rs` (WebSocket protocol v1: channels, ports, origin/host checks), `op.rs` (`Op`), `apply.rs` (`apply`: one attributed commit per agent op), `attribution.rs`, `sync` | +| `crates/rupok-live` | Live agent bridge shared by the board and `rupok mcp --live` | `protocol.rs` (WebSocket protocol v1: channels, ports, origin/host checks), `op.rs` (`Op`), `apply.rs` (`apply`: one attributed commit per agent op), `fit.rs` (agent text fitted inside the page), `progress.rs` (`show_progress` working cards), `attribution.rs`, `sync` | | `crates/rupok-render` | wgpu ink renderer | `InkRenderer` (SDF capsules, chunk culling, cached dry layer, wet layer), `Camera`, `Gpu::headless`, `ink.wgsl` | | `crates/rupok-wasm` | Board engine and wasm-bindgen API | `engine.rs` (`Engine`: tools, gestures, selection), `lib.rs` (`Board` JS API), `replay.rs`, `shapes.rs` | -| `crates/rupok-cli` | `rupok` binary: CLI and MCP server | `cli.rs` (clap), `ops.rs` (shared operations), `mcp.rs` + `tools.rs` (15 MCP tools), `workspace.rs` (path sandbox), `spec.rs`, `live/` (`LiveHub`: loopback WebSocket, pairing, Loro mirror) + `mcp_live.rs` (live tools; docs/ai-agents.md), `chat/` (`rupok agent`: ACP client relaying the in-app chat) + `mcp_http.rs` (MCP over loopback HTTP for it) | +| `crates/rupok-cli` | `rupok` binary: CLI and MCP server | `cli.rs` (clap), `ops.rs` (shared operations), `mcp.rs` + `tools.rs` (15 MCP tools), `workspace.rs` (path sandbox), `spec.rs`, `live/` (`LiveHub`: loopback WebSocket, pairing, Loro mirror) + `mcp_live.rs` + `mcp_progress.rs` (live tools; docs/ai-agents.md), `chat/` (`rupok agent`: ACP client relaying the in-app chat) + `mcp_http.rs` (MCP over loopback HTTP for it) | | `bench/` | Performance harness and budgets | `cargo run -p rupok-bench --release [-- --check]` | -| `apps/board` | SolidJS board UI (Vite) | `controller.ts`, `objects.ts` (Smart Object host), `media/` + `components/Media*.tsx` (YouTube, video, audio, web embeds), `pdf.ts`, `storage.ts`, `live.ts` + `snapshot.ts` + `components/LivePanel.tsx` (Connect AI), `chat.ts` + `components/ChatPanel.tsx` + `markdown.ts` (AI chat), `components/` | +| `apps/board` | SolidJS board UI (Vite) | `controller.ts`, `objects.ts` (Smart Object host), `media/` + `components/Media*.tsx` (YouTube, video, audio, web embeds), `pdf.ts`, `storage.ts`, `live.ts` + `snapshot.ts` + `components/LivePanel.tsx` (Connect AI), `chat.ts` + `components/ChatPanel.tsx` + `markdown.ts` (AI chat), `aiAction/` (AI in action: working cards, class mode, live solve, students ask), `components/` | | `packages/object-sdk` | In-object SDK, `window.rupok` (Apache-2.0) | `sdk.js` (ES2019 IIFE), `index.d.ts`, `test/` | | `spec/` | Normative specs (Apache-2.0) | `rupok-format.md`, `smart-object.md` | | `examples/objects/` | Validated example Smart Objects | checked by `crates/rupok-format/tests/examples.rs` | diff --git a/apps/board/src/App.tsx b/apps/board/src/App.tsx index 0ffbfcd..f1121cd 100644 --- a/apps/board/src/App.tsx +++ b/apps/board/src/App.tsx @@ -19,6 +19,8 @@ import { overlayRole } from "./overlay/role"; import { registerSettingsOpener } from "./components/ToText"; import LivePanel from "./components/LivePanel"; import ChatPanel from "./components/ChatPanel"; +import AiActionLayer from "./aiAction/AiActionLayer"; +import { initAiAction } from "./aiAction"; import VoiceLayer from "./voice/VoiceLayer"; import { LibraryRoot } from "./components/Library"; import { UpgradeHost } from "./components/Billing"; @@ -111,6 +113,7 @@ export default function App() { setReady(true); startUpdateChecks(); // desktop: new release; web: offline service worker, new build void import("./solve").then((m) => m.initSolve()); // Solve this: AI handwriting, preview, reveal + initAiAction(controller); // AI in action: working cards, class mode, live solve, students ask startLibrary(controller); // the Library home and saving lessons to their files (before files below arrive) // Back from a payment page (?billing=…) or sent by the pricing page (?upgrade=pro). const billingParams = takeBillingParams(); @@ -179,6 +182,8 @@ export default function App() { {/* AI chat with the teacher's own agent (chat.ts, `rupok agent`). */} + {/* AI in action: working cards, Undo toasts, students' own layer (aiAction/). */} + diff --git a/apps/board/src/aiAction/AiActionLayer.tsx b/apps/board/src/aiAction/AiActionLayer.tsx new file mode 100644 index 0000000..6a4c164 --- /dev/null +++ b/apps/board/src/aiAction/AiActionLayer.tsx @@ -0,0 +1,251 @@ +// The "AI in action" layer over the board: working cards where results will +// land, the sparkle when they do, the class-mode Undo toast and destructive +// confirmations, and the students' "Ask AI" box and own layer. + +import { For, Show, createEffect, createSignal, on, onCleanup } from "solid-js"; +import { camera, isView, mode, pageIndex } from "../state"; +import { controller } from "../controller"; +import { liveHasChat } from "../live"; +import { renderMarkdown } from "../markdown"; +import { Icon } from "../components/Icon"; +import { cancelCard, removeCard, retryCard } from "./progress"; +import { aiToast, cards, confirmReq, setAiToast, sparkle, type Card } from "./state"; +import { askOpen, asksLeft, clearStudentLayer, setAskOpen, studentAsk, studentLayer, studentsMayAsk } from "./student"; +import "./aiAction.css"; + +/** Slide px → screen px on the board. */ +function screen(r: { x: number; y: number; w: number; h: number }) { + const [cx, cy, z] = camera(); + return { left: (r.x - cx) * z, top: (r.y - cy) * z, width: r.w * z, height: r.h * z }; +} + +const KIND_ICON: Record = { object: "smartink", handwriting: "pen", text: "text", shape: "rect", other: "smartink" }; + +function Preview(props: { html: string }) { + let frame!: HTMLIFrameElement; + // Re-render when the agent sends a new partial object (debounced a little). + let t: number | undefined; + createEffect(on(() => props.html, (h) => { + clearTimeout(t); + t = window.setTimeout(() => { if (frame) frame.srcdoc = controller.objects.wrap(h); }, 150); + })); + onCleanup(() => clearTimeout(t)); + return ( +
+