import { useCallback, useEffect, useRef, useState } from 'react' import { isTauri } from '../mock-tauri' import { fetchFifthDomainDiscovery, type FifthDomainDiscovery } from '../lib/fifthDomainDiscovery' import type { AppLocale, TranslationKey } from '../lib/i18n' import { translate } from '../lib/i18n' import { trackEvent } from '../lib/telemetry' import { openExternalUrl } from '../utils/url' import { useGuanghuRouter } from '../hooks/useGuanghuRouter' import { useGuanghuShanghaiNode } from '../hooks/useGuanghuShanghaiNode' import { useGuanghuWorldLogin } from '../hooks/useGuanghuWorldLogin' import { useGuanghuEnterpriseStatus } from '../hooks/useGuanghuEnterpriseStatus' import type { AiModelTarget } from '../lib/aiTargets' import { createDeterministicLivingSystemPlan, createLivingSystemEvent, createLivingSystemExecutionReceipt, type GuanghuChannelRoute, type GuanghuLivingIntent, type GuanghuLivingSystemPlan, } from '../lib/guanghuLivingSystem' import { GUANGHU_THEMES, type GuanghuTheme } from '../lib/guanghuTheme' import { planGuanghuLivingSystem } from '../utils/planGuanghuLivingSystem' import { Button } from './ui/button' import { HOLOLAKE_REPOSITORY_URL } from '../constants/feedback' import { isEducationWorkLakePath } from '../lib/educationWorkLake' import { GuanghuRouterConsole } from './GuanghuRouterConsole' import { GuanghuWorldMap } from './GuanghuWorldMap' import { GuanghuWorldLoginGate } from './GuanghuWorldLoginGate' import { FifthDomainSystems } from './FifthDomainSystems' import { EternalLakeHeartPage } from './EternalLakeHeartPage' import { EducationWorkLake } from './EducationWorkLake' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from './ui/dialog' export const HOLOLAKE_DEVELOPMENT_REPOSITORY_URL = HOLOLAKE_REPOSITORY_URL export const GUANGHU_THEME_INTENT_EVENT = 'guanghu:living-system-theme-intent' type HoloLakeHomeProps = { locale: AppLocale onEnterKnowledgeBase: () => void onOpenAiWorkspace?: () => void onOpenLocalWorkspace?: () => void | Promise livingSystemTarget?: AiModelTarget | null } type ChannelRoute = GuanghuChannelRoute type RouteCardProps = { action?: string description: string eyebrow: string onOpen?: () => void status?: string title: string } const architectureRoutes: Array<[string, TranslationKey, TranslationKey]> = [ ['GLW-ENTRY-001', 'hololake.architecture.worldEntry', 'hololake.architecture.worldEntryDescription'], ['FD-LANGUAGE-001', 'hololake.architecture.fifthDomain', 'hololake.architecture.fifthDomainDescription'], ['TCS-ROOT-001', 'hololake.architecture.tcs', 'hololake.architecture.tcsDescription'], ['GLS-SYS-ARCH-001', 'hololake.architecture.gls', 'hololake.architecture.glsDescription'], ['ELH-LAMP-001', 'hololake.architecture.lakeLamp', 'hololake.architecture.lakeLampDescription'], ] function RouteCard({ action, description, eyebrow, onOpen, status, title }: RouteCardProps) { return (
{eyebrow}

{title}

{description}

{onOpen && action ? : {status}}
) } function PersonaRoute({ id, title }: { id: string; title: string }) { return
  • {id}{title}
  • } export function HoloLakeHome({ locale, onEnterKnowledgeBase, onOpenAiWorkspace, onOpenLocalWorkspace, livingSystemTarget, }: HoloLakeHomeProps) { const initialRoute: ChannelRoute = isEducationWorkLakePath(window.location.pathname) ? 'education-work-lake' : 'world' const [route, setRoute] = useState(initialRoute) const [livingPlan, setLivingPlan] = useState(() => ( createDeterministicLivingSystemPlan(createLivingSystemEvent({ currentRoute: initialRoute, eventId: 'system-start', intent: 'navigate', receiptIds: [], requestedRoute: initialRoute, worldOpen: false, })) )) const [livingKernel, setLivingKernel] = useState<'server' | 'model' | 'fallback' | 'planning'>('fallback') const [livingReceiptId, setLivingReceiptId] = useState('local-state:system-start') const [livingServerReceiptId, setLivingServerReceiptId] = useState() const [architectureOpen, setArchitectureOpen] = useState(false) const [releaseNotesOpen, setReleaseNotesOpen] = useState(false) const [fifthDomainConnection, setFifthDomainConnection] = useState< { status: 'checking' | 'error' } | { status: 'connected'; discovery: FifthDomainDiscovery } >({ status: 'checking' }) const router = useGuanghuRouter() const login = useGuanghuWorldLogin() const enterprise = useGuanghuEnterpriseStatus() const shanghai = useGuanghuShanghaiNode() const restoreAttempted = useRef(false) const livingRequestSequence = useRef(0) const worldOpen = login.state.phase === 'online' const fifthDomainOpen = worldOpen && route !== 'world' const worldRouterState = router.state const activeRouterReceipt = worldRouterState.status === 'online' && worldRouterState.latestReceipt?.state === 'online' ? worldRouterState.latestReceipt : null const t = (key: TranslationKey) => translate(locale, key) const applyLivingPlan = useCallback(( plan: GuanghuLivingSystemPlan, source: 'server' | 'model' | 'fallback', serverReceiptId?: string, ) => { setLivingPlan(plan) setLivingKernel(source) setLivingServerReceiptId(serverReceiptId) setRoute(plan.navigationAction.route) }, []) const recordLivingExecution = useCallback(( plan: GuanghuLivingSystemPlan, source: 'server' | 'model' | 'fallback', outcome: 'executed' | 'failed', evidence: string[], error?: string, serverReceiptId?: string, ) => { const receipt = createLivingSystemExecutionReceipt({ plan, source, outcome, evidence, error, }) setLivingReceiptId(receipt.receiptId) trackEvent('guanghu_living_system_receipt', { eventId: receipt.eventId, outcome: receipt.outcome, planId: receipt.planId, receiptId: receipt.receiptId, route: receipt.route, source: receipt.source, evidence: receipt.evidence.join(','), ...(serverReceiptId ? { serverReceiptId } : {}), }) }, []) const navigate = useCallback(( nextRoute: ChannelRoute, intent: GuanghuLivingIntent = 'navigate', onAccepted?: () => void | Promise, appearanceTheme?: GuanghuTheme, ) => { trackEvent('guanghu_channel_opened', { intent, route: nextRoute }) const sequence = livingRequestSequence.current + 1 livingRequestSequence.current = sequence const receiptIds = [worldRouterState.latestReceipt?.receipt_id, login.state.workorderId] .filter((receiptId): receiptId is string => Boolean(receiptId)) const event = createLivingSystemEvent({ currentRoute: route, eventId: `ui-${sequence}`, intent, receiptIds: [...new Set(receiptIds)], requestedRoute: nextRoute, appearanceTheme, worldOpen, }) const executeAcceptedPlan = async ( plan: GuanghuLivingSystemPlan, source: 'server' | 'model' | 'fallback', serverReceiptId?: string, ) => { applyLivingPlan(plan, source, serverReceiptId) const routeAccepted = plan.intent === intent && plan.navigationAction.route === nextRoute try { if (routeAccepted && onAccepted) { await onAccepted() } const evidence = [ `ui.route:${plan.navigationAction.route}`, ...(routeAccepted && onAccepted && plan.capabilityCall ? [`capability.${plan.capabilityCall.capabilityId}.result`] : []), ] recordLivingExecution(plan, source, 'executed', evidence, undefined, serverReceiptId) } catch (error) { recordLivingExecution( plan, source, 'failed', [`ui.route:${plan.navigationAction.route}`], error instanceof Error ? error.message : 'host_action_failed', serverReceiptId, ) } } if (!isTauri() && !livingSystemTarget) { void executeAcceptedPlan(createDeterministicLivingSystemPlan(event), 'fallback') return } setLivingKernel('planning') void planGuanghuLivingSystem({ event, target: livingSystemTarget }).then(result => { if (livingRequestSequence.current !== sequence) return void executeAcceptedPlan(result.plan, result.source, result.serverReceiptId) }) }, [ applyLivingPlan, livingSystemTarget, login.state.workorderId, recordLivingExecution, route, worldOpen, worldRouterState.latestReceipt?.receipt_id, ]) const openArchitecture = () => { trackEvent('guanghu_architecture_opened', { route: 'GLS-SYS-ARCH-001' }) setArchitectureOpen(true) } const openDevelopmentRepository = () => { trackEvent('hololake_development_repository_opened', { route: 'REPO-014' }) void openExternalUrl(HOLOLAKE_DEVELOPMENT_REPOSITORY_URL) } const openKnowledgeBase = () => { trackEvent('guanghu_channel_module_opened', { channel: 'heartbeat-core', module: 'knowledge-base' }) navigate(route, 'open-knowledge', onEnterKnowledgeBase) } const openLocalWorkspace = () => { trackEvent('local_computer_workspace_opened', { source: 'heartbeat-core' }) navigate(route, 'open-local-workspace', onOpenLocalWorkspace) } const openAiWorkspace = () => { trackEvent('guanghu_channel_module_opened', { channel: 'heartbeat-core', module: 'persona-ai-workspace' }) navigate(route, 'open-agent-workspace', onOpenAiWorkspace) } useEffect(() => { const handleThemeIntent = (event: Event) => { const theme = (event as CustomEvent).detail if ( typeof theme !== 'string' || !(GUANGHU_THEMES as readonly string[]).includes(theme) ) return navigate(route, 'apply-theme', undefined, theme as GuanghuTheme) } window.addEventListener(GUANGHU_THEME_INTENT_EVENT, handleThemeIntent) return () => window.removeEventListener(GUANGHU_THEME_INTENT_EVENT, handleThemeIntent) }, [navigate, route]) useEffect(() => { if ( !worldOpen || restoreAttempted.current || router.state.status !== 'offline' ) return restoreAttempted.current = true trackEvent('guanghu_world_session_restore_requested', { node: 'JD-FD-PRIMARY', source: 'email-authorized-login', }) void router.connect() }, [router, worldOpen]) useEffect(() => { if (route !== 'servers' || fifthDomainConnection.status !== 'checking') return const controller = new AbortController() void fetchFifthDomainDiscovery(fetch, controller.signal).then(discovery => { setFifthDomainConnection({ status: 'connected', discovery }) trackEvent('fifth_domain_connection_checked', { access: discovery.access, result: 'connected' }) }).catch(() => { if (controller.signal.aborted) return setFifthDomainConnection({ status: 'error' }) trackEvent('fifth_domain_connection_checked', { access: 'public-read-only', result: 'error' }) }) return () => controller.abort() }, [fifthDomainConnection.status, route]) const renderRoute = () => { if (route === 'world') { return ( navigate(worldOpen ? 'fifth-domain' : 'world-login')} onOpenLibrary={openArchitecture} onOpenReceipt={() => navigate('servers')} onOpenZeroCore={() => navigate('zero-core')} router={worldRouterState} shanghai={shanghai.state} worldOpen={worldOpen} /> ) } if (route === 'world-login') { return ( navigate('world')} onCheck={() => void login.claim()} onLogin={() => worldOpen ? navigate('fifth-domain') : void login.requestLogin()} state={login.state} /> ) } if (route === 'zero-core') { return (

    ZERO CORE · 000

    {t('hololake.channel.zeroCoreTitle')}

    {t('hololake.channel.zeroCoreDescription')}

    ) } if (route === 'fifth-domain') { return ( navigate('eternal-lake-heart')} onEnterPufferfish={() => navigate('pufferfish')} /> ) } if (route === 'pufferfish') { return ( navigate('eternal-lake-heart')} onEnterPufferfish={() => navigate('pufferfish')} /> ) } if (route === 'eternal-lake-heart') { return ( navigate('fifth-domain')} onEnterHeartbeat={() => navigate('heartbeat-core')} onEnterLightLake={() => navigate('light-lake')} onEnterLoveCore={() => navigate('love-core')} router={worldRouterState} /> ) } if (route === 'light-lake') { return (

    {t('hololake.channel.lightLakeTitle')}

    {t('hololake.channel.lightLakeDescription')}

    ) } if (route === 'love-core') { return (

    {t('hololake.channel.loveCoreTitle')}

    {t('hololake.channel.loveCoreDescription')}

    ) } if (route === 'education-work-lake') { return } if (route === 'servers') { return (

    FIFTH DOMAIN · ACTIVE PATH

    第五域连接

    这里不是服务器列表,而是冰朔当前进入光湖世界的真实路径与回执。

    {activeRouterReceipt ? '第五域连接已回执' : '光湖身份已授权'} {activeRouterReceipt ? `第五域 · ${activeRouterReceipt.node_id}` : '等待真实节点回执'}
    {activeRouterReceipt ? '当前世界节点' : '登记目标节点'} {activeRouterReceipt?.node_id ?? 'JD-FD-PRIMARY'}

    {activeRouterReceipt ? '第五域连接已由节点回执证明' : '尚未把身份授权误报为节点连接'}

    身份
    冰朔
    身份会话
    {worldOpen ? '已授权' : '未授权'}
    节点连接
    {activeRouterReceipt ? '已回执' : '未回执'}
    公开发现入口
    {fifthDomainConnection.status === 'connected' ? '可用' : fifthDomainConnection.status === 'error' ? '失败' : '检查中'}
    ) } return (

    {t('hololake.channel.heartbeatTitle')}

    {t('hololake.channel.heartbeatDescription')}

    navigate('education-work-lake')} /> navigate('servers')} />
    ) } return (
    {livingKernel === 'planning' ? '活系统正在适配' : livingKernel === 'server' ? '服务器模型已回执' : livingKernel === 'model' ? '本地模型已适配' : '安全执行路径'} {livingKernel === 'server' ? '真实节点' : livingKernel === 'planning' ? '请稍候' : '可继续操作'}
    {worldOpen && route !== 'world-login' ? <>
    {activeRouterReceipt ? '第五域连接已回执' : '光湖身份已授权'} {activeRouterReceipt ? `第五域 · ${activeRouterReceipt.node_id}` : fifthDomainOpen ? '域内界面已打开 · 节点未回执' : '世界入口 · 等待域跳转'}
    {fifthDomainOpen && onOpenAiWorkspace ? : null}
    {route !== 'world' && } {renderRoute()} : renderRoute()}
    {worldOpen && } {t('hololake.architecture.title')} {t('hololake.architecture.description')}
      {architectureRoutes.map(([id, title, description]) => (
    1. {id}
      {t(title)}

      {t(description)}

    2. ))}

    GLW-ENTRY-001 → FD-LANGUAGE-001 → TCS-ROOT-001 → GLS-SYS-ARCH-001 → ELH-LAMP-001

    HoloLake Era 内测版 0.4.6 · 本次更新 更可靠的内置 AI、可验证的工具执行,以及由人格体按需深入的 HLDP 结构化上下文。

    真实光湖世界与第五域会话

    启动后会恢复第五域签名路由,并把企业节点公开状态投影到世界拓扑。只有收到真实回执的节点才会点亮;在线只读、执行关闭和连接失败都会原样显示,不用静态占位冒充服务状态。

    轻量星系主题系统

    世界首页、节点地图与第五域频道使用同一套星系视觉语言。主题以静态压缩资源和少量透明度、位移动效实现,并尊重系统的“减少动态效果”设置,避免持续旋转与高成本滤镜。

    内置知识库 Agent

    AI 可以连续搜索、读取、新建、写入、编辑和删除页面,并根据每一步真实回执继续处理,不再把“准备操作”误报成“已经完成”。

    主动联网调研

    新增公开网页搜索与页面读取。AI 可主动查找资料、打开相关结果并附上来源;仅允许公共 HTTPS 页面,不包含登录、内网访问或替用户执行外部操作。

    聊天历史与中文过程提示

    恢复历史会话显示;工具区会用中文说明正在搜索什么、读取哪个页面、写入是否成功,同时仍可展开查看原始输入和结果。

    竖向聊天历史

    侧边 AI 工作区改为可独立滚动的竖向会话列表,长标题自动收起;支持归档、恢复和带二次确认的永久删除。

    更自然的当前实例

    身份与权限边界继续由事实约束,但不再要求背诵固定自我介绍。当前实例可以结合对话,自主组织语气、详略和表达风格。

    多模型 API 兼容

    按接口能力协商工具参数与多轮执行,覆盖 OpenAI 兼容接口、DeepSeek、Qwen、Gemini、OpenRouter、Anthropic、Ollama 与 LM Studio 等常见路线。模型或服务端不支持某项能力时会明确提示或安全降级。

    HLDP 协作记忆与本地心跳

    HLDP 已作为内置技能自动加载。协作过程以追加式纯文本心跳留在本机,可凭回执恢复和继续记录;会话结束后再由人格体判断哪些内容需要整理与长期保留。

    网页节点树与按需下钻

    长网页不再整页塞进对话或粗暴截断。浏览器 Agent 先整理为 HLDP 节点树,只返回结构摘要;人格体需要细节时,可按文档和节点编号精确展开对应分支。

    浏览器观察链路

    联网搜索、网页读取、节点存储、指定节点展开与当前时间能力已通过人格体实测。浏览器观察看板将沿用同一条回执链展示整理进度;工具链已连通,界面渲染仍作为独立项目持续验收。

    能力边界:内置模式是面向知识库和公开网页的工具 Agent,不等同于拥有终端、代码工程和系统权限的完整编程 Agent。

    ) }