@ai-rpg-engine/presentation 2.0.0

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.
@@ -0,0 +1,3 @@
1
+ export type { NarrationPlan, NarrationTone, Urgency, Interruptibility, SpeakerCue, SfxCue, SfxTiming, AmbientCue, MusicCue, UiEffect, UiEffectType, VoiceProfile, VoicePreset, PresentationState, PresentationRenderer, } from './types.js';
2
+ export { validateNarrationPlan, isValidNarrationPlan, type ValidationError, } from './validate.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { validateNarrationPlan, isValidNarrationPlan, } from './validate.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,71 @@
1
+ /** Structured narration recipe for multi-modal presentation. */
2
+ export type NarrationPlan = {
3
+ sceneText: string;
4
+ tone: NarrationTone;
5
+ urgency: Urgency;
6
+ speaker?: SpeakerCue;
7
+ musicCue?: MusicCue;
8
+ sfx: SfxCue[];
9
+ ambientLayers: AmbientCue[];
10
+ uiEffects: UiEffect[];
11
+ interruptibility: Interruptibility;
12
+ voiceProfile?: VoiceProfile;
13
+ };
14
+ export type NarrationTone = 'tense' | 'calm' | 'wonder' | 'dread' | 'combat' | 'triumph' | 'sorrow';
15
+ export type Urgency = 'idle' | 'normal' | 'elevated' | 'critical';
16
+ export type Interruptibility = 'free' | 'locked' | 'soft-lock';
17
+ /** Voice synthesis cue for a speaker (narrator or NPC). */
18
+ export type SpeakerCue = {
19
+ entityId: string;
20
+ voiceId: string;
21
+ emotion: string;
22
+ speed: number;
23
+ text: string;
24
+ };
25
+ /** Sound effect trigger. */
26
+ export type SfxCue = {
27
+ effectId: string;
28
+ timing: SfxTiming;
29
+ intensity: number;
30
+ };
31
+ export type SfxTiming = 'immediate' | 'with-text' | 'after-text';
32
+ /** Ambient audio layer control. */
33
+ export type AmbientCue = {
34
+ layerId: string;
35
+ action: 'start' | 'stop' | 'crossfade';
36
+ volume: number;
37
+ fadeMs: number;
38
+ };
39
+ /** Background music control. */
40
+ export type MusicCue = {
41
+ action: 'play' | 'stop' | 'crossfade' | 'intensify' | 'soften';
42
+ trackId?: string;
43
+ fadeMs: number;
44
+ };
45
+ /** Terminal/screen visual effect. */
46
+ export type UiEffect = {
47
+ type: UiEffectType;
48
+ durationMs: number;
49
+ color?: string;
50
+ };
51
+ export type UiEffectType = 'flash' | 'shake' | 'fade-in' | 'fade-out' | 'border-pulse';
52
+ /** Voice configuration for speech synthesis. */
53
+ export type VoiceProfile = {
54
+ voiceId: string;
55
+ preset: VoicePreset;
56
+ emotion: string;
57
+ speed: number;
58
+ };
59
+ export type VoicePreset = 'narrator' | 'storyteller' | 'announcer' | 'whisper' | 'assistant';
60
+ /** Presentation state for the game session. */
61
+ export type PresentationState = 'exploration' | 'dialogue' | 'tension' | 'combat' | 'aftermath' | 'menu' | 'dream' | 'director';
62
+ /** Render contract — any frontend implements this to receive presentation commands. */
63
+ export interface PresentationRenderer {
64
+ renderText(text: string): Promise<void>;
65
+ playVoice(cue: SpeakerCue): Promise<void>;
66
+ playSfx(cue: SfxCue): Promise<void>;
67
+ setAmbient(cue: AmbientCue): Promise<void>;
68
+ setMusic(cue: MusicCue): Promise<void>;
69
+ applyUiEffect(effect: UiEffect): Promise<void>;
70
+ }
71
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,aAAa,EAAE,UAAU,EAAE,CAAC;IAC5B,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,MAAM,GACN,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,SAAS,GACT,QAAQ,CAAC;AAEb,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE/D,2DAA2D;AAC3D,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,4BAA4B;AAC5B,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC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CAAC;IACxC,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,aAAa,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ // Narration plan schema and presentation types
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,+CAA+C"}
@@ -0,0 +1,10 @@
1
+ import type { NarrationPlan } from './types.js';
2
+ export type ValidationError = {
3
+ field: string;
4
+ message: string;
5
+ };
6
+ /** Validate a NarrationPlan, returning errors if any. */
7
+ export declare function validateNarrationPlan(plan: unknown): ValidationError[];
8
+ /** Returns true if the plan is valid. */
9
+ export declare function isValidNarrationPlan(plan: unknown): plan is NarrationPlan;
10
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAA4C,MAAM,YAAY,CAAC;AAQ1F,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,yDAAyD;AACzD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,EAAE,CAsDtE;AAED,yCAAyC;AACzC,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAEzE"}
@@ -0,0 +1,58 @@
1
+ // Validate a NarrationPlan against expected shape
2
+ const VALID_TONES = [
3
+ 'tense', 'calm', 'wonder', 'dread', 'combat', 'triumph', 'sorrow',
4
+ ];
5
+ const VALID_URGENCIES = ['idle', 'normal', 'elevated', 'critical'];
6
+ const VALID_INTERRUPTIBILITIES = ['free', 'locked', 'soft-lock'];
7
+ /** Validate a NarrationPlan, returning errors if any. */
8
+ export function validateNarrationPlan(plan) {
9
+ const errors = [];
10
+ if (!plan || typeof plan !== 'object') {
11
+ return [{ field: 'root', message: 'NarrationPlan must be an object' }];
12
+ }
13
+ const p = plan;
14
+ if (typeof p.sceneText !== 'string' || p.sceneText.length === 0) {
15
+ errors.push({ field: 'sceneText', message: 'sceneText must be a non-empty string' });
16
+ }
17
+ if (!VALID_TONES.includes(p.tone)) {
18
+ errors.push({ field: 'tone', message: `tone must be one of: ${VALID_TONES.join(', ')}` });
19
+ }
20
+ if (!VALID_URGENCIES.includes(p.urgency)) {
21
+ errors.push({ field: 'urgency', message: `urgency must be one of: ${VALID_URGENCIES.join(', ')}` });
22
+ }
23
+ if (!VALID_INTERRUPTIBILITIES.includes(p.interruptibility)) {
24
+ errors.push({
25
+ field: 'interruptibility',
26
+ message: `interruptibility must be one of: ${VALID_INTERRUPTIBILITIES.join(', ')}`,
27
+ });
28
+ }
29
+ if (!Array.isArray(p.sfx)) {
30
+ errors.push({ field: 'sfx', message: 'sfx must be an array' });
31
+ }
32
+ else {
33
+ for (let i = 0; i < p.sfx.length; i++) {
34
+ const sfx = p.sfx[i];
35
+ if (typeof sfx.effectId !== 'string') {
36
+ errors.push({ field: `sfx[${i}].effectId`, message: 'effectId must be a string' });
37
+ }
38
+ if (!['immediate', 'with-text', 'after-text'].includes(sfx.timing)) {
39
+ errors.push({ field: `sfx[${i}].timing`, message: 'timing must be immediate, with-text, or after-text' });
40
+ }
41
+ if (typeof sfx.intensity !== 'number' || sfx.intensity < 0 || sfx.intensity > 1) {
42
+ errors.push({ field: `sfx[${i}].intensity`, message: 'intensity must be a number between 0 and 1' });
43
+ }
44
+ }
45
+ }
46
+ if (!Array.isArray(p.ambientLayers)) {
47
+ errors.push({ field: 'ambientLayers', message: 'ambientLayers must be an array' });
48
+ }
49
+ if (!Array.isArray(p.uiEffects)) {
50
+ errors.push({ field: 'uiEffects', message: 'uiEffects must be an array' });
51
+ }
52
+ return errors;
53
+ }
54
+ /** Returns true if the plan is valid. */
55
+ export function isValidNarrationPlan(plan) {
56
+ return validateNarrationPlan(plan).length === 0;
57
+ }
58
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAIlD,MAAM,WAAW,GAAoB;IACnC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;CAClE,CAAC;AACF,MAAM,eAAe,GAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAC9E,MAAM,wBAAwB,GAAuB,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAOrF,yDAAyD;AACzD,MAAM,UAAU,qBAAqB,CAAC,IAAa;IACjD,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,CAAC,GAAG,IAA+B,CAAC;IAE1C,IAAI,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO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0.0",
4
+ "description": "Narration plan schema, render contracts, and presentation state types for AI RPG Engine",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": ["dist"],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "test": "vitest run"
18
+ },
19
+ "license": "MIT",
20
+ "author": "mcp-tool-shop",
21
+ "homepage": "https://mcp-tool-shop-org.github.io/ai-rpg-engine/",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/mcp-tool-shop-org/ai-rpg-engine.git",
25
+ "directory": "packages/presentation"
26
+ },
27
+ "keywords": ["rpg", "narration", "presentation", "audio", "immersion", "game-engine"],
28
+ "bugs": {
29
+ "url": "https://github.com/mcp-tool-shop-org/ai-rpg-engine/issues"
30
+ },
31
+ "engines": {
32
+ "node": ">=20"
33
+ }
34
+ }