mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:39:47 +08:00
A broad consolidation release across four product surfaces. - Learning Space: Space becomes a learning dashboard; My Agents imports local Claude Code / Codex chat history into resumable agents (with an objective explore_context briefing so the tutor never role-plays the user); Memory is promoted to a top-level /memory route; Partner conversations flow into Memory; EduHub skills install inline. - Knowledge Center: /knowledge rebuilt as a console with per-engine detail pages; GraphRAG / PageIndex / LightRAG engines join LlamaIndex; linked-KB read-only mounts; Obsidian live-vault capability. - Settings: pluggable document parsing (MinerU / Docling / MarkItDown) with a content-addressed cache and MinerU cloud/local backends; voice TTS/STT; image & video generation; rebuilt settings navigation. - Platform: per-user capability gating by assigned model; Solve rebuilt on the chat loop with a per-step gate and mid-run failure fallback; username login + inline errors; CLI skill publish/update; picker polish; math-before-citation render fix. Docs were split out to a standalone site, so site/ is now landing-page only. Bumps __version__ to 1.4.6 and adds assets/releases/ver1-4-6.md. Folds in mypy fixes surfaced by pre-commit (mineru/local Path typing, knowledge/manager no-redef, explore_context token kwargs, CLI set_dist_tag capability probe) plus prettier reformatting of previously-committed web files. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
/**
|
|
* Map imported sessions (which live on the backend) back to the client-side
|
|
* agents that own them. An agent's identity lives in IndexedDB, so this is how
|
|
* both the Space management page and the chat reference picker decide which
|
|
* conversations belong to which named agent.
|
|
*/
|
|
|
|
import type { SessionSummary } from "@/lib/session-api";
|
|
import type { ImportAgent } from "./agent-store";
|
|
import { epochMsToISODate } from "./shared";
|
|
import type { AgentScope, ImportSource } from "./types";
|
|
|
|
export interface SessionImportMeta {
|
|
source: ImportSource;
|
|
sourceCwd: string;
|
|
agentId?: string;
|
|
}
|
|
|
|
export function readImportMeta(
|
|
session: SessionSummary,
|
|
): SessionImportMeta | null {
|
|
const imp = (
|
|
session.preferences as
|
|
| { import?: { source?: string; source_cwd?: string; agent_id?: string } }
|
|
| undefined
|
|
)?.import;
|
|
const src = imp?.source;
|
|
if (src !== "claude_code" && src !== "codex") return null;
|
|
return {
|
|
source: src,
|
|
sourceCwd: imp?.source_cwd ?? "",
|
|
agentId: imp?.agent_id || undefined,
|
|
};
|
|
}
|
|
|
|
/** Which selection unit a session falls under, for scope membership tests. */
|
|
export function sessionUnitKey(
|
|
source: ImportSource,
|
|
meta: SessionImportMeta,
|
|
createdAtSec: number,
|
|
): string {
|
|
return source === "codex"
|
|
? epochMsToISODate(createdAtSec * 1000)
|
|
: meta.sourceCwd;
|
|
}
|
|
|
|
export function scopeContainsSession(
|
|
scope: AgentScope,
|
|
meta: SessionImportMeta,
|
|
createdAtSec: number,
|
|
): boolean {
|
|
if (scope.kind === "all") return true;
|
|
if (scope.kind === "projects") return scope.cwds.includes(meta.sourceCwd);
|
|
return scope.days.includes(epochMsToISODate(createdAtSec * 1000));
|
|
}
|
|
|
|
/**
|
|
* Assign each imported session to exactly one agent: by explicit `agent_id`
|
|
* when present, else by source + scope membership. The fallback re-attaches
|
|
* conversations imported before the agent model and migrated legacy agents
|
|
* (whose scope is `all`). Returns sessionId → agentId; unmatched maps to null.
|
|
*/
|
|
export function assignSessionsToAgents(
|
|
sessions: SessionSummary[],
|
|
agents: ImportAgent[],
|
|
): Map<string, string | null> {
|
|
const byId = new Map(agents.map((a) => [a.id, a]));
|
|
const out = new Map<string, string | null>();
|
|
for (const session of sessions) {
|
|
const sid = session.session_id || session.id;
|
|
const meta = readImportMeta(session);
|
|
if (!meta) {
|
|
out.set(sid, null);
|
|
continue;
|
|
}
|
|
if (meta.agentId && byId.has(meta.agentId)) {
|
|
out.set(sid, meta.agentId);
|
|
continue;
|
|
}
|
|
const owner = agents.find(
|
|
(a) =>
|
|
a.source === meta.source &&
|
|
scopeContainsSession(a.scope, meta, session.created_at),
|
|
);
|
|
out.set(sid, owner?.id ?? null);
|
|
}
|
|
return out;
|
|
}
|