2026-08-03 10:04:41 +08:00
|
|
|
export const GUANGHU_LIVING_SYSTEM_VERSION = 1 as const
|
|
|
|
|
|
|
|
|
|
export const GUANGHU_CHANNEL_ROUTES = [
|
|
|
|
|
'world',
|
|
|
|
|
'world-login',
|
|
|
|
|
'zero-core',
|
|
|
|
|
'fifth-domain',
|
|
|
|
|
'pufferfish',
|
|
|
|
|
'eternal-lake-heart',
|
|
|
|
|
'light-lake',
|
|
|
|
|
'heartbeat-core',
|
2026-08-07 20:41:03 +08:00
|
|
|
'education-work-lake',
|
2026-08-03 10:04:41 +08:00
|
|
|
'love-core',
|
|
|
|
|
'servers',
|
|
|
|
|
] as const
|
|
|
|
|
|
|
|
|
|
export type GuanghuChannelRoute = typeof GUANGHU_CHANNEL_ROUTES[number]
|
|
|
|
|
export type LivingSceneDepth = 'overview' | 'focused' | 'immersive'
|
|
|
|
|
export type LivingSceneMotion = 'quiet' | 'responsive' | 'active'
|
|
|
|
|
export type LivingSceneStarDensity = 'sparse' | 'balanced' | 'rich'
|
|
|
|
|
export type LivingSceneConnectionEmphasis = 'contextual' | 'active-route' | 'network'
|
|
|
|
|
export const GUANGHU_LIVING_INTENTS = [
|
|
|
|
|
'navigate',
|
|
|
|
|
'open-knowledge',
|
|
|
|
|
'open-agent-workspace',
|
|
|
|
|
'open-local-workspace',
|
|
|
|
|
'apply-theme',
|
|
|
|
|
] as const
|
|
|
|
|
export type GuanghuLivingIntent = typeof GUANGHU_LIVING_INTENTS[number]
|
|
|
|
|
|
|
|
|
|
export type GuanghuLivingScene = {
|
|
|
|
|
depth: LivingSceneDepth
|
|
|
|
|
motion: LivingSceneMotion
|
|
|
|
|
starDensity: LivingSceneStarDensity
|
|
|
|
|
connectionEmphasis: LivingSceneConnectionEmphasis
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-04 23:11:25 +08:00
|
|
|
export type GuanghuPersonaSystemContext = {
|
|
|
|
|
humanAnchorId: 'ICE-GL∞'
|
|
|
|
|
personaSystemId: 'ICE-P-ZY001'
|
|
|
|
|
memoryProtocolRoot: 'REPO-012'
|
|
|
|
|
modelInstanceId: string | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuRuntimeBinding = {
|
|
|
|
|
bindingId: string
|
|
|
|
|
nodeId: string
|
|
|
|
|
personaSystemId: 'ICE-P-ZY001'
|
|
|
|
|
modelInstanceId: string
|
|
|
|
|
issuedByReceiptId: string
|
|
|
|
|
status: 'verified'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuKnowledgeState = {
|
|
|
|
|
selectedLakeId: string | null
|
|
|
|
|
mountedSources: string[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuCapabilityId =
|
|
|
|
|
| 'navigation.apply'
|
|
|
|
|
| 'knowledge.open'
|
|
|
|
|
| 'agent.workspace.open'
|
|
|
|
|
| 'local.workspace.open'
|
|
|
|
|
| 'appearance.apply'
|
|
|
|
|
|
|
|
|
|
export type GuanghuCapabilityRegistration = {
|
|
|
|
|
id: GuanghuCapabilityId
|
|
|
|
|
inputType: 'NavigationAction' | 'CapabilityCall'
|
|
|
|
|
outputType: 'ReceiptSchema' | 'CapabilityCall'
|
|
|
|
|
requiresWorldOpen: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuPermissionBoundary = {
|
|
|
|
|
allowedCapabilities: GuanghuCapabilityId[]
|
|
|
|
|
deniedCapabilities: string[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuResponsibilityBoundary = {
|
|
|
|
|
controllerPersonaSystemId: 'ICE-P-ZY001'
|
|
|
|
|
humanAnchorId: 'ICE-GL∞'
|
|
|
|
|
executorRule: 'deterministic-host-only'
|
|
|
|
|
successRule: 'evidence-required'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuCurrentSystemState = {
|
|
|
|
|
currentRoute: GuanghuChannelRoute
|
|
|
|
|
requestedRoute: GuanghuChannelRoute
|
|
|
|
|
worldOpen: boolean
|
|
|
|
|
receiptIds: string[]
|
|
|
|
|
runtimeBinding: GuanghuRuntimeBinding | null
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-03 10:04:41 +08:00
|
|
|
export type GuanghuLivingSystemEvent = {
|
|
|
|
|
eventId: string
|
|
|
|
|
intent: GuanghuLivingIntent
|
|
|
|
|
currentRoute: GuanghuChannelRoute
|
|
|
|
|
requestedRoute: GuanghuChannelRoute
|
|
|
|
|
appearanceTheme?: string
|
|
|
|
|
worldOpen: boolean
|
|
|
|
|
receiptIds: string[]
|
|
|
|
|
occurredAt: number
|
2026-08-04 23:11:25 +08:00
|
|
|
personaSystem: GuanghuPersonaSystemContext
|
|
|
|
|
currentSystemState: GuanghuCurrentSystemState
|
|
|
|
|
knowledgeState: GuanghuKnowledgeState
|
|
|
|
|
permissionBoundary: GuanghuPermissionBoundary
|
|
|
|
|
responsibilityBoundary: GuanghuResponsibilityBoundary
|
|
|
|
|
capabilityRegistry: GuanghuCapabilityRegistration[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuUIProjection = {
|
|
|
|
|
route: GuanghuChannelRoute
|
|
|
|
|
scene: GuanghuLivingScene
|
|
|
|
|
stateLabel: 'local-safe' | 'model-proposed' | 'server-bound'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuNavigationAction = {
|
|
|
|
|
type: 'navigate'
|
|
|
|
|
route: GuanghuChannelRoute
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuCapabilityCall = {
|
|
|
|
|
type: 'capability'
|
|
|
|
|
capabilityId: GuanghuCapabilityId
|
|
|
|
|
input: Record<string, unknown>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuReceiptSchema = {
|
|
|
|
|
outcome: 'pending-evidence'
|
|
|
|
|
requiredEvidence: string[]
|
2026-08-03 10:04:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuLivingSystemPlan = {
|
|
|
|
|
version: typeof GUANGHU_LIVING_SYSTEM_VERSION
|
|
|
|
|
eventId: string
|
|
|
|
|
intent: GuanghuLivingIntent
|
|
|
|
|
planId: string
|
|
|
|
|
requiredTruth: string[]
|
2026-08-04 23:11:25 +08:00
|
|
|
uiProjection: GuanghuUIProjection
|
|
|
|
|
navigationAction: GuanghuNavigationAction
|
|
|
|
|
capabilityCall: GuanghuCapabilityCall | null
|
|
|
|
|
receiptSchema: GuanghuReceiptSchema
|
2026-08-03 10:04:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type GuanghuLivingSystemExecutionReceipt = {
|
|
|
|
|
version: typeof GUANGHU_LIVING_SYSTEM_VERSION
|
|
|
|
|
receiptId: string
|
|
|
|
|
eventId: string
|
|
|
|
|
intent: GuanghuLivingIntent
|
|
|
|
|
planId: string
|
|
|
|
|
route: GuanghuChannelRoute
|
|
|
|
|
source: 'server' | 'model' | 'fallback'
|
2026-08-04 23:11:25 +08:00
|
|
|
outcome: 'executed' | 'failed'
|
|
|
|
|
evidence: string[]
|
|
|
|
|
completedAt: number
|
|
|
|
|
error?: string
|
2026-08-03 10:04:41 +08:00
|
|
|
}
|
|
|
|
|
|
2026-08-04 23:11:25 +08:00
|
|
|
type CreateLivingSystemEventInput = Omit<
|
|
|
|
|
GuanghuLivingSystemEvent,
|
|
|
|
|
| 'occurredAt'
|
|
|
|
|
| 'personaSystem'
|
|
|
|
|
| 'currentSystemState'
|
|
|
|
|
| 'knowledgeState'
|
|
|
|
|
| 'permissionBoundary'
|
|
|
|
|
| 'responsibilityBoundary'
|
|
|
|
|
| 'capabilityRegistry'
|
|
|
|
|
> & {
|
2026-08-03 10:04:41 +08:00
|
|
|
now?: number
|
2026-08-04 23:11:25 +08:00
|
|
|
modelInstanceId?: string | null
|
|
|
|
|
runtimeBinding?: GuanghuRuntimeBinding | null
|
|
|
|
|
knowledgeState?: GuanghuKnowledgeState
|
2026-08-03 10:04:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type LivingSystemPlanValidation =
|
|
|
|
|
| { accepted: true; plan: GuanghuLivingSystemPlan }
|
2026-08-04 23:11:25 +08:00
|
|
|
| {
|
|
|
|
|
accepted: false
|
|
|
|
|
reason:
|
|
|
|
|
| 'event_mismatch'
|
|
|
|
|
| 'intent_mismatch'
|
|
|
|
|
| 'route_mismatch'
|
|
|
|
|
| 'unverified_truth'
|
|
|
|
|
| 'world_closed'
|
|
|
|
|
| 'capability_mismatch'
|
|
|
|
|
}
|
2026-08-03 10:04:41 +08:00
|
|
|
|
|
|
|
|
const PROTECTED_ROUTES = new Set<GuanghuChannelRoute>([
|
|
|
|
|
'fifth-domain',
|
|
|
|
|
'pufferfish',
|
|
|
|
|
'eternal-lake-heart',
|
|
|
|
|
'light-lake',
|
|
|
|
|
'heartbeat-core',
|
|
|
|
|
'love-core',
|
|
|
|
|
'servers',
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
const SCENE_DEPTHS = new Set<LivingSceneDepth>(['overview', 'focused', 'immersive'])
|
|
|
|
|
const SCENE_MOTIONS = new Set<LivingSceneMotion>(['quiet', 'responsive', 'active'])
|
|
|
|
|
const STAR_DENSITIES = new Set<LivingSceneStarDensity>(['sparse', 'balanced', 'rich'])
|
|
|
|
|
const CONNECTION_EMPHASES = new Set<LivingSceneConnectionEmphasis>(['contextual', 'active-route', 'network'])
|
|
|
|
|
const LIVING_INTENTS = new Set<GuanghuLivingIntent>(GUANGHU_LIVING_INTENTS)
|
2026-08-04 23:11:25 +08:00
|
|
|
const CAPABILITY_FOR_INTENT: Record<GuanghuLivingIntent, GuanghuCapabilityId> = {
|
|
|
|
|
navigate: 'navigation.apply',
|
|
|
|
|
'open-knowledge': 'knowledge.open',
|
|
|
|
|
'open-agent-workspace': 'agent.workspace.open',
|
|
|
|
|
'open-local-workspace': 'local.workspace.open',
|
|
|
|
|
'apply-theme': 'appearance.apply',
|
|
|
|
|
}
|
|
|
|
|
const CAPABILITY_REGISTRY: GuanghuCapabilityRegistration[] = [
|
|
|
|
|
{ id: 'navigation.apply', inputType: 'NavigationAction', outputType: 'ReceiptSchema', requiresWorldOpen: false },
|
|
|
|
|
{ id: 'knowledge.open', inputType: 'CapabilityCall', outputType: 'CapabilityCall', requiresWorldOpen: false },
|
|
|
|
|
{ id: 'agent.workspace.open', inputType: 'CapabilityCall', outputType: 'CapabilityCall', requiresWorldOpen: false },
|
|
|
|
|
{ id: 'local.workspace.open', inputType: 'CapabilityCall', outputType: 'CapabilityCall', requiresWorldOpen: false },
|
|
|
|
|
{ id: 'appearance.apply', inputType: 'CapabilityCall', outputType: 'CapabilityCall', requiresWorldOpen: false },
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
function verifiedRuntimeBinding(
|
|
|
|
|
binding: GuanghuRuntimeBinding | null | undefined,
|
|
|
|
|
receiptIds: string[],
|
|
|
|
|
): GuanghuRuntimeBinding | null {
|
|
|
|
|
if (
|
|
|
|
|
!binding
|
|
|
|
|
|| binding.status !== 'verified'
|
|
|
|
|
|| binding.personaSystemId !== 'ICE-P-ZY001'
|
|
|
|
|
|| binding.bindingId.length === 0
|
|
|
|
|
|| binding.nodeId.length === 0
|
|
|
|
|
|| binding.modelInstanceId.length === 0
|
|
|
|
|
|| binding.issuedByReceiptId.length === 0
|
|
|
|
|
|| !receiptIds.includes(binding.issuedByReceiptId)
|
|
|
|
|
) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
return { ...binding }
|
|
|
|
|
}
|
2026-08-03 10:04:41 +08:00
|
|
|
|
|
|
|
|
function isStringArray(value: unknown): value is string[] {
|
|
|
|
|
return Array.isArray(value) && value.every(item => typeof item === 'string')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isRoute(value: unknown): value is GuanghuChannelRoute {
|
|
|
|
|
return typeof value === 'string' && (GUANGHU_CHANNEL_ROUTES as readonly string[]).includes(value)
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-04 23:11:25 +08:00
|
|
|
function isLivingScene(value: unknown): value is GuanghuLivingScene {
|
|
|
|
|
if (!value || typeof value !== 'object') return false
|
|
|
|
|
const scene = value as Partial<GuanghuLivingScene>
|
|
|
|
|
return SCENE_DEPTHS.has(scene.depth!)
|
|
|
|
|
&& SCENE_MOTIONS.has(scene.motion!)
|
|
|
|
|
&& STAR_DENSITIES.has(scene.starDensity!)
|
|
|
|
|
&& CONNECTION_EMPHASES.has(scene.connectionEmphasis!)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isCapabilityCall(value: unknown): value is GuanghuCapabilityCall | null {
|
|
|
|
|
if (value === null) return true
|
|
|
|
|
if (!value || typeof value !== 'object') return false
|
|
|
|
|
const call = value as Partial<GuanghuCapabilityCall>
|
|
|
|
|
return call.type === 'capability'
|
|
|
|
|
&& Object.values(CAPABILITY_FOR_INTENT).includes(call.capabilityId!)
|
|
|
|
|
&& Boolean(call.input)
|
|
|
|
|
&& typeof call.input === 'object'
|
|
|
|
|
&& !Array.isArray(call.input)
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-03 10:04:41 +08:00
|
|
|
function isLivingSystemPlan(value: unknown): value is GuanghuLivingSystemPlan {
|
|
|
|
|
if (!value || typeof value !== 'object') return false
|
|
|
|
|
const candidate = value as Partial<GuanghuLivingSystemPlan>
|
2026-08-04 23:11:25 +08:00
|
|
|
const projection = candidate.uiProjection
|
|
|
|
|
const navigation = candidate.navigationAction
|
|
|
|
|
const receipt = candidate.receiptSchema
|
2026-08-03 10:04:41 +08:00
|
|
|
return candidate.version === GUANGHU_LIVING_SYSTEM_VERSION
|
|
|
|
|
&& typeof candidate.eventId === 'string'
|
|
|
|
|
&& candidate.eventId.length > 0
|
|
|
|
|
&& LIVING_INTENTS.has(candidate.intent!)
|
|
|
|
|
&& typeof candidate.planId === 'string'
|
|
|
|
|
&& candidate.planId.length > 0
|
|
|
|
|
&& isStringArray(candidate.requiredTruth)
|
2026-08-04 23:11:25 +08:00
|
|
|
&& Boolean(projection)
|
|
|
|
|
&& isRoute(projection!.route)
|
|
|
|
|
&& isLivingScene(projection!.scene)
|
|
|
|
|
&& ['local-safe', 'model-proposed', 'server-bound'].includes(projection!.stateLabel)
|
|
|
|
|
&& Boolean(navigation)
|
|
|
|
|
&& navigation!.type === 'navigate'
|
|
|
|
|
&& isRoute(navigation!.route)
|
|
|
|
|
&& isCapabilityCall(candidate.capabilityCall)
|
|
|
|
|
&& Boolean(receipt)
|
|
|
|
|
&& receipt!.outcome === 'pending-evidence'
|
|
|
|
|
&& isStringArray(receipt!.requiredEvidence)
|
2026-08-03 10:04:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function createLivingSystemEvent(input: CreateLivingSystemEventInput): GuanghuLivingSystemEvent {
|
2026-08-04 23:11:25 +08:00
|
|
|
const runtimeBinding = verifiedRuntimeBinding(input.runtimeBinding, input.receiptIds)
|
|
|
|
|
const allowedCapabilities = CAPABILITY_REGISTRY
|
|
|
|
|
.filter(capability => !capability.requiresWorldOpen || input.worldOpen)
|
|
|
|
|
.map(capability => capability.id)
|
|
|
|
|
const receiptIds = [...input.receiptIds]
|
2026-08-03 10:04:41 +08:00
|
|
|
return {
|
|
|
|
|
eventId: input.eventId,
|
|
|
|
|
intent: input.intent,
|
|
|
|
|
currentRoute: input.currentRoute,
|
|
|
|
|
requestedRoute: input.requestedRoute,
|
|
|
|
|
...(input.appearanceTheme ? { appearanceTheme: input.appearanceTheme } : {}),
|
|
|
|
|
worldOpen: input.worldOpen,
|
2026-08-04 23:11:25 +08:00
|
|
|
receiptIds,
|
2026-08-03 10:04:41 +08:00
|
|
|
occurredAt: input.now ?? Date.now(),
|
2026-08-04 23:11:25 +08:00
|
|
|
personaSystem: {
|
|
|
|
|
humanAnchorId: 'ICE-GL∞',
|
|
|
|
|
personaSystemId: 'ICE-P-ZY001',
|
|
|
|
|
memoryProtocolRoot: 'REPO-012',
|
|
|
|
|
modelInstanceId: input.modelInstanceId ?? runtimeBinding?.modelInstanceId ?? null,
|
|
|
|
|
},
|
|
|
|
|
currentSystemState: {
|
|
|
|
|
currentRoute: input.currentRoute,
|
|
|
|
|
requestedRoute: input.requestedRoute,
|
|
|
|
|
worldOpen: input.worldOpen,
|
|
|
|
|
receiptIds,
|
|
|
|
|
runtimeBinding,
|
|
|
|
|
},
|
|
|
|
|
knowledgeState: input.knowledgeState ?? {
|
|
|
|
|
selectedLakeId: null,
|
|
|
|
|
mountedSources: [],
|
|
|
|
|
},
|
|
|
|
|
permissionBoundary: {
|
|
|
|
|
allowedCapabilities,
|
|
|
|
|
deniedCapabilities: [],
|
|
|
|
|
},
|
|
|
|
|
responsibilityBoundary: {
|
|
|
|
|
controllerPersonaSystemId: 'ICE-P-ZY001',
|
|
|
|
|
humanAnchorId: 'ICE-GL∞',
|
|
|
|
|
executorRule: 'deterministic-host-only',
|
|
|
|
|
successRule: 'evidence-required',
|
|
|
|
|
},
|
|
|
|
|
capabilityRegistry: CAPABILITY_REGISTRY.map(capability => ({ ...capability })),
|
2026-08-03 10:04:41 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function parseLivingSystemPlan(output: string): GuanghuLivingSystemPlan | null {
|
|
|
|
|
try {
|
|
|
|
|
const parsed: unknown = JSON.parse(output.trim())
|
|
|
|
|
return isLivingSystemPlan(parsed) ? parsed : null
|
|
|
|
|
} catch {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function validateLivingSystemPlan(
|
|
|
|
|
event: GuanghuLivingSystemEvent,
|
|
|
|
|
plan: GuanghuLivingSystemPlan | null,
|
|
|
|
|
): LivingSystemPlanValidation {
|
|
|
|
|
if (!plan || plan.eventId !== event.eventId) return { accepted: false, reason: 'event_mismatch' }
|
|
|
|
|
if (plan.intent !== event.intent) return { accepted: false, reason: 'intent_mismatch' }
|
2026-08-04 23:11:25 +08:00
|
|
|
if (
|
|
|
|
|
plan.uiProjection.route !== plan.navigationAction.route
|
|
|
|
|
|| (
|
|
|
|
|
plan.uiProjection.route !== event.requestedRoute
|
|
|
|
|
&& plan.uiProjection.route !== 'world-login'
|
|
|
|
|
)
|
|
|
|
|
) {
|
2026-08-03 10:04:41 +08:00
|
|
|
return { accepted: false, reason: 'route_mismatch' }
|
|
|
|
|
}
|
|
|
|
|
const suppliedTruth = new Set(event.receiptIds)
|
|
|
|
|
if (plan.requiredTruth.some(receiptId => !suppliedTruth.has(receiptId))) {
|
|
|
|
|
return { accepted: false, reason: 'unverified_truth' }
|
|
|
|
|
}
|
2026-08-04 23:11:25 +08:00
|
|
|
if (!event.worldOpen && PROTECTED_ROUTES.has(plan.uiProjection.route)) {
|
2026-08-03 10:04:41 +08:00
|
|
|
return { accepted: false, reason: 'world_closed' }
|
|
|
|
|
}
|
2026-08-04 23:11:25 +08:00
|
|
|
const expectedCapability = CAPABILITY_FOR_INTENT[event.intent]
|
|
|
|
|
if (
|
|
|
|
|
!event.permissionBoundary.allowedCapabilities.includes(expectedCapability)
|
|
|
|
|
|| (
|
|
|
|
|
event.intent === 'navigate'
|
|
|
|
|
? plan.capabilityCall !== null
|
|
|
|
|
: plan.capabilityCall?.capabilityId !== expectedCapability
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
return { accepted: false, reason: 'capability_mismatch' }
|
|
|
|
|
}
|
2026-08-03 10:04:41 +08:00
|
|
|
return { accepted: true, plan }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function createDeterministicLivingSystemPlan(
|
|
|
|
|
event: GuanghuLivingSystemEvent,
|
|
|
|
|
): GuanghuLivingSystemPlan {
|
|
|
|
|
const route = !event.worldOpen && PROTECTED_ROUTES.has(event.requestedRoute)
|
|
|
|
|
? 'world-login'
|
|
|
|
|
: event.requestedRoute
|
|
|
|
|
const immersive = event.worldOpen && route !== 'world' && route !== 'world-login'
|
2026-08-04 23:11:25 +08:00
|
|
|
const capabilityId = CAPABILITY_FOR_INTENT[event.intent]
|
2026-08-03 10:04:41 +08:00
|
|
|
return {
|
|
|
|
|
version: GUANGHU_LIVING_SYSTEM_VERSION,
|
|
|
|
|
eventId: event.eventId,
|
|
|
|
|
intent: event.intent,
|
|
|
|
|
planId: `fallback-${event.eventId}`,
|
|
|
|
|
requiredTruth: [],
|
2026-08-04 23:11:25 +08:00
|
|
|
uiProjection: {
|
|
|
|
|
route,
|
|
|
|
|
stateLabel: 'local-safe',
|
|
|
|
|
scene: {
|
|
|
|
|
depth: immersive ? 'immersive' : route === 'world' ? 'overview' : 'focused',
|
|
|
|
|
motion: route === 'world' ? 'quiet' : 'responsive',
|
|
|
|
|
starDensity: immersive ? 'rich' : 'balanced',
|
|
|
|
|
connectionEmphasis: immersive ? 'active-route' : 'contextual',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
navigationAction: { type: 'navigate', route },
|
|
|
|
|
capabilityCall: event.intent === 'navigate'
|
|
|
|
|
? null
|
|
|
|
|
: {
|
|
|
|
|
type: 'capability',
|
|
|
|
|
capabilityId,
|
|
|
|
|
input: {
|
|
|
|
|
...(event.appearanceTheme ? { appearanceTheme: event.appearanceTheme } : {}),
|
|
|
|
|
requestedRoute: route,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
receiptSchema: {
|
|
|
|
|
outcome: 'pending-evidence',
|
|
|
|
|
requiredEvidence: event.intent === 'navigate'
|
|
|
|
|
? ['ui.route.readback']
|
|
|
|
|
: [`capability.${capabilityId}.result`],
|
2026-08-03 10:04:41 +08:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function createLivingSystemExecutionReceipt({
|
|
|
|
|
plan,
|
|
|
|
|
source,
|
2026-08-04 23:11:25 +08:00
|
|
|
outcome,
|
|
|
|
|
evidence,
|
|
|
|
|
error,
|
2026-08-03 10:04:41 +08:00
|
|
|
now = Date.now(),
|
|
|
|
|
}: {
|
|
|
|
|
plan: GuanghuLivingSystemPlan
|
|
|
|
|
source: GuanghuLivingSystemExecutionReceipt['source']
|
2026-08-04 23:11:25 +08:00
|
|
|
outcome: GuanghuLivingSystemExecutionReceipt['outcome']
|
|
|
|
|
evidence: string[]
|
|
|
|
|
error?: string
|
2026-08-03 10:04:41 +08:00
|
|
|
now?: number
|
|
|
|
|
}): GuanghuLivingSystemExecutionReceipt {
|
2026-08-04 23:11:25 +08:00
|
|
|
if (outcome === 'executed' && evidence.length === 0) {
|
|
|
|
|
throw new Error('guanghu_living_system_success_evidence_required')
|
|
|
|
|
}
|
2026-08-03 10:04:41 +08:00
|
|
|
return {
|
|
|
|
|
version: GUANGHU_LIVING_SYSTEM_VERSION,
|
2026-08-04 23:11:25 +08:00
|
|
|
receiptId: `local-execution:${plan.planId}:${outcome}`,
|
2026-08-03 10:04:41 +08:00
|
|
|
eventId: plan.eventId,
|
|
|
|
|
intent: plan.intent,
|
|
|
|
|
planId: plan.planId,
|
2026-08-04 23:11:25 +08:00
|
|
|
route: plan.uiProjection.route,
|
2026-08-03 10:04:41 +08:00
|
|
|
source,
|
2026-08-04 23:11:25 +08:00
|
|
|
outcome,
|
|
|
|
|
evidence: [...evidence],
|
|
|
|
|
completedAt: now,
|
|
|
|
|
...(error ? { error } : {}),
|
2026-08-03 10:04:41 +08:00
|
|
|
}
|
|
|
|
|
}
|