Files
Genarrative/packages/shared/src/contracts/story.ts

105 lines
2.5 KiB
TypeScript

import type { JsonObject } from './common';
/**
* story session 主链共享契约。
* 字段命名与 server-rs/shared-contracts/src/story.rs 的 camelCase 回包保持一致。
*/
export type BeginStorySessionRequest = {
runtimeSessionId: string;
worldProfileId: string;
initialPrompt: string;
openingSummary?: string | null;
};
export type ContinueStoryRequest = {
storySessionId: string;
narrativeText: string;
choiceFunctionId?: string | null;
};
export type StorySessionPayload = {
storySessionId: string;
runtimeSessionId: string;
actorUserId: string;
worldProfileId: string;
initialPrompt: string;
openingSummary?: string | null;
latestNarrativeText: string;
latestChoiceFunctionId?: string | null;
status: string;
version: number;
createdAt: string;
updatedAt: string;
};
export type StoryEventPayload = {
eventId: string;
storySessionId: string;
eventKind: string;
narrativeText: string;
choiceFunctionId?: string | null;
createdAt: string;
};
export type StorySessionMutationResponse = {
storySession: StorySessionPayload;
storyEvent: StoryEventPayload;
};
export type StorySessionStateResponse = {
storySession: StorySessionPayload;
storyEvents: StoryEventPayload[];
};
export type StoryRuntimeProjectionRequest = {
storySessionId: string;
clientVersion?: number;
};
export type StoryRuntimeActorProjection = {
hp: number;
maxHp: number;
mana: number;
maxMana: number;
currency: number;
currencyText: string;
};
export type StoryRuntimeInventoryProjection = {
backpackItems: JsonObject[];
equipmentSlots: JsonObject[];
forgeRecipes: JsonObject[];
};
export type StoryRuntimeOptionProjection = {
functionId: string;
actionText: string;
detailText?: string | null;
scope: string;
payload?: JsonObject | null;
enabled: boolean;
reason?: string | null;
};
export type StoryRuntimeStatusProjection = {
inBattle: boolean;
npcInteractionActive: boolean;
currentEncounterId?: string | null;
currentNpcBattleMode?: string | null;
currentNpcBattleOutcome?: string | null;
};
export type StoryRuntimeProjectionResponse = {
storySession: StorySessionPayload;
storyEvents: StoryEventPayload[];
serverVersion: number;
actor: StoryRuntimeActorProjection;
inventory: StoryRuntimeInventoryProjection;
options: StoryRuntimeOptionProjection[];
status: StoryRuntimeStatusProjection;
currentNarrativeText?: string | null;
actionResultText?: string | null;
toast?: string | null;
};