The custom-message scheme (user-decided 2026-09-12): system-authored
user-role messages are NOT human messages — they carry marker data parts
only, the adapter owns their model-facing wording, and the UI renders
them under control. Nothing fake is ever persisted as human speech.
The inventory (all migrated):
- probe→teacher handoff wake: was a text-bearing user message rendering
as a fake user bubble; now data-probe-handoff marker-only — the
adapter flattens it to HANDOFF_TEXT (core/contracts/chat.ts), the UI
renders a quiet 'Preparing your plan…' system line.
- plan accept/decline: was boilerplate text ('The plan is accepted…',
'I'd like the plan revised…') masquerading as learner speech — the
decline wasn't even marked; now data-verdict {accepted, at} on its own
message, adapter flattens to verdictText(), UI renders the quiet
verdict marker ('✓ Plan accepted' / '↻ Plan revision requested').
sendVerdict sends TWO REAL MESSAGES when the learner typed a note
(the note as a genuine user message, then the verdict) in ONE turn
via setMessages + sendMessage() — no 409 dance, no double teacher turn.
- sub-agent steers: the abort steer gains its data-subagent-aborted
marker part; the UI keys steer rendering off PARTS (artifact/aborted),
not metadata — metadata stays as pump mechanics only.
- record-adapter: systemTextOf() flattens marker-only messages; steers
keep their text (payload — briefs are content, not boilerplate).
phases.ts: plan→teach advances on data-verdict{accepted:true} only;
learner text alone can never sanction teaching (pinned). data-plan-
accepted retired, no back-compat (user-decided: wiped-data doctrine).
Pinned: record-adapter.test.ts (verdict/handoff flattening, note+verdict
order, steer payload kept, UI-only parts skipped), phases.test.ts
(verdict marker semantics, out-of-order, text-never-fakes), jobs.test.ts
(abort marker part), demos.test.tsx (badge renders off the part, not
metadata).
Live GLM smoke (disposable driver, deleted): probe→conclude→wake→plan→
decline-with-note (revised, still plan)→accept-with-note (teach) — ALL
CHECKS PASS, including marker-only handoff/verdict on the wire and zero
fake human speech in the transcript.
Gates: tsc, lint, build, 335/335.
54 lines
2.3 KiB
TypeScript
54 lines
2.3 KiB
TypeScript
import type { UIMessage } from "ai";
|
|
import type {
|
|
DemoToolInput,
|
|
PlanVerdictData,
|
|
PlanBlockData,
|
|
ProbeDoneInput,
|
|
ProbeDoneResult,
|
|
ResearchToolInput,
|
|
SubagentArtifactData,
|
|
SubagentResultMeta,
|
|
VisualToolInput,
|
|
} from "./contracts.ts";
|
|
import type { AskToolInput, QuestionAnswerData, QuizToolInput } from "./question-core.ts";
|
|
|
|
/**
|
|
* The typed UI message for the teacher chat — gives the frontend typed tool
|
|
* parts ("tool-quiz" / "tool-ask_user_question" / "tool-research" / …) without
|
|
* importing the server-side agent into the client bundle.
|
|
*
|
|
* Question tools are CLIENT-SIDE (no execute): their OUTPUT type is the
|
|
* structured answer record the client builds and sends via addToolOutput.
|
|
* Job tools are SERVER-EXECUTED: their output is the plain-string dispatch
|
|
* acknowledgement (the result later arrives as a steer message — see
|
|
* SubagentSteerMessage in contracts.ts, whose artifact rides the
|
|
* data-subagent-artifact part typed here as DATA_PARTS).
|
|
*/
|
|
export type TeacherUITools = {
|
|
quiz: { input: QuizToolInput; output: QuestionAnswerData };
|
|
ask_user_question: { input: AskToolInput; output: QuestionAnswerData };
|
|
/** The prober's conclusion tool (docs/probe-teach-split.md §2): the
|
|
* input IS the learner assessment; the output confirms the handoff. */
|
|
probe_done: { input: ProbeDoneInput; output: ProbeDoneResult };
|
|
research: { input: ResearchToolInput; output: string };
|
|
demo: { input: DemoToolInput; output: string };
|
|
visual: { input: VisualToolInput; output: string };
|
|
};
|
|
|
|
export type TeacherUIDataParts = {
|
|
"subagent-artifact": SubagentArtifactData;
|
|
/** Plan blocks (wave 4): frozen plan snapshots rendered in the chat flow. */
|
|
"plan-block": PlanBlockData;
|
|
/** The learner's plan verdict (accept/decline): its own user message,
|
|
* carrying ONLY this part — the plan→teach phase seam (docs/probe-
|
|
* teach-split.md §4, the custom-message scheme 2026-09-12). */
|
|
verdict: PlanVerdictData;
|
|
/** The probe→teach handoff wake: the wake pipeline's steer message,
|
|
* carrying ONLY this part (the model-facing text lives in the adapter). */
|
|
"probe-handoff": { chatId: string };
|
|
/** The abort steer's message-type marker (the abort badge renders off it). */
|
|
"subagent-aborted": SubagentResultMeta & { aborted: true };
|
|
};
|
|
|
|
export type TeacherUIMessage = UIMessage<unknown, TeacherUIDataParts, TeacherUITools>;
|