feat(consultation): unify server-distributed agents without fixed roles
This commit is contained in:
@@ -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 }>(
|
||||
|
||||
Reference in New Issue
Block a user