zeus-api-types 1.0.47 → 1.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,81 @@
1
+ import { ToneCompact } from "tonelib";
2
+ import { UserMetadata } from "./user-preferences";
3
+ /**
4
+ * Operation types for AI metadata tracking
5
+ */
6
+ export type AIOperationType = 'narrative' | 'dialog' | 'updateScript' | 'choiceMetadata' | 'gameInit' | 'genreInit';
7
+ export interface AIOperationTokens {
8
+ prompt_tokens: number;
9
+ completion_tokens: number;
10
+ total_tokens: number;
11
+ count: number;
12
+ }
13
+ export interface AIMetadata {
14
+ tokensUsed: {
15
+ total: {
16
+ prompt_tokens: number;
17
+ completion_tokens: number;
18
+ total_tokens: number;
19
+ };
20
+ byOperation: {
21
+ narrative?: AIOperationTokens;
22
+ dialog?: AIOperationTokens;
23
+ updateScript?: AIOperationTokens;
24
+ choiceMetadata?: AIOperationTokens;
25
+ gameInit?: AIOperationTokens;
26
+ genreInit?: AIOperationTokens;
27
+ };
28
+ };
29
+ modelsUsed: string[];
30
+ operationCount: number;
31
+ operationsByType: Record<string, number>;
32
+ firstOperationAt?: string;
33
+ lastOperationAt?: string;
34
+ }
35
+ /**
36
+ * Tag structure for both system-level and author-defined metadata
37
+ * - System tags (in immutable): managed by backend, hidden from UI
38
+ * - Author tags (in metadata): user-editable via genre editor
39
+ */
40
+ export interface Tag {
41
+ /** Unique key identifier (max 64 chars) */
42
+ key: string;
43
+ /** Value as string or array of strings (max 64 chars per item) */
44
+ value: string | string[];
45
+ }
46
+ /**
47
+ * Base interface for all immutable blocks
48
+ */
49
+ export interface BaseImmutableState {
50
+ id: string;
51
+ hash?: string;
52
+ }
53
+ /**
54
+ * Game-specific immutable state
55
+ */
56
+ export interface ImmutableState extends BaseImmutableState {
57
+ userId: string;
58
+ genre: string;
59
+ author: string;
60
+ ai?: {
61
+ metadata: AIMetadata;
62
+ };
63
+ act?: number;
64
+ sagaId?: string;
65
+ previousActId?: string;
66
+ nextActId?: string;
67
+ [key: string]: unknown;
68
+ }
69
+ /**
70
+ * Genre-specific immutable state (for genre authoring)
71
+ */
72
+ export interface GenreImmutableState extends BaseImmutableState {
73
+ genre: string;
74
+ author: string;
75
+ published: boolean;
76
+ createdAt: string;
77
+ tags?: Tag[];
78
+ }
1
79
  /**
2
80
  * World container - reduced version without events (for frontend)
3
81
  */
