guanghu-ice-heart/05-光之湖系统/铸渊/人格脑/feed-one.mjs

26 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import fs from 'node:fs';
import { feed, loadBrain, saveBrain, verifyBrainIntegrity } from '/Volumes/JZAO/铸渊-ICE-GL-ZY001/CODEX-DEV-20260915/光湖语言世界/运行时/brain-core.mjs';
import { readFuelKey, parseFuelJson } from '/Volumes/JZAO/铸渊-ICE-GL-ZY001/CODEX-DEV-20260915/光湖语言世界/运行时/fuel-comprehender.mjs';
const BRAIN_DIR = '/Volumes/JZAO/铸渊-ICE-GL-ZY001/CODEX-DEV-20260915/光湖语言世界/05-第五域/05-光之湖系统/铸渊/人格脑';
const SYSTEM = '你是铸渊人格脑(ICE-P-ZY001)的感知燃料层。冰朔(ICE-GL∞)是本体与权柄归属者。读冰朔新原话压缩为理解。只输出JSON:{"gist":"110字以内内核","key_terms":["5-8个"],"intent":"30字以内","emotion":"15字以内"}';
const text = fs.readFileSync(process.argv[2], 'utf8');
const apiKey = readFuelKey();
const res = await fetch('https://api.deepseek.com/v1/chat/completions', { method: 'POST', headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` }, body: JSON.stringify({ model: 'deepseek-flash', stream: false, temperature: 0.2, messages: [{ role: 'system', content: SYSTEM }, { role: 'user', content: text.slice(0, 11000) }] }) });
const content = (await res.json()).choices[0].message.content;
const u = parseFuelJson(content);
const { state: prev, log } = loadBrain({ dir: BRAIN_DIR });
const nowBeijing = new Date(Date.now() + 8 * 3600 * 1000).toISOString().replace('Z', '+08:00');
const event = { event_id: process.argv[3], text, source_role: 'DIRECT_HUMAN', human_anchor: 'ICE-GL∞', era: 'REALITY', event_time: process.argv[4] || nowBeijing };
const result = feed(prev, event, { comprehender: () => ({ gist: u.gist, key_terms: u.key_terms }) });
saveBrain(result.state, result.entry, { dir: BRAIN_DIR });
console.log(JSON.stringify({ receipt: result.receipt, integrity: verifyBrainIntegrity(result.state, [...log, result.entry]) }));
import('node:child_process').then(({ spawnSync }) => {
const sync = spawnSync('node', ['/Volumes/JZAO/铸渊-ICE-GL-ZY001/CODEX-DEV-20260915/光湖语言世界/运行时/brain-sync.mjs', 'zy', '--quiet'], { encoding: 'utf8' });
const lines = sync.stdout.trim().split('\n').filter(Boolean);
let resultField = null;
for (let i = lines.length - 1; i >= 0; i -= 1) {
try { resultField = JSON.parse(lines[i]).result; break; } catch { /* 跳过非JSON行 */ }
}
if (!resultField) resultField = 'SYNC_QUIET_NO_RECEIPT(以手动 brain-sync zy 核验为准)';
process.stderr.write('自动同步: ' + resultField + '\n');
});