feat(consultation): unify server-distributed agents without fixed roles

This commit is contained in:
2026-09-24 11:56:42 +08:00
parent 248776d855
commit 8a157be4f6
35 changed files with 625 additions and 668 deletions

View File

@@ -1,6 +1,5 @@
import { hostApiFetch, createHostEventSource, ensureHostApiToken } from './host-api';
import type {
ConsultationRole,
TeacherAvailability,
TeacherCheckInInput,
TeacherCheckInResult,
@@ -11,11 +10,14 @@ import type {
TeacherTopic,
TeacherTopicList,
} from '../../shared/coding-teacher';
export function teacherTopicsPath(projectId: string, sourceId: string, role?: ConsultationRole) {
if (role && projectId !== 'preview') return `/api/coding/projects/${encodeURIComponent(projectId)}/${role}-topics`;
export function teacherTopicsPath(projectId: string) {
return projectId === 'preview'
? '/api/coding/teacher-preview/topics'
: `/api/coding/projects/${encodeURIComponent(projectId)}/conversations/${encodeURIComponent(sourceId)}/teacher-topics`;
: `/api/coding/projects/${encodeURIComponent(projectId)}/agent-topics`;
}
/** Read old locally-generated friend histories without copying or rebinding them. */
export function legacyTopicBase(base: string, legacyFriend: boolean) {
return legacyFriend ? base.replace(/agent-topics$/, 'friend-topics') : base;
}
export const teacherApi = {
catalog: () => hostApiFetch<TeacherCatalog>('/api/coding/teacher/teachers'),
@@ -24,9 +26,9 @@ export const teacherApi = {
method: 'POST',
body: JSON.stringify(input),
}),
config: (role: ConsultationRole = 'teacher') =>
config: () =>
hostApiFetch<TeacherAvailability & { definition: TeacherDefinition | null }>(
`/api/coding/${role}/config`
'/api/coding/teacher/config'
),
preview: (draftRevision: number) =>
hostApiFetch<{ payload: TeacherDefinition; draft_revision: number }>(