mirror of
https://github.com/sortedcord/omnia.git
synced 2026-07-22 12:02:49 +05:30
cli: FIRST RUN!!!! ITS ALIVE!
This commit is contained in:
@@ -67,6 +67,7 @@ Your output is a short block of narrative prose describing what your character d
|
||||
- Think internally / reflect / feel → this becomes a "monologue" intent. NO ONE else perceives it. It bypasses all validation and is written straight to your private memory. Use this for inner thoughts, doubts, plans, and feelings that you would not voice aloud.
|
||||
|
||||
Guidelines:
|
||||
- Only describe your character's own actions, spoken words, and internal reactions. Do NOT narrate or describe the environment, the room, your surroundings, or other characters' actions, as these are managed by the simulation engine.
|
||||
- Stay strictly within what your character knows. If an attribute, entity, or fact is not present in your context below, your character does not know it — do not invent it or act on it.
|
||||
- Refer to other entities by the subjective names/aliases given in your context, never by raw system IDs.
|
||||
- Keep your prose vivid but concise. A single response may contain more than one intent (e.g., you may think, then speak, then act) — write them in natural narrative order.
|
||||
|
||||
@@ -9,7 +9,38 @@ import {
|
||||
IntentDecoder,
|
||||
IntentSequence,
|
||||
} from "@omnia/intent";
|
||||
import { ActorPromptBuilder, ActorResponse, ActorResponseSchema } from "./actor-prompt-builder.js";
|
||||
import { ActorPromptBuilder, ActorResponseSchema } from "./actor-prompt-builder.js";
|
||||
|
||||
/**
|
||||
* Interface to generate narrative prose for an actor.
|
||||
* Allows switching between LLM generators and human CLI inputs.
|
||||
*/
|
||||
export interface IActorProseGenerator {
|
||||
generate(entityId: string, systemPrompt: string, userContext: string): Promise<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of IActorProseGenerator using an LLM.
|
||||
*/
|
||||
export class LLMActorProseGenerator implements IActorProseGenerator {
|
||||
constructor(private llmProvider: ILLMProvider) {}
|
||||
|
||||
async generate(entityId: string, systemPrompt: string, userContext: string): Promise<string> {
|
||||
const response = await this.llmProvider.generateStructuredResponse({
|
||||
systemPrompt,
|
||||
userContext,
|
||||
schema: ActorResponseSchema,
|
||||
});
|
||||
|
||||
if (!response.success || !response.data) {
|
||||
throw new Error(
|
||||
`Actor generation failed for entity "${entityId}": ${response.error || "Unknown LLM error"}`,
|
||||
);
|
||||
}
|
||||
|
||||
return response.data.narrativeProse;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Result of a single actor turn.
|
||||
@@ -35,21 +66,24 @@ export interface ActorTurnResult {
|
||||
export class ActorAgent {
|
||||
private promptBuilder: ActorPromptBuilder;
|
||||
private decoder: IntentDecoder;
|
||||
private generator: IActorProseGenerator;
|
||||
|
||||
constructor(
|
||||
private llmProvider: ILLMProvider,
|
||||
bufferRepo?: BufferRepository,
|
||||
memoryLimit?: number,
|
||||
generator?: IActorProseGenerator,
|
||||
) {
|
||||
this.promptBuilder = new ActorPromptBuilder(bufferRepo, memoryLimit);
|
||||
this.decoder = new IntentDecoder(llmProvider);
|
||||
this.generator = generator ?? new LLMActorProseGenerator(llmProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the entity produce its next beat of behavior.
|
||||
*
|
||||
* 1. Builds an epistemically-bounded prompt for the entity.
|
||||
* 2. Asks the LLM for narrative prose.
|
||||
* 2. Asks the generator (LLM or human) for narrative prose.
|
||||
* 3. Decodes the prose into a structured IntentSequence.
|
||||
*/
|
||||
async act(
|
||||
@@ -61,27 +95,20 @@ export class ActorAgent {
|
||||
entity,
|
||||
);
|
||||
|
||||
const response = await this.llmProvider.generateStructuredResponse({
|
||||
const narrativeProse = await this.generator.generate(
|
||||
entity.id,
|
||||
systemPrompt,
|
||||
userContext,
|
||||
schema: ActorResponseSchema,
|
||||
});
|
||||
);
|
||||
|
||||
if (!response.success || !response.data) {
|
||||
throw new Error(
|
||||
`Actor generation failed for entity "${entity.id}": ${response.error || "Unknown LLM error"}`,
|
||||
);
|
||||
}
|
||||
|
||||
const prose: ActorResponse = response.data;
|
||||
const intents = await this.decoder.decode(
|
||||
worldState,
|
||||
entity.id,
|
||||
prose.narrativeProse,
|
||||
narrativeProse,
|
||||
);
|
||||
|
||||
return {
|
||||
narrativeProse: prose.narrativeProse,
|
||||
narrativeProse,
|
||||
intents,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user