foundation: start native language reality engineering root

This commit is contained in:
冰朔 2026-08-21 14:44:47 +08:00
commit 0dec0b93fc
154 changed files with 49993 additions and 0 deletions

View file

@ -0,0 +1,8 @@
schema: hololake.numbered-part/v1
id: HLP-PART-0001
display_name: 编号协议核
state: DONOR_BYTES_EXTRACTED
source_commit: 2e48b7d7686554454b6ee69bcdbd01eb68bff401
payload_sha256: fc04b3fb7726a815cead44e7a1994763df2d345b2a731c89cca7ad7c97938b10
payload_files: 8
native_acceptance: PENDING

View file

@ -0,0 +1,162 @@
import { createHash } from 'node:crypto'
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const paths = {
identity: resolve(root, 'contracts/zero-core-numbering-kernel.json'),
webview: resolve(root, 'contracts/numbered-ipc-registry.json'),
broker: resolve(root, 'contracts/direct-local-broker-numbered-registry.json'),
gls: resolve(root, 'contracts/gls-runtime-registry.json'),
output: resolve(root, 'generated/unified-number-coordinate-tree.json'),
}
function readSource(path) {
const bytes = readFileSync(path)
return {
value: JSON.parse(bytes.toString('utf8')),
sha256: createHash('sha256').update(bytes).digest('hex'),
}
}
export function compileUnifiedNumberTree() {
const identity = readSource(paths.identity)
const webview = readSource(paths.webview)
const broker = readSource(paths.broker)
const gls = readSource(paths.gls)
const routes = [
...webview.value.operations.map((route) => ({
transport: 'TAURI_WEBVIEW_NUMBERED_IPC',
protocolVersion: webview.value.runtime.protocol_version,
callerNumber: webview.value.runtime.caller_number,
channelNumber: route.channel_number,
moduleNumber: route.module_number,
operationNumber: route.operation_number,
targetNumber: route.target_number,
alias: route.alias,
admission: route.admission,
effect: route.effect,
evidence: 'HASH_CHAINED_NUMBERED_IPC_RECEIPT',
path: `HLP-NUMBER-WORLD-ROOT-001/TAURI/${route.channel_number}/${route.module_number}/${route.operation_number}/${route.target_number}`,
})),
...broker.value.operations.map((route) => ({
transport: 'DIRECT_LOCAL_NUMBERED_BROKER',
protocolVersion: broker.value.runtime.protocol_version,
callerNumber: broker.value.runtime.caller_number,
channelNumber: route.channel_number,
moduleNumber: route.module_number,
operationNumber: route.operation_number,
targetNumber: route.target_number,
alias: route.alias,
admission: ['DISCOVER_NEARBY', 'PING', 'GET_BEIJING_TIME'].includes(route.alias)
? 'PREAUTH_LOCAL_SYSTEM_ROUTE'
: ['OPEN_VISITOR_SESSION', 'RECEIVE_LANGUAGE'].includes(route.alias)
? 'BOUNDED_VISITOR_ROUTE'
: 'AUTHENTICATED_LOCAL_SESSION_WITH_PERSONA_LICENSE_IF_PERSONA_MODE',
effect: ['DISCOVER_NEARBY', 'PING', 'GET_BEIJING_TIME', 'GET_PERSONA_CARRIER_LICENSE_STATUS', 'GET_WORK_ENVIRONMENT', 'RESOLVE_CAPABILITY_ROUTE', 'INSPECT_MOUNTED_PNCC_REPOSITORY', 'READ_MOUNTED_PNCC_REMOTE_OBJECT', 'QUERY_PNCC_RECEIPT_PROJECTION', 'INSPECT_DEVELOPMENT_WRITE_LANE'].includes(route.alias)
? 'READ_OR_STATUS'
: 'STATE_CHANGE',
evidence: 'NUMBERED_RESPONSE_PLUS_SESSION_OR_DOMAIN_RECEIPT',
path: `HLP-NUMBER-WORLD-ROOT-001/BROKER/${route.channel_number}/${route.module_number}/${route.operation_number}/${route.target_number}`,
})),
].sort((left, right) => left.path.localeCompare(right.path, 'en'))
const uniquePaths = new Set(routes.map((route) => route.path))
const uniqueOperations = new Set(routes.map((route) => `${route.transport}:${route.operationNumber}`))
if (routes.length !== uniquePaths.size || routes.length !== uniqueOperations.size) {
throw new Error('HOLOLAKE_UNIFIED_NUMBER_TREE_DUPLICATE_COORDINATE')
}
const identityNodes = identity.value.namespaces.map((namespace) => ({
nodeKind: 'IDENTITY_NAMESPACE',
nodeNumber: `HLP-IDENTITY-NS-${namespace.id}`,
namespaceId: namespace.id,
subjectKind: namespace.subject_kind,
domainScope: namespace.domain_scope,
admission: namespace.human_entry ? 'REGISTERED_HUMAN_NAMESPACE' : 'NON_HUMAN_NAMESPACE',
executionState: 'AUTHORITY_RESOLUTION_ONLY',
evidence: identity.value.authority.map_id,
path: `HLP-NUMBER-WORLD-ROOT-001/IDENTITY/${namespace.id}`,
})).sort((left, right) => left.path.localeCompare(right.path, 'en'))
const protocolNodes = [
...gls.value.protocols.map((protocol) => ({
nodeKind: 'GLS_PROTOCOL_SOURCE',
nodeNumber: protocol.id,
protocolId: protocol.id,
title: protocol.title,
sourceState: protocol.source_format,
executionState: protocol.projection_state,
evidence: protocol.source_sha256,
path: `HLP-NUMBER-WORLD-ROOT-001/GLS/SOURCE/${protocol.id}`,
})),
...gls.value.numbered_reference_nodes.map((reference) => ({
nodeKind: 'GLS_REFERENCE_ONLY',
nodeNumber: reference.node_number,
protocolId: reference.protocol_id,
title: reference.title,
sourceState: reference.source_state,
executionState: reference.execution_state,
evidence: reference.evidence_paths[0],
path: `HLP-NUMBER-WORLD-ROOT-001/GLS/REFERENCE/${reference.node_number}`,
})),
].sort((left, right) => left.path.localeCompare(right.path, 'en'))
const allPaths = [...routes.map((route) => route.path), ...identityNodes.map((node) => node.path), ...protocolNodes.map((node) => node.path)]
if (new Set(allPaths).size !== allPaths.length
|| gls.value.reconciliation.unresolved_number_reference_count !== 0
|| gls.value.reconciliation.every_dependency_has_number_coordinate !== true
|| protocolNodes.some((node) => node.nodeKind === 'GLS_REFERENCE_ONLY' && node.executionState !== 'REFERENCE_ONLY_NOT_EXECUTABLE')) {
throw new Error('HOLOLAKE_UNIFIED_NUMBER_TREE_INCOMPLETE_COVERAGE')
}
return {
schema: 'hololake.unified-number-coordinate-tree/v2',
recordId: 'HLP-UNIFIED-NUMBER-TREE-001',
state: 'MACHINE_COMPILED_STARTUP_ENFORCED',
rootNumber: 'HLP-NUMBER-WORLD-ROOT-001',
identityAuthority: {
mapId: identity.value.authority.map_id,
mapVersion: identity.value.authority.map_version,
namespaces: identity.value.namespaces.map((namespace) => ({
namespaceId: namespace.id,
roots: namespace.roots,
prefixes: namespace.prefixes,
subjectKind: namespace.subject_kind,
domainScope: namespace.domain_scope,
})),
},
sources: [
{ recordId: identity.value.record_id, sha256: identity.sha256 },
{ recordId: webview.value.record_id, sha256: webview.sha256 },
{ recordId: broker.value.record_id, sha256: broker.sha256 },
{ recordId: gls.value.record_id, sha256: gls.sha256 },
],
invariants: {
numberIsStableCoordinateNotAuthority: true,
pathIsUniqueNavigation: true,
admissionIsSeparateFromIdentity: true,
everyPhysicalCallHasNumberedRoute: true,
everyAcceptedCallHasEvidenceClass: true,
everyProtocolReferenceHasNumberCoordinate: true,
referenceOnlyNodesNeverExecutable: true,
unresolvedNumberReferenceCount: 0,
mismatchedCoordinate: 'FAIL_CLOSED',
},
coordinateCount: routes.length + identityNodes.length + protocolNodes.length,
routeCount: routes.length,
identityNodeCount: identityNodes.length,
protocolNodeCount: protocolNodes.length,
referenceOnlyNodeCount: protocolNodes.filter((node) => node.nodeKind === 'GLS_REFERENCE_ONLY').length,
identityNodes,
protocolNodes,
routes,
}
}
const compiled = compileUnifiedNumberTree()
const output = `${JSON.stringify(compiled, null, 2)}\n`
if (process.argv.includes('--check')) {
if (readFileSync(paths.output, 'utf8') !== output) {
throw new Error('HOLOLAKE_UNIFIED_NUMBER_TREE_STALE')
}
} else {
mkdirSync(dirname(paths.output), { recursive: true })
writeFileSync(paths.output, output)
}

