chore: Format files

This commit is contained in:
2026-07-15 19:20:13 +05:30
parent 9838d4ce59
commit 9d18444220
78 changed files with 9416 additions and 5242 deletions

View File

@@ -14,14 +14,15 @@ describe("GeminiProvider Eval", () => {
});
const response = await provider.generateStructuredResponse({
systemPrompt: "You are a helpful assistant. Classify the tone of the user's sentence.",
systemPrompt:
"You are a helpful assistant. Classify the tone of the user's sentence.",
userContext: "I absolutely love this new engine, it works perfectly!",
schema: ToneSchema,
});
expect(response.success).toBe(true);
expect(response.data).toBeDefined();
const data = response.data!;
expect(data.tone).toBe("positive");
expect(data.confidence).toBeGreaterThan(0.8);

View File

@@ -6,7 +6,7 @@ import { IntentDecoder } from "@omnia/intent";
describe("IntentDecoder Live Eval (Tier 3)", () => {
test("decodes real complex narrative prose using live Gemini API", async () => {
expect(llmConfig.GOOGLE_API_KEY).toBeDefined();
// 1. Initialize live provider and decoder
const provider = new GeminiProvider(llmConfig.GOOGLE_API_KEY);
const decoder = new IntentDecoder(provider);
@@ -19,7 +19,8 @@ describe("IntentDecoder Live Eval (Tier 3)", () => {
world.addEntity(bob);
// 3. Narrative prose containing both a dialogue and physical action
const narrativeProse = '"Let\'s see if this key opens the main vault," Alice said to Bob. She slipped the silver key into the keyhole and turned it slowly.';
const narrativeProse =
'"Let\'s see if this key opens the main vault," Alice said to Bob. She slipped the silver key into the keyhole and turned it slowly.';
// 4. Decode prose using live Gemini model
const result = await decoder.decode(world, "alice", narrativeProse);
@@ -30,14 +31,16 @@ describe("IntentDecoder Live Eval (Tier 3)", () => {
expect(result.intents.length).toBeGreaterThanOrEqual(1);
// Verify first intent is dialogue spoken to Bob
const dialogueIntent = result.intents.find(i => i.type === "dialogue");
const dialogueIntent = result.intents.find((i) => i.type === "dialogue");
expect(dialogueIntent).toBeDefined();
expect(dialogueIntent!.actorId).toBe("alice");
expect(dialogueIntent!.targetIds).toContain("bob");
expect(dialogueIntent!.originalText).toContain("Let's see if this key opens the main vault");
expect(dialogueIntent!.originalText).toContain(
"Let's see if this key opens the main vault",
);
// Verify second intent is action
const actionIntent = result.intents.find(i => i.type === "action");
const actionIntent = result.intents.find((i) => i.type === "action");
expect(actionIntent).toBeDefined();
expect(actionIntent!.actorId).toBe("alice");
expect(actionIntent!.originalText).toContain("slipped the silver key");
@@ -45,28 +48,29 @@ describe("IntentDecoder Live Eval (Tier 3)", () => {
test("resolves targets correctly using the actor's subjective alias map", async () => {
expect(llmConfig.GOOGLE_API_KEY).toBeDefined();
const provider = new GeminiProvider(llmConfig.GOOGLE_API_KEY);
const decoder = new IntentDecoder(provider);
const world = new WorldState("world-xyz");
const alice = new Entity("alice");
const bob = new Entity("bob");
// Register alias mapping: Bob is known to Alice as "the hooded stranger"
alice.aliases.set("bob", "the hooded stranger");
world.addEntity(alice);
world.addEntity(bob);
// Narrative prose referring to Bob only by the subjective alias
const narrativeProse = "Alice handed the silver key to the hooded stranger.";
const narrativeProse =
"Alice handed the silver key to the hooded stranger.";
const result = await decoder.decode(world, "alice", narrativeProse);
expect(result.intents).toHaveLength(1);
const intent = result.intents[0];
expect(intent.type).toBe("action");
expect(intent.actorId).toBe("alice");
// Verify target resolution resolved the alias back to the correct system entity ID

View File

@@ -9,10 +9,7 @@ import {
import { MockLLMProvider } from "@omnia/llm";
import { IntentSequence } from "@omnia/intent";
import { Architect } from "@omnia/architect";
import {
BufferRepository,
BufferEntry,
} from "@omnia/memory";
import { BufferRepository, BufferEntry } from "@omnia/memory";
import {
ActorAgent,
ActorResponseSchema,
@@ -53,16 +50,22 @@ describe("Actor Agent + Monologue Intent Integration (Tier 2)", () => {
// --- Mock LLM response queue ---
// 1. Actor produces prose containing a thought, a spoken line, and an action.
const mockActorProse = { narrativeProse: "I can't believe Bob hasn't noticed me yet, Alice thought. \"Hey Bob,\" she called out softly. She reached for the ledger on the table." };
const mockActorProse = {
narrativeProse:
"I can't believe Bob hasn't noticed me yet, Alice thought. \"Hey Bob,\" she called out softly. She reached for the ledger on the table.",
};
// 2. IntentDecoder splits that prose into 3 intents.
const mockDecodedSequence: IntentSequence = {
intents: [
{
type: "monologue",
originalText: "I can't believe Bob hasn't noticed me yet, Alice thought.",
description: "Alice internally reflects that Bob has not noticed her.",
selfDescription: "You internally reflect that Bob has not noticed you.",
originalText:
"I can't believe Bob hasn't noticed me yet, Alice thought.",
description:
"Alice internally reflects that Bob has not noticed her.",
selfDescription:
"You internally reflect that Bob has not noticed you.",
actorId: "alice",
targetIds: [],
modifiers: [],
@@ -90,16 +93,25 @@ describe("Actor Agent + Monologue Intent Integration (Tier 2)", () => {
// 3. Architect: dialogue is always valid (1 min), action is valid (2 min).
// NOTE: monologue never reaches the validator/delta generator.
const mockDialogueValidation = { isValid: true, reason: "Alice can speak." };
const mockActionValidation = { isValid: true, reason: "The ledger is within reach." };
const mockActionTimeDelta = { minutesToAdvance: 2, explanation: "Reaching for the ledger takes 2 minutes." };
const mockDialogueValidation = {
isValid: true,
reason: "Alice can speak.",
};
const mockActionValidation = {
isValid: true,
reason: "The ledger is within reach.",
};
const mockActionTimeDelta = {
minutesToAdvance: 2,
explanation: "Reaching for the ledger takes 2 minutes.",
};
const llmProvider = new MockLLMProvider([
mockActorProse, // 1. Actor generation
mockDecodedSequence, // 2. IntentDecoder
mockDialogueValidation, // 3. Architect.validateIntent (dialogue)
mockActionValidation, // 4. Architect.validateIntent (action)
mockActionTimeDelta, // 5. TimeDeltaGenerator (action)
mockActorProse, // 1. Actor generation
mockDecodedSequence, // 2. IntentDecoder
mockDialogueValidation, // 3. Architect.validateIntent (dialogue)
mockActionValidation, // 4. Architect.validateIntent (action)
mockActionTimeDelta, // 5. TimeDeltaGenerator (action)
]);
const actor = new ActorAgent(llmProvider, bufferRepo);
@@ -178,9 +190,7 @@ describe("Actor Agent + Monologue Intent Integration (Tier 2)", () => {
expect(ActorResponseSchema.parse(valid)).toEqual(valid);
expect(() => ActorResponseSchema.parse({})).toThrow();
expect(() =>
ActorResponseSchema.parse({ narrativeProse: 123 }),
).toThrow();
expect(() => ActorResponseSchema.parse({ narrativeProse: 123 })).toThrow();
});
test("serializeSubjectiveWorldState is epistemically bounded", async () => {

View File

@@ -1,6 +1,11 @@
import { describe, test, expect } from "vitest";
import Database from "better-sqlite3";
import { WorldState, Entity, SQLiteRepository, AttributeVisibility } from "@omnia/core";
import {
WorldState,
Entity,
SQLiteRepository,
AttributeVisibility,
} from "@omnia/core";
import { MockLLMProvider } from "@omnia/llm";
import { IntentDecoder, IntentSequence } from "@omnia/intent";
import { Architect } from "@omnia/architect";
@@ -51,34 +56,54 @@ describe("Omnia Integration Tests (Tier 2)", () => {
};
// 2. Architect validation & delta generation responses
const mockDialogueValidation = { isValid: true, reason: "Alice is able to speak to Bob." };
const mockDialogueValidation = {
isValid: true,
reason: "Alice is able to speak to Bob.",
};
const mockActionValidation = { isValid: true, reason: "The door is unlocked and reachable." };
const mockActionTimeDelta = { minutesToAdvance: 3, explanation: "Creeping silently and opening a door takes 3 minutes." };
const mockActionValidation = {
isValid: true,
reason: "The door is unlocked and reachable.",
};
const mockActionTimeDelta = {
minutesToAdvance: 3,
explanation: "Creeping silently and opening a door takes 3 minutes.",
};
const llmProvider = new MockLLMProvider([
mockIntentSequence, // Used by IntentDecoder
mockDialogueValidation, // Used by Architect.validateIntent (Dialogue)
mockActionValidation, // Used by Architect.validateIntent (Action)
mockActionTimeDelta // Used by TimeDeltaGenerator (Action)
mockIntentSequence, // Used by IntentDecoder
mockDialogueValidation, // Used by Architect.validateIntent (Dialogue)
mockActionValidation, // Used by Architect.validateIntent (Action)
mockActionTimeDelta, // Used by TimeDeltaGenerator (Action)
]);
const decoder = new IntentDecoder(llmProvider);
const architect = new Architect(llmProvider, repo);
// 1. Decode the raw prose into structured intents
const narrativeProse = '"Cover me," Alice whispered to Bob. She crept towards the door and pulled the handle.';
const decodedSequence = await decoder.decode(world, "alice", narrativeProse);
const narrativeProse =
'"Cover me," Alice whispered to Bob. She crept towards the door and pulled the handle.';
const decodedSequence = await decoder.decode(
world,
"alice",
narrativeProse,
);
expect(decodedSequence.intents).toHaveLength(2);
// 2. Process first intent (dialogue)
const result1 = await architect.processIntent(world, decodedSequence.intents[0]);
const result1 = await architect.processIntent(
world,
decodedSequence.intents[0],
);
expect(result1.isValid).toBe(true);
expect(result1.timeDelta!.minutesToAdvance).toBe(1);
// 3. Process second intent (action)
const result2 = await architect.processIntent(world, decodedSequence.intents[1]);
const result2 = await architect.processIntent(
world,
decodedSequence.intents[1],
);
expect(result2.isValid).toBe(true);
expect(result2.timeDelta!.minutesToAdvance).toBe(3);
@@ -88,7 +113,9 @@ describe("Omnia Integration Tests (Tier 2)", () => {
// 5. Verify database state clock was advanced and persisted
const reloadedWorld = repo.loadWorldState("world-abc")!;
expect(reloadedWorld.clock.get().toISOString()).toBe(expectedTime.toISOString());
expect(reloadedWorld.clock.get().toISOString()).toBe(
expectedTime.toISOString(),
);
db.close();
});
@@ -128,13 +155,19 @@ describe("Omnia Integration Tests (Tier 2)", () => {
// LLM validation / time delta mock responses:
// For intent1 (action):
const mockActionValidation = { isValid: false, reason: "Hairpins cannot pick high-security locks." };
const mockActionValidation = {
isValid: false,
reason: "Hairpins cannot pick high-security locks.",
};
// For intent2 (dialogue):
const mockDialogueValidation = { isValid: true, reason: "Alice is free to talk." };
const mockDialogueValidation = {
isValid: true,
reason: "Alice is free to talk.",
};
const llmProvider = new MockLLMProvider([
mockActionValidation, // Used by Architect.validateIntent (Action)
mockDialogueValidation, // Used by Architect.validateIntent (Dialogue)
mockActionValidation, // Used by Architect.validateIntent (Action)
mockDialogueValidation, // Used by Architect.validateIntent (Dialogue)
]);
const architect = new Architect(llmProvider, repo);