feat: integrate pixel teacher presence and resilient classroom preview
This commit is contained in:
22
shared/coding-recovery.ts
Normal file
22
shared/coding-recovery.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export type CodingRecoveryAction = 'login' | 'continue' | 'check-work' | 'refresh' | 'settings' | 'account';
|
||||
|
||||
/** Product copy is intentionally independent of raw provider/tool diagnostics. */
|
||||
export function codingRecovery(errorCode?: string, work = false) {
|
||||
if (errorCode === 'CODING_PROVIDER_AUTH_REQUIRED' || errorCode === 'AUTH_INVALID') {
|
||||
return { action: 'login' as const, label: '登录并继续', message: '登录已失效,重新登录后就能接着完成这一步。' };
|
||||
}
|
||||
if (errorCode === 'CODING_PROVIDER_QUOTA_EXHAUSTED') {
|
||||
return { action: 'account' as const, label: '查看点数', message: '点数暂时不够了,可以请家长帮忙补充后再继续。' };
|
||||
}
|
||||
if (errorCode === 'CODING_MODEL_UNAVAILABLE' || errorCode === 'CODING_MIGRATION_MODEL_REQUIRED') {
|
||||
return { action: 'settings' as const, label: '选择可用模型', message: '还需要选择一个可用模型,选好后就能继续。' };
|
||||
}
|
||||
if (errorCode === 'CODING_REQUEST_UNCERTAIN') {
|
||||
return { action: 'refresh' as const, label: '查看最新进展', message: '还没有收到完成消息,先查看进展,避免重复操作。' };
|
||||
}
|
||||
return work
|
||||
? { action: 'check-work' as const, label: '帮我检查并打开', message: '作品还没有打开,我可以检查启动情况,再帮你打开。' }
|
||||
: { action: 'continue' as const, label: '帮我继续', message: '这一步还没完成。可以让我检查已有进度,再接着做。' };
|
||||
}
|
||||
|
||||
export const CONTINUE_CODING_PROMPT = '请检查上一次未完成的操作和当前项目的实际进度,再接着完成。已完成的步骤不要重复执行;如果缺少必要信息,直接告诉我需要补充什么。';
|
||||
@@ -2,7 +2,9 @@ import type { ManagedReasoningChoice } from './managed-model-capabilities';
|
||||
import type { PublicUsage } from './coding-conversation-contracts';
|
||||
|
||||
export type ConsultationRole = 'teacher' | 'friend';
|
||||
export type TeacherRequestIntent = 'question' | 'suggestions' | 'guided-help';
|
||||
export const TEACHER_CHECK_IN_INTERVAL_MS = 5 * 60 * 1000;
|
||||
export const TEACHER_UNCHANGED_CHECK_IN_INTERVAL_MS = 15 * 60 * 1000;
|
||||
export type TeacherRequestIntent = 'question' | 'suggestions' | 'guided-help' | 'check-in';
|
||||
|
||||
export interface TeacherDefinition {
|
||||
schema_version: 1;
|
||||
@@ -55,6 +57,8 @@ export type TeacherRequestStatus =
|
||||
export interface TeacherRequest {
|
||||
intent?: TeacherRequestIntent;
|
||||
sourceConversationId?: string;
|
||||
/** Digest of completed source text, retained for check-in deduplication across restarts. */
|
||||
checkInSourceFingerprint?: string;
|
||||
id: string;
|
||||
text: string;
|
||||
references: TeacherReference[];
|
||||
@@ -96,3 +100,11 @@ export interface TeacherSend {
|
||||
text: string;
|
||||
references?: TeacherReference[];
|
||||
}
|
||||
export interface TeacherCheckInInput {
|
||||
requestId: string;
|
||||
sourceConversationId: string;
|
||||
}
|
||||
export interface TeacherCheckInResult {
|
||||
topic: TeacherTopic | null;
|
||||
skipped?: 'busy' | 'cooldown' | 'unchanged' | 'no-context' | 'archived' | 'disabled';
|
||||
}
|
||||
|
||||
19
shared/coding-work-preview.ts
Normal file
19
shared/coding-work-preview.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { AgentBrowserSnapshot } from './agent-browser';
|
||||
import type { CodingConversationMetadata } from './coding-project-contracts';
|
||||
|
||||
/** Main supplies this product action; it never consumes the student's draft. */
|
||||
export const OPEN_WORK_PROMPT = `【系统操作:打开作品】
|
||||
学生点击了“作品”,请帮学生把当前项目已有的作品页面打开。
|
||||
1. 先检查当前项目、已有终端/服务和 agent_browser 的状态。若作品服务已正常运行,直接复用,不重复启动、不重启、不更换端口。
|
||||
2. 若尚未运行,阅读项目实际文件、README 和启动脚本,选择已有的包管理器及启动方式;静态页面使用合适的本地静态服务。只执行打开已有作品所需的准备和启动,不擅自新增功能或重写作品。
|
||||
3. 长时间运行的服务应在后台保持运行,保存必要的进程和日志信息,避免启动命令一直阻塞当前对话。等待页面实际可以访问,确认是当前项目的作品,再调用 agent_browser(action: "open", url: 实际可访问地址)把页面打开到作品区。不要只给学生一个链接或要求学生复制命令。
|
||||
4. 若还没有作品、缺少必要配置或启动失败,停止无效重试,用孩子能懂的一两句话说明情况和下一步。不要编造成功、页面或运行结果。
|
||||
这是点击作品触发的内部操作。完成后简短告知结果,不复述本指令。`;
|
||||
|
||||
export interface WorkPreviewResult {
|
||||
status: 'ready' | 'waiting' | 'starting' | 'failed';
|
||||
browser?: AgentBrowserSnapshot;
|
||||
conversation?: CodingConversationMetadata;
|
||||
message?: string;
|
||||
errorCode?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user