zeus-api-types 1.0.48 → 1.0.51

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.
package/dist/ai.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Operation types for AI metadata tracking
3
+ */
4
+ export type AIOperationType = 'narrative' | 'dialog' | 'updateScript' | 'choiceMetadata' | 'gameInit' | 'genreInit';
5
+ export interface AIOperationTokens {
6
+ prompt_tokens: number;
7
+ completion_tokens: number;
8
+ total_tokens: number;
9
+ count: number;
10
+ }
11
+ export interface AIMetadata {
12
+ tokensUsed: {
13
+ total: {
14
+ prompt_tokens: number;
15
+ completion_tokens: number;
16
+ total_tokens: number;
17
+ };
18
+ byOperation: {
19
+ narrative?: AIOperationTokens;
20
+ dialog?: AIOperationTokens;
21
+ updateScript?: AIOperationTokens;
22
+ choiceMetadata?: AIOperationTokens;
23
+ gameInit?: AIOperationTokens;
24
+ genreInit?: AIOperationTokens;
25
+ };
26
+ };
27
+ modelsUsed: string[];
28
+ operationCount: number;
29
+ operationsByType: Record<string, number>;
30
+ firstOperationAt?: string;
31
+ lastOperationAt?: string;
32
+ }
package/dist/ai.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // AI METADATA TRACKING
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/deck.d.ts ADDED
@@ -0,0 +1,81 @@
1
+ import type { GameState } from "./game-state";
2
+ export interface StoryArc {
3
+ id?: string;
4
+ theme?: string;
5
+ title?: string;
6
+ description?: string;
7
+ narrative_hooks?: string[];
8
+ atmosphere_modifiers?: Record<string, number>;
9
+ /**
10
+ * Arc pattern representing emotional trajectory
11
+ * 11 values (0-100) at 0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% progress
12
+ */
13
+ arc_pattern?: number[];
14
+ /**
15
+ * Tone pattern representing emotional tone trajectory throughout the story
16
+ * 11 tone values in compact notation at progress intervals
17
+ */
18
+ tone_pattern?: string[];
19
+ [key: string]: unknown;
20
+ }
21
+ /**
22
+ * Base card interface - shared properties across all card types
23
+ */
24
+ export interface BaseDeckCard {
25
+ id: string;
26
+ theme?: string;
27
+ title?: string;
28
+ description?: string;
29
+ emoji?: string;
30
+ [key: string]: unknown;
31
+ }
32
+ /**
33
+ * Story Arc card - used for narrative trajectory
34
+ */
35
+ export interface StoryArcCard extends BaseDeckCard {
36
+ narrative_hooks?: string[];
37
+ /**
38
+ * Arc pattern representing emotional trajectory
39
+ * 11 values (0-100) at 0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% progress
40
+ * 0 = darkest/worst, 100 = brightest/best
41
+ * Based on Kurt Vonnegut's story shapes
42
+ */
43
+ arc_pattern?: number[];
44
+ /**
45
+ * Tone pattern representing emotional tone trajectory throughout the story
46
+ * 11 tone values in compact notation at 0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% progress
47
+ * Each tone is in format "HHH:SSS:LLL" (hue:saturation:lightness)
48
+ * Interpolated between values to get tone at any progression point
49
+ */
50
+ tone_pattern?: string[];
51
+ }
52
+ /**
53
+ * Narrative Style card - used for writing style and voice
54
+ */
55
+ export interface NarrativeStyleCard extends BaseDeckCard {
56
+ representative_authors?: string[];
57
+ technical_guide?: string;
58
+ example?: string;
59
+ }
60
+ export interface DeckDefinition {
61
+ deckId: string;
62
+ name?: string;
63
+ description?: string;
64
+ version?: string;
65
+ genre?: string;
66
+ cards: BaseDeckCard[];
67
+ draw_rules?: Record<string, unknown>;
68
+ [key: string]: unknown;
69
+ }
70
+ /**
71
+ * Multi-deck format - contains multiple named decks
72
+ * Example: { story_arc: {...}, mood: {...}, etc. }
73
+ */
74
+ export interface MultiDeckDefinition {
75
+ story_arc: DeckDefinition;
76
+ [deckName: string]: DeckDefinition;
77
+ }
78
+ export interface FixtureSet {
79
+ state: GameState;
80
+ deck: DeckDefinition;
81
+ }
package/dist/deck.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // STORY ARC & CARD SYSTEM
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,43 @@
1
+ import type { WorldEntity } from "./game-state";
2
+ export interface EventPropagation {
3
+ to: string;
4
+ effect: Record<string, unknown>;
5
+ decay?: number;
6
+ }
7
+ export interface BaseEvent extends WorldEntity {
8
+ id: string;
9
+ name?: string;
10
+ description?: string;
11
+ location?: string;
12
+ conditions?: Record<string, unknown>;
13
+ effects?: Record<string, unknown>;
14
+ propagation?: EventPropagation[];
15
+ cooldown?: number;
16
+ cooldown_remaining?: number;
17
+ }
18
+ export interface DeterministicEvent extends BaseEvent {
19
+ }
20
+ export interface ScheduledEvent extends BaseEvent {
21
+ timestamp: string;
22
+ interrupts?: boolean;
23
+ severity?: string;
24
+ }
25
+ export interface ProbabilisticEvent extends BaseEvent {
26
+ base_probability: number;
27
+ current_probability: number;
28
+ modifiers?: Record<string, unknown>;
29
+ last_triggered_turn?: number;
30
+ }
31
+ export interface EventHistoryEntry {
32
+ event_id: string;
33
+ type: 'deterministic' | 'scheduled' | 'probabilistic';
34
+ turn: number;
35
+ timestamp?: string;
36
+ outcome?: string;
37
+ }
38
+ export interface WorldEvents {
39
+ deterministic: DeterministicEvent[];
40
+ scheduled: ScheduledEvent[];
41
+ probabilistic: ProbabilisticEvent[];
42
+ history: EventHistoryEntry[];
43
+ }
package/dist/events.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // WORLD EVENT SYSTEM
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,31 +1,8 @@
1
- export interface AIOperationTokens {
2
- prompt_tokens: number;
3
- completion_tokens: number;
4
- total_tokens: number;
5
- count: number;
6
- }
7
- export interface AIMetadata {
8
- tokensUsed: {
9
- total: {
10
- prompt_tokens: number;
11
- completion_tokens: number;
12
- total_tokens: number;
13
- };
14
- byOperation: {
15
- narrative?: AIOperationTokens;
16
- dialog?: AIOperationTokens;
17
- updateScript?: AIOperationTokens;
18
- choiceMetadata?: AIOperationTokens;
19
- gameInit?: AIOperationTokens;
20
- genreInit?: AIOperationTokens;
21
- };
22
- };
23
- modelsUsed: string[];
24
- operationCount: number;
25
- operationsByType: Record<string, number>;
26
- firstOperationAt?: string;
27
- lastOperationAt?: string;
28
- }
1
+ import { ToneCompact } from "tonelib";
2
+ import type { AIMetadata } from "./ai";
3
+ import type { NarrativeStyleCard, StoryArc } from "./deck";
4
+ import type { WorldEvents } from "./events";
5
+ import { UserMetadata } from "./user-preferences";
29
6
  /**
30
7
  * Tag structure for both system-level and author-defined metadata
31
8
  * - System tags (in immutable): managed by backend, hidden from UI
@@ -81,7 +58,6 @@ export interface WorldReduced {
81
58
  * Game State Types
82
59
  *
83
60
  * Core game state interfaces shared between middle-layer and frontend.
84
- * Extracted from middle-layer/src/core/GameState.ts
85
61
  */
