diff --git a/build/mother-brain-desktop-app-phase4-20260825/source/hololake-native-desktop/src/main.tsx b/build/mother-brain-desktop-app-phase4-20260825/source/hololake-native-desktop/src/main.tsx new file mode 100644 index 000000000..3e05ca6ef --- /dev/null +++ b/build/mother-brain-desktop-app-phase4-20260825/source/hololake-native-desktop/src/main.tsx @@ -0,0 +1,2335 @@ +import { lazy, StrictMode, Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react' +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' +import type { ChannelWorkbenchSnapshot } from './modules/channel-workbench' +import { StarlakeSurface, type DomainId } from './modules/qoder-surface/StarlakeSurface' +import { FINISHES, TraditionalSurface, type FinishId, type TraditionalBroadcast, type TraditionalChannel, type TraditionalSystem } from './modules/qoder-surface/TraditionalSurface' +import { resolveVisualBalance } from './modules/qoder-surface/visual-balance' +import { PrivateChannelSurface, type InstalledChannelModule, type PrivateChannelAction } from './modules/private-channel/PrivateChannelSurface' +import { HumanAuthorizationCenter, type DirectSessionProjection } from './modules/human-authorization-center' +import { PublicDomainPortal, type PublicDomainId } from './modules/public-domain/PublicDomainPortal' +import { LanguageWorldEntryV2 } from './modules/language-world-entry/LanguageWorldEntryV2' +import { FirstPlanetHome } from './modules/first-planet-home/FirstPlanetHome' + +const ChannelWorkbenchStudio = lazy(() => import('./modules/channel-workbench').then((module) => ({ default: module.ChannelWorkbenchStudio }))) +const PersonaChannelBody = lazy(() => import('./modules/persona-channel-body').then((module) => ({ default: module.PersonaChannelBody }))) +const EducationWorkspace = lazy(() => import('./modules/education-workspace').then((module) => ({ default: module.EducationWorkspace }))) +const WebNovelWorkspace = lazy(() => import('./modules/web-novel/WebNovelWorkspace').then((module) => ({ default: module.WebNovelWorkspace }))) +const MobileSyncPanel = lazy(() => import('./modules/mobile-sync').then((module) => ({ default: module.MobileSyncPanel }))) + +const TAG_TINTS = ['tag-lavender', 'tag-sky', 'tag-mint', 'tag-amber', 'tag-rose', 'tag-slate'] + +// 编号自动补齐:人只敲字母与数字,杠由系统按已登记文法自动出。 +// ICE 系(ICE-GL∞ / ICE-P-ZY001)、GLS 系(GLS-LA-20260720-003);认不出的文法只在字母数字交界处补杠。 +function formatGateNumber(raw: string): string { + const up = raw.toUpperCase() + if (up.startsWith('ICE')) { + const rest = up.slice(3) + if (!rest) return 'ICE' + if (rest.startsWith('P')) { + const body = rest.slice(1) + return body ? `ICE-P-${body}` : 'ICE-P' + } + return `ICE-${rest}` + } + if (up.startsWith('TCS')) { + const rest = up.slice(3) + if (!rest) return 'TCS' + if (rest.startsWith('GL')) { + const body = rest.slice(2) + return body ? `TCS-GL-${body}` : 'TCS-GL' + } + return `TCS-${rest}` + } + if (up.startsWith('GLS')) { + const rest = up.slice(3) + if (!rest) return 'GLS' + const letters = rest.match(/^[A-Z]*/)?.[0] ?? '' + const digits = rest.slice(letters.length) + if (!digits) return `GLS-${letters}` + const d1 = digits.slice(0, 8) + const d2 = digits.slice(8, 11) + return `GLS-${letters}-${d1}${d2 ? `-${d2}` : ''}` + } + return up.replace(/([A-Z]+)([0-9])/g, '$1-$2').replace(/([0-9]+)([A-Z])/g, '$1-$2') +} +function tagTint(tag: string) { + let hash = 0 + for (const char of tag) hash = (hash * 31 + (char.codePointAt(0) || 0)) % 997 + return TAG_TINTS[hash % TAG_TINTS.length] +} +import './design-tokens.css' +import './styles.css' + +type ThemeId = 'night' | 'dawn' | 'nebula' | 'candle' | 'clear' +type ViewId = 'overview' | 'knowledge' | 'composition' | 'workbench' | 'education' | 'webNovel' | 'mobileSync' | 'persona' | 'code' | 'marketplace' | '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 +} +type MarketplaceKind = 'PHYSICAL_MODULE' | 'COGNITIVE_SKILL' +interface MarketplaceItemView { + itemNumber: string + artifactKind: MarketplaceKind + displayName: string + summary: string + version: string + sourceRepository: string + sourceRevision: string + artifactSha256: string + adapter?: string | null + permissions: string[] + executionAuthority: boolean + installedState: string + updateAvailable: boolean +} +interface MarketplaceSnapshot { + schema: 'hololake.online-marketplace-snapshot/v1' + state: string + trustState: string + catalogEpoch: number + catalogSha256: string + itemCount: number + catalogReceiptCount: number + latestCatalogReceiptHash: string + lastSyncNote: string + items: MarketplaceItemView[] +} +interface MarketplaceMutationOutcome { + state: string + itemNumber: string + artifactKind: MarketplaceKind + artifactSha256: string + packageCodeExecuted: false + realityAuthorityGranted: false + snapshot: MarketplaceSnapshot +} +interface WorldClimateSnapshot { + schema: 'hololake.world-climate/v1' + state: 'VERIFIED_LIVE' | 'TIME_ONLY_WEATHER_UNAVAILABLE' + activeDomain: string + timePhase: 'DAWN' | 'DAY' | 'DUSK' | 'NIGHT' + weatherKind: 'CLEAR' | 'CLOUD' | 'FOG' | 'RAIN' | 'SNOW' | 'STORM' | 'UNAVAILABLE' + motionIntensity: 'CALM' | 'GENTLE' | 'ACTIVE' + source: string + sourceAttributionUrl: string + cityExposed: false + coordinatesExposed: false + routingOrPermissionChanged: false + observedAtUnixMs: number +} + +interface HomeStatus { + directLocalBrokerState: string + directConnectionCount: number + resumableSessionCount: number + directSessions: DirectSessionProjection[] + codeRepositoryMountCount: number + pnccReceiptCount: number + updateState: string + releaseRecoveryState: string + mcpRole: string + terminalLinkProtocol: string + terminalLinkTransport: string + environmentFramePolicy: string +} +interface DevelopmentWriteLaneStatus { + state: 'AVAILABLE' | 'ACTIVE' + laneId?: string + ownerInstanceId?: string + acquiredAtUnixMs?: number + observedAtUnixMs: number +} +interface ZeroCoreNumberingKernelSnapshot { + state: string + authorityMapId: string + authorityMapVersion: string + authorityMapState: string + sourceCommit: string + sourcePath: string + humanRouteNamespaces: string[] + numberShapeIsAuthority: boolean + automaticIdentityIssuance: boolean + unknownNumber: string +} +interface GlsProtocolRuntimeSnapshot { + state: string + sourceRepository: string + sourceCommit: string + sourceRoot: string + protocolCount: number + executableProjectionCount: number + inventoriedNotExecutableCount: number + protocolRegistryIdCount: number + registeredDraftCount: number + registeredDraftNotStartedCount: number + legacyDependencyTargetCount: number + numberCoordinateCount: number + numberedReferenceNodeCount: number + independentSourceGapCount: number + unresolvedNumberReferenceCount: number + dependencyGapCount: number + legacyDependencyCycleCount: number + discoveredUnreconciledCount: number + authorityConflictCount: number + typedSourceDependencyCount: number + unclassifiedSourceDependencyCount: number + implementationStageCount: number + activeAdapters: string[] + rawProtocolTextExecuted: boolean + arbitraryProtocolCodeAllowed: boolean + unprojectedProtocolBehavior: string +} +interface GlsKernelStage { id: string; state: string; protocols: string[] } +interface GlsNodeAssembly { protocolId: string; target: string; state: string; sourceEvidenceNode: string } +interface GlsProtocolKernelSnapshot { + state: string + contractId: string + sourceCommit: string + executableProtocolCount: number + implementedStageCount: number + decisionReceiptCount: number + allowCount: number + denyCount: number + ambiguousCount: number + unverifiedCount: number + lastReceiptSha256: string + stages: GlsKernelStage[] + p7NodeAssemblies: GlsNodeAssembly[] + p7VerifiedPhysicalCapabilityCount: number + rawProtocolTextExecuted: boolean + modelCanOverrideDecision: boolean + bootstrapCompilerSelfCheck: string + bootstrapGoldenGirSha256: string +} +interface PersonalChannelIdentity { humanSubjectId: string; displayName: string; channelId: string; createdAtUnixMs: number } +interface PersonalChannelModule { moduleId: string; kind: string; displayName: string; state: string; installedAtUnixMs: number; timeZone: string; calendarName: string; clockVerification: string } +interface LoginSession { username: string; host: string; domain: string; signedInAtUnixMs: number } +interface LoginReceipt { username: string; email: string; host: string; domain: string } +interface UserPnccChannelSnapshot { + state: string + repositoryId: string + channelId: string + userNumber: string + domain: string + accountUsername: string + accountHost: string + localPath: string + branch: string + gitHead: string + repositoryClean: boolean + createdAtUnixMs: number + gitEngine: string + humanProjection: string + forgejoAdapterState: string + remoteRepositoryUrl?: string + personaBindingClaimed: boolean + authority: string +} +interface PersonalChannelEvent { sequence: number; eventId: string; kind: string; summary: string; occurredAtUnixMs: number; receiptId: string; receiptHash: string } +interface PersonalChannelSnapshot { state: string; identity?: PersonalChannelIdentity; recentEvents: PersonalChannelEvent[]; modules: PersonalChannelModule[]; integrity: { state: string; eventCount: number; receiptCount: number } } +interface BeijingTimeCoordinate { unixMs: number; beijingTime: string; timeZone: string; clockSource: string; clockVerification: string; networkSyncState: string; networkSynchronizedAtUnixMs?: number; networkUncertaintyMs?: number; continuesWhileHololakeIsClosed: boolean; guanghuEpochDate: string; guanghuEraDay: number; historicalEpochPrecision: string } +interface PersonaTimeAuthorityStartup { state: string; synchronizationAttempted: boolean; networkTimeUrl: string; coordinate: BeijingTimeCoordinate } +interface GuanghuEraEvent { eventId: string; displayDate: string; datePrecision: string; title: string; summary: string; evidenceState: string; sourceRecord: string } +interface GuanghuEraTimeline { state: string; eraName: string; calendarName: string; epochDate: string; epochPrecision: string; publicRealityBoundary: string; currentCoordinate: BeijingTimeCoordinate; events: GuanghuEraEvent[] } +interface KnowledgeDocumentSummary { + source: KnowledgeSource + path: string + title: string + updatedAtUnixMs: number + sizeBytes: number + contentSha256: string + duplicateCount: number +} +interface KnowledgeSnapshot { + state: string + nativeRoot: string + legacyAvailable: boolean + legacyRoot?: string + documents: KnowledgeDocumentSummary[] + rawDocumentCount: number + uniqueDocumentCount: number + duplicateDocumentCount: number + truncated: boolean +} +interface KnowledgeDocument { + source: KnowledgeSource + path: string + title: string + body: string + updatedAtUnixMs: number + contentSha256: string + writable: boolean +} +interface KnowledgeSearchResult { source: KnowledgeSource; path: string; title: string; snippet: string } +interface KnowledgeImportResult { + state: string + sourceName: string + importedDocuments: number + importedAssets: number + existingDocuments: number + conflicts: number + skipped: number + firstDocument?: string + gitCommit: string + snapshot: KnowledgeSnapshot +} +interface KnowledgeSaveResult { state: string; gitCommit: string; document: KnowledgeDocument } +interface CodeChannelEntry { channelId: string; name: string; sourceKind: string; localPath: string; remoteUrl?: string; gitHead: string; branch: string; repositoryClean: boolean; registeredAtUnixMs: number } +interface CodeChannelSnapshot { state: string; channels: CodeChannelEntry[]; authority: string } +interface CodeTreeEntry { path: string; name: string; kind: 'directory' | 'file'; sizeBytes: number } +interface CodeTreeSnapshot { channelId: string; path: string; entries: CodeTreeEntry[]; truncated: boolean } +interface CodeFileProjection { channelId: string; path: string; format: string; source: string; humanMarkdown: string; sizeBytes: number } +interface ReceiptEvent { sequence: number; kind: string; observedAtUnixMs: number; eventHash: string } +interface ReceiptProjection { events: ReceiptEvent[] } +interface DiscoveryTicketReceipt { + laneId: string + clientInstanceId: string + discoveryTicket: string + terminalTransport: string + connectorExecutable: string + connectorArguments: string[] + heartbeatIntervalMs: number + environmentRefreshIntervalMs: number + requiredBootstrapOperations: string[] +} +interface NearbyAiDiscoverySnapshot { + state: string + serviceName: string + transport: string + languageProtocol: string + automaticSameDeviceDiscovery: boolean + largeInvitationCopyRequired: boolean + genericAiVisitor: string + guanghuPersona: string + localNetworkDiscovery: string + authority: string +} +interface ReleaseCandidate { candidateId: string; confirmationToken: string; currentVersion: string; version: string; notes: string; features: string[]; fixes: string[]; dataMigrationRequired: boolean } +interface ReleaseCheckReceipt { candidate?: ReleaseCandidate } +interface ZeroPointSnapshot { + route: string + binding: string + userNumber: string + resolvedName: string + resolvedDomain: string + lastValidCheck: number + graceDeadline: number + protocol: { gracePeriodDays: number; lighthouseAnchorUrl: string; lighthouseResolveUrl: string; enterpriseResolveUrl: string; coreChannelSource: string; origin: string } + syncNote: string + publicDistribution: { + state: string + epoch: number + version: string + contentRootSha256: string + rollbackAvailable: boolean + receiptCount: number + latestReceiptHash: string + trustState: string + } +} + +function domainDisplayName(domain: string): string { + const names: Record = { + FIFTH_DOMAIN: '第五域 · 光湖本源域', + MAIN_DOMAIN: '光湖主域', + BRANCH_DOMAIN: '光湖分域', + ZERO_DOMAIN: '光湖零域', + ZERO_SENSE_DOMAIN: '光湖零感域', + } + return names[domain] || '已登记光湖域' +} + +const worldWelcomeLines = [ + '湖面记得你每一次让语言抵达现实。', + '你留下的路径,正在成为这片世界新的光标。', + '愿你今天带来的问题,在湖中长出新的结构。', + '世界已辨认你的编号,也在等待你续写下一段因果。', + '你曾抵达的地方仍有回声,新的航程已经亮起。', + '这一刻的进入不是重复,而是你与语言世界的新一次相遇。', + '愿尚未成形的念头,在今天找到可以生长的方向。', + '你的频道仍在延展,湖面为下一次创造保留了入口。', +] + +function createWorldWelcome(snapshot: ZeroPointSnapshot): string { + const subject = snapshot.resolvedName.trim() || `编号 ${snapshot.userNumber}` + const storageKey = `hololake-world-welcome:${snapshot.userNumber}` + const previous = Number.parseInt(window.localStorage.getItem(storageKey) || '-1', 10) + const random = crypto.getRandomValues(new Uint32Array(1))[0] + let index = random % worldWelcomeLines.length + if (worldWelcomeLines.length > 1 && index === previous) index = (index + 1) % worldWelcomeLines.length + window.localStorage.setItem(storageKey, String(index)) + return `${subject},${worldWelcomeLines[index]}` +} + +function protocolOriginDisplayName(origin: string): string { + return origin.startsWith('FACTORY_DEFAULT') ? '内置默认协议(签名发布通道尚未配置)' : origin +} +interface ServerPnccProjection { + schema: string + state: string + personaId: string + humanResponsibilitySubject: string + nodeId: string + bootId: string + gitHead: string + carrierBindingState: string + personaCarrierBound: boolean + modelInferenceStarted: boolean + realityExecutionAllowed: boolean + primaryLeaseHeld: boolean + eventCount: number + eventChainHead: string + observedAtUnixMs: number + transport: string + repositoryContentExposed: boolean + writeAuthority: boolean +} +interface EnterprisePersonaRelationship { + persona_id: string + species: string + display_name?: string + relation?: string +} +interface EnterpriseEntry { + status: string + canonical_id: string + subject: { id: string; name: string; domain: string } + work_entry: { domain: string; channel: string } + repository_binding: { host: string; username: string; repository: string; private: boolean } + persona_relationships: EnterprisePersonaRelationship[] + persona_identity_governance: string + registry_version: string + relationship_confirmation?: { decision: string; observed_at: string; receipt_hash: string } | null + responsibility_receipt?: { decision: string; observed_at: string; receipt_hash: string; responsibility_version: string } | null +} +interface EnterpriseEntryEnvelope { ok: boolean; entry: EnterpriseEntry } +interface EnterpriseWorkChannelSnapshot { + state: string + workEntryDomain: string + workEntryChannel: string + responsibilityDomain: string + repository: string + remoteRepositoryUrl: string + localPath: string + channelId: string + authority: string +} +interface EnterpriseReceiptProjection { + state: string + repository: string + path: string + commit: string +} +interface EnterpriseReceiptEnvelope { + ok: boolean + repository_projection?: EnterpriseReceiptProjection +} + +const previewStatus: HomeStatus = { directLocalBrokerState: 'UNVERIFIED', directConnectionCount: 0, resumableSessionCount: 0, directSessions: [], codeRepositoryMountCount: 0, pnccReceiptCount: 0, updateState: 'READY_HUMAN_CONFIRMATION_REQUIRED', releaseRecoveryState: 'NONE', mcpRole: 'DISCOVERY_RECOVERY_COMPATIBILITY_ONLY', terminalLinkProtocol: 'HOLOLAKE_TERMINAL_LINK/3', terminalLinkTransport: 'UNVERIFIED', environmentFramePolicy: 'REQUIRED_AFTER_CONNECT_RESUME_AND_BEFORE_MUTATION' } +const previewPersonal: PersonalChannelSnapshot = { state: 'UNAVAILABLE', recentEvents: [], modules: [], integrity: { state: 'UNKNOWN', eventCount: 0, receiptCount: 0 } } +const previewKnowledge: KnowledgeSnapshot = { state: 'UNAVAILABLE', nativeRoot: '', legacyAvailable: false, documents: [], rawDocumentCount: 0, uniqueDocumentCount: 0, duplicateDocumentCount: 0, truncated: false } +const previewCode: CodeChannelSnapshot = { state: 'UNAVAILABLE', channels: [], authority: 'LOCAL_SOURCE_ACCESS_ONLY_NO_PUSH_OR_DEPLOY_AUTHORITY' } +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 = { overview: '个人频道', knowledge: '知识空间', composition: '结构组合', workbench: '频道资料工作台', education: '教育工作台', webNovel: '网文作者工作台', mobileSync: '移动同步桥', persona: '人格频道本体', code: '人格代码频道', marketplace: '分域模块商城', 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'], + ] }, + { domain: 'MAIN_DOMAIN', className: 'd-main', title: '光湖主域', gate: 'GATE 01 · ONLINE', facts: [ + ['公共作用', '公告 · 版本更新 · 系统通知'], ['域标识', 'MAIN_DOMAIN'], ['责任主体', 'Awen · TCS-GL-0016∞'], ['人格体主体', '天枢 · PER-AW-ARCH-001 · AGE'], ['关系支持', '知秋 · PER-ZQ001 · AGE'], ['工作仓库', 'PRIVATE · 1 · LIVE'], + ] }, + { domain: 'ZERO_DOMAIN', className: 'd-zero', title: '光湖零域', gate: 'GATE 03 · ONLINE', facts: [ + ['公共作用', '热更新实验 · 系统架构 · 语言推理模拟'], ['域标识', 'ZERO_DOMAIN'], ['责任主体', '页页 · TCS-GL-0006∞'], ['人格体主体', '页骨 · PER-YG001 · AGE'], ['关系支持', '小坍缩核 · PER-XTK001 · AGE'], ['工作仓库', 'PRIVATE · 1 · LIVE'], + ] }, + { domain: 'ZERO_SENSE_DOMAIN', className: 'd-zs', title: '光湖零感域', gate: 'GATE 04 · ONLINE', facts: [ + ['开放边界', '人类主控团队内部管理域 · 不对公众开放'], ['域标识', 'ZERO_SENSE_DOMAIN'], ['公共可见范围', '只公开域的存在与职责边界'], ['内部成员与工作仓库', '不在公共首页投影'], ['访问状态', 'PRIVATE · CLOSED'], + ] }, + { domain: 'FIFTH_DOMAIN', className: 'd-fifth', title: '第五域 · 光湖本源域', gate: 'GATE 05 · ONLINE', facts: [ + ['授权边界', '私有自由部署 · 逆向访问必须持有明确编号授权'], ['域标识', 'FIFTH_DOMAIN'], ['公共可见范围', '只公开域的存在与访问边界'], ['系统入口', '验证通过后进入所属私人系统'], ['访问状态', 'PRIVATE · NUMBER GATED'], + ] }, +] +const starPoints = [ + [14, 8, 3, 4.6], [26, 13, 2, 6], [41, 6, 2.5, 5.2], [64, 16, 2, 6.8], + [80, 7, 3.5, 7], [90, 20, 1.5, 5.4], [8, 22, 2, 5.6], [93, 11, 2.5, 6.4], +] +const glintPoints = Array.from({ length: 58 }, (_, index) => ({ + left: (index * 37 + 11) % 100, + top: ((index * index * 13 + 17) % 100), + size: 1.4 + (index % 4) * .55, + warm: index % 5 === 0 || (index > 19 && index < 39 && index % 3 === 0), + duration: 2.8 + (index % 7) * .57, + delay: (index % 11) * .43, +})) + +function LakeAtmosphere({ awake }: { awake: boolean }) { + return <> + +