@sharpee/engine 0.9.111 → 1.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.
Files changed (146) hide show
  1. package/action-context-factory.d.ts +10 -2
  2. package/action-context-factory.d.ts.map +1 -1
  3. package/action-context-factory.js +29 -5
  4. package/action-context-factory.js.map +1 -1
  5. package/command-executor.d.ts +2 -1
  6. package/command-executor.d.ts.map +1 -1
  7. package/command-executor.js +3 -3
  8. package/command-executor.js.map +1 -1
  9. package/game-engine.d.ts +87 -4
  10. package/game-engine.d.ts.map +1 -1
  11. package/game-engine.js +250 -9
  12. package/game-engine.js.map +1 -1
  13. package/index.d.ts +1 -0
  14. package/index.d.ts.map +1 -1
  15. package/index.js +2 -0
  16. package/index.js.map +1 -1
  17. package/package.json +13 -12
  18. package/prose-pipeline/assemble.d.ts +77 -0
  19. package/prose-pipeline/assemble.d.ts.map +1 -0
  20. package/prose-pipeline/assemble.js +96 -0
  21. package/prose-pipeline/assemble.js.map +1 -0
  22. package/prose-pipeline/decorations/index.d.ts +18 -0
  23. package/prose-pipeline/decorations/index.d.ts.map +1 -0
  24. package/prose-pipeline/decorations/index.js +24 -0
  25. package/prose-pipeline/decorations/index.js.map +1 -0
  26. package/prose-pipeline/decorations/parser.d.ts +34 -0
  27. package/prose-pipeline/decorations/parser.d.ts.map +1 -0
  28. package/prose-pipeline/decorations/parser.js +177 -0
  29. package/prose-pipeline/decorations/parser.js.map +1 -0
  30. package/prose-pipeline/decorations/platform-vocabulary.d.ts +27 -0
  31. package/prose-pipeline/decorations/platform-vocabulary.d.ts.map +1 -0
  32. package/prose-pipeline/decorations/platform-vocabulary.js +65 -0
  33. package/prose-pipeline/decorations/platform-vocabulary.js.map +1 -0
  34. package/prose-pipeline/decorations/resolver.d.ts +28 -0
  35. package/prose-pipeline/decorations/resolver.d.ts.map +1 -0
  36. package/prose-pipeline/decorations/resolver.js +39 -0
  37. package/prose-pipeline/decorations/resolver.js.map +1 -0
  38. package/prose-pipeline/decorations/types.d.ts +16 -0
  39. package/prose-pipeline/decorations/types.d.ts.map +1 -0
  40. package/prose-pipeline/decorations/types.js +17 -0
  41. package/prose-pipeline/decorations/types.js.map +1 -0
  42. package/prose-pipeline/handlers/about.d.ts +31 -0
  43. package/prose-pipeline/handlers/about.d.ts.map +1 -0
  44. package/prose-pipeline/handlers/about.js +50 -0
  45. package/prose-pipeline/handlers/about.js.map +1 -0
  46. package/prose-pipeline/handlers/audibility.d.ts +46 -0
  47. package/prose-pipeline/handlers/audibility.d.ts.map +1 -0
  48. package/prose-pipeline/handlers/audibility.js +79 -0
  49. package/prose-pipeline/handlers/audibility.js.map +1 -0
  50. package/prose-pipeline/handlers/banner.d.ts +44 -0
  51. package/prose-pipeline/handlers/banner.d.ts.map +1 -0
  52. package/prose-pipeline/handlers/banner.js +88 -0
  53. package/prose-pipeline/handlers/banner.js.map +1 -0
  54. package/prose-pipeline/handlers/client-query.d.ts +22 -0
  55. package/prose-pipeline/handlers/client-query.d.ts.map +1 -0
  56. package/prose-pipeline/handlers/client-query.js +55 -0
  57. package/prose-pipeline/handlers/client-query.js.map +1 -0
  58. package/prose-pipeline/handlers/command-failed.d.ts +24 -0
  59. package/prose-pipeline/handlers/command-failed.d.ts.map +1 -0
  60. package/prose-pipeline/handlers/command-failed.js +46 -0
  61. package/prose-pipeline/handlers/command-failed.js.map +1 -0
  62. package/prose-pipeline/handlers/domain-message.d.ts +31 -0
  63. package/prose-pipeline/handlers/domain-message.d.ts.map +1 -0
  64. package/prose-pipeline/handlers/domain-message.js +66 -0
  65. package/prose-pipeline/handlers/domain-message.js.map +1 -0
  66. package/prose-pipeline/handlers/game.d.ts +31 -0
  67. package/prose-pipeline/handlers/game.d.ts.map +1 -0
  68. package/prose-pipeline/handlers/game.js +35 -0
  69. package/prose-pipeline/handlers/game.js.map +1 -0
  70. package/prose-pipeline/handlers/generic.d.ts +27 -0
  71. package/prose-pipeline/handlers/generic.d.ts.map +1 -0
  72. package/prose-pipeline/handlers/generic.js +67 -0
  73. package/prose-pipeline/handlers/generic.js.map +1 -0
  74. package/prose-pipeline/handlers/help.d.ts +21 -0
  75. package/prose-pipeline/handlers/help.d.ts.map +1 -0
  76. package/prose-pipeline/handlers/help.js +68 -0
  77. package/prose-pipeline/handlers/help.js.map +1 -0
  78. package/prose-pipeline/handlers/implicit-take.d.ts +20 -0
  79. package/prose-pipeline/handlers/implicit-take.d.ts.map +1 -0
  80. package/prose-pipeline/handlers/implicit-take.js +26 -0
  81. package/prose-pipeline/handlers/implicit-take.js.map +1 -0
  82. package/prose-pipeline/handlers/index.d.ts +24 -0
  83. package/prose-pipeline/handlers/index.d.ts.map +1 -0
  84. package/prose-pipeline/handlers/index.js +40 -0
  85. package/prose-pipeline/handlers/index.js.map +1 -0
  86. package/prose-pipeline/handlers/revealed.d.ts +24 -0
  87. package/prose-pipeline/handlers/revealed.d.ts.map +1 -0
  88. package/prose-pipeline/handlers/revealed.js +54 -0
  89. package/prose-pipeline/handlers/revealed.js.map +1 -0
  90. package/prose-pipeline/handlers/room.d.ts +25 -0
  91. package/prose-pipeline/handlers/room.d.ts.map +1 -0
  92. package/prose-pipeline/handlers/room.js +78 -0
  93. package/prose-pipeline/handlers/room.js.map +1 -0
  94. package/prose-pipeline/handlers/types.d.ts +47 -0
  95. package/prose-pipeline/handlers/types.d.ts.map +1 -0
  96. package/prose-pipeline/handlers/types.js +15 -0
  97. package/prose-pipeline/handlers/types.js.map +1 -0
  98. package/prose-pipeline/index.d.ts +20 -0
  99. package/prose-pipeline/index.d.ts.map +1 -0
  100. package/prose-pipeline/index.js +50 -0
  101. package/prose-pipeline/index.js.map +1 -0
  102. package/prose-pipeline/pipeline.d.ts +58 -0
  103. package/prose-pipeline/pipeline.d.ts.map +1 -0
  104. package/prose-pipeline/pipeline.js +120 -0
  105. package/prose-pipeline/pipeline.js.map +1 -0
  106. package/prose-pipeline/stages/filter.d.ts +26 -0
  107. package/prose-pipeline/stages/filter.d.ts.map +1 -0
  108. package/prose-pipeline/stages/filter.js +38 -0
  109. package/prose-pipeline/stages/filter.js.map +1 -0
  110. package/prose-pipeline/stages/index.d.ts +13 -0
  111. package/prose-pipeline/stages/index.d.ts.map +1 -0
  112. package/prose-pipeline/stages/index.js +19 -0
  113. package/prose-pipeline/stages/index.js.map +1 -0
  114. package/prose-pipeline/stages/sort.d.ts +38 -0
  115. package/prose-pipeline/stages/sort.d.ts.map +1 -0
  116. package/prose-pipeline/stages/sort.js +94 -0
  117. package/prose-pipeline/stages/sort.js.map +1 -0
  118. package/prose-pipeline/types.d.ts +45 -0
  119. package/prose-pipeline/types.d.ts.map +1 -0
  120. package/prose-pipeline/types.js +23 -0
  121. package/prose-pipeline/types.js.map +1 -0
  122. package/save-restore-service.d.ts +17 -23
  123. package/save-restore-service.d.ts.map +1 -1
  124. package/save-restore-service.js +79 -138
  125. package/save-restore-service.js.map +1 -1
  126. package/sound/dispatcher.d.ts +75 -0
  127. package/sound/dispatcher.d.ts.map +1 -0
  128. package/sound/dispatcher.js +122 -0
  129. package/sound/dispatcher.js.map +1 -0
  130. package/sound/index.d.ts +26 -0
  131. package/sound/index.d.ts.map +1 -0
  132. package/sound/index.js +34 -0
  133. package/sound/index.js.map +1 -0
  134. package/sound/propagation.d.ts +69 -0
  135. package/sound/propagation.d.ts.map +1 -0
  136. package/sound/propagation.js +219 -0
  137. package/sound/propagation.js.map +1 -0
  138. package/story.d.ts +28 -1
  139. package/story.d.ts.map +1 -1
  140. package/story.js.map +1 -1
  141. package/test-helpers/mock-prose-pipeline.d.ts +22 -0
  142. package/test-helpers/mock-prose-pipeline.d.ts.map +1 -0
  143. package/test-helpers/mock-prose-pipeline.js +56 -0
  144. package/test-helpers/mock-prose-pipeline.js.map +1 -0
  145. package/types.d.ts +14 -0
  146. package/types.d.ts.map +1 -1
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Class-name resolver — bare bracket name → final CSS class name.
3
+ *
4
+ * Public interface: `resolveClassName`. Used by the parser to settle
5
+ * the platform-vs-author distinction at parse time so the wire shape
6
+ * carries renderer-ready strings.
7
+ *
8
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
9
+ *
10
+ * @see ADR-174 §Platform vs author classes
11
+ * @see ADR-174 §Internal interfaces
12
+ */
13
+ /**
14
+ * Resolve a bracketed name to its final CSS class name.
15
+ *
16
+ * Platform names (those listed in `PLATFORM_VOCABULARY`) receive the
17
+ * `sharpee-` prefix. Author names — anything else — pass through
18
+ * verbatim. Empty input returns the empty string; the caller is
19
+ * responsible for the AC-12 no-op-wrapper behavior, since the
20
+ * resolver is a pure mapping.
21
+ *
22
+ * @param rawName Bare name as written between `[` and `:` in the
23
+ * template, e.g., `em`, `thief-taunt`.
24
+ * @returns Final class name to place on the wire as
25
+ * `IDecoration.className`.
26
+ */
27
+ export declare function resolveClassName(rawName: string): string;
28
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/decorations/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMxD"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * Class-name resolver — bare bracket name → final CSS class name.
4
+ *
5
+ * Public interface: `resolveClassName`. Used by the parser to settle
6
+ * the platform-vs-author distinction at parse time so the wire shape
7
+ * carries renderer-ready strings.
8
+ *
9
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
10
+ *
11
+ * @see ADR-174 §Platform vs author classes
12
+ * @see ADR-174 §Internal interfaces
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.resolveClassName = resolveClassName;
16
+ const platform_vocabulary_1 = require("./platform-vocabulary");
17
+ /**
18
+ * Resolve a bracketed name to its final CSS class name.
19
+ *
20
+ * Platform names (those listed in `PLATFORM_VOCABULARY`) receive the
21
+ * `sharpee-` prefix. Author names — anything else — pass through
22
+ * verbatim. Empty input returns the empty string; the caller is
23
+ * responsible for the AC-12 no-op-wrapper behavior, since the
24
+ * resolver is a pure mapping.
25
+ *
26
+ * @param rawName Bare name as written between `[` and `:` in the
27
+ * template, e.g., `em`, `thief-taunt`.
28
+ * @returns Final class name to place on the wire as
29
+ * `IDecoration.className`.
30
+ */
31
+ function resolveClassName(rawName) {
32
+ if (rawName === '')
33
+ return '';
34
+ if (platform_vocabulary_1.PLATFORM_VOCABULARY.has(rawName)) {
35
+ return `sharpee-${rawName}`;
36
+ }
37
+ return rawName;
38
+ }
39
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/decorations/resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAkBH,4CAMC;AAtBD,+DAA4D;AAE5D;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC9B,IAAI,yCAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,OAAO,WAAW,OAAO,EAAE,CAAC;IAC9B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Type re-exports for the engine-internal prose pipeline's decoration
3
+ * primitives. Sub-phase 1.1 declared these locally; sub-phase 1.2
4
+ * lifted the shape change into `@sharpee/text-blocks`, so the
5
+ * engine-side module now re-exports the canonical types from there.
6
+ *
7
+ * Public interface: `IDecoration`, `TextContent`. Used internally by
8
+ * the parser, resolver, and (after sub-phase 1.5) by the pipeline
9
+ * class.
10
+ *
11
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
12
+ *
13
+ * @see ADR-174 §Wire shape
14
+ */
15
+ export type { IDecoration, TextContent } from "../../../text-blocks/index";
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/decorations/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * Type re-exports for the engine-internal prose pipeline's decoration
4
+ * primitives. Sub-phase 1.1 declared these locally; sub-phase 1.2
5
+ * lifted the shape change into `@sharpee/text-blocks`, so the
6
+ * engine-side module now re-exports the canonical types from there.
7
+ *
8
+ * Public interface: `IDecoration`, `TextContent`. Used internally by
9
+ * the parser, resolver, and (after sub-phase 1.5) by the pipeline
10
+ * class.
11
+ *
12
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
13
+ *
14
+ * @see ADR-174 §Wire shape
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/decorations/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * About event handler — `if.event.about_displayed`.
3
+ *
4
+ * Produces the same structured banner as `handleGameStarted`, via the
5
+ * shared `buildBannerBlocks` helper. The ABOUT action gives us a
6
+ * flat `params: Record<string, string>` that mirrors `event.data.story`
7
+ * — we project it into the `BannerStoryInfo` shape and reuse the
8
+ * builder.
9
+ *
10
+ * Public interface: `handleAboutDisplayed`. Used by the pipeline's
11
+ * event-type dispatch.
12
+ *
13
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
14
+ *
15
+ * @see ADR-174 §Engine-internal prose pipeline (port from text-service)
16
+ */
17
+ import type { ITextBlock } from "../../../text-blocks/index";
18
+ import type { ISemanticEvent } from "../../../core/index";
19
+ import type { HandlerContext } from './types';
20
+ /**
21
+ * Handle `if.event.about_displayed` by showing the structured banner.
22
+ *
23
+ * Reads the about action's `params` payload (title, author, version,
24
+ * description, engineVersion, buildDate, portedBy). The ABOUT action
25
+ * does not currently pass `credits` directly; when present, the
26
+ * builder falls back to `By {author}` for a single author-list line.
27
+ * Stories that want richer ABOUT credit blocks should propagate
28
+ * `credits` through the about action's params.
29
+ */
30
+ export declare function handleAboutDisplayed(event: ISemanticEvent, context: HandlerContext): ITextBlock[];
31
+ //# sourceMappingURL=about.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"about.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/handlers/about.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,cAAc,GACtB,UAAU,EAAE,CAoBd"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * About event handler — `if.event.about_displayed`.
4
+ *
5
+ * Produces the same structured banner as `handleGameStarted`, via the
6
+ * shared `buildBannerBlocks` helper. The ABOUT action gives us a
7
+ * flat `params: Record<string, string>` that mirrors `event.data.story`
8
+ * — we project it into the `BannerStoryInfo` shape and reuse the
9
+ * builder.
10
+ *
11
+ * Public interface: `handleAboutDisplayed`. Used by the pipeline's
12
+ * event-type dispatch.
13
+ *
14
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
15
+ *
16
+ * @see ADR-174 §Engine-internal prose pipeline (port from text-service)
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.handleAboutDisplayed = handleAboutDisplayed;
20
+ const banner_1 = require("./banner");
21
+ /**
22
+ * Handle `if.event.about_displayed` by showing the structured banner.
23
+ *
24
+ * Reads the about action's `params` payload (title, author, version,
25
+ * description, engineVersion, buildDate, portedBy). The ABOUT action
26
+ * does not currently pass `credits` directly; when present, the
27
+ * builder falls back to `By {author}` for a single author-list line.
28
+ * Stories that want richer ABOUT credit blocks should propagate
29
+ * `credits` through the about action's params.
30
+ */
31
+ function handleAboutDisplayed(event, context) {
32
+ const data = event.data;
33
+ const params = (data?.params ?? {});
34
+ const story = {
35
+ title: stringOrUndef(params.title),
36
+ version: stringOrUndef(params.version),
37
+ buildDate: stringOrUndef(params.buildDate),
38
+ description: stringOrUndef(params.description),
39
+ author: stringOrUndef(params.author),
40
+ credits: Array.isArray(params.credits)
41
+ ? params.credits.filter((s) => typeof s === 'string' && s.length > 0)
42
+ : undefined,
43
+ };
44
+ const engineVersion = stringOrUndef(params.engineVersion);
45
+ return (0, banner_1.buildBannerBlocks)('about.text', story, engineVersion, context);
46
+ }
47
+ function stringOrUndef(value) {
48
+ return typeof value === 'string' && value.length > 0 ? value : undefined;
49
+ }
50
+ //# sourceMappingURL=about.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"about.js","sourceRoot":"","sources":["../../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/handlers/about.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAiBH,oDAuBC;AAnCD,qCAAmE;AAEnE;;;;;;;;;GASG;AACH,SAAgB,oBAAoB,CAClC,KAAqB,EACrB,OAAuB;IAEvB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAwD,CAAC;IAC5E,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,CAA4B,CAAC;IAE/D,MAAM,KAAK,GAAoB;QAC7B,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC;QAClC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC;QACtC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC;QAC1C,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC;QAC9C,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;QACpC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;YACpC,CAAC,CAAE,MAAM,CAAC,OAAqB,CAAC,MAAM,CAClC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAC1D;YACH,CAAC,CAAC,SAAS;KACd,CAAC;IAEF,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAE1D,OAAO,IAAA,0BAAiB,EAAC,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Audibility event handler — ADR-172 Phase 7a, ported to engine prose
3
+ * pipeline per ADR-174.
4
+ *
5
+ * Handles `sound.audibility.heard`. Converts each `IAudibilityEvent`
6
+ * (per-listener perception of a propagated sound, produced by the
7
+ * engine's sound dispatcher in Phase 6) into a single text block via
8
+ * the `sound.heard.<kind>.<tier>` template family registered in the
9
+ * active language pack (lang-en-us ships defaults; stories override
10
+ * per kind).
11
+ *
12
+ * Naming discipline:
13
+ * - `audio` — Web Audio playback (ADR-169 `AudioManager`).
14
+ * - `sound` — the media-cue channel id (`media.sound.play`,
15
+ * ADR-163).
16
+ * - `audibility` — ADR-172 perception of propagated sound, this
17
+ * handler.
18
+ *
19
+ * Public interface: `handleAudibilityHeard`.
20
+ *
21
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
22
+ *
23
+ * Listener filtering: in single-user scope today the player is the
24
+ * only entity carrying `ListenerTrait` automatically, so every
25
+ * audibility event delivered here is for the player. The dispatcher
26
+ * already writes the listener id into `event.entities.target`; when
27
+ * L2's NPC-listener work lands, this handler will need to filter
28
+ * `event.entities.target === playerId` before rendering.
29
+ *
30
+ * @see ADR-172 — Spatial Sound Propagation §Channel routing
31
+ * @see ADR-174 §Engine-internal prose pipeline (port from text-service)
32
+ */
33
+ import type { ITextBlock } from "../../../text-blocks/index";
34
+ import type { ISemanticEvent } from "../../../core/index";
35
+ import type { HandlerContext } from './types';
36
+ /**
37
+ * Handle a `sound.audibility.heard` event.
38
+ *
39
+ * Resolves `sound.heard.<kind>.<tier>` from the language provider,
40
+ * falling back to `sound.heard.default.<tier>` when the kind-specific
41
+ * template is not registered. Returns one `ITextBlock` per event, or
42
+ * `[]` when the event is malformed, the tier is `silent`, or no
43
+ * template resolves.
44
+ */
45
+ export declare function handleAudibilityHeard(event: ISemanticEvent, context: HandlerContext): ITextBlock[];
46
+ //# sourceMappingURL=audibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audibility.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/handlers/audibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,cAAc,GACtB,UAAU,EAAE,CAiCd"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ /**
3
+ * Audibility event handler — ADR-172 Phase 7a, ported to engine prose
4
+ * pipeline per ADR-174.
5
+ *
6
+ * Handles `sound.audibility.heard`. Converts each `IAudibilityEvent`
7
+ * (per-listener perception of a propagated sound, produced by the
8
+ * engine's sound dispatcher in Phase 6) into a single text block via
9
+ * the `sound.heard.<kind>.<tier>` template family registered in the
10
+ * active language pack (lang-en-us ships defaults; stories override
11
+ * per kind).
12
+ *
13
+ * Naming discipline:
14
+ * - `audio` — Web Audio playback (ADR-169 `AudioManager`).
15
+ * - `sound` — the media-cue channel id (`media.sound.play`,
16
+ * ADR-163).
17
+ * - `audibility` — ADR-172 perception of propagated sound, this
18
+ * handler.
19
+ *
20
+ * Public interface: `handleAudibilityHeard`.
21
+ *
22
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
23
+ *
24
+ * Listener filtering: in single-user scope today the player is the
25
+ * only entity carrying `ListenerTrait` automatically, so every
26
+ * audibility event delivered here is for the player. The dispatcher
27
+ * already writes the listener id into `event.entities.target`; when
28
+ * L2's NPC-listener work lands, this handler will need to filter
29
+ * `event.entities.target === playerId` before rendering.
30
+ *
31
+ * @see ADR-172 — Spatial Sound Propagation §Channel routing
32
+ * @see ADR-174 §Engine-internal prose pipeline (port from text-service)
33
+ */
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.handleAudibilityHeard = handleAudibilityHeard;
36
+ const text_blocks_1 = require("../../../text-blocks/index.js");
37
+ const assemble_1 = require("../assemble");
38
+ const AUDIBILITY_TEMPLATE_PREFIX = 'sound.heard';
39
+ /**
40
+ * Handle a `sound.audibility.heard` event.
41
+ *
42
+ * Resolves `sound.heard.<kind>.<tier>` from the language provider,
43
+ * falling back to `sound.heard.default.<tier>` when the kind-specific
44
+ * template is not registered. Returns one `ITextBlock` per event, or
45
+ * `[]` when the event is malformed, the tier is `silent`, or no
46
+ * template resolves.
47
+ */
48
+ function handleAudibilityHeard(event, context) {
49
+ const provider = context.languageProvider;
50
+ if (!provider)
51
+ return [];
52
+ const data = event.data;
53
+ if (!data || typeof data !== 'object')
54
+ return [];
55
+ if (!data.kind || !data.audibilityTier)
56
+ return [];
57
+ // Defense-in-depth: the dispatcher already filters `silent`, but
58
+ // never render it if one slips through.
59
+ if (data.audibilityTier === 'silent')
60
+ return [];
61
+ const params = {
62
+ kind: data.kind,
63
+ };
64
+ if (data.content?.messageId) {
65
+ const innerParams = data.content.params;
66
+ params.content = provider.getMessage(data.content.messageId, innerParams);
67
+ }
68
+ const kindId = `${AUDIBILITY_TEMPLATE_PREFIX}.${data.kind}.${data.audibilityTier}`;
69
+ let message = provider.getMessage(kindId, params);
70
+ if (!message || message === kindId) {
71
+ const fallbackId = `${AUDIBILITY_TEMPLATE_PREFIX}.default.${data.audibilityTier}`;
72
+ message = provider.getMessage(fallbackId, params);
73
+ if (!message || message === fallbackId) {
74
+ return [];
75
+ }
76
+ }
77
+ return (0, assemble_1.createBlocks)(text_blocks_1.BLOCK_KEYS.ACTION_RESULT, message);
78
+ }
79
+ //# sourceMappingURL=audibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audibility.js","sourceRoot":"","sources":["../../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/handlers/audibility.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;AAoBH,sDAoCC;AArDD,sDAAkD;AAIlD,0CAA2C;AAE3C,MAAM,0BAA0B,GAAG,aAAa,CAAC;AAEjD;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACnC,KAAqB,EACrB,OAAuB;IAEvB,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAC1C,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IAEzB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAoC,CAAC;IACxD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACjD,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;IAElD,iEAAiE;IACjE,wCAAwC;IACxC,IAAK,IAAI,CAAC,cAAyB,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IAE5D,MAAM,MAAM,GAA4B;QACtC,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC;IACF,IAAI,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC;QAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,MAEpB,CAAC;QACd,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,0BAA0B,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;IACnF,IAAI,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,GAAG,0BAA0B,YAAY,IAAI,CAAC,cAAc,EAAE,CAAC;QAClF,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;YACvC,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,OAAO,IAAA,uBAAY,EAAC,wBAAU,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Shared banner-block builder.
3
+ *
4
+ * Emits the opening banner as a sequence of semantically-classed
5
+ * blocks. Used by both `handleGameStarted` and `handleAboutDisplayed`
6
+ * so the banner shown at game-start and via the ABOUT command are
7
+ * structurally identical.
8
+ *
9
+ * Pieces (in order):
10
+ *
11
+ * 1. `game-title` — title
12
+ * 2. `story-version` — `Story v{version}` + optional build date
13
+ * 3. `platform-version` — `Sharpee v{engineVersion}` (if provided)
14
+ * 4. `sub-title` — description (if provided)
15
+ * 5. `author-list[]` — `credits` if provided, else single
16
+ * `By {author}` line if `author` is set
17
+ * 6. `banner-spacer` — empty `<p>` for visual separation
18
+ * 7. story-tail — appended via `createBlocks` from
19
+ * `game.banner.story-tail` if the language
20
+ * provider has that template
21
+ *
22
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
23
+ */
24
+ import type { ITextBlock } from "../../../text-blocks/index";
25
+ import type { HandlerContext } from './types';
26
+ /**
27
+ * Subset of story metadata used by the banner builder.
28
+ * Both `handleGameStarted` (`event.data.story`) and
29
+ * `handleAboutDisplayed` (`event.data.params`) project into this shape.
30
+ */
31
+ export interface BannerStoryInfo {
32
+ title?: string;
33
+ version?: string;
34
+ buildDate?: string;
35
+ description?: string;
36
+ author?: string;
37
+ credits?: string[];
38
+ }
39
+ /**
40
+ * Build the structured banner blocks for a `key` (typically
41
+ * `'game.banner'` from `game.started` or `'about.text'` from ABOUT).
42
+ */
43
+ export declare function buildBannerBlocks(key: string, story: BannerStoryInfo | undefined, engineVersion: string | undefined, context: HandlerContext): ITextBlock[];
44
+ //# sourceMappingURL=banner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/handlers/banner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,eAAe,GAAG,SAAS,EAClC,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,EAAE,cAAc,GACtB,UAAU,EAAE,CAmDd"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * Shared banner-block builder.
4
+ *
5
+ * Emits the opening banner as a sequence of semantically-classed
6
+ * blocks. Used by both `handleGameStarted` and `handleAboutDisplayed`
7
+ * so the banner shown at game-start and via the ABOUT command are
8
+ * structurally identical.
9
+ *
10
+ * Pieces (in order):
11
+ *
12
+ * 1. `game-title` — title
13
+ * 2. `story-version` — `Story v{version}` + optional build date
14
+ * 3. `platform-version` — `Sharpee v{engineVersion}` (if provided)
15
+ * 4. `sub-title` — description (if provided)
16
+ * 5. `author-list[]` — `credits` if provided, else single
17
+ * `By {author}` line if `author` is set
18
+ * 6. `banner-spacer` — empty `<p>` for visual separation
19
+ * 7. story-tail — appended via `createBlocks` from
20
+ * `game.banner.story-tail` if the language
21
+ * provider has that template
22
+ *
23
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.buildBannerBlocks = buildBannerBlocks;
27
+ const assemble_1 = require("../assemble");
28
+ const STORY_TAIL_MESSAGE_ID = 'game.banner.story-tail';
29
+ /**
30
+ * Build the structured banner blocks for a `key` (typically
31
+ * `'game.banner'` from `game.started` or `'about.text'` from ABOUT).
32
+ */
33
+ function buildBannerBlocks(key, story, engineVersion, context) {
34
+ if (!story)
35
+ return [];
36
+ const blocks = [];
37
+ if (story.title) {
38
+ blocks.push((0, assemble_1.createBlock)(key, story.title, { className: 'game-title' }));
39
+ }
40
+ if (story.version) {
41
+ const buildDate = formatBuildDate(story.buildDate);
42
+ const versionText = buildDate
43
+ ? `Story v${story.version} (built ${buildDate})`
44
+ : `Story v${story.version}`;
45
+ blocks.push((0, assemble_1.createBlock)(key, versionText, { className: 'story-version' }));
46
+ }
47
+ if (engineVersion) {
48
+ blocks.push((0, assemble_1.createBlock)(key, `Sharpee v${engineVersion}`, {
49
+ className: 'platform-version',
50
+ }));
51
+ }
52
+ if (story.description) {
53
+ blocks.push((0, assemble_1.createBlock)(key, story.description, { className: 'sub-title' }));
54
+ }
55
+ const creditLines = story.credits && story.credits.length > 0
56
+ ? story.credits
57
+ : story.author
58
+ ? [`By ${story.author}`]
59
+ : [];
60
+ for (const line of creditLines) {
61
+ blocks.push((0, assemble_1.createBlock)(key, line, { className: 'author-list' }));
62
+ }
63
+ if (blocks.length > 0) {
64
+ blocks.push((0, assemble_1.createBlock)(key, '', { className: 'banner-spacer' }));
65
+ }
66
+ const tail = context.languageProvider?.getMessage(STORY_TAIL_MESSAGE_ID, {});
67
+ if (tail && tail !== STORY_TAIL_MESSAGE_ID) {
68
+ blocks.push(...(0, assemble_1.createBlocks)(key, tail));
69
+ }
70
+ return blocks;
71
+ }
72
+ /**
73
+ * Format an ISO build date as `YYYY-MM-DD` for the version line.
74
+ * Returns the original string if it doesn't parse cleanly, or empty
75
+ * when missing.
76
+ */
77
+ function formatBuildDate(buildDate) {
78
+ if (!buildDate)
79
+ return '';
80
+ try {
81
+ const iso = new Date(buildDate).toISOString();
82
+ return iso.split('T')[0];
83
+ }
84
+ catch {
85
+ return buildDate;
86
+ }
87
+ }
88
+ //# sourceMappingURL=banner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"banner.js","sourceRoot":"","sources":["../../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/handlers/banner.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;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
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Client-query handler — `client.query`.
3
+ *
4
+ * Today only the `disambiguation` source is rendered. The handler
5
+ * formats a candidate list as natural English ("the X or the Y" /
6
+ * "the X, the Y, or the Z") and resolves the
7
+ * `core.disambiguation_prompt` template with the resulting `options`
8
+ * string.
9
+ *
10
+ * Public interface: `handleClientQuery`. Used by the pipeline's
11
+ * event-type dispatch.
12
+ *
13
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
14
+ *
15
+ * @see ADR-174 §Engine-internal prose pipeline (extracted from
16
+ * text-service.ts inline)
17
+ */
18
+ import type { ITextBlock } from "../../../text-blocks/index";
19
+ import type { ISemanticEvent } from "../../../core/index";
20
+ import type { HandlerContext } from './types';
21
+ export declare function handleClientQuery(event: ISemanticEvent, context: HandlerContext): ITextBlock[];
22
+ //# sourceMappingURL=client-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-query.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/handlers/client-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAU9C,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,cAAc,GACtB,UAAU,EAAE,CAgBd"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /**
3
+ * Client-query handler — `client.query`.
4
+ *
5
+ * Today only the `disambiguation` source is rendered. The handler
6
+ * formats a candidate list as natural English ("the X or the Y" /
7
+ * "the X, the Y, or the Z") and resolves the
8
+ * `core.disambiguation_prompt` template with the resulting `options`
9
+ * string.
10
+ *
11
+ * Public interface: `handleClientQuery`. Used by the pipeline's
12
+ * event-type dispatch.
13
+ *
14
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
15
+ *
16
+ * @see ADR-174 §Engine-internal prose pipeline (extracted from
17
+ * text-service.ts inline)
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.handleClientQuery = handleClientQuery;
21
+ const text_blocks_1 = require("../../../text-blocks/index.js");
22
+ const assemble_1 = require("../assemble");
23
+ function handleClientQuery(event, context) {
24
+ const data = event.data;
25
+ if (data?.source !== 'disambiguation') {
26
+ return [];
27
+ }
28
+ const candidateNames = (data.candidates || []).map((c) => c.name);
29
+ const options = formatCandidateList(candidateNames);
30
+ const message = context.languageProvider?.getMessage('core.disambiguation_prompt', {
31
+ options,
32
+ }) ?? `Which do you mean: ${options}?`;
33
+ return (0, assemble_1.createBlocks)(text_blocks_1.BLOCK_KEYS.ERROR, message);
34
+ }
35
+ /**
36
+ * Format a list of candidate names as natural English.
37
+ *
38
+ * Examples:
39
+ * ["red ball", "blue ball"] → "the red ball or the blue ball"
40
+ * ["sword", "axe", "knife"] → "the sword, the axe, or the knife"
41
+ */
42
+ function formatCandidateList(names) {
43
+ if (names.length === 0)
44
+ return '';
45
+ if (names.length === 1)
46
+ return `the ${names[0]}`;
47
+ const withArticles = names.map((n) => `the ${n}`);
48
+ if (withArticles.length === 2) {
49
+ return `${withArticles[0]} or ${withArticles[1]}`;
50
+ }
51
+ // Oxford-comma style: "the X, the Y, or the Z"
52
+ const last = withArticles.pop();
53
+ return `${withArticles.join(', ')}, or ${last}`;
54
+ }
55
+ //# sourceMappingURL=client-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-query.js","sourceRoot":"","sources":["../../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/handlers/client-query.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;AAeH,8CAmBC;AA/BD,sDAAkD;AAGlD,0CAA2C;AAS3C,SAAgB,iBAAiB,CAC/B,KAAqB,EACrB,OAAuB;IAEvB,MAAM,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.failed`.
3
+ *
4
+ * Maps parser / entity-resolution failure reasons to user-facing
5
+ * error prose. Recognized reason fragments:
6
+ * - `ENTITY_NOT_FOUND` / `modifiers_not_matched` →
7
+ * `core.entity_not_found` (default: "I don't see that here.")
8
+ * - `NO_MATCH` / `parse` →
9
+ * `core.command_not_understood` (default: "I don't understand that.")
10
+ * Anything else → `core.command_failed` (same default).
11
+ *
12
+ * Public interface: `handleCommandFailed`. Used by the pipeline's
13
+ * event-type dispatch.
14
+ *
15
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
16
+ *
17
+ * @see ADR-174 §Engine-internal prose pipeline (extracted from
18
+ * text-service.ts inline)
19
+ */
20
+ import type { ITextBlock } from "../../../text-blocks/index";
21
+ import type { ISemanticEvent } from "../../../core/index";
22
+ import type { HandlerContext } from './types';
23
+ export declare function handleCommandFailed(event: ISemanticEvent, context: HandlerContext): ITextBlock[];
24
+ //# sourceMappingURL=command-failed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-failed.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/engine/src/prose-pipeline/handlers/command-failed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAQ9C,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,cAAc,GACtB,UAAU,EAAE,CA6Bd"}