mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 06:09:33 +08:00
Bind mastery drafts before their opening turn and preserve stored session modes. Track chat duration from submission through terminal completion. Run async reading extensions on their event loop and allow retries after cancellable timeouts. Allow first uploads into empty LlamaIndex knowledge bases, preserve Telegram thread routing, parse embedding Retry-After dates, and enforce robots rules and host pacing during documentation crawls, including redirects. Fixes #1461 Fixes #1458 Fixes #1451 Fixes #1448 Fixes #1392 Fixes #1429 Refs #1435, #1412 Reuses contributions from PRs #1462, #1452 and #1403. Co-authored-by: sjagadee <srini.jagadeesh@gmail.com> Co-authored-by: AoHanBei <dongaohan21@gmail.com> Co-authored-by: Gao-Chenkai <DevChenkai@outlook.com>
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
export interface MasteryDraftRouteGuard {
|
|
routeKey: string;
|
|
previousSessionId: string | null;
|
|
}
|
|
|
|
/**
|
|
* A draft route starts while UnifiedChatContext may still expose the session
|
|
* that was visible on the previous page. Only promote the URL after the
|
|
* backend has bound a different session to this draft.
|
|
*/
|
|
export function isMasteryDraftSessionReady({
|
|
guard,
|
|
routeKey,
|
|
sessionId,
|
|
masteryPathId,
|
|
pathId,
|
|
}: {
|
|
guard: MasteryDraftRouteGuard | null;
|
|
routeKey: string;
|
|
sessionId: string | null;
|
|
masteryPathId: string | null;
|
|
pathId: string;
|
|
}): boolean {
|
|
return Boolean(
|
|
guard &&
|
|
guard.routeKey === routeKey &&
|
|
sessionId &&
|
|
sessionId !== guard.previousSessionId &&
|
|
masteryPathId === pathId,
|
|
);
|
|
}
|
|
|
|
/** Sending the first turn requires a committed local draft, not a server ID. */
|
|
export function isMasteryDraftSendReady(input: {
|
|
binding: { routeKey: string; draftKey: string } | null;
|
|
routeKey: string;
|
|
sessionKey: string;
|
|
workspaceMode: string | null;
|
|
masteryPathId: string | null;
|
|
pathId: string;
|
|
masterySessionMode: string | null;
|
|
requestedMode: string;
|
|
}): boolean {
|
|
return Boolean(
|
|
input.binding &&
|
|
input.binding.routeKey === input.routeKey &&
|
|
input.binding.draftKey === input.sessionKey &&
|
|
input.workspaceMode === "mastery_path" &&
|
|
input.masteryPathId === input.pathId &&
|
|
input.masterySessionMode === input.requestedMode,
|
|
);
|
|
}
|