- Added new contracts for intent interpretation, including InterpreterOutput and ResolverMode. - Implemented deterministic intent resolver with clarity checks for ambiguous references and empty input. - Developed LLM intent resolver that communicates with an external model, handling JSON responses and fallback clarifications. - Created an interpretTurn function to manage intent resolution based on the selected resolver mode. - Introduced validation for interpreter output to ensure integrity before processing actions. - Established a turn manager to orchestrate turn processing, including action validation and world state mutation. - Added integration tests to verify the functionality of the new intent resolution system. Co-authored-by: Copilot <copilot@github.com>
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import type { Action } from "./action";
|
|
|
|
export type InterpreterStatus =
|
|
| "resolved"
|
|
| "needs_clarification"
|
|
| "rejected";
|
|
|
|
export type ClarificationReasonCode =
|
|
| "UNRECOGNIZED_INTENT"
|
|
| "AMBIGUOUS_REFERENCE"
|
|
| "EMPTY_INPUT"
|
|
| "LOW_CONFIDENCE"
|
|
| "INTERNAL_INVALID_OUTPUT";
|
|
|
|
export type ClarificationOption = {
|
|
id: string;
|
|
label: string;
|
|
value: string;
|
|
entityId?: string;
|
|
entityType?: "character" | "item" | "room" | "unknown";
|
|
};
|
|
|
|
export type ClarificationRequest = {
|
|
reasonCode: ClarificationReasonCode;
|
|
question: string;
|
|
field?: "verb" | "target" | "item" | "recipient" | "location";
|
|
options?: ClarificationOption[];
|
|
};
|
|
|
|
export type InterpreterCandidate = {
|
|
action: Action;
|
|
confidence: number;
|
|
rationale?: string;
|
|
};
|
|
|
|
export type InterpreterOutput = {
|
|
interpreterVersion: string;
|
|
rawText: string;
|
|
actorId: string;
|
|
resolutionSource: "deterministic" | "llm" | "hybrid";
|
|
minConfidence: number;
|
|
selectedConfidence?: number;
|
|
status: InterpreterStatus;
|
|
selectedActions: Action[];
|
|
candidates: InterpreterCandidate[];
|
|
diagnostics: string[];
|
|
clarification?: ClarificationRequest;
|
|
};
|