feat: admit signed native composition module
This commit is contained in:
parent
7673c337fc
commit
593d5e5884
22 changed files with 1735 additions and 28 deletions
|
|
@ -2,6 +2,7 @@ import { StrictMode, useCallback, useEffect, useMemo, useRef, useState } from 'r
|
|||
import { createRoot } from 'react-dom/client'
|
||||
import { numberedInvoke as invoke } from './modules/numbered-ipc'
|
||||
import { splitFrontmatter, documentOutline, jumpToHeading, MarkdownDocument, markdownHtml } from './modules/knowledge-render'
|
||||
import { NativeCompositionStudio, type CompositionDimension, type CompositionMeasure, type NativeCompositionProjection, type ProjectionView } from './modules/native-composition'
|
||||
|
||||
const TAG_TINTS = ['tag-lavender', 'tag-sky', 'tag-mint', 'tag-amber', 'tag-rose', 'tag-slate']
|
||||
|
||||
|
|
@ -48,10 +49,21 @@ import './design-tokens.css'
|
|||
import './styles.css'
|
||||
|
||||
type ThemeId = 'night' | 'dawn' | 'nebula' | 'candle' | 'clear'
|
||||
type ViewId = 'overview' | 'knowledge' | 'code' | 'receipts' | 'system'
|
||||
type ViewId = 'overview' | 'knowledge' | 'composition' | 'code' | 'receipts' | 'system'
|
||||
type WorldStage = 'domain' | 'heart' | 'heartbeat' | 'lightLake' | 'love' | 'tomorrow' | 'bottle' | 'channel' | 'enterpriseWork' | 'personalNodeGuide' | 'tool'
|
||||
type KnowledgeSource = 'native' | 'legacy'
|
||||
|
||||
interface BundledModuleDescriptor {
|
||||
moduleNumber: string
|
||||
displayName: string
|
||||
version: string
|
||||
adapter: string
|
||||
permissions: string[]
|
||||
packageSha256: string
|
||||
installedState: string
|
||||
signatureVerified: boolean
|
||||
}
|
||||
|
||||
interface HomeStatus {
|
||||
directLocalBrokerState: string
|
||||
directConnectionCount: number
|
||||
|
|
@ -351,7 +363,7 @@ const previewCode: CodeChannelSnapshot = { state: 'UNAVAILABLE', channels: [], a
|
|||
const themes: Array<{ id: ThemeId; name: string }> = [
|
||||
{ id: 'night', name: '夜湖星光' }, { id: 'dawn', name: '晨湖曦光' }, { id: 'nebula', name: '星云紫夜' }, { id: 'candle', name: '烛畔暖湖' }, { id: 'clear', name: '清浅澄湖' },
|
||||
]
|
||||
const viewLabels: Record<ViewId, string> = { overview: '个人频道', knowledge: '知识空间', code: '人格代码频道', receipts: '运行回执', system: '系统详情' }
|
||||
const viewLabels: Record<ViewId, string> = { overview: '个人频道', knowledge: '知识空间', composition: '结构组合', code: '人格代码频道', receipts: '运行回执', system: '系统详情' }
|
||||
const domainGates = [
|
||||
{ domain: 'BRANCH_DOMAIN', className: 'd-sub', title: '光湖分域', gate: 'GATE 02 · ONLINE', facts: [
|
||||
['域标识', 'BRANCH_DOMAIN'], ['责任主体', '花尔 · TCS-GL-0005∞'], ['人格体主体', '爆米花 · PER-BMH001 · AGE'], ['关系支持', '糖星云 · PER-TXY001 · AGE'], ['工作仓库', 'PRIVATE · 1 · LIVE'],
|
||||
|
|
@ -577,6 +589,13 @@ function HoloLakeApp() {
|
|||
const [searchResults, setSearchResults] = useState<KnowledgeSearchResult[] | null>(null)
|
||||
const [knowledgeBusy, setKnowledgeBusy] = useState(false)
|
||||
const [knowledgeMessage, setKnowledgeMessage] = useState('')
|
||||
const [compositionModule, setCompositionModule] = useState<BundledModuleDescriptor | null>(null)
|
||||
const [compositionProjection, setCompositionProjection] = useState<NativeCompositionProjection | null>(null)
|
||||
const [compositionDimension, setCompositionDimension] = useState<CompositionDimension>('TOP_LEVEL_FOLDER')
|
||||
const [compositionMeasure, setCompositionMeasure] = useState<CompositionMeasure>('DOCUMENT_COUNT')
|
||||
const [compositionViews, setCompositionViews] = useState<ProjectionView[]>(['DASHBOARD', 'VERTICAL_BAR', 'TABLE'])
|
||||
const [compositionBusy, setCompositionBusy] = useState(false)
|
||||
const [compositionMessage, setCompositionMessage] = useState('')
|
||||
const [expanded, setExpanded] = useState<Set<string>>(() => new Set(['导入']))
|
||||
const [editing, setEditing] = useState(false)
|
||||
const [draft, setDraft] = useState('')
|
||||
|
|
@ -1015,6 +1034,51 @@ function HoloLakeApp() {
|
|||
finally { setKnowledgeBusy(false) }
|
||||
}
|
||||
|
||||
const refreshCompositionModule = async () => {
|
||||
try {
|
||||
const catalog = await invoke<BundledModuleDescriptor[]>('get_bundled_module_catalog')
|
||||
const module = catalog.find((item) => item.moduleNumber === 'HLP-MOD-LOCAL-NATIVE-COMPOSITION-0001') || null
|
||||
setCompositionModule(module)
|
||||
return module
|
||||
} catch (error) {
|
||||
setCompositionMessage(humanError(error, 'system'))
|
||||
return null
|
||||
}
|
||||
}
|
||||
const executeComposition = async () => {
|
||||
setCompositionBusy(true)
|
||||
setCompositionMessage('')
|
||||
try {
|
||||
const projection = await invoke<NativeCompositionProjection>('execute_knowledge_native_composition', {
|
||||
input: { dimension: compositionDimension, measure: compositionMeasure, views: compositionViews },
|
||||
})
|
||||
setCompositionProjection(projection)
|
||||
} catch (error) {
|
||||
setCompositionMessage(humanError(error, 'knowledge'))
|
||||
} finally { setCompositionBusy(false) }
|
||||
}
|
||||
const activateCompositionModule = async () => {
|
||||
setCompositionBusy(true)
|
||||
setCompositionMessage('正在验证签名、登记编号并执行模块自检……')
|
||||
try {
|
||||
await invoke('activate_bundled_module', {
|
||||
input: {
|
||||
moduleNumber: 'HLP-MOD-LOCAL-NATIVE-COMPOSITION-0001',
|
||||
humanConfirmedPermissionExpansion: true,
|
||||
},
|
||||
})
|
||||
const module = await refreshCompositionModule()
|
||||
if (!module || module.installedState !== 'ACTIVE') throw new Error('HOLOLAKE_MODULE_NOT_ACTIVE')
|
||||
setCompositionMessage('模块已通过签名、编号、权限与自检验收。')
|
||||
const projection = await invoke<NativeCompositionProjection>('execute_knowledge_native_composition', {
|
||||
input: { dimension: compositionDimension, measure: compositionMeasure, views: compositionViews },
|
||||
})
|
||||
setCompositionProjection(projection)
|
||||
} catch (error) {
|
||||
setCompositionMessage(humanError(error, 'system'))
|
||||
} finally { setCompositionBusy(false) }
|
||||
}
|
||||
|
||||
const cloneCodeChannel = async (event: React.FormEvent) => {
|
||||
event.preventDefault()
|
||||
if (!cloneUrl.trim()) return
|
||||
|
|
@ -1362,6 +1426,31 @@ function HoloLakeApp() {
|
|||
</section>
|
||||
)
|
||||
|
||||
const renderComposition = () => (
|
||||
<section className="full-workbench composition-workspace-world">
|
||||
{compositionModule?.installedState === 'ACTIVE'
|
||||
? <NativeCompositionStudio
|
||||
projection={compositionProjection}
|
||||
dimension={compositionDimension}
|
||||
measure={compositionMeasure}
|
||||
selectedViews={compositionViews}
|
||||
busy={compositionBusy}
|
||||
message={compositionMessage}
|
||||
onDimensionChange={setCompositionDimension}
|
||||
onMeasureChange={setCompositionMeasure}
|
||||
onViewsChange={setCompositionViews}
|
||||
onExecute={() => void executeComposition()}/>
|
||||
: <div className="workbench-empty">
|
||||
<span>组</span>
|
||||
<h2>启用原生组合视图</h2>
|
||||
<p>模块将读取当前账号的知识目录,生成只读仪表盘、对比、柱状图、分类和明细表。它不能修改知识原文,也不执行仓库代码或网页脚本。</p>
|
||||
<code>HLP-MOD-LOCAL-NATIVE-COMPOSITION-0001 · KNOWLEDGE_READ</code>
|
||||
<button className="primary-button" type="button" disabled={compositionBusy} onClick={() => void activateCompositionModule()}>{compositionBusy ? '正在验收模块…' : '确认权限并启用'}</button>
|
||||
{compositionMessage && <p>{compositionMessage}</p>}
|
||||
</div>}
|
||||
</section>
|
||||
)
|
||||
|
||||
const renderCode = () => (
|
||||
<section className="full-workbench code-workbench">
|
||||
<aside className="code-channels">
|
||||
|
|
@ -1573,6 +1662,7 @@ function HoloLakeApp() {
|
|||
<div className="world-location"><h1>明天见频道</h1><p>频道全景 · 湖面按操作继续展开</p></div>
|
||||
<LakePool className="channel-main" title="频道全景" meta="明天见 · 私人生活区" open onClick={() => openWorldTool('overview')}/>
|
||||
<LakePool className="channel-knowledge" title="知识空间" meta={`${knowledge.uniqueDocumentCount} 唯一页`} onClick={() => openWorldTool('knowledge')}/>
|
||||
<LakePool className="channel-light" title="结构组合" meta="签名模块 · 只读知识投影" onClick={() => { openWorldTool('composition'); void refreshCompositionModule() }}/>
|
||||
<LakePool className="channel-code" title="内置代码频道" meta={userPncc?.state === 'READY' ? '明天见 · Git 已就绪' : '正在建立'} onClick={() => openWorldTool('code')}/>
|
||||
<LakePool className="channel-light" title="奶瓶频道" meta="前往陪伴宝宝人格体" onClick={() => setWorldStage('bottle')}/>
|
||||
{timeAuthorityModule && <LakePool className="channel-time" title="时间主控" meta={beijingCoordinate ? `光湖历第 ${beijingCoordinate.guanghuEraDay} 天` : '北京时间正在流动'} onClick={openEraTimeline}/>}
|
||||
|
|
@ -1628,6 +1718,7 @@ function HoloLakeApp() {
|
|||
<div className="world-location"><h1>心跳核心频道</h1><p>冰朔 · ICE-GL∞ · 私人频道全景</p></div>
|
||||
<LakePool className="channel-main" title="频道全景" meta="心跳核心频道" open onClick={() => openWorldTool('overview')}/>
|
||||
<LakePool className="channel-knowledge" title="知识空间" meta={`${knowledge.uniqueDocumentCount} 唯一页`} onClick={() => openWorldTool('knowledge')}/>
|
||||
<LakePool className="channel-light" title="结构组合" meta="签名模块 · 只读知识投影" onClick={() => { openWorldTool('composition'); void refreshCompositionModule() }}/>
|
||||
{timeAuthorityModule && <LakePool className="channel-time" title="时间主控" meta={beijingCoordinate ? `光湖历第 ${beijingCoordinate.guanghuEraDay} 天` : '北京时间正在流动'} onClick={openEraTimeline}/>}
|
||||
<LakePool className="channel-status" title="湖面天气" meta={connectionLabel} onClick={() => openWorldTool('system')}/>
|
||||
</section>}
|
||||
|
|
@ -1640,7 +1731,7 @@ function HoloLakeApp() {
|
|||
</section>}
|
||||
{worldStage === 'tool' && <section className={`world-tool world-tool-${view}`}>
|
||||
<header className="tool-worldbar"><button type="button" onClick={() => setWorldStage(toolReturnStage)}>← 退回频道全景</button><b>{viewLabels[view]}</b><span>{domainDisplayName(repoLogin.domain)}</span></header>
|
||||
<div className={`tool-projection${inspectorOpen ? '' : ' inspector-closed'}`}>{view === 'overview' ? renderOverview() : view === 'knowledge' ? renderKnowledge() : view === 'code' ? renderCode() : view === 'receipts' ? renderReceipts() : renderSystem()}</div>
|
||||
<div className={`tool-projection${inspectorOpen ? '' : ' inspector-closed'}`}>{view === 'overview' ? renderOverview() : view === 'knowledge' ? renderKnowledge() : view === 'composition' ? renderComposition() : view === 'code' ? renderCode() : view === 'receipts' ? renderReceipts() : renderSystem()}</div>
|
||||
</section>}
|
||||
</main>
|
||||
<footer className="world-footer"><b>光湖语言系统 · 通用人工智能操作平台</b><span>GH-AIOS</span></footer>
|
||||
|
|
|
|||
Loading…
Reference in a new issue