@sharpee/engine 0.9.60-beta
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/LICENSE +21 -0
- package/README.md +328 -0
- package/dist/action-context-factory.d.ts +11 -0
- package/dist/action-context-factory.d.ts.map +1 -0
- package/dist/action-context-factory.js +258 -0
- package/dist/action-context-factory.js.map +1 -0
- package/dist/capability-dispatch-helper.d.ts +106 -0
- package/dist/capability-dispatch-helper.d.ts.map +1 -0
- package/dist/capability-dispatch-helper.js +269 -0
- package/dist/capability-dispatch-helper.js.map +1 -0
- package/dist/command-executor.d.ts +53 -0
- package/dist/command-executor.d.ts.map +1 -0
- package/dist/command-executor.js +329 -0
- package/dist/command-executor.js.map +1 -0
- package/dist/event-adapter.d.ts +44 -0
- package/dist/event-adapter.d.ts.map +1 -0
- package/dist/event-adapter.js +127 -0
- package/dist/event-adapter.js.map +1 -0
- package/dist/event-sequencer.d.ts +73 -0
- package/dist/event-sequencer.d.ts.map +1 -0
- package/dist/event-sequencer.js +134 -0
- package/dist/event-sequencer.js.map +1 -0
- package/dist/events/event-emitter.d.ts +34 -0
- package/dist/events/event-emitter.d.ts.map +1 -0
- package/dist/events/event-emitter.js +67 -0
- package/dist/events/event-emitter.js.map +1 -0
- package/dist/game-engine.d.ts +292 -0
- package/dist/game-engine.d.ts.map +1 -0
- package/dist/game-engine.js +1631 -0
- package/dist/game-engine.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/narrative/index.d.ts +5 -0
- package/dist/narrative/index.d.ts.map +1 -0
- package/dist/narrative/index.js +10 -0
- package/dist/narrative/index.js.map +1 -0
- package/dist/narrative/narrative-settings.d.ts +73 -0
- package/dist/narrative/narrative-settings.d.ts.map +1 -0
- package/dist/narrative/narrative-settings.js +28 -0
- package/dist/narrative/narrative-settings.js.map +1 -0
- package/dist/parser-interface.d.ts +77 -0
- package/dist/parser-interface.d.ts.map +1 -0
- package/dist/parser-interface.js +48 -0
- package/dist/parser-interface.js.map +1 -0
- package/dist/platform-operations.d.ts +83 -0
- package/dist/platform-operations.d.ts.map +1 -0
- package/dist/platform-operations.js +218 -0
- package/dist/platform-operations.js.map +1 -0
- package/dist/save-restore-service.d.ts +133 -0
- package/dist/save-restore-service.d.ts.map +1 -0
- package/dist/save-restore-service.js +446 -0
- package/dist/save-restore-service.js.map +1 -0
- package/dist/scheduler/index.d.ts +9 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/index.js +25 -0
- package/dist/scheduler/index.js.map +1 -0
- package/dist/scheduler/scheduler-service.d.ts +75 -0
- package/dist/scheduler/scheduler-service.d.ts.map +1 -0
- package/dist/scheduler/scheduler-service.js +310 -0
- package/dist/scheduler/scheduler-service.js.map +1 -0
- package/dist/scheduler/seeded-random.d.ts +7 -0
- package/dist/scheduler/seeded-random.d.ts.map +1 -0
- package/dist/scheduler/seeded-random.js +11 -0
- package/dist/scheduler/seeded-random.js.map +1 -0
- package/dist/scheduler/types.d.ts +134 -0
- package/dist/scheduler/types.d.ts.map +1 -0
- package/dist/scheduler/types.js +9 -0
- package/dist/scheduler/types.js.map +1 -0
- package/dist/shared-data-keys.d.ts +53 -0
- package/dist/shared-data-keys.d.ts.map +1 -0
- package/dist/shared-data-keys.js +29 -0
- package/dist/shared-data-keys.js.map +1 -0
- package/dist/story.d.ts +211 -0
- package/dist/story.d.ts.map +1 -0
- package/dist/story.js +60 -0
- package/dist/story.js.map +1 -0
- package/dist/test-helpers/mock-text-service.d.ts +11 -0
- package/dist/test-helpers/mock-text-service.d.ts.map +1 -0
- package/dist/test-helpers/mock-text-service.js +47 -0
- package/dist/test-helpers/mock-text-service.js.map +1 -0
- package/dist/turn-event-processor.d.ts +89 -0
- package/dist/turn-event-processor.d.ts.map +1 -0
- package/dist/turn-event-processor.js +144 -0
- package/dist/turn-event-processor.js.map +1 -0
- package/dist/types.d.ts +214 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/vocabulary-manager.d.ts +35 -0
- package/dist/vocabulary-manager.d.ts.map +1 -0
- package/dist/vocabulary-manager.js +74 -0
- package/dist/vocabulary-manager.js.map +1 -0
- package/package.json +70 -0
package/dist/story.d.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Story configuration and interfaces
|
|
3
|
+
*/
|
|
4
|
+
import { WorldModel, IFEntity, IGameEvent, SimpleEventHandler } from '@sharpee/world-model';
|
|
5
|
+
import { LanguageProvider } from '@sharpee/if-domain';
|
|
6
|
+
import { Parser } from '@sharpee/stdlib';
|
|
7
|
+
import { ISemanticEvent } from '@sharpee/core';
|
|
8
|
+
import type { GameEngine } from './game-engine';
|
|
9
|
+
import { NarrativeConfig } from './narrative';
|
|
10
|
+
/**
|
|
11
|
+
* Story configuration
|
|
12
|
+
*/
|
|
13
|
+
export interface StoryConfig {
|
|
14
|
+
/**
|
|
15
|
+
* Story ID
|
|
16
|
+
*/
|
|
17
|
+
id: string;
|
|
18
|
+
/**
|
|
19
|
+
* Story title
|
|
20
|
+
*/
|
|
21
|
+
title: string;
|
|
22
|
+
/**
|
|
23
|
+
* Story author(s)
|
|
24
|
+
*/
|
|
25
|
+
author: string | string[];
|
|
26
|
+
/**
|
|
27
|
+
* Story version
|
|
28
|
+
*/
|
|
29
|
+
version: string;
|
|
30
|
+
/**
|
|
31
|
+
* Story description
|
|
32
|
+
*/
|
|
33
|
+
description?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Website URL
|
|
36
|
+
*/
|
|
37
|
+
website?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Contact email
|
|
40
|
+
*/
|
|
41
|
+
email?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Story tags
|
|
44
|
+
*/
|
|
45
|
+
tags?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* IFID (Interactive Fiction ID)
|
|
48
|
+
*/
|
|
49
|
+
ifid?: string;
|
|
50
|
+
/**
|
|
51
|
+
* License
|
|
52
|
+
*/
|
|
53
|
+
license?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Release date
|
|
56
|
+
*/
|
|
57
|
+
releaseDate?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Custom configuration
|
|
60
|
+
*/
|
|
61
|
+
custom?: Record<string, any>;
|
|
62
|
+
/**
|
|
63
|
+
* Narrative settings (perspective, tense)
|
|
64
|
+
*
|
|
65
|
+
* ADR-089: Controls how the story narrates player actions.
|
|
66
|
+
* Defaults to 2nd person present tense ("You take the lamp").
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // 1st person narrative (Anchorhead-style)
|
|
70
|
+
* narrative: { perspective: '1st' }
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // 3rd person with specific pronouns
|
|
74
|
+
* narrative: { perspective: '3rd', playerPronouns: PRONOUNS.SHE_HER }
|
|
75
|
+
*/
|
|
76
|
+
narrative?: NarrativeConfig;
|
|
77
|
+
/**
|
|
78
|
+
* Implicit action settings (ADR-104)
|
|
79
|
+
*
|
|
80
|
+
* Controls automatic inference and implicit actions like "first taking".
|
|
81
|
+
* All default to true.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* // Disable all implicit behavior (strict mode)
|
|
85
|
+
* implicitActions: { inference: false, implicitTake: false }
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* // Allow inference but disable implicit take
|
|
89
|
+
* implicitActions: { implicitTake: false }
|
|
90
|
+
*/
|
|
91
|
+
implicitActions?: {
|
|
92
|
+
/**
|
|
93
|
+
* Whether to infer alternative targets when pronouns fail requirements.
|
|
94
|
+
* Example: "read it" (it=mailbox) infers leaflet if only readable thing.
|
|
95
|
+
* Default: true
|
|
96
|
+
*/
|
|
97
|
+
inference?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether to automatically take items when actions require holding them.
|
|
100
|
+
* Example: "read leaflet" auto-takes if not held.
|
|
101
|
+
* Default: true
|
|
102
|
+
*/
|
|
103
|
+
implicitTake?: boolean;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Custom vocabulary that a story can provide
|
|
108
|
+
*/
|
|
109
|
+
export interface CustomVocabulary {
|
|
110
|
+
/**
|
|
111
|
+
* Custom verbs for this story
|
|
112
|
+
*/
|
|
113
|
+
verbs?: Array<{
|
|
114
|
+
actionId: string;
|
|
115
|
+
verbs: string[];
|
|
116
|
+
pattern?: string;
|
|
117
|
+
prepositions?: string[];
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* Custom nouns (future expansion)
|
|
121
|
+
*/
|
|
122
|
+
nouns?: Array<{
|
|
123
|
+
word: string;
|
|
124
|
+
entityId?: string;
|
|
125
|
+
priority?: number;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Custom adjectives (future expansion)
|
|
129
|
+
*/
|
|
130
|
+
adjectives?: Array<{
|
|
131
|
+
word: string;
|
|
132
|
+
entityId?: string;
|
|
133
|
+
}>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Story interface - what a story module exports
|
|
137
|
+
*/
|
|
138
|
+
export interface Story {
|
|
139
|
+
/**
|
|
140
|
+
* Story configuration
|
|
141
|
+
*/
|
|
142
|
+
config: StoryConfig;
|
|
143
|
+
/**
|
|
144
|
+
* Initialize the world for this story
|
|
145
|
+
*/
|
|
146
|
+
initializeWorld(world: WorldModel): void;
|
|
147
|
+
/**
|
|
148
|
+
* Create the player entity
|
|
149
|
+
*/
|
|
150
|
+
createPlayer(world: WorldModel): IFEntity;
|
|
151
|
+
/**
|
|
152
|
+
* Get custom actions for this story (optional)
|
|
153
|
+
*/
|
|
154
|
+
getCustomActions?(): any[];
|
|
155
|
+
/**
|
|
156
|
+
* Get custom vocabulary for this story (optional)
|
|
157
|
+
* Called after story initialization to register custom verbs, nouns, etc.
|
|
158
|
+
*/
|
|
159
|
+
getCustomVocabulary?(): CustomVocabulary;
|
|
160
|
+
/**
|
|
161
|
+
* Story-specific initialization (optional)
|
|
162
|
+
*/
|
|
163
|
+
initialize?(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Check if the story is complete (optional)
|
|
166
|
+
*/
|
|
167
|
+
isComplete?(): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Extend the parser with story-specific vocabulary (optional)
|
|
170
|
+
*/
|
|
171
|
+
extendParser?(parser: Parser): void;
|
|
172
|
+
/**
|
|
173
|
+
* Extend the language provider with story-specific messages (optional)
|
|
174
|
+
*/
|
|
175
|
+
extendLanguage?(language: LanguageProvider): void;
|
|
176
|
+
/**
|
|
177
|
+
* Called after the engine is fully initialized (optional).
|
|
178
|
+
* Use this to register parsed command transformers or other engine hooks.
|
|
179
|
+
*
|
|
180
|
+
* @param engine - The fully initialized game engine
|
|
181
|
+
*/
|
|
182
|
+
onEngineReady?(engine: GameEngine): void;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Extended story class with event handling capabilities
|
|
186
|
+
*/
|
|
187
|
+
export declare class StoryWithEvents implements Story {
|
|
188
|
+
config: StoryConfig;
|
|
189
|
+
private eventEmitter;
|
|
190
|
+
constructor(config: StoryConfig);
|
|
191
|
+
/**
|
|
192
|
+
* Register a story-level event handler (daemon)
|
|
193
|
+
*/
|
|
194
|
+
on(eventType: string, handler: SimpleEventHandler): void;
|
|
195
|
+
/**
|
|
196
|
+
* Remove a story-level event handler
|
|
197
|
+
*/
|
|
198
|
+
off(eventType: string, handler: SimpleEventHandler): void;
|
|
199
|
+
/**
|
|
200
|
+
* Emit an event to story-level handlers
|
|
201
|
+
* Returns any semantic events generated by handlers
|
|
202
|
+
*/
|
|
203
|
+
emit(event: IGameEvent): ISemanticEvent[];
|
|
204
|
+
initializeWorld(world: WorldModel): void;
|
|
205
|
+
createPlayer(world: WorldModel): IFEntity;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Validate story configuration
|
|
209
|
+
*/
|
|
210
|
+
export declare function validateStoryConfig(config: StoryConfig): void;
|
|
211
|
+
//# sourceMappingURL=story.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"story.d.ts","sourceRoot":"","sources":["../src/story.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE1B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAGhB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAA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IACH,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC;;OAEG;IACH,cAAc,CAAC,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAElD;;;;;OAKG;IACH,aAAa,CAAC,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,KAAK;IAC3C,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,CAAC,YAAY,CAAe;gBAEvB,MAAM,EAAE,WAAW;IAK/B;;OAEG;IACH,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAIxD;;OAEG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAIzD;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,cAAc,EAAE;IAKzC,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAIxC,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ;CAG1C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAU7D"}
|
package/dist/story.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Story configuration and interfaces
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StoryWithEvents = void 0;
|
|
7
|
+
exports.validateStoryConfig = validateStoryConfig;
|
|
8
|
+
const event_emitter_1 = require("./events/event-emitter");
|
|
9
|
+
/**
|
|
10
|
+
* Extended story class with event handling capabilities
|
|
11
|
+
*/
|
|
12
|
+
class StoryWithEvents {
|
|
13
|
+
config;
|
|
14
|
+
eventEmitter;
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.eventEmitter = new event_emitter_1.EventEmitter();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Register a story-level event handler (daemon)
|
|
21
|
+
*/
|
|
22
|
+
on(eventType, handler) {
|
|
23
|
+
this.eventEmitter.on(eventType, handler);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Remove a story-level event handler
|
|
27
|
+
*/
|
|
28
|
+
off(eventType, handler) {
|
|
29
|
+
this.eventEmitter.off(eventType, handler);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Emit an event to story-level handlers
|
|
33
|
+
* Returns any semantic events generated by handlers
|
|
34
|
+
*/
|
|
35
|
+
emit(event) {
|
|
36
|
+
return this.eventEmitter.emit(event);
|
|
37
|
+
}
|
|
38
|
+
// Abstract methods that must be implemented by subclasses
|
|
39
|
+
initializeWorld(world) {
|
|
40
|
+
throw new Error('initializeWorld must be implemented');
|
|
41
|
+
}
|
|
42
|
+
createPlayer(world) {
|
|
43
|
+
throw new Error('createPlayer must be implemented');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.StoryWithEvents = StoryWithEvents;
|
|
47
|
+
/**
|
|
48
|
+
* Validate story configuration
|
|
49
|
+
*/
|
|
50
|
+
function validateStoryConfig(config) {
|
|
51
|
+
if (!config.id || !config.title || !config.author || !config.version) {
|
|
52
|
+
throw new Error('Missing required story configuration fields');
|
|
53
|
+
}
|
|
54
|
+
// Validate semantic version
|
|
55
|
+
const versionRegex = /^\d+\.\d+\.\d+$/;
|
|
56
|
+
if (!versionRegex.test(config.version)) {
|
|
57
|
+
throw new Error('Invalid version format. Must be semantic version (e.g., 1.0.0)');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"story.js","sourceRoot":"","sources":["../src/story.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAoQH,kDAUC;AAzQD,0DAAsD;AA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AAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock text service for testing
|
|
3
|
+
*/
|
|
4
|
+
import type { ITextService } from '@sharpee/text-service';
|
|
5
|
+
import type { ITextBlock } from '@sharpee/text-blocks';
|
|
6
|
+
import type { ISemanticEvent } from '@sharpee/core';
|
|
7
|
+
export declare class MockTextService implements ITextService {
|
|
8
|
+
processTurn(events: ISemanticEvent[]): ITextBlock[];
|
|
9
|
+
}
|
|
10
|
+
export declare function createMockTextService(): ITextService;
|
|
11
|
+
//# sourceMappingURL=mock-text-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-text-service.d.ts","sourceRoot":"","sources":["../../src/test-helpers/mock-text-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,qBAAa,eAAgB,YAAW,YAAY;IAClD,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,UAAU,EAAE;CAkCpD;AAED,wBAAgB,qBAAqB,IAAI,YAAY,CAEpD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Mock text service for testing
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MockTextService = void 0;
|
|
7
|
+
exports.createMockTextService = createMockTextService;
|
|
8
|
+
class MockTextService {
|
|
9
|
+
processTurn(events) {
|
|
10
|
+
const blocks = [];
|
|
11
|
+
// Process events
|
|
12
|
+
for (const event of events) {
|
|
13
|
+
const data = event.data;
|
|
14
|
+
if (event.type === 'action.error') {
|
|
15
|
+
blocks.push({
|
|
16
|
+
key: 'error',
|
|
17
|
+
content: [String(data?.message || 'Error occurred')],
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else if (event.type === 'action.success') {
|
|
21
|
+
blocks.push({
|
|
22
|
+
key: 'action.result',
|
|
23
|
+
content: [`Action completed: ${String(data?.action || 'unknown')}`],
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
else if (event.type === 'room.described') {
|
|
27
|
+
blocks.push({
|
|
28
|
+
key: 'room.description',
|
|
29
|
+
content: [String(data?.description || 'You are in a room.')],
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Default message if no events
|
|
34
|
+
if (blocks.length === 0) {
|
|
35
|
+
blocks.push({
|
|
36
|
+
key: 'game.message',
|
|
37
|
+
content: ['Nothing happened.'],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return blocks;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.MockTextService = MockTextService;
|
|
44
|
+
function createMockTextService() {
|
|
45
|
+
return new MockTextService();
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=mock-text-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-text-service.js","sourceRoot":"","sources":["../../src/test-helpers/mock-text-service.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA2CH,sDAEC;AAvCD,MAAa,eAAe;IAC1B,WAAW,CAAC,MAAwB;QAClC,MAAM,MAAM,GAAiB,EAAE,CAAC;QAEhC,iBAAiB;QACjB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,KAAK,CAAC,IAA2B,CAAC;YAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;gBAClC,MAAM,CAAC,IAAI,CAAC;oBACV,GAAG,EAAE,OAAO;oBACZ,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,IAAI,gBAAgB,CAAC,CAAC;iBACrD,CAAC,CAAC;YACL,CAAC;iBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;gBAC3C,MAAM,CAAC,IAAI,CAAC;oBACV,GAAG,EAAE,eAAe;oBACpB,OAAO,EAAE,CAAC,qBAAqB,MAAM,CAAC,IAAI,EAAE,MAAM,IAAI,SAAS,CAAC,EAAE,CAAC;iBACpE,CAAC,CAAC;YACL,CAAC;iBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;gBAC3C,MAAM,CAAC,IAAI,CAAC;oBACV,GAAG,EAAE,kBAAkB;oBACvB,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,IAAI,oBAAoB,CAAC,CAAC;iBAC7D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,+BAA+B;QAC/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC;gBACV,GAAG,EAAE,cAAc;gBACnB,OAAO,EAAE,CAAC,mBAAmB,CAAC;aAC/B,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAnCD,0CAmCC;AAED,SAAgB,qBAAqB;IACnC,OAAO,IAAI,eAAe,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn Event Processor - Processes events during turn execution
|
|
3
|
+
*
|
|
4
|
+
* Extracted from GameEngine as part of Phase 4 remediation.
|
|
5
|
+
* Handles event enrichment, perception filtering, and event emission.
|
|
6
|
+
*/
|
|
7
|
+
import { ISemanticEvent, ISemanticEventSource, IPlatformEvent } from '@sharpee/core';
|
|
8
|
+
import { WorldModel, IFEntity } from '@sharpee/world-model';
|
|
9
|
+
import { IPerceptionService } from '@sharpee/stdlib';
|
|
10
|
+
import { SequencedEvent, EngineConfig } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Context for event enrichment - matches EventProcessingContext
|
|
13
|
+
*/
|
|
14
|
+
export interface EnrichmentContext {
|
|
15
|
+
turn: number;
|
|
16
|
+
playerId: string;
|
|
17
|
+
locationId: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Result of processing events for a turn phase
|
|
21
|
+
*/
|
|
22
|
+
export interface ProcessedEventsResult {
|
|
23
|
+
/** Processed semantic events */
|
|
24
|
+
semanticEvents: ISemanticEvent[];
|
|
25
|
+
/** Platform events that need handling */
|
|
26
|
+
platformEvents: IPlatformEvent[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Callback type for emitting events
|
|
30
|
+
*/
|
|
31
|
+
export type EventEmitCallback = (event: SequencedEvent) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Callback type for dispatching to entity handlers
|
|
34
|
+
*/
|
|
35
|
+
export type EntityHandlerDispatcher = (event: SequencedEvent) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Service for processing turn events
|
|
38
|
+
*/
|
|
39
|
+
export declare class TurnEventProcessor {
|
|
40
|
+
private perceptionService?;
|
|
41
|
+
constructor(perceptionService?: IPerceptionService | undefined);
|
|
42
|
+
/**
|
|
43
|
+
* Process action events from command execution
|
|
44
|
+
*
|
|
45
|
+
* @param events - Raw events from command executor
|
|
46
|
+
* @param enrichmentContext - Context for event enrichment
|
|
47
|
+
* @param player - Player entity for perception filtering
|
|
48
|
+
* @param world - World model for perception filtering
|
|
49
|
+
* @returns Processed events and platform events
|
|
50
|
+
*/
|
|
51
|
+
processActionEvents(events: SequencedEvent[], enrichmentContext: EnrichmentContext, player: IFEntity, world: WorldModel): ProcessedEventsResult;
|
|
52
|
+
/**
|
|
53
|
+
* Process semantic events (e.g., from NPC or scheduler ticks)
|
|
54
|
+
*
|
|
55
|
+
* @param events - Semantic events to process
|
|
56
|
+
* @param enrichmentContext - Context for event enrichment
|
|
57
|
+
* @param player - Player entity for perception filtering
|
|
58
|
+
* @param world - World model for perception filtering
|
|
59
|
+
* @returns Processed events and platform events
|
|
60
|
+
*/
|
|
61
|
+
processSemanticEvents(events: ISemanticEvent[], enrichmentContext: EnrichmentContext, player: IFEntity, world: WorldModel): ProcessedEventsResult;
|
|
62
|
+
/**
|
|
63
|
+
* Emit events through all configured channels
|
|
64
|
+
*
|
|
65
|
+
* @param semanticEvents - Events to emit
|
|
66
|
+
* @param eventSource - Event source for tracking
|
|
67
|
+
* @param turnEvents - Turn events map to update
|
|
68
|
+
* @param turn - Current turn number
|
|
69
|
+
* @param config - Engine config with event callback
|
|
70
|
+
* @param eventEmitter - Callback for engine event emission
|
|
71
|
+
* @param entityDispatcher - Optional callback for entity handler dispatch
|
|
72
|
+
*/
|
|
73
|
+
emitEvents(semanticEvents: ISemanticEvent[], eventSource: ISemanticEventSource, turnEvents: Map<number, ISemanticEvent[]>, turn: number, config: EngineConfig, eventEmitter: EventEmitCallback, entityDispatcher?: EntityHandlerDispatcher): void;
|
|
74
|
+
/**
|
|
75
|
+
* Check for victory events in the processed events
|
|
76
|
+
*
|
|
77
|
+
* @param events - Events to check
|
|
78
|
+
* @returns Victory details if found, null otherwise
|
|
79
|
+
*/
|
|
80
|
+
checkForVictory(events: SequencedEvent[]): {
|
|
81
|
+
reason: string;
|
|
82
|
+
score: number;
|
|
83
|
+
} | null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Create a turn event processor instance
|
|
87
|
+
*/
|
|
88
|
+
export declare function createTurnEventProcessor(perceptionService?: IPerceptionService): TurnEventProcessor;
|
|
89
|
+
//# sourceMappingURL=turn-event-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-event-processor.d.ts","sourceRoot":"","sources":["../src/turn-event-processor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,oBAAoB,EAEpB,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,QAAQ,EA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EACpB,YAAY,EAAE,iBAAiB,EAC/B,gBAAgB,CAAC,EAAE,uBAAuB,GACzC,IAAI;IA4BP;;;;;OAKG;IACH,eAAe,CACb,MAAM,EAAE,cAAc,EAAE,GACvB;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;CAY5C;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,iBAAiB,CAAC,EAAE,kBAAkB,GACrC,kBAAkB,CAEpB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Turn Event Processor - Processes events during turn execution
|
|
4
|
+
*
|
|
5
|
+
* Extracted from GameEngine as part of Phase 4 remediation.
|
|
6
|
+
* Handles event enrichment, perception filtering, and event emission.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TurnEventProcessor = void 0;
|
|
10
|
+
exports.createTurnEventProcessor = createTurnEventProcessor;
|
|
11
|
+
const core_1 = require("@sharpee/core");
|
|
12
|
+
const event_adapter_1 = require("./event-adapter");
|
|
13
|
+
/**
|
|
14
|
+
* Service for processing turn events
|
|
15
|
+
*/
|
|
16
|
+
class TurnEventProcessor {
|
|
17
|
+
perceptionService;
|
|
18
|
+
constructor(perceptionService) {
|
|
19
|
+
this.perceptionService = perceptionService;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Process action events from command execution
|
|
23
|
+
*
|
|
24
|
+
* @param events - Raw events from command executor
|
|
25
|
+
* @param enrichmentContext - Context for event enrichment
|
|
26
|
+
* @param player - Player entity for perception filtering
|
|
27
|
+
* @param world - World model for perception filtering
|
|
28
|
+
* @returns Processed events and platform events
|
|
29
|
+
*/
|
|
30
|
+
processActionEvents(events, enrichmentContext, player, world) {
|
|
31
|
+
// Convert to semantic events and process through pipeline
|
|
32
|
+
const context = {
|
|
33
|
+
turn: enrichmentContext.turn,
|
|
34
|
+
playerId: enrichmentContext.playerId,
|
|
35
|
+
locationId: enrichmentContext.locationId
|
|
36
|
+
};
|
|
37
|
+
let semanticEvents = events.map((e) => {
|
|
38
|
+
const semantic = (0, event_adapter_1.toSemanticEvent)(e);
|
|
39
|
+
return (0, event_adapter_1.processEvent)(semantic, context);
|
|
40
|
+
});
|
|
41
|
+
// Apply perception filtering if service is configured
|
|
42
|
+
if (this.perceptionService) {
|
|
43
|
+
semanticEvents = this.perceptionService.filterEvents(semanticEvents, player, world);
|
|
44
|
+
}
|
|
45
|
+
// Check for platform request events
|
|
46
|
+
const platformEvents = [];
|
|
47
|
+
for (const event of semanticEvents) {
|
|
48
|
+
if ((0, core_1.isPlatformRequestEvent)(event)) {
|
|
49
|
+
platformEvents.push(event);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { semanticEvents, platformEvents };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Process semantic events (e.g., from NPC or scheduler ticks)
|
|
56
|
+
*
|
|
57
|
+
* @param events - Semantic events to process
|
|
58
|
+
* @param enrichmentContext - Context for event enrichment
|
|
59
|
+
* @param player - Player entity for perception filtering
|
|
60
|
+
* @param world - World model for perception filtering
|
|
61
|
+
* @returns Processed events and platform events
|
|
62
|
+
*/
|
|
63
|
+
processSemanticEvents(events, enrichmentContext, player, world) {
|
|
64
|
+
const context = {
|
|
65
|
+
turn: enrichmentContext.turn,
|
|
66
|
+
playerId: enrichmentContext.playerId,
|
|
67
|
+
locationId: enrichmentContext.locationId
|
|
68
|
+
};
|
|
69
|
+
// Process events through the pipeline
|
|
70
|
+
let semanticEvents = events.map((e) => (0, event_adapter_1.processEvent)(e, context));
|
|
71
|
+
// Apply perception filtering if service is configured
|
|
72
|
+
if (this.perceptionService) {
|
|
73
|
+
semanticEvents = this.perceptionService.filterEvents(semanticEvents, player, world);
|
|
74
|
+
}
|
|
75
|
+
// Check for platform request events
|
|
76
|
+
const platformEvents = [];
|
|
77
|
+
for (const event of semanticEvents) {
|
|
78
|
+
if ((0, core_1.isPlatformRequestEvent)(event)) {
|
|
79
|
+
platformEvents.push(event);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { semanticEvents, platformEvents };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Emit events through all configured channels
|
|
86
|
+
*
|
|
87
|
+
* @param semanticEvents - Events to emit
|
|
88
|
+
* @param eventSource - Event source for tracking
|
|
89
|
+
* @param turnEvents - Turn events map to update
|
|
90
|
+
* @param turn - Current turn number
|
|
91
|
+
* @param config - Engine config with event callback
|
|
92
|
+
* @param eventEmitter - Callback for engine event emission
|
|
93
|
+
* @param entityDispatcher - Optional callback for entity handler dispatch
|
|
94
|
+
*/
|
|
95
|
+
emitEvents(semanticEvents, eventSource, turnEvents, turn, config, eventEmitter, entityDispatcher) {
|
|
96
|
+
// Store events for this turn
|
|
97
|
+
const existingEvents = turnEvents.get(turn) || [];
|
|
98
|
+
turnEvents.set(turn, [...existingEvents, ...semanticEvents]);
|
|
99
|
+
// Track in event source for save/restore
|
|
100
|
+
for (const event of semanticEvents) {
|
|
101
|
+
eventSource.emit(event);
|
|
102
|
+
}
|
|
103
|
+
// Emit events if configured
|
|
104
|
+
if (config.onEvent) {
|
|
105
|
+
for (const event of semanticEvents) {
|
|
106
|
+
config.onEvent(event);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Emit through engine's event system
|
|
110
|
+
for (const event of semanticEvents) {
|
|
111
|
+
eventEmitter(event);
|
|
112
|
+
// Dispatch to entity handlers if provided
|
|
113
|
+
if (entityDispatcher) {
|
|
114
|
+
entityDispatcher(event);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Check for victory events in the processed events
|
|
120
|
+
*
|
|
121
|
+
* @param events - Events to check
|
|
122
|
+
* @returns Victory details if found, null otherwise
|
|
123
|
+
*/
|
|
124
|
+
checkForVictory(events) {
|
|
125
|
+
for (const event of events) {
|
|
126
|
+
if (event.type === 'story.victory') {
|
|
127
|
+
const data = event.data;
|
|
128
|
+
return {
|
|
129
|
+
reason: data?.reason || 'Story completed',
|
|
130
|
+
score: data?.score || 0
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.TurnEventProcessor = TurnEventProcessor;
|
|
138
|
+
/**
|
|
139
|
+
* Create a turn event processor instance
|
|
140
|
+
*/
|
|
141
|
+
function createTurnEventProcessor(perceptionService) {
|
|
142
|
+
return new TurnEventProcessor(perceptionService);
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=turn-event-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-event-processor.js","sourceRoot":"","sources":["../src/turn-event-processor.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAqNH,4DAIC;AAvND,wCAKuB;AAIvB,mDAAwF;AA+BxF;;GAEG;AACH,MAAa,kBAAkB;IAEnB;IADV,YACU,iBAAsC;QAAtC,sBAAiB,GAAjB,iBAAiB,CAAqB;IAC7C,CAAC;IAEJ;;;;;;;;OAQG;IACH,mBAAmB,CACjB,MAAwB,EACxB,iBAAoC,EACpC,MAAgB,EAChB,KAAiB;QAEjB,0DAA0D;QAC1D,MAAM,OAAO,GAA2B;YACtC,IAAI,EAAE,iBAAiB,CAAC,IAAI;YAC5B,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;YACpC,UAAU,EAAE,iBAAiB,CAAC,UAAU;SACzC,CAAC;QAEF,IAAI,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACpC,MAAM,QAAQ,GAAG,IAAA,+BAAe,EAAC,CAAC,CAAC,CAAC;YACpC,OAAO,IAAA,4BAAY,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,sDAAsD;QACtD,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