Fifth revision: share-link AI safety, sturdier generation, cleaner UI
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 1m0s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 1m0s
- Malformed model JSON is sent back for repair, then retried; a failed job starts over once before it fails. Visitors can dismiss failed sets. - Generated sets get a short distinct name and description; flashcards are atomic and have no hints; standard study shows known/learning counts. - Share links: "In progress" list, finished sets join the normal lists with a "New" tag, plain progress steps, newest exam first. - Share-link AI expires after a week, can be limited to the US or Arizona (DB-IP Lite or Cloudflare headers) and is locked by abuse protection (migration 8). - The assistant never answers from general knowledge; MCP and web search tools load without a manual test. - Plain-text copy, no question count in exam mode, filler text removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d8df5edf30
commit
85d5c9186d
46 changed files with 1242 additions and 283 deletions
53
docs/AI.md
53
docs/AI.md
|
|
@ -91,6 +91,17 @@ has no calculations. Topics are kept broad ("Stroke", not "Right hemisphere stro
|
|||
prompt lists the class's existing topics, and narrower labels that contain an existing one are
|
||||
merged into it after generation.
|
||||
|
||||
Flashcards are atomic: one fact per card, the back only the answer (a word, number or short
|
||||
phrase), and no hints (the schema has no hint field any more). When generation finishes, one
|
||||
small call names the set: a 2-6 word title for what it covers, different from the class's other
|
||||
titles (a clash gets a number), and a one-sentence description. The generic title stays if
|
||||
naming fails.
|
||||
|
||||
Malformed output: tool-call arguments that `jsonrepair` cannot fix are sent back to the model to
|
||||
be rewritten as valid JSON (`repairStructured` in `server/ai/service.ts`); if that fails the
|
||||
request is asked once more. A job that still fails on bad output or a passing provider error
|
||||
starts over once with the same request ("Starting over"); a second failure fails the draft.
|
||||
|
||||
## MCP servers
|
||||
|
||||
Settings → AI → MCP servers connects Model Context Protocol servers over Streamable HTTP
|
||||
|
|
@ -140,6 +151,16 @@ arguments (`session_id`, `client_model`) are hidden from the model, and ids, usa
|
|||
warnings are stripped from results. It is on for chat and Explain by default (off in tests),
|
||||
with its own instructions and area switches like any server.
|
||||
|
||||
Tools load without a manual test: the server connects to every enabled MCP server (and the web
|
||||
search) a few seconds after start, again every few minutes, and right after a server is saved
|
||||
or signed in to. A listing that fails is retried once on a fresh connection before the server
|
||||
is reported as unavailable for that turn.
|
||||
|
||||
The assistant never answers factual questions from its own knowledge. When the class materials
|
||||
do not cover a question it asks "Search the web" or "No, skip it", and if the student skips it
|
||||
says it has no information to answer. Without the web search it says so straight away. The
|
||||
shared assistant answers only from the shared material (and web results, when allowed).
|
||||
|
||||
### Tool steps
|
||||
|
||||
Every tool call shows as one line: an icon for the kind of tool, a friendly name ("Searched
|
||||
|
|
@ -214,6 +235,29 @@ Each share link has two switches, both off by default:
|
|||
Neither has library tools; MCP servers join only when allowed on share links. Both use the
|
||||
owner's models and keys and show only when an AI model is configured.
|
||||
|
||||
AI on a link lasts a week: turning any switch on starts it, and it switches itself off
|
||||
afterwards (`shares.ai_expires_at`, migration 8). The share dialog shows the end date with
|
||||
**Extend a week**; once lapsed, **Turn on for a week** brings back the same switches, while
|
||||
turning a single switch on starts a fresh week with only that feature.
|
||||
|
||||
**Region** (Settings → Sharing → AI on public links): Anywhere, United States (default) or
|
||||
Arizona. Visitors elsewhere still see and study everything, but the page shows no AI and the
|
||||
API answers 403 `ai_region`. The location comes from Cloudflare's `CF-IPCountry` and
|
||||
`CF-Region-Code` headers when `TRUST_PROXY` is on, otherwise from the free DB-IP Lite database
|
||||
(CC BY 4.0), downloaded monthly into `DATA_DIR/geoip` from db-ip.com with the ip-location-db
|
||||
mirror on jsDelivr as a fallback (country file about 8 MB; Arizona also needs the city file,
|
||||
over 100 MB, held in memory). Visitor addresses are never sent anywhere. Private and loopback
|
||||
addresses count as local and are allowed; a public address that can't be placed is refused.
|
||||
State-level location is approximate: mobile networks can appear to be in another state.
|
||||
Settings shows the database dates, the last day's allowed and blocked checks, and a warning when
|
||||
every visitor looks local (the proxy is not passing real addresses).
|
||||
|
||||
**Abuse protection** turns a link's AI off (`shares.ai_blocked`, with the reason) when, within
|
||||
an hour, it is used from 25 different networks or 40 different browsers, gets 60 requests in
|
||||
five minutes, or keeps being refused (10 requests from outside the region, which the page never
|
||||
offers, or 30 over the per-device limit). The owner sees why in the share dialog and can turn it
|
||||
back on. Thresholds are `ABUSE` in `server/routes/shares.ts`.
|
||||
|
||||
Limits are per device, not per IP address, so students on one campus network do not share an
|
||||
allowance: each browser gets a random visitor id in a signed, HTTP-only cookie
|
||||
(`sd_visitor`, scoped to `/api/public`), limited to 20 requests per 10 minutes per link. A
|
||||
|
|
@ -232,9 +276,12 @@ select-all and the Python check. A link may make 4 quizzes and 2 flashcard sets
|
|||
midnight, failed attempts not counted), on top of the per-device request limit; **Reset
|
||||
limits** in the share dialog starts a fresh allowance. Each set is a draft tied to the link
|
||||
(`drafts.share_id`, migration 7): it shows in the owner's Drafts while it is written, then is
|
||||
saved into the class (and the exam, for an exam link) as if the owner had approved it, with the
|
||||
description "Made with AI on a share link". From then on it is ordinary class material: the
|
||||
link lists it with everything else, and Explain works on it. If the automatic save fails, the
|
||||
saved into the class (and the exam, for an exam link) as if the owner had approved it, with its
|
||||
generated name and description. From then on it is ordinary class material: the link lists it
|
||||
with everything else (marked "New" for two hours), and Explain works on it. While it is written
|
||||
the link shows it under "In progress" with plain steps ("Verifying questions" rather than the
|
||||
Python details). A failed set stays there until a visitor dismisses it
|
||||
(`drafts.share_hidden`); the owner still sees it in Drafts. If the automatic save fails, the
|
||||
draft waits in Drafts for review. Deleting the link keeps what was made on it (running jobs
|
||||
finish and save too).
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue