refactor(architect): Add self description for intent decoder and refine context (#22)

This commit is contained in:
2026-07-11 09:11:49 +05:30
parent 9bdc3ca04b
commit bfff93e793
12 changed files with 106 additions and 36 deletions

View File

@@ -17,8 +17,10 @@ import type { LLMProviderInstance } from "@omnia/llm";
function IntentTag({
intent,
isSelf,
}: {
intent: SimSnapshot["log"][number]["intents"][number];
isSelf?: boolean;
}) {
const labels: Record<string, string> = {
monologue: "thought",
@@ -33,9 +35,13 @@ function IntentTag({
outcome = intent.isValid ? " ✅" : ` ❌ (${intent.reason})`;
}
const textToDisplay = (isSelf && intent.selfDescription)
? intent.selfDescription
: intent.description;
return (
<span className="intent-tag">
[{label}] &ldquo;{intent.description}&rdquo;{outcome}
[{label}] &ldquo;{textToDisplay}&rdquo;{outcome}
{intent.minutesToAdvance ? ` [+${intent.minutesToAdvance}min]` : ""}
</span>
);
@@ -301,9 +307,11 @@ function formatSimTime(isoString: string) {
function LogEntryCard({
entry,
onShowPrompt,
isPlayerCard,
}: {
entry: SimSnapshot["log"][number];
onShowPrompt: (entry: SimSnapshot["log"][number]) => void;
isPlayerCard: boolean;
}) {
const showMenu = !!(entry.rawPrompt || entry.decoderPrompt);
@@ -330,7 +338,7 @@ function LogEntryCard({
<div className="log-prose">{entry.narrativeProse}</div>
<div className="log-intents">
{entry.intents.map((intent, i) => (
<IntentTag key={i} intent={intent} />
<IntentTag key={i} intent={intent} isSelf={isPlayerCard} />
))}
</div>
</div>
@@ -744,13 +752,17 @@ export function PlayView() {
</div>
<div className="log-container">
{snapshot.log.map((entry, i) => (
<LogEntryCard
key={i}
entry={entry}
onShowPrompt={setSelectedEntryForModal}
/>
))}
{(() => {
const playerEntity = snapshot.entities.find((e) => e.isPlayer);
return snapshot.log.map((entry, i) => (
<LogEntryCard
key={i}
entry={entry}
onShowPrompt={setSelectedEntryForModal}
isPlayerCard={entry.entityId === playerEntity?.id}
/>
));
})()}
{loading && (
<div className="log-processing">
<span className="spinner" />

View File

@@ -1,6 +1,7 @@
export interface IntentInfo {
type: string;
description: string;
selfDescription?: string;
targetIds: string[];
isValid?: boolean;
reason?: string;

View File

@@ -119,7 +119,7 @@ class SimulationManager {
playEntityName?: string,
providerInstanceId?: string,
): Promise<SimSnapshot> {
let activeInstance = providerInstanceId
const activeInstance = providerInstanceId
? ProviderManager.list().find((p) => p.id === providerInstanceId)
: ProviderManager.getActive();
@@ -385,6 +385,7 @@ class SimulationManager {
entry.intents.push({
type: intent.type,
description: intent.description,
selfDescription: intent.selfDescription,
targetIds: intent.targetIds,
isValid: outcome.isValid,
reason: outcome.reason,
@@ -528,6 +529,7 @@ class SimulationManager {
entry.intents.push({
type: intent.type,
description: intent.description,
selfDescription: intent.selfDescription,
targetIds: intent.targetIds,
isValid: outcome.isValid,
reason: outcome.reason,