86
62
  export interface TimeState {
87
63
  current: string;
@@ -142,6 +118,13 @@ export interface Location extends WorldEntity {
142
118
  name: string;
143
119
  description: string;
144
120
  }
121
+ export interface PresentationChoiceMeta {
122
+ timeCost?: string;
123
+ vectors?: Record<string, string>;
124
+ expectedNPCs?: string[];
125
+ tone?: ToneCompact;
126
+ [key: string]: unknown;
127
+ }
145
128
  export interface DialogMessage {
146
129
  speaker: string;
147
130
  message: string;
@@ -171,6 +154,8 @@ export interface PresentationCache {
171
154
  dialogHistory?: DialogMessage[];
172
155
  generatedAt?: string;
173
156
  source?: string;
157
+ choiceMetadata?: PresentationChoiceMeta[];
158
+ presentationCache?: PresentationCache;
174
159
  }
175
160
  export interface Session {
176
161
  history: HistoryEntry[];
@@ -180,22 +165,110 @@ export interface Session {
180
165
  presentationCache?: PresentationCache;
181
166
  prologue?: string;
182
167
  }
183
- export interface StoryArc {
184
- id?: string;
185
- theme?: string;
168
+ export interface World extends WorldReduced {
169
+ events: WorldEvents;
170
+ }
171
+ export interface DialogContext {
172
+ context: Record<string, unknown>;
173
+ last_updated_turn?: number;
174
+ history: DialogMessage[];
175
+ }
176
+ /**
177
+ * Metadata for game state
178
+ * NOTE: genre moved to immutable block (pre-MVP, no backward compatibility)
179
+ */
180
+ export interface Metadata {
181
+ genreTitle?: string;
182
+ expectedTurns: number;
183
+ storyArcCutoff: number;
184
+ storyArcProgression?: number;
185
+ version?: string;
186
+ tags?: Tag[];
186
187
  title?: string;
187
188
  description?: string;
188
- narrative_hooks?: string[];
189
- atmosphere_modifiers?: Record<string, number>;
190
- /**
191
- * Arc pattern representing emotional trajectory
192
- * 11 values (0-100) at 0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100% progress
193
- */
194
- arc_pattern?: number[];
195
- /**
196
- * Tone pattern representing emotional tone trajectory throughout the story
197
- * 11 tone values in compact notation at progress intervals
198
- */
199
- tone_pattern?: string[];
189
+ image?: string;
190
+ blacklist?: string[];
191
+ dialog?: DialogContext;
192
+ totalActs?: number;
193
+ nextActPrologue?: string;
194
+ nextActTime?: string;
195
+ nextActLocation?: string;
196
+ user?: UserMetadata;
200
197
  [key: string]: unknown;
201
198
  }
199
+ export interface GameState {
200
+ immutable: ImmutableState;
201
+ currentTurn: number;
202
+ time: TimeState;
203
+ location: string;
204
+ player: Player;
205
+ world: World;
206
+ session: Session;
207
+ metadata: Metadata;
208
+ storyArc?: StoryArc;
209
+ narrativeStyle?: NarrativeStyleCard;
210
+ }
211
+ export interface GameStateReduced {
212
+ immutable: ImmutableState;
213
+ currentTurn: number;
214
+ time: TimeState;
215
+ location: string;
216
+ player: Player;
217
+ world: WorldReduced;
218
+ metadata: Metadata;
219
+ storyArc?: StoryArc;
220
+ narrativeStyle?: NarrativeStyleCard;
221
+ }
222
+ export interface StateSnapshot {
223
+ state: GameState;
224
+ timestamp: string;
225
+ turn: number;
226
+ }
227
+ export interface PromptVariables {
228
+ [key: string]: string | number | boolean | object | undefined;
229
+ }
230
+ /**
231
+ * Lightweight game metadata for efficient game listing
232
+ * Stored separately from full game state in metadata.json
233
+ * Updated on every save, read by listGamesWithMetadata()
234
+ */
235
+ export interface GameMetadata {
236
+ /** Schema version for future evolution */
237
+ version: 1;
238
+ /** Unique game identifier */
239
+ gameId: string;
240
+ /** User who owns this game */
241
+ userId: string;
242
+ /** Genre this game is based on */
243
+ genreId: string;
244
+ /** Current turn number */
245
+ turn: number;
246
+ /** Current location ID */
247
+ location: string;
248
+ /** Human-readable location name */
249
+ locationName?: string;
250
+ /** Location image filename (not full URL) */
251
+ locationImage?: string;
252
+ /** Genre ID (duplicate for convenience) */
253
+ genre: string;
254
+ /** Game/Genre title */
255
+ title?: string;
256
+ /** Player character name */
257
+ playerName?: string;
258
+ /** Player image filename (not full URL) */
259
+ playerImage?: string;
260
+ /** Current act number (for multi-act games) */
261
+ act?: number;
262
+ /** Total number of acts planned */
263
+ totalActs?: number;
264
+ /** Saga ID (links acts together) */
265
+ sagaId?: string;
266
+ /** Previous act's game ID */
267
+ previousActId?: string;
268
+ /** Next act's game ID (if created) */
269
+ nextActId?: string;
270
+ /** ISO 8601 timestamp of last modification */
271
+ lastModified: string;
272
+ /** File size in bytes (of game.json) */
273
+ sizeBytes: number;
274
+ }
@@ -1,5 +1,2 @@
1
1
  "use strict";
2
- // ============================================================================
3
- // AI METADATA TRACKING
4
- // ============================================================================
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,8 @@
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, AIOperationTokens, AIMetadata, Tag, BaseImmutableState, ImmutableState, GenreImmutableState, } 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, AIOperationType } from './ai';
4
+ export type { BaseDeckCard, DeckDefinition, FixtureSet, MultiDeckDefinition, NarrativeStyleCard, StoryArc, StoryArcCard } from './deck';
5
+ export type { BaseEvent, DeterministicEvent, EventHistoryEntry, EventPropagation, ProbabilisticEvent, ScheduledEvent, WorldEvents } from './events';
6
+ export type { BaseImmutableState, DialogContext, DialogMessage, GameMetadata, GameState, GameStateReduced, GenreImmutableState, HistoryEntry, ImmutableState, Location, Metadata, NPC, NpcExistingOrNewOp, Player, PresentationCache, PresentationChoiceMeta, PromptVariables, Session, StateSnapshot, Tag, TimeState, World, WorldEntity, WorldReduced } from './game-state';
7
+ export type { AIPreferences, ModelEntry, ModelStack, ModelStackPreferences, ModelStackPreset, NarrativeFontPreferences, SoundPreferences, SystemModelPresets, UserMetadata, UserPreferences } from './user-preferences';
8
+ export type { CreatePresetRequest, CreatePresetResponse, DeletePresetResponse, ListPresetsResponse, PaginatedPresetsResponse, PaginationMetadata, PresetIndex, PresetMetadata, UpdatePresetRequest, UpdatePresetResponse } from './preset';
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Preset Types
3
+ *
4
+ * Presets are portable game state snapshots that can be cloned
5
+ * to create new games with identical initial conditions.
6
+ */
7
+ /**
8
+ * Lightweight metadata for a single preset (stored in index.json)
9
+ */
10
+ export interface PresetMetadata {
11
+ /** Unique identifier for this preset */
12
+ presetId: string;
13
+ /** Display name for the preset */
14
+ name: string;
15
+ /** Brief description of the opening scene */
16
+ description: string;
17
+ /** Original Act 1 gameId this preset was created from (for reference/debugging) */
18
+ sourceGameId: string;
19
+ /** ISO 8601 timestamp when preset was created */
20
+ createdAt: string;
21
+ }
22
+ /**
23
+ * Index file structure for genre presets
24
+ * Stored at: fixtures/genres/{genreId}/presets/index.json
25
+ */
26
+ export interface PresetIndex {
27
+ /** Schema version for future evolution */
28
+ version: number;
29
+ /** Array of preset metadata entries */
30
+ presets: PresetMetadata[];
31
+ }
32
+ /**
33
+ * Response from GET /genres/{genreId}/presets (non-paginated, deprecated)
34
+ */
35
+ export interface ListPresetsResponse {
36
+ /** Genre identifier */
37
+ genreId: string;
38
+ /** Array of available presets */
39
+ presets: PresetMetadata[];
40
+ }
41
+ /**
42
+ * Pagination metadata for list responses
43
+ */
44
+ export interface PaginationMetadata {
45
+ /** Total number of items across all pages */
46
+ total: number;
47
+ /** Number of items per page */
48
+ limit: number;
49
+ /** Current offset (number of items skipped) */
50
+ offset: number;
51
+ /** Whether there are more items after this page */
52
+ hasMore: boolean;
53
+ }
54
+ /**
55
+ * Paginated response from GET /genres/{genreId}/presets
56
+ */
57
+ export interface PaginatedPresetsResponse {
58
+ /** Genre identifier */
59
+ genreId: string;
60
+ /** Array of presets for this page */
61
+ presets: PresetMetadata[];
62
+ /** Pagination metadata */
63
+ pagination: PaginationMetadata;
64
+ }
65
+ /**
66
+ * Request body for POST /genres/{genreId}/presets
67
+ */
68
+ export interface CreatePresetRequest {
69
+ /** Game ID to create preset from (can be any act - will resolve to Act 1 Turn 0) */
70
+ sourceGameId: string;
71
+ /** Display name for the new preset */
72
+ name: string;
73
+ /** Brief description of the opening scene */
74
+ description: string;
75
+ }
76
+ /**
77
+ * Response from POST /genres/{genreId}/presets
78
+ */
79
+ export interface CreatePresetResponse extends PresetMetadata {
80
+ /** Genre this preset belongs to */
81
+ genreId: string;
82
+ }
83
+ /**
84
+ * Request body for PUT /genres/{genreId}/presets/{presetId}
85
+ */
86
+ export interface UpdatePresetRequest {
87
+ /** Updated display name for the preset */
88
+ name: string;
89
+ /** Updated description of the opening scene */
90
+ description: string;
91
+ }
92
+ /**
93
+ * Response from PUT /genres/{genreId}/presets/{presetId}
94
+ */
95
+ export interface UpdatePresetResponse extends PresetMetadata {
96
+ /** Genre this preset belongs to */
97
+ genreId: string;
98
+ }
99
+ /**
100
+ * Response from DELETE /genres/{genreId}/presets/{presetId}
101
+ */
102
+ export interface DeletePresetResponse {
103
+ /** ID of the deleted preset */
104
+ presetId: string;
105
+ /** Genre the preset was deleted from */
106
+ genreId: string;
107
+ /** Confirmation message */
108
+ message: string;
109
+ }
package/dist/preset.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * Preset Types
4
+ *
5
+ * Presets are portable game state snapshots that can be cloned
6
+ * to create new games with identical initial conditions.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zeus-api-types",
3
- "version": "1.0.48",
3
+ "version": "1.0.51",
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"