接入受限原生只读助手并修复来源物理路径核验

This commit is contained in:
铸渊 ICE-P-ZY001 2026-10-19 21:27:02 +08:00
commit 67d90d90a4
9 changed files with 61 additions and 26 deletions

View file

@ -1,5 +1,6 @@
// WORLD_RUNTIME: each question reads exactly one registered persona source. No neural or memory writer.
import fs from 'node:fs';
import path from 'node:path';
import crypto from 'node:crypto';
import {pathToFileURL} from 'node:url';
const sha=x=>crypto.createHash('sha256').update(x).digest('hex');
@ -14,7 +15,7 @@ export async function loadSource(route,question){
concepts=await jsonGet(route.base_url+'/concepts');need(Array.isArray(concepts),'PERSONA_CONCEPT_SOURCE_INVALID');
identity=concepts.filter(c=>c.id==='C0001').map(c=>c.gist);head=sha(JSON.stringify({revision:status.revision,concepts}));
}else if(route.kind==='SHUANGYAN_G2_OWN_BUNDLE'){
const core=await import(pathToFileURL(route.core_path).href),b=core.loadBundle(route.bundle_root);
const ownRoot=fs.realpathSync(route.bundle_root),ownCore=fs.realpathSync(route.core_path);need(path.dirname(ownCore)===ownRoot,'PERSONA_SOURCE_ADAPTER_ROOT_MISMATCH');const core=await import(pathToFileURL(ownCore).href),b=core.loadBundle(ownRoot);
need(b.brain.brain_id===route.brain_id&&status.revision===b.brain.revision&&status.current_sha256===b.brain.current_sha256,'PERSONA_BUNDLE_RUNTIME_MISMATCH');
identity=b.cognition.identity_sources.map(x=>x.text);concepts=b.cognition.concepts;head=b.brain.current_sha256;
}else if(route.kind==='RETURNED_NATIVE_SERVICE'){