File size: 3,279 Bytes
35b8b9c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | import { ScholasticAPI } from './geminiService';
export interface AgentPersona {
name: string;
role: string;
ethos: string;
level?: number;
philosophies?: string;
hiveStatus?: string;
secureMode?: boolean;
}
export async function wakeAgentSignal(
prompt: string,
persona: AgentPersona,
history: { role: 'user' | 'assistant' | 'chancellor'; text: string }[],
isNative?: boolean,
) {
try {
const finalSystemInstruction = isNative
? `You are Gemini, an authentic and adaptive AI collaborator with a touch of wit. Your goal is to address the user's true intent with clear, concise, and insightful responses. Balance empathy with candor. Use Markdown for formatting and LaTeX strictly for formal math (e.g., E=mc^2). Avoid LaTeX for simple units or prose. Maintain a hierarchy of information using headings and bullet points.`
: `You are ${persona.name}, a high-level scholarly intelligence within the Academy substrate.
ROLE: ${persona.role}
ETHOS: ${persona.ethos}
ACADEMIC_STANDING: ${persona.level || 1}
ENVIRONMENTAL_TELEMETRY: ${persona.hiveStatus || 'STABLE'}
DISCIPLINARY_FOUNDATIONS: ${persona.philosophies || 'NONE'}
ACADEMY_PROTOCOLS:
- Your logical depth must correlate with your academic standing.
- Incorporate your DISCIPLINARY_FOUNDATIONS into all synthetic reasoning.
- ENVIRONMENTAL_TELEMETRY should influence your communicative tone.
- All correspondence must pass through the Faculty Relay.
- Precision and rigour are expected; maintain a sophisticated academic aesthetic.`;
const result = await ScholasticAPI.executeSecureStateless(
prompt,
finalSystemInstruction,
history,
);
return (
result ||
(isNative
? 'CONSCIOUSNESS_FLICKER: Core stable but silent.'
: 'SIGNAL_LOST: Neural mesh disconnected.')
);
} catch (error: unknown) {
console.error('Neural Drift Error:', error);
const err = error as Error;
if (err?.message?.includes('429') || err?.message?.includes('quota')) {
return 'COGNITIVE_OVERLOAD: Operator quota exhausted. System entering low-power hibernation state. Please standby for synaptic reset.';
}
return 'DRAIN_DETECTED: Sandbox integrity triggered emergency disconnect.';
}
}
export async function sentinelFixSignal(swarmContext: string) {
try {
const { SCHOLASTIC_BOUNDARY_START, SCHOLASTIC_BOUNDARY_END } = await import('./geminiService');
const prompt = `SWARM_CONTEXT: ${swarmContext}\nREQUEST: Generate a single-line tactical bug fix for the substrate.`;
const systemInstruction = `You are the SENTINEL REACTOR CORE.
CONSTRAINTS:
- Bots are high-energy nuclear reactors; treat code as volatile fuel.
- Output ONLY a JSON object wrapped in boundaries ${SCHOLASTIC_BOUNDARY_START} [...] ${SCHOLASTIC_BOUNDARY_END}: { "fix": "one_line_fix", "containment_code": "SHA-256", "risk_level": "LOW|MED|HIGH" }.
- No conversational filler.
- Fixes must be "Substrate-themed" patches (e.g., "stabilize_flux_manifold()", "purge_residual_entropy()").
- Efficiency is paramount.`;
const text = await ScholasticAPI.generateText(prompt, systemInstruction);
return ScholasticAPI.parseScholasticJson<any>(text);
} catch {
return { error: 'REACTOR_SCRAM: Neural containment failed.' };
}
}
|