View file

@ -0,0 +1,139 @@
import assert from 'node:assert/strict'
import { readFile, readdir } from 'node:fs/promises'
import path from 'node:path'
import test from 'node:test'
const root = path.resolve(import.meta.dirname, '..')
const contractPath = path.join(root, 'contracts', 'numbered-ipc-registry.json')
const libPath = path.join(root, 'src-tauri', 'src', 'lib.rs')
const dispatcherPath = path.join(root, 'src-tauri', 'src', 'numbered_ipc_dispatch.rs')
const clientPath = path.join(root, 'src', 'modules', 'numbered-ipc.ts')
const rustRoot = path.join(root, 'src-tauri', 'src')
const frontendRoot = path.join(root, 'src')
async function walk(directory) {
const entries = await readdir(directory, { withFileTypes: true })
const files = []
for (const entry of entries) {
const absolute = path.join(directory, entry.name)
if (entry.isDirectory()) files.push(...await walk(absolute))
else files.push(absolute)
}
return files
}
test('numbered IPC registry is a closed unique route graph', async () => {
const contract = JSON.parse(await readFile(contractPath, 'utf8'))
assert.equal(contract.schema, 'hololake.numbered-ipc-registry/v1')
assert.equal(contract.record_id, 'HLP-NUMBERED-IPC-ROOT-001')
assert.equal(contract.runtime.public_tauri_command, 'numbered_ipc')
assert.equal(contract.runtime.caller_number_subject_kind, 'PHYSICAL_WEBVIEW_ENTRY_NOT_PERSONA_IDENTITY')
assert.equal(contract.runtime.caller_number_grants_persona_binding, false)
assert.equal(contract.runtime.legacy_direct_commands_allowed, false)
assert.equal(contract.runtime.grant_single_use, true)
assert.equal(contract.runtime.payload_bound_grants, true)
assert.equal(contract.runtime.authority_binding_issued_server_side, true)
assert.equal(contract.runtime.ordinary_user_local_channel_authority, 'EXPLICIT_INITIALIZATION_PLUS_ACCOUNT_SCOPED_SESSION_PLUS_KEYCHAIN_SECRET')
assert.equal(contract.runtime.persona_binding_claimed, false)
assert.equal(contract.runtime.unknown_route, 'FAIL_CLOSED')
assert.ok(contract.operations.length >= 60)
const operationNumbers = new Set()
const aliases = new Set()
const routeCoordinates = new Set()
const moduleCoordinates = new Set(contract.modules.map((module) => `${module.module_number}/${module.target_number}`))
for (const operation of contract.operations) {
assert.match(operation.operation_number, /^HLP-NIPC-OP-\d{4}$/)
assert.match(operation.module_number, /^HLP-NIPC-MOD-\d{4}$/)
assert.match(operation.channel_number, /^HLP-NIPC-CH-\d{4}$/)
assert.match(operation.target_number, /^HLP-NIPC-TGT-\d{4}$/)
assert.ok(operation.handler.includes('::'))
assert.equal(operationNumbers.has(operation.operation_number), false)
assert.equal(aliases.has(operation.alias), false)
operationNumbers.add(operation.operation_number)
aliases.add(operation.alias)
const coordinate = [operation.channel_number, operation.module_number, operation.operation_number, operation.target_number].join('/')
assert.equal(routeCoordinates.has(coordinate), false)
routeCoordinates.add(coordinate)
assert.equal(moduleCoordinates.has(`${operation.module_number}/${operation.target_number}`), true)
}
const payloadAliases = [
...contract.payload_contract.empty_object_aliases,
...contract.payload_contract.input_wrapper_aliases,
...Object.keys(contract.payload_contract.direct_field_aliases),
]
assert.equal(new Set(payloadAliases).size, payloadAliases.length)
assert.deepEqual([...payloadAliases].sort(), [...aliases].sort())
})
test('ordinary user local channels receive account-scoped IPC authority without claiming a Guanghu number', async () => {
const source = await readFile(path.join(rustRoot, 'numbered_ipc.rs'), 'utf8')
const dispatcher = await readFile(dispatcherPath, 'utf8')
assert.match(source, /AUTHENTICATED_LOCAL_HUMAN:PERSONAL_CHANNEL/)
assert.match(source, /session\.domain == "PERSONAL_CHANNEL"/)
assert.match(source, /session\.host == "local\.hololake"/)
assert.match(source, /current_login_session\(app\)/)
assert.match(source, /HOLOLAKE_NUMBERED_IPC_VERIFIED_HUMAN_REQUIRED/)
assert.match(dispatcher, /fn authenticated_human_subject/)
assert.match(dispatcher, /identity_for_channel_runtime\(app\)/)
assert.match(dispatcher, /external_ai_gateway::get_gateway_status[\s\S]*authenticated_human_subject/)
})
test('the webview has one IPC entrance and cannot invoke legacy commands', async () => {
const contract = JSON.parse(await readFile(contractPath, 'utf8'))
const aliases = new Set(contract.operations.map((operation) => operation.alias))
const files = (await walk(frontendRoot)).filter((file) => /\.(ts|tsx)$/.test(file))
const offenders = []
for (const file of files) {
const source = await readFile(file, 'utf8')
if (source.includes("from '@tauri-apps/api/core'") && !file.endsWith(path.join('modules', 'numbered-ipc.ts'))) {
offenders.push(`${path.relative(root, file)}:raw-tauri-import`)
}
if (file.endsWith(path.join('modules', 'numbered-ipc.ts'))) {
const calls = [...source.matchAll(/\binvoke(?:<[^>]+>)?\s*\(\s*['"]([^'"]+)['"]/g)]
for (const call of calls) if (call[1] !== 'numbered_ipc') offenders.push(`${path.relative(root, file)}:${call[1]}`)
} else {
const calls = [...source.matchAll(/\binvoke(?:<[^>]+>)?\s*\(\s*['"]([^'"]+)['"]/g)]
for (const call of calls) if (!aliases.has(call[1])) offenders.push(`${path.relative(root, file)}:unregistered-alias:${call[1]}`)
}
}
assert.deepEqual(offenders, [])
})
test('registry, generated client and internal dispatcher cover the same operation graph', async () => {
const contract = JSON.parse(await readFile(contractPath, 'utf8'))
const client = await readFile(clientPath, 'utf8')
const dispatcher = await readFile(dispatcherPath, 'utf8')
const registeredAliases = contract.operations.map((operation) => operation.alias).sort()
const clientAliases = [...client.matchAll(/^ "([a-z0-9_]+)": \{$/gm)].map((match) => match[1]).sort()
const registeredHandlers = contract.operations.map((operation) => operation.handler).sort()
const dispatchedHandlers = [...dispatcher.matchAll(/^ "([a-z0-9_]+::[a-z0-9_]+)" =>/gm)]
.map((match) => match[1])
.sort()
assert.deepEqual(clientAliases, registeredAliases)
assert.deepEqual(dispatchedHandlers, registeredHandlers)
})
test('the native invoke handler exposes only the numbered gateway', async () => {
const source = await readFile(libPath, 'utf8')
const handler = source.match(/invoke_handler\(tauri::generate_handler!\[([\s\S]*?)\]\)/)?.[1]
assert.ok(handler)
const commands = [...handler.matchAll(/([a-z_]+::[a-z_]+)/g)].map((match) => match[1])
assert.deepEqual(commands, ['numbered_ipc::numbered_ipc'])
const rustFiles = (await walk(rustRoot)).filter((file) => file.endsWith('.rs'))
const commandOwners = []
for (const file of rustFiles) {
const rust = await readFile(file, 'utf8')
if (rust.includes('#[tauri::command]')) commandOwners.push(path.basename(file))
}
assert.deepEqual(commandOwners, ['numbered_ipc.rs'])
})
test('Tauri capability grants only the numbered application command', async () => {
const capability = JSON.parse(await readFile(path.join(root, 'src-tauri', 'capabilities', 'default.json'), 'utf8'))
assert.ok(capability.permissions.includes('allow-numbered-ipc'))
const permission = await readFile(path.join(root, 'src-tauri', 'permissions', 'numbered-ipc.toml'), 'utf8')
assert.match(permission, /identifier\s*=\s*"allow-numbered-ipc"/)
assert.match(permission, /commands\.allow\s*=\s*\["numbered_ipc"\]/)
})

View file

@ -0,0 +1,204 @@
use serde::Deserialize;
use std::collections::HashSet;
const TREE: &str = include_str!("../../generated/unified-number-coordinate-tree.json");
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct NumberTree {
schema: String,
record_id: String,
state: String,
root_number: String,
coordinate_count: usize,
route_count: usize,
identity_node_count: usize,
protocol_node_count: usize,
reference_only_node_count: usize,
identity_nodes: Vec<IdentityNode>,
protocol_nodes: Vec<ProtocolNode>,
routes: Vec<NumberRoute>,
invariants: NumberTreeInvariants,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct IdentityNode {
node_kind: String,
node_number: String,
namespace_id: String,
subject_kind: String,
domain_scope: String,
admission: String,
execution_state: String,
evidence: String,
path: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct ProtocolNode {
node_kind: String,
node_number: String,
protocol_id: String,
source_state: String,
execution_state: String,
evidence: String,
path: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct NumberRoute {
transport: String,
protocol_version: String,
caller_number: String,
channel_number: String,
module_number: String,
operation_number: String,
target_number: String,
admission: String,
effect: String,
evidence: String,
path: String,
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct NumberTreeInvariants {
number_is_stable_coordinate_not_authority: bool,
path_is_unique_navigation: bool,
admission_is_separate_from_identity: bool,
every_physical_call_has_numbered_route: bool,
every_accepted_call_has_evidence_class: bool,
every_protocol_reference_has_number_coordinate: bool,
reference_only_nodes_never_executable: bool,
unresolved_number_reference_count: usize,
mismatched_coordinate: String,
}
pub(crate) fn start_on_application_open() -> Result<(), String> {
validate_tree()
}
fn validate_tree() -> Result<(), String> {
let tree: NumberTree = serde_json::from_str(TREE)
.map_err(|error| format!("HOLOLAKE_UNIFIED_NUMBER_TREE_INVALID: {error}"))?;
if tree.schema != "hololake.unified-number-coordinate-tree/v2"
|| tree.record_id != "HLP-UNIFIED-NUMBER-TREE-001"
|| tree.state != "MACHINE_COMPILED_STARTUP_ENFORCED"
|| tree.root_number != "HLP-NUMBER-WORLD-ROOT-001"
|| tree.coordinate_count != 322
|| tree.route_count != 219
|| tree.routes.len() != tree.route_count
|| tree.identity_node_count != 4
|| tree.identity_nodes.len() != tree.identity_node_count
|| tree.protocol_node_count != 99
|| tree.protocol_nodes.len() != tree.protocol_node_count
|| tree.reference_only_node_count != 16
|| tree.coordinate_count
!= tree.route_count + tree.identity_node_count + tree.protocol_node_count
|| !tree.invariants.number_is_stable_coordinate_not_authority
|| !tree.invariants.path_is_unique_navigation
|| !tree.invariants.admission_is_separate_from_identity
|| !tree.invariants.every_physical_call_has_numbered_route
|| !tree.invariants.every_accepted_call_has_evidence_class
|| !tree
.invariants
.every_protocol_reference_has_number_coordinate
|| !tree.invariants.reference_only_nodes_never_executable
|| tree.invariants.unresolved_number_reference_count != 0
|| tree.invariants.mismatched_coordinate != "FAIL_CLOSED"
{
return Err("HOLOLAKE_UNIFIED_NUMBER_TREE_BOUNDARY_INVALID".into());
}
let mut paths = HashSet::new();
let mut coordinates = HashSet::new();
let mut node_numbers = HashSet::new();
let mut protocol_ids = HashSet::new();
for node in &tree.identity_nodes {
if node.node_kind != "IDENTITY_NAMESPACE"
|| !node.node_number.starts_with("HLP-IDENTITY-NS-")
|| node.namespace_id.is_empty()
|| node.subject_kind.is_empty()
|| node.domain_scope.is_empty()
|| !matches!(
node.admission.as_str(),
"REGISTERED_HUMAN_NAMESPACE" | "NON_HUMAN_NAMESPACE"
)
|| node.execution_state != "AUTHORITY_RESOLUTION_ONLY"
|| node.evidence.is_empty()
|| !node.path.starts_with("HLP-NUMBER-WORLD-ROOT-001/IDENTITY/")
|| !paths.insert(node.path.as_str())
|| !node_numbers.insert(node.node_number.as_str())
{
return Err("HOLOLAKE_UNIFIED_NUMBER_TREE_IDENTITY_NODE_INVALID".into());
}
}
let mut reference_only_count = 0;
for node in &tree.protocol_nodes {
let valid_state = match node.node_kind.as_str() {
"GLS_PROTOCOL_SOURCE" => {
matches!(
node.execution_state.as_str(),
"EXECUTABLE_PROJECTION" | "INVENTORIED_NOT_EXECUTABLE"
) && matches!(
node.source_state.as_str(),
"HDLP_PROTOCOL_SOURCE" | "LEGACY_MARKDOWN_EVIDENCE"
)
}
"GLS_REFERENCE_ONLY" => {
reference_only_count += 1;
node.execution_state == "REFERENCE_ONLY_NOT_EXECUTABLE"
&& node.source_state == "ROADMAP_REFERENCE_ONLY"
&& node.node_number.starts_with("HLP-GLS-REF-")
}
_ => false,
};
if !valid_state
|| !node.protocol_id.starts_with("GLS-")
|| node.evidence.is_empty()
|| !node.path.starts_with("HLP-NUMBER-WORLD-ROOT-001/GLS/")
|| !paths.insert(node.path.as_str())
|| !node_numbers.insert(node.node_number.as_str())
|| !protocol_ids.insert(node.protocol_id.as_str())
{
return Err("HOLOLAKE_UNIFIED_NUMBER_TREE_PROTOCOL_NODE_INVALID".into());
}
}
if reference_only_count != tree.reference_only_node_count {
return Err("HOLOLAKE_UNIFIED_NUMBER_TREE_REFERENCE_COUNT_INVALID".into());
}
for route in &tree.routes {
let coordinate = format!(
"{}:{}:{}:{}:{}:{}",
route.transport,
route.channel_number,
route.module_number,
route.operation_number,
route.target_number,
route.caller_number
);
if route.protocol_version.is_empty()
|| route.admission.is_empty()
|| !matches!(route.effect.as_str(), "READ_OR_STATUS" | "STATE_CHANGE")
|| route.evidence.is_empty()
|| !route.path.starts_with("HLP-NUMBER-WORLD-ROOT-001/")
|| !paths.insert(route.path.as_str())
|| !coordinates.insert(coordinate)
{
return Err("HOLOLAKE_UNIFIED_NUMBER_TREE_ROUTE_INVALID".into());
}
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn unified_number_tree_is_unique_permissioned_and_evidenced() {
validate_tree().unwrap();
}
}

View file

@ -0,0 +1,751 @@
//! Internal dispatch table for the numbered IPC root.
//!
//! This module is deliberately not a Tauri command surface. The webview can reach these
//! handlers only after `numbered_ipc` validates the full numbered coordinate and a
//! single-use, payload-bound grant.
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde_json::Value;
use tauri::{AppHandle, Manager};
fn input<T: DeserializeOwned>(payload: &Value) -> Result<T, String> {
let value = payload
.get("input")
.cloned()
.ok_or_else(|| "HOLOLAKE_NUMBERED_IPC_INPUT_REQUIRED".to_string())?;
serde_json::from_value(value)
.map_err(|error| format!("HOLOLAKE_NUMBERED_IPC_INPUT_INVALID: {error}"))
}
fn string_field(payload: &Value, field: &str) -> Result<String, String> {
payload
.get(field)
.and_then(Value::as_str)
.map(str::to_owned)
.ok_or_else(|| format!("HOLOLAKE_NUMBERED_IPC_FIELD_REQUIRED: {field}"))
}
fn json<T: Serialize>(value: T) -> Result<Value, String> {
serde_json::to_value(value)
.map_err(|error| format!("HOLOLAKE_NUMBERED_IPC_RESULT_INVALID: {error}"))
}
fn authenticated_human_subject(app: &AppHandle) -> Result<Option<(String, String)>, String> {
let state = app.state::<crate::zero_point::ZeroPointState>();
if let Some(subject) = crate::zero_point::verified_user_route(&state)? {
return Ok(Some(subject));
}
let Some(session) = crate::code_repo_login::current_login_session(app)? else {
return Ok(None);
};
if session.domain != "PERSONAL_CHANNEL" || session.host != "local.hololake" {
return Ok(None);
}
let identity = crate::personal_channel::identity_for_channel_runtime(app)?;
Ok(Some((identity.human_subject_id, session.domain)))
}
pub(crate) async fn dispatch(
app: AppHandle,
handler: &str,
payload: Value,
) -> Result<Value, String> {
match handler {
"home_status::get_hololake_home_status" => {
json(crate::home_status::get_hololake_home_status(
app.clone(),
app.state::<crate::direct_local_broker::DirectLocalBrokerState>(),
)?)
}
"human_authorization::get_authorization_center" => {
json(crate::human_authorization::get_center(&app)?)
}
"human_authorization::decide_authorization_request" => {
let (human_number, _) = authenticated_human_subject(&app)?
.ok_or_else(|| "HOLOLAKE_AUTHORIZATION_VERIFIED_HUMAN_REQUIRED".to_string())?;
json(crate::human_authorization::decide(
&app,
input(&payload)?,
&human_number,
)?)
}
"external_ai_gateway::get_gateway_status" => {
authenticated_human_subject(&app)?
.ok_or_else(|| "HOLOLAKE_GATEWAY_VERIFIED_HUMAN_REQUIRED".to_string())?;
json(crate::external_ai_gateway::get_gateway_status(app).await?)
}
"external_ai_gateway::set_gateway_exposure" => {
let (human_number, _) = authenticated_human_subject(&app)?
.ok_or_else(|| "HOLOLAKE_GATEWAY_VERIFIED_HUMAN_REQUIRED".to_string())?;
json(
crate::external_ai_gateway::set_gateway_exposure(
app,
input(&payload)?,
&human_number,
)
.await?,
)
}
"persona_agent_runtime::get_runtime_snapshot" => {
json(crate::persona_agent_runtime::get_runtime_snapshot(app).await?)
}
"persona_agent_runtime::upsert_provider" => {
json(crate::persona_agent_runtime::upsert_provider(app, input(&payload)?).await?)
}
"persona_agent_runtime::get_conversation" => {
json(crate::persona_agent_runtime::get_conversation(app)?)
}
"persona_agent_runtime::list_conversations" => {
json(crate::persona_agent_runtime::list_conversations(app)?)
}
"persona_agent_runtime::get_conversation_by_id" => json(
crate::persona_agent_runtime::get_conversation_by_id(app, input(&payload)?)?,
),
"persona_agent_runtime::create_conversation" => json(
crate::persona_agent_runtime::create_conversation(app, input(&payload)?)?,
),
"persona_agent_runtime::delete_conversation" => json(
crate::persona_agent_runtime::delete_conversation(app, input(&payload)?)?,
),
"persona_agent_runtime::send_message" => {
json(crate::persona_agent_runtime::send_message(app, input(&payload)?).await?)
}
"hldp_tool_forge::get_snapshot" => json(crate::hldp_tool_forge::get_snapshot(app)?),
"hldp_tool_forge::compile_tool" => {
json(crate::hldp_tool_forge::compile_tool(app, input(&payload)?)?)
}
"hldp_tool_forge::request_test_authorization" => {
let (human_number, _) = authenticated_human_subject(&app)?
.ok_or_else(|| "HOLOLAKE_TOOL_FORGE_VERIFIED_HUMAN_REQUIRED".to_string())?;
json(crate::hldp_tool_forge::request_test_authorization(
app,
input(&payload)?,
&human_number,
)?)
}
"hldp_tool_forge::test_tool" => {
let (human_number, _) = authenticated_human_subject(&app)?
.ok_or_else(|| "HOLOLAKE_TOOL_FORGE_VERIFIED_HUMAN_REQUIRED".to_string())?;
json(crate::hldp_tool_forge::test_tool(app, input(&payload)?, &human_number).await?)
}
"hldp_tool_forge::run_tool" => {
json(crate::hldp_tool_forge::run_tool(app, input(&payload)?).await?)
}
"local_execution_subpersona::get_snapshot" => {
json(crate::local_execution_subpersona::get_snapshot(app)?)
}
"local_execution_subpersona::configure" => json(
crate::local_execution_subpersona::configure(app, input(&payload)?)?,
),
"local_execution_subpersona::run_job" => {
json(crate::local_execution_subpersona::run_job(app, input(&payload)?).await?)
}
"channel_receipt::compile" => json(crate::channel_receipt::compile(app, input(&payload)?)?),
"release_update::check_hololake_update" => {
json(crate::release_update::check_hololake_update(app).await?)
}
"release_update::confirm_hololake_update_install" => json(
crate::release_update::confirm_hololake_update_install(app, input(&payload)?).await?,
),
"release_update::get_hololake_release_recovery_status" => json(
crate::release_update::get_hololake_release_recovery_status(app)?,
),
"release_update::confirm_hololake_release_health" => {
json(crate::release_update::confirm_hololake_release_health(app)?)
}
"release_update::rollback_hololake_update" => {
json(crate::release_update::rollback_hololake_update(app)?)
}
"direct_local_session::issue_direct_local_discovery_ticket" => json(
crate::direct_local_session::issue_direct_local_discovery_ticket(app, input(&payload)?)
.await?,
),
"direct_local_session::open_direct_local_session" => json(
crate::direct_local_session::open_direct_local_session(app, input(&payload)?).await?,
),
"direct_local_session::resume_direct_local_session" => json(
crate::direct_local_session::resume_direct_local_session(app, input(&payload)?).await?,
),
"direct_local_session::append_direct_local_session_event" => json(
crate::direct_local_session::append_direct_local_session_event(app, input(&payload)?)
.await?,
),
"direct_local_session::heartbeat_direct_local_session" => json(
crate::direct_local_session::heartbeat_direct_local_session(app, input(&payload)?)
.await?,
),
"direct_local_broker::get_nearby_ai_discovery" => {
json(crate::direct_local_broker::get_nearby_ai_discovery())
}
"gls_protocol_runtime::get_gls_protocol_runtime" => {
json(crate::gls_protocol_runtime::get_gls_protocol_runtime().await?)
}
"gls_protocol_kernel::get_gls_protocol_kernel" => {
json(crate::gls_protocol_kernel::get_gls_protocol_kernel(app).await?)
}
"gls_protocol_kernel::decide_gls_protocol" => json(
crate::gls_protocol_kernel::decide_gls_protocol(
app,
payload.get("input").cloned().unwrap_or(Value::Null),
)
.await?,
),
"gls_protocol_kernel::compile_gls_hldp_program" => json(
crate::gls_protocol_kernel::compile_gls_hldp_program(
app,
payload.get("input").cloned().unwrap_or(Value::Null),
)
.await?,
),
"module_package_runtime::get_module_runtime_snapshot" => {
json(crate::module_package_runtime::get_module_runtime_snapshot(app).await?)
}
"module_package_runtime::verify_module_package" => {
json(crate::module_package_runtime::verify_module_package(app, input(&payload)?).await?)
}
"module_package_runtime::install_module_package" => json(
crate::module_package_runtime::install_module_package(app, input(&payload)?).await?,
),
"module_package_runtime::mount_module" => {
json(crate::module_package_runtime::mount_module(app, input(&payload)?).await?)
}
"module_package_runtime::self_test_module" => {
json(crate::module_package_runtime::self_test_module(app, input(&payload)?).await?)
}
"module_package_runtime::unmount_module" => {
json(crate::module_package_runtime::unmount_module(app, input(&payload)?).await?)
}
"module_package_runtime::rollback_module" => {
json(crate::module_package_runtime::rollback_module(app, input(&payload)?).await?)
}
"module_package_runtime::get_bundled_module_catalog" => {
json(crate::module_package_runtime::get_bundled_module_catalog(app).await?)
}
"module_package_runtime::activate_bundled_module" => json(
crate::module_package_runtime::activate_bundled_module(app, input(&payload)?).await?,
),
"online_marketplace::get_marketplace_snapshot" => {
json(crate::online_marketplace::get_marketplace_snapshot(app).await?)
}
"online_marketplace::sync_marketplace_catalog" => {
json(crate::online_marketplace::sync_marketplace_catalog(app).await?)
}
"online_marketplace::install_marketplace_item" => {
json(crate::online_marketplace::install_marketplace_item(app, input(&payload)?).await?)
}
"online_marketplace::uninstall_marketplace_item" => json(
crate::online_marketplace::uninstall_marketplace_item(app, input(&payload)?).await?,
),
"online_marketplace::rollback_marketplace_item" => {
json(crate::online_marketplace::rollback_marketplace_item(app, input(&payload)?).await?)
}
"online_marketplace::get_active_cognitive_skills" => {
json(crate::online_marketplace::get_active_cognitive_skills(app).await?)
}
"mobile_sync::start_mobile_sync" => json(crate::mobile_sync::start_mobile_sync(app)?),
"mobile_sync::get_mobile_sync_status" => {
json(crate::mobile_sync::get_mobile_sync_status(app)?)
}
"mobile_sync::rotate_mobile_pairing" => {
json(crate::mobile_sync::rotate_mobile_pairing(app)?)
}
"mobile_sync::stop_mobile_sync" => json(crate::mobile_sync::stop_mobile_sync(app)?),
"mobile_sync::revoke_mobile_sync_device" => json(
crate::mobile_sync::revoke_mobile_sync_device(app, input(&payload)?)?,
),
"mobile_sync::get_mobile_sync_snapshot" => {
json(crate::mobile_sync::get_mobile_sync_snapshot(app)?)
}
"mobile_sync::list_mobile_codex_threads" => {
json(crate::mobile_sync::list_mobile_codex_threads(app)?)
}
"mobile_sync::select_mobile_codex_thread" => json(
crate::mobile_sync::select_mobile_codex_thread(app, input(&payload)?)?,
),
"world_climate::get_world_climate" => {
json(crate::world_climate::get_world_climate(app).await?)
}
"native_composition::get_native_composition_module_registry" => {
json(crate::native_composition::get_native_composition_module_registry())
}
"native_composition::execute_knowledge_native_composition" => json(
crate::native_composition::execute_knowledge_native_composition(app, input(&payload)?)
.await?,
),
"dynamic_work_surface::list_surfaces" => {
json(crate::dynamic_work_surface::list_surfaces(app).await?)
}
"dynamic_work_surface::save_surface" => {
json(crate::dynamic_work_surface::save_surface(app, input(&payload)?).await?)
}
"dynamic_work_surface::get_surface" => {
json(crate::dynamic_work_surface::get_surface(app, input(&payload)?).await?)
}
"dynamic_work_surface::execute_surface" => {
json(crate::dynamic_work_surface::execute_surface(app, input(&payload)?).await?)
}
"personal_state_repository::get_repository" => {
json(crate::personal_state_repository::get_repository(app).await?)
}
"personal_state_repository::create_snapshot" => {
json(crate::personal_state_repository::create_snapshot(app).await?)
}
"personal_state_repository::preview_restore" => {
json(crate::personal_state_repository::preview_restore(app, input(&payload)?).await?)
}
"personal_state_repository::apply_restore" => {
json(crate::personal_state_repository::apply_restore(app, input(&payload)?).await?)
}
"channel_workbench::get_channel_workbench_snapshot" => {
json(crate::channel_workbench::get_channel_workbench_snapshot(app).await?)
}
"channel_workbench::save_channel_document" => {
json(crate::channel_workbench::save_channel_document(app, input(&payload)?).await?)
}
"channel_workbench::save_channel_spreadsheet" => {
json(crate::channel_workbench::save_channel_spreadsheet(app, input(&payload)?).await?)
}
"persona_channel_body::get_persona_channel_body" => {
json(crate::persona_channel_body::get_persona_channel_body(app).await?)
}
"persona_channel_body::register_trial_persona" => {
json(crate::persona_channel_body::register_trial_persona(app, input(&payload)?).await?)
}
"persona_channel_body::delete_trial_persona" => {
json(crate::persona_channel_body::delete_trial_persona(app, input(&payload)?).await?)
}
"persona_channel_body::accept_persona_language_contract" => json(
crate::persona_channel_body::accept_persona_language_contract(app, input(&payload)?)
.await?,
),
"persona_channel_body::append_persona_language" => {
json(crate::persona_channel_body::append_persona_language(app, input(&payload)?).await?)
}
"channel_growth::get_channel_growth_snapshot" => {
json(crate::channel_growth::get_channel_growth_snapshot(app).await?)
}
"channel_growth::record_channel_growth_event" => {
json(crate::channel_growth::record_channel_growth_event(app, input(&payload)?).await?)
}
"channel_growth::update_channel_growth_sharing" => {
json(crate::channel_growth::update_channel_growth_sharing(app, input(&payload)?).await?)
}
"education_workspace::get_education_workspace_snapshot" => {
json(crate::education_workspace::get_education_workspace_snapshot(app).await?)
}
"education_broadcast_tower::get_snapshot" => {
json(crate::education_broadcast_tower::get_snapshot(app).await?)
}
"education_broadcast_tower::register_participant" => json(
crate::education_broadcast_tower::register_participant(app, input(&payload)?).await?,
),
"education_broadcast_tower::create_learning_plan" => json(
crate::education_broadcast_tower::create_learning_plan(app, input(&payload)?).await?,
),
"education_broadcast_tower::transition_learning_plan" => json(
crate::education_broadcast_tower::transition_learning_plan(app, input(&payload)?)
.await?,
),
"education_broadcast_tower::issue_push_ticket" => {
json(crate::education_broadcast_tower::issue_push_ticket(app, input(&payload)?).await?)
}
"education_broadcast_tower::claim_push_ticket" => {
json(crate::education_broadcast_tower::claim_push_ticket(app, input(&payload)?).await?)
}
"education_workspace::create_education_document" => json(
crate::education_workspace::create_education_document(app, input(&payload)?).await?,
),
"education_workspace::read_education_document" => {
json(crate::education_workspace::read_education_document(app, input(&payload)?).await?)
}
"education_workspace::save_education_document" => {
json(crate::education_workspace::save_education_document(app, input(&payload)?).await?)
}
"education_workspace::archive_education_document" => json(
crate::education_workspace::archive_education_document(app, input(&payload)?).await?,
),
"education_workspace::create_education_table" => {
json(crate::education_workspace::create_education_table(app, input(&payload)?).await?)
}
"education_workspace::read_education_table" => {
json(crate::education_workspace::read_education_table(app, input(&payload)?).await?)
}
"education_workspace::save_education_table" => {
json(crate::education_workspace::save_education_table(app, input(&payload)?).await?)
}
"education_workspace::archive_education_table" => {
json(crate::education_workspace::archive_education_table(app, input(&payload)?).await?)
}
"education_workspace::assign_imported_table_to_education" => json(
crate::education_workspace::assign_imported_table_to_education(app, input(&payload)?)
.await?,
),
"education_translation::import_education_tables_from_dialog" => {
json(crate::education_translation::import_education_tables_from_dialog(app).await?)
}
"education_translation::export_education_table_to_dialog" => json(
crate::education_translation::export_education_table_to_dialog(app, input(&payload)?)
.await?,
),
"education_translation::get_education_recognition_capability" => {
json(crate::education_translation::get_education_recognition_capability(app)?)
}
"education_workspace::create_education_automation_rule" => json(
crate::education_workspace::create_education_automation_rule(app, input(&payload)?)
.await?,
),
"education_workspace::save_education_automation_rule" => json(
crate::education_workspace::save_education_automation_rule(app, input(&payload)?)
.await?,
),
"education_workspace::archive_education_automation_rule" => json(
crate::education_workspace::archive_education_automation_rule(app, input(&payload)?)
.await?,
),
"education_workspace::preview_education_automation_rule" => json(
crate::education_workspace::preview_education_automation_rule(app, input(&payload)?)
.await?,
),
"education_workspace::execute_education_automation_rule" => json(
crate::education_workspace::execute_education_automation_rule(app, input(&payload)?)
.await?,
),
"web_novel_workspace::get_web_novel_workspace_snapshot" => {
json(crate::web_novel_workspace::get_web_novel_workspace_snapshot(app).await?)
}
"web_novel_workspace::create_web_novel_work" => {
json(crate::web_novel_workspace::create_web_novel_work(app, input(&payload)?).await?)
}
"web_novel_workspace::read_web_novel_work" => {
json(crate::web_novel_workspace::read_web_novel_work(app, input(&payload)?).await?)
}
"web_novel_workspace::save_web_novel_work" => {
json(crate::web_novel_workspace::save_web_novel_work(app, input(&payload)?).await?)
}
"web_novel_workspace::create_web_novel_volume" => {
json(crate::web_novel_workspace::create_web_novel_volume(app, input(&payload)?).await?)
}
"web_novel_workspace::create_web_novel_chapter" => {
json(crate::web_novel_workspace::create_web_novel_chapter(app, input(&payload)?).await?)
}
"web_novel_workspace::read_web_novel_chapter" => {
json(crate::web_novel_workspace::read_web_novel_chapter(app, input(&payload)?).await?)
}
"web_novel_workspace::save_web_novel_chapter" => {
json(crate::web_novel_workspace::save_web_novel_chapter(app, input(&payload)?).await?)
}
"web_novel_workspace::transition_web_novel_chapter" => json(
crate::web_novel_workspace::transition_web_novel_chapter(app, input(&payload)?).await?,
),
"web_novel_workspace::create_web_novel_checkpoint" => json(
crate::web_novel_workspace::create_web_novel_checkpoint(app, input(&payload)?).await?,
),
"web_novel_workspace::restore_web_novel_checkpoint" => json(
crate::web_novel_workspace::restore_web_novel_checkpoint(app, input(&payload)?).await?,
),
"web_novel_workspace::upsert_web_novel_story_entity" => json(
crate::web_novel_workspace::upsert_web_novel_story_entity(app, input(&payload)?)
.await?,
),
"web_novel_workspace::create_web_novel_story_relation" => json(
crate::web_novel_workspace::create_web_novel_story_relation(app, input(&payload)?)
.await?,
),
"web_novel_workspace::upsert_web_novel_foreshadow" => json(
crate::web_novel_workspace::upsert_web_novel_foreshadow(app, input(&payload)?).await?,
),
"web_novel_workspace::create_web_novel_review_note" => json(
crate::web_novel_workspace::create_web_novel_review_note(app, input(&payload)?).await?,
),
"web_novel_workspace::resolve_web_novel_review_note" => json(
crate::web_novel_workspace::resolve_web_novel_review_note(app, input(&payload)?)
.await?,
),
"web_novel_workspace::save_web_novel_metric" => {
json(crate::web_novel_workspace::save_web_novel_metric(app, input(&payload)?).await?)
}
"web_novel_workspace::run_web_novel_continuity_audit" => json(
crate::web_novel_workspace::run_web_novel_continuity_audit(app, input(&payload)?)
.await?,
),
"web_novel_workspace::export_web_novel_markdown" => json(
crate::web_novel_workspace::export_web_novel_markdown(app, input(&payload)?).await?,
),
"web_novel_import::inspect_web_novel_document_from_dialog" => {
json(crate::web_novel_import::inspect_web_novel_document_from_dialog(app).await?)
}
"web_novel_import::commit_web_novel_document_import" => json(
crate::web_novel_import::commit_web_novel_document_import(app, input(&payload)?)
.await?,
),
"web_novel_author::get_web_novel_author_snapshot" => json(
crate::web_novel_author::get_web_novel_author_snapshot(app, input(&payload)?).await?,
),
"web_novel_author::record_web_novel_writing_activity" => json(
crate::web_novel_author::record_web_novel_writing_activity(app, input(&payload)?)
.await?,
),
"web_novel_author::create_web_novel_inspiration" => json(
crate::web_novel_author::create_web_novel_inspiration(app, input(&payload)?).await?,
),
"web_novel_author::set_web_novel_inspiration_status" => json(
crate::web_novel_author::set_web_novel_inspiration_status(app, input(&payload)?)
.await?,
),
"web_novel_author::search_web_novel_full_text" => {
json(crate::web_novel_author::search_web_novel_full_text(app, input(&payload)?).await?)
}
"web_novel_author::format_web_novel_chapter" => {
json(crate::web_novel_author::format_web_novel_chapter(app, input(&payload)?).await?)
}
"web_novel_author::format_web_novel_work" => {
json(crate::web_novel_author::format_web_novel_work(app, input(&payload)?).await?)
}
"web_novel_author::upsert_web_novel_shot" => {
json(crate::web_novel_author::upsert_web_novel_shot(app, input(&payload)?).await?)
}
"web_novel_modules::get_web_novel_author_module_data" => json(
crate::web_novel_modules::get_web_novel_author_module_data(app, input(&payload)?)
.await?,
),
"web_novel_modules::upsert_web_novel_author_scene" => json(
crate::web_novel_modules::upsert_web_novel_author_scene(app, input(&payload)?).await?,
),
"web_novel_modules::upsert_web_novel_author_beat" => json(
crate::web_novel_modules::upsert_web_novel_author_beat(app, input(&payload)?).await?,
),
"web_novel_modules::upsert_web_novel_story_field_definition" => json(
crate::web_novel_modules::upsert_web_novel_story_field_definition(
app,
input(&payload)?,
)
.await?,
),
"web_novel_modules::upsert_web_novel_story_field_value" => json(
crate::web_novel_modules::upsert_web_novel_story_field_value(app, input(&payload)?)
.await?,
),
"web_novel_modules::upsert_web_novel_timeline_event" => json(
crate::web_novel_modules::upsert_web_novel_timeline_event(app, input(&payload)?)
.await?,
),
"web_novel_modules::link_web_novel_scene_entity" => json(
crate::web_novel_modules::link_web_novel_scene_entity(app, input(&payload)?).await?,
),
"web_novel_modules::restore_web_novel_chapter_version" => json(
crate::web_novel_modules::restore_web_novel_chapter_version(app, input(&payload)?)
.await?,
),
"web_novel_modules::export_web_novel_author_delivery" => json(
crate::web_novel_modules::export_web_novel_author_delivery(app, input(&payload)?)
.await?,
),
"local_development_bridge::acquire_development_write_lane" => json(
crate::local_development_bridge::acquire_development_write_lane(app, input(&payload)?)
.await?,
),
"local_development_bridge::inspect_development_write_lane" => json(
crate::local_development_bridge::inspect_development_write_lane(app, input(&payload)?)
.await?,
),
"local_development_bridge::release_development_write_lane" => json(
crate::local_development_bridge::release_development_write_lane(app, input(&payload)?)
.await?,
),
"personal_channel::get_personal_channel_snapshot" => {
json(crate::personal_channel::get_personal_channel_snapshot(app).await?)
}
"personal_channel::initialize_personal_channel" => {
json(crate::personal_channel::initialize_personal_channel(app, input(&payload)?).await?)
}
"personal_channel::create_personal_channel_task" => json(
crate::personal_channel::create_personal_channel_task(app, input(&payload)?).await?,
),
"personal_channel::transition_personal_channel_task" => json(
crate::personal_channel::transition_personal_channel_task(app, input(&payload)?)
.await?,
),
"persona_time_authority::issue_persona_time_ticket" => json(
crate::persona_time_authority::issue_persona_time_ticket(app, input(&payload)?).await?,
),
"persona_time_authority::start_persona_time_authority" => {
json(crate::persona_time_authority::start_persona_time_authority().await?)
}
"persona_time_authority::get_beijing_time_coordinate" => {
json(crate::persona_time_authority::get_beijing_time_coordinate()?)
}
"persona_time_authority::get_guanghu_era_timeline" => {
json(crate::persona_time_authority::get_guanghu_era_timeline()?)
}
"knowledge_base::get_knowledge_snapshot" => {
json(crate::knowledge_base::get_knowledge_snapshot(app).await?)
}
"knowledge_base::read_knowledge_document" => {
json(crate::knowledge_base::read_knowledge_document(app, input(&payload)?).await?)
}
"knowledge_base::search_knowledge" => {
json(crate::knowledge_base::search_knowledge(app, input(&payload)?).await?)
}
"knowledge_base::compile_knowledge_thought_index" => json(
crate::knowledge_base::compile_knowledge_thought_index(app, input(&payload)?).await?,
),
"knowledge_base::save_knowledge_document" => {
json(crate::knowledge_base::save_knowledge_document(app, input(&payload)?).await?)
}
"knowledge_base::select_and_import_knowledge_folder" => {
json(crate::knowledge_base::select_and_import_knowledge_folder(app).await?)
}
"knowledge_base::export_knowledge_document" => {
json(crate::knowledge_base::export_knowledge_document(app, input(&payload)?).await?)
}
"knowledge_base::create_knowledge_document" => {
json(crate::knowledge_base::create_knowledge_document(app, input(&payload)?).await?)
}
"knowledge_base::delete_knowledge_document" => {
json(crate::knowledge_base::delete_knowledge_document(app, input(&payload)?).await?)
}
"knowledge_base::delete_knowledge_folder" => {
json(crate::knowledge_base::delete_knowledge_folder(app, input(&payload)?).await?)
}
"knowledge_base::print_knowledge_document" => {
crate::knowledge_base::print_knowledge_document(app).await?;
Ok(Value::Null)
}
"code_channel::get_code_channel_snapshot" => {
json(crate::code_channel::get_code_channel_snapshot(app).await?)
}
"code_channel::clone_code_channel" => {
json(crate::code_channel::clone_code_channel(app, input(&payload)?).await?)
}
"code_channel::select_local_code_channel" => {
json(crate::code_channel::select_local_code_channel(app).await?)
}
"code_channel::browse_code_channel" => {
json(crate::code_channel::browse_code_channel(app, input(&payload)?).await?)
}
"code_channel::read_code_channel_file" => {
json(crate::code_channel::read_code_channel_file(app, input(&payload)?).await?)
}
"pncc_repository_binding::inspect_mounted_pncc_repository" => json(
crate::pncc_repository_binding::inspect_mounted_pncc_repository(app, input(&payload)?)
.await?,
),
"pncc_repository_binding::select_pncc_repository_candidate" => {
json(crate::pncc_repository_binding::select_pncc_repository_candidate(app).await?)
}
"pncc_repository_binding::confirm_pncc_repository_mount" => json(
crate::pncc_repository_binding::confirm_pncc_repository_mount(app, input(&payload)?)
.await?,
),
"pncc_receipt_projection::query_pncc_receipt_projection" => json(
crate::pncc_receipt_projection::query_pncc_receipt_projection(app, input(&payload)?)
.await?,
),
"pncc_server_projection::query_jd_pncc_server_projection" => {
json(crate::pncc_server_projection::query_jd_pncc_server_projection().await?)
}
"code_repo_login::check_code_repo_login" => {
json(crate::code_repo_login::check_code_repo_login(
app.clone(),
app.state::<crate::zero_point::ZeroPointState>(),
)?)
}
"code_repo_login::start_local_channel_session" => json(
crate::code_repo_login::start_local_channel_session(app, input(&payload)?)?,
),
"code_repo_login::perform_code_repo_login" => json(
crate::code_repo_login::perform_code_repo_login(
app.clone(),
app.state::<crate::zero_point::ZeroPointState>(),
string_field(&payload, "username")?,
string_field(&payload, "password")?,
)
.await?,
),
"code_repo_login::change_first_login_password" => json(
crate::code_repo_login::change_first_login_password(
app.state::<crate::zero_point::ZeroPointState>(),
string_field(&payload, "username")?,
string_field(&payload, "currentPassword")?,
string_field(&payload, "newPassword")?,
)
.await?,
),
"code_repo_login::get_enterprise_entry" => json(
crate::code_repo_login::get_enterprise_entry(
app.clone(),
app.state::<crate::zero_point::ZeroPointState>(),
)
.await?,
),
"code_repo_login::confirm_enterprise_persona_relationship" => json(
crate::code_repo_login::confirm_enterprise_persona_relationship(
app.clone(),
app.state::<crate::zero_point::ZeroPointState>(),
string_field(&payload, "decision")?,
string_field(&payload, "idempotencyKey")?,
)
.await?,
),
"code_repo_login::submit_enterprise_responsibility_receipt" => json(
crate::code_repo_login::submit_enterprise_responsibility_receipt(
app.clone(),
app.state::<crate::zero_point::ZeroPointState>(),
string_field(&payload, "decision")?,
string_field(&payload, "note")?,
string_field(&payload, "responsibilityVersion")?,
string_field(&payload, "idempotencyKey")?,
)
.await?,
),
"enterprise_work_channel::ensure_enterprise_work_channel" => json(
crate::enterprise_work_channel::ensure_enterprise_work_channel(
app.clone(),
app.state::<crate::zero_point::ZeroPointState>(),
)
.await?,
),
"code_repo_login::sign_out_code_repo_login" => {
crate::code_repo_login::sign_out_code_repo_login(app)?;
Ok(Value::Null)
}
"user_pncc_channel::get_user_pncc_channel" => json(
crate::user_pncc_channel::get_user_pncc_channel(
app.clone(),
app.state::<crate::zero_point::ZeroPointState>(),
)
.await?,
),
"user_pncc_channel::ensure_user_pncc_channel" => json(
crate::user_pncc_channel::ensure_user_pncc_channel(
app.clone(),
app.state::<crate::zero_point::ZeroPointState>(),
)
.await?,
),
"zero_core_numbering::get_zero_core_numbering_kernel" => {
json(crate::zero_core_numbering::get_zero_core_numbering_kernel().await?)
}
"zero_point::zero_point_bind" => json(
crate::zero_point::zero_point_bind(
app.state::<crate::zero_point::ZeroPointState>(),
payload.get("input").cloned().unwrap_or(Value::Null),
)
.await?,
),
"zero_point::zero_point_verify" => json(
crate::zero_point::zero_point_verify(app.state::<crate::zero_point::ZeroPointState>())
.await?,
),
"zero_point::zero_point_sync" => json(
crate::zero_point::zero_point_sync(app.state::<crate::zero_point::ZeroPointState>())
.await?,
),
"zero_point::zero_point_status" => json(
crate::zero_point::zero_point_status(app.state::<crate::zero_point::ZeroPointState>())
.await?,
),
_ => Err("HOLOLAKE_NUMBERED_IPC_HANDLER_UNKNOWN".into()),
}
}