fix(core): misc fixes

This commit is contained in:
2026-07-12 12:28:14 +05:30
parent 01b2e650f3
commit 0dcb968670
8 changed files with 42 additions and 41 deletions

View File

@@ -42,7 +42,7 @@ export function DashboardView() {
const [savedSessions, setSavedSessions] = useState<SimSnapshot[]>([]);
const [scenarios, setScenarios] = useState<{ path: string; name: string; description: string }[]>([]);
const [providerInstances, setProviderInstances] = useState<ModelProviderInstance[]>([]);
const [, setProviderInstances] = useState<ModelProviderInstance[]>([]);
// Modal State
const [scenarioForModal, setScenarioForModal] = useState<{ path: string; name: string } | null>(null);
@@ -57,7 +57,7 @@ export function DashboardView() {
setSavedSessions(res.sessions);
}
} catch {
// ignore
// sessions load failed, ignore
}
}, []);
@@ -70,21 +70,27 @@ export function DashboardView() {
if (active && sessionsRes.ok) {
setSavedSessions(sessionsRes.sessions);
}
} catch {}
} catch {
// session load failed, ignore
}
try {
const configStatus = await getConfigStatus();
if (active) {
setScenarios(configStatus.availableScenarios);
}
} catch {}
} catch {
// scenarios load failed, ignore
}
try {
const providersList = await listProviderInstances();
if (active) {
setProviderInstances(providersList);
}
} catch {}
} catch {
// providers load failed, ignore
}
if (active) {
setLoadingData(false);

View File

@@ -202,8 +202,6 @@ export function PromptModal({ entry, onClose }: PromptModalProps) {
onTabChange={setActiveTab}
hasActor={!!entry.rawPrompt}
hasDecoder={!!entry.decoderPrompt}
showActorStats={!!entry.usage}
showDecoderStats={!!entry.decoderUsage}
/>
<div className="overflow-y-auto flex-1 p-5">

View File

@@ -5,8 +5,6 @@ interface PromptSwitcherProps {
onTabChange: (tab: "actor" | "decoder") => void;
hasActor: boolean;
hasDecoder: boolean;
showActorStats: boolean;
showDecoderStats: boolean;
}
export function PromptSwitcher({
@@ -14,8 +12,6 @@ export function PromptSwitcher({
onTabChange,
hasActor,
hasDecoder,
showActorStats,
showDecoderStats,
}: PromptSwitcherProps) {
return (
<div className="flex items-center justify-center gap-4 border-b bg-muted/50 px-5 py-4">

View File

@@ -106,7 +106,9 @@ Guidelines:
if (this.bufferRepo) {
try {
recentEntries = this.bufferRepo.listForOwner(entity.id);
} catch {}
} catch {
// bufferRepo may not be available
}
}
// --- Recent memory ---

View File

@@ -1,6 +1,6 @@
import { describe, it, expect, beforeEach, afterEach } from "vitest";
import Database from "better-sqlite3";
import { WorldState, Entity, AttributeVisibility } from "@omnia/core";
import { WorldState, Entity } from "@omnia/core";
import { BufferRepository, LedgerRepository } from "@omnia/memory";
import { ActorPromptBuilder } from "../src/actor-prompt-builder";

View File

@@ -154,7 +154,7 @@ export function splitBufferForHandoff(
"several minutes ago",
]);
let watermarkStartIndex = sorted.length;
let watermarkStartIndex: number;
// 1. Mark last K entries as watermark
if (sorted.length > K) {
@@ -243,7 +243,7 @@ ${candidatesList}
const ledgerEntries: LedgerEntry[] = [];
for (const chunk of result.chunks) {
let embedding: number[] = [];
let embedding: number[];
try {
embedding = await this.embedProvider.embed(chunk.content);
} catch (err) {

View File

@@ -92,28 +92,27 @@ export class LedgerRepository {
})();
}
private mapRowToEntry(row: any, involvedEntityIds: string[]): LedgerEntry {
let embedding: number[] = [];
if (row.embedding) {
const buffer = row.embedding as Buffer;
const floatArray = new Float32Array(
buffer.buffer,
buffer.byteOffset,
buffer.byteLength / Float32Array.BYTES_PER_ELEMENT
);
embedding = Array.from(floatArray);
}
private mapRowToEntry(row: Record<string, unknown>, involvedEntityIds: string[]): LedgerEntry {
const embedding: number[] = row.embedding
? Array.from(
new Float32Array(
(row.embedding as Buffer).buffer,
(row.embedding as Buffer).byteOffset,
(row.embedding as Buffer).byteLength / Float32Array.BYTES_PER_ELEMENT
)
)
: [];
return {
id: row.id,
ownerId: row.owner_id,
timestamp: row.timestamp,
locationId: row.location_id,
id: row.id as string,
ownerId: row.owner_id as string,
timestamp: row.timestamp as string,
locationId: row.location_id as string | null,
involvedEntityIds,
content: row.content,
quotes: JSON.parse(row.quotes_json || "[]"),
importance: row.importance,
embedding: embedding,
content: row.content as string,
quotes: JSON.parse((row.quotes_json as string) || "[]"),
importance: row.importance as number,
embedding,
};
}
@@ -126,7 +125,7 @@ export class LedgerRepository {
WHERE id = ?
`
)
.get(id) as any;
.get(id) as Record<string, unknown> | undefined;
if (!row) return null;
@@ -163,7 +162,7 @@ export class LedgerRepository {
le.importance >= 8
`;
const params: any[] = [ownerId];
const params: (string | number)[] = [ownerId];
if (currentLocationId) {
query += ` OR le.location_id = ?`;
@@ -183,7 +182,7 @@ export class LedgerRepository {
`;
params.push(limit);
const rows = this.db.prepare(query).all(...params) as any[];
const rows = this.db.prepare(query).all(...params) as Record<string, any>[];
if (rows.length === 0) return [];
@@ -223,7 +222,7 @@ export class LedgerRepository {
LIMIT 1
`
)
.get(ownerId, timestamp) as any;
.get(ownerId, timestamp) as Record<string, unknown> | undefined;
if (preceding) {
neighbors.push(this.mapRowToEntry(preceding, []));
@@ -240,7 +239,7 @@ export class LedgerRepository {
LIMIT 1
`
)
.get(ownerId, timestamp) as any;
.get(ownerId, timestamp) as Record<string, unknown> | undefined;
if (succeeding) {
neighbors.push(this.mapRowToEntry(succeeding, []));
@@ -310,7 +309,7 @@ export class LedgerRepository {
scored.sort((a, b) => b.score - a.score);
const selected = scored.slice(0, limit).map((s) => s.entry);
let finalEntries = [...selected];
const finalEntries = [...selected];
// Optionally retrieve associative neighbors
if (includeAssociativeNeighbors && selected.length > 0) {

View File

@@ -152,7 +152,7 @@ describe("Memory Handoff Tests (Tier 1)", () => {
const success = await engine.runHandoff(entity, entries, now);
expect(success).toBe(true);
const ledgerRows = db.prepare("SELECT * FROM ledger_entries WHERE owner_id = ?").all("alice") as any[];
const ledgerRows = db.prepare("SELECT * FROM ledger_entries WHERE owner_id = ?").all("alice") as Record<string, unknown>[];
expect(ledgerRows.length).toBe(1);
expect(ledgerRows[0].content).toBe("Alice initiated dialogue and performed various tasks.");
expect(JSON.parse(ledgerRows[0].quotes_json)).toEqual(["Event 0"]);