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

@@ -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);