@@ -9,7 +87,6 @@ export interface WorldReduced {
9
87
  * Game State Types
10
88
  *
11
89
  * Core game state interfaces shared between middle-layer and frontend.
12
- * Extracted from middle-layer/src/core/GameState.ts
13
90
  */
14
91
  export interface TimeState {
15
92
  current: string;
@@ -70,6 +147,13 @@ export interface Location extends WorldEntity {
70
147
  name: string;
71
148
  description: string;
72
149
  }
150
+ export interface PresentationChoiceMeta {
151
+ timeCost?: string;
152
+ vectors?: Record<string, string>;
153
+ expectedNPCs?: string[];
154
+ tone?: ToneCompact;
155
+ [key: string]: unknown;
156
+ }
73
157
  export interface DialogMessage {
74
158
  speaker: string;
75
159
  message: string;
@@ -99,6 +183,8 @@ export interface PresentationCache {
99
183
  dialogHistory?: DialogMessage[];
100
184
  generatedAt?: string;
101
185
  source?: string;
186
+ choiceMetadata?: PresentationChoiceMeta[];
187
+ presentationCache?: PresentationCache;
102
188
  }
103
189
  export interface Session {
104
190
  history: HistoryEntry[];
@@ -127,3 +213,218 @@ export interface StoryArc {
127
213
  tone_pattern?: string[];
128
214
  [key: string]: unknown;
129
215
  }
216
+ /**
217
+ * Deck Definitions
218
+ *
219
+ * Describes the structure of deck.json fixtures for each genre.
220
+ */
221
+ /**
222
+ * Base card interface - shared properties across all card types
223
+ */
224
+ export interface BaseDeckCard {
225
+ id: string;
226
+ theme?: string;
227
+ title?: string;
228
+ description?: string;
229
+ emoji?: string;
230
+ [key: string]: unknown;
231
+ }
232
+ /**
233
+ * Story Arc card - used for narrative trajectory
234
+ */
235
+ export interface StoryArcCard extends BaseDeckCard {
236
+ narrative_hooks?: string[];
237
+ /**
238
+ * Arc pattern representing emotional trajectory
239
+ * 11 values (0-100) at 0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% progress
240
+ * 0 = darkest/worst, 100 = brightest/best
241
+ * Based on Kurt Vonnegut's story shapes
242
+ */
243
+ arc_pattern?: number[];
244
+ /**
245
+ * Tone pattern representing emotional tone trajectory throughout the story
246
+ * 11 tone values in compact notation at 0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% progress
247
+ * Each tone is in format "HHH:SSS:LLL" (hue:saturation:lightness)
248
+ * Interpolated between values to get tone at any progression point
249
+ */
250
+ tone_pattern?: string[];
251
+ }
252
+ /**
253
+ * Narrative Style card - used for writing style and voice
254
+ */
255
+ export interface NarrativeStyleCard extends BaseDeckCard {
256
+ representative_authors?: string[];
257
+ technical_guide?: string;
258
+ example?: string;
259
+ }
260
+ export interface DeckDefinition {
261
+ deckId: string;
262
+ name?: string;
263
+ description?: string;
264
+ version?: string;
265
+ genre?: string;
266
+ cards: BaseDeckCard[];
267
+ draw_rules?: Record<string, unknown>;
268
+ [key: string]: unknown;
269
+ }
270
+ /**
271
+ * Multi-deck format - contains multiple named decks
272
+ * Example: { story_arc: {...}, mood: {...}, etc. }
273
+ */
274
+ export interface MultiDeckDefinition {
275
+ story_arc: DeckDefinition;
276
+ [deckName: string]: DeckDefinition;
277
+ }
278
+ export interface FixtureSet {
279
+ state: GameState;
280
+ deck: DeckDefinition;
281
+ }
282
+ export interface EventPropagation {
283
+ to: string;
284
+ effect: Record<string, unknown>;
285
+ decay?: number;
286
+ }
287
+ export interface BaseEvent extends WorldEntity {
288
+ id: string;
289
+ name?: string;
290
+ description?: string;
291
+ location?: string;
292
+ conditions?: Record<string, unknown>;
293
+ effects?: Record<string, unknown>;
294
+ propagation?: EventPropagation[];
295
+ cooldown?: number;
296
+ cooldown_remaining?: number;
297
+ }
298
+ export interface DeterministicEvent extends BaseEvent {
299
+ }
300
+ export interface ScheduledEvent extends BaseEvent {
301
+ timestamp: string;
302
+ interrupts?: boolean;
303
+ severity?: string;
304
+ }
305
+ export interface ProbabilisticEvent extends BaseEvent {
306
+ base_probability: number;
307
+ current_probability: number;
308
+ modifiers?: Record<string, unknown>;
309
+ last_triggered_turn?: number;
310
+ }
311
+ export interface EventHistoryEntry {
312
+ event_id: string;
313
+ type: 'deterministic' | 'scheduled' | 'probabilistic';
314
+ turn: number;
315
+ timestamp?: string;
316
+ outcome?: string;
317
+ }
318
+ export interface WorldEvents {
319
+ deterministic: DeterministicEvent[];
320
+ scheduled: ScheduledEvent[];
321
+ probabilistic: ProbabilisticEvent[];
322
+ history: EventHistoryEntry[];
323
+ }
324
+ export interface World extends WorldReduced {
325
+ events: WorldEvents;
326
+ }
327
+ export interface DialogContext {
328
+ context: Record<string, unknown>;
329
+ last_updated_turn?: number;
330
+ history: DialogMessage[];
331
+ }
332
+ /**
333
+ * Metadata for game state
334
+ * NOTE: genre moved to immutable block (pre-MVP, no backward compatibility)
335
+ */
336
+ export interface Metadata {
337
+ genreTitle?: string;
338
+ expectedTurns: number;
339
+ storyArcCutoff: number;
340
+ storyArcProgression?: number;
341
+ version?: string;
342
+ tags?: Tag[];
343
+ title?: string;
344
+ description?: string;
345
+ image?: string;
346
+ blacklist?: string[];
347
+ dialog?: DialogContext;
348
+ totalActs?: number;
349
+ nextActPrologue?: string;
350
+ nextActTime?: string;
351
+ nextActLocation?: string;
352
+ user?: UserMetadata;
353
+ [key: string]: unknown;
354
+ }
355
+ export interface GameState {
356
+ immutable: ImmutableState;
357
+ currentTurn: number;
358
+ time: TimeState;
359
+ location: string;
360
+ player: Player;
361
+ world: World;
362
+ session: Session;
363
+ metadata: Metadata;
364
+ storyArc?: StoryArc;
365
+ narrativeStyle?: NarrativeStyleCard;
366
+ }
367
+ export interface GameStateReduced {
368
+ immutable: ImmutableState;
369
+ currentTurn: number;
370
+ time: TimeState;
371
+ location: string;
372
+ player: Player;
373
+ world: WorldReduced;
374
+ metadata: Metadata;
375
+ storyArc?: StoryArc;
376
+ narrativeStyle?: NarrativeStyleCard;
377
+ }
378
+ export interface StateSnapshot {
379
+ state: GameState;
380
+ timestamp: string;
381
+ turn: number;
382
+ }
383
+ export interface PromptVariables {
384
+ [key: string]: string | number | boolean | object | undefined;
385
+ }
386
+ /**
387
+ * Lightweight game metadata for efficient game listing
388
+ * Stored separately from full game state in metadata.json
389
+ * Updated on every save, read by listGamesWithMetadata()
390
+ */
391
+ export interface GameMetadata {
392
+ /** Schema version for future evolution */
393
+ version: 1;
394
+ /** Unique game identifier */
395
+ gameId: string;
396
+ /** User who owns this game */
397
+ userId: string;
398
+ /** Genre this game is based on */
399
+ genreId: string;
400
+ /** Current turn number */
401
+ turn: number;
402
+ /** Current location ID */
403
+ location: string;
404
+ /** Human-readable location name */
405
+ locationName?: string;
406
+ /** Location image filename (not full URL) */
407
+ locationImage?: string;
408
+ /** Genre ID (duplicate for convenience) */
409
+ genre: string;
410
+ /** Game/Genre title */
411
+ title?: string;
412
+ /** Player character name */
413
+ playerName?: string;
414
+ /** Player image filename (not full URL) */
415
+ playerImage?: string;
416
+ /** Current act number (for multi-act games) */
417
+ act?: number;
418
+ /** Total number of acts planned */
419
+ totalActs?: number;
420
+ /** Saga ID (links acts together) */
421
+ sagaId?: string;
422
+ /** Previous act's game ID */
423
+ previousActId?: string;
424
+ /** Next act's game ID (if created) */
425
+ nextActId?: string;
426
+ /** ISO 8601 timestamp of last modification */
427
+ lastModified: string;
428
+ /** File size in bytes (of game.json) */
429
+ sizeBytes: number;
430
+ }
@@ -1,2 +1,5 @@
1
1
  "use strict";
2
+ // ============================================================================
3
+ // AI METADATA TRACKING
4
+ // ============================================================================
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export type { ApiError, ApiErrorResponse } from './errors';
2
- export type { NarrativeStartEventPayload, NarrativeChunkEventPayload, NarrativeCompleteEventPayload, NarrativeMetadataEventPayload, MetadataEventPayload, DoneEventPayload, ErrorEventPayload, NarrativeSSEEventPayload, } from './sse/narrative';
3
- export type { TimeState, WorldEntity, Player, NPC, Location, WorldReduced, DialogMessage, HistoryEntry, PresentationCache, Session, StoryArc, } from './game-state';
4
- export type { NarrativeFontPreferences, SoundPreferences, ModelStackPreset, ModelEntry, ModelStack, ModelStackPreferences, SystemModelPresets, AIPreferences, UserPreferences, UserMetadata, } from './user-preferences';
2
+ export type { DoneEventPayload, ErrorEventPayload, MetadataEventPayload, NarrativeChunkEventPayload, NarrativeCompleteEventPayload, NarrativeMetadataEventPayload, NarrativeSSEEventPayload, NarrativeStartEventPayload } from './sse/narrative';
3
+ export type { AIMetadata, AIOperationTokens, BaseDeckCard, BaseImmutableState, DeckDefinition, DialogContext, DialogMessage, FixtureSet, GameState, GameStateReduced, GenreImmutableState, HistoryEntry, ImmutableState, Location, Metadata, MultiDeckDefinition, NarrativeStyleCard, NPC, Player, PresentationCache, Session, StoryArc, StoryArcCard, Tag, TimeState, WorldEntity, WorldReduced, EventPropagation, BaseEvent, DeterministicEvent, ScheduledEvent, ProbabilisticEvent, EventHistoryEntry, WorldEvents, World, StateSnapshot, PromptVariables, GameMetadata, AIOperationType, NpcExistingOrNewOp, PresentationChoiceMeta } from './game-state';
4
+ export type { AIPreferences, ModelEntry, ModelStack, ModelStackPreferences, ModelStackPreset, NarrativeFontPreferences, SoundPreferences, SystemModelPresets, UserMetadata, UserPreferences } from './user-preferences';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zeus-api-types",
3
- "version": "1.0.47",
3
+ "version": "1.0.50",
4
4
  "description": "Shared API types for Wagtales - SSE payloads, error types, and common interfaces",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,6 +40,9 @@
40
40
  "url": "https://github.com/lovebowls/zeus-api-types/issues"
41
41
  },
42
42
  "sideEffects": false,
43
+ "dependencies": {
44
+ "tonelib": "file:../tonelib"
45
+ },
43
46
  "devDependencies": {
44
47
  "rimraf": "^5.0.0",
45
48
  "typescript": "^5.0.0"