@sharpee/engine 1.5.0 → 2.1.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 (138) hide show
  1. package/action-context-factory.d.ts.map +1 -1
  2. package/action-context-factory.js.map +1 -1
  3. package/capability-dispatch-helper.d.ts +5 -3
  4. package/capability-dispatch-helper.d.ts.map +1 -1
  5. package/capability-dispatch-helper.js +6 -4
  6. package/capability-dispatch-helper.js.map +1 -1
  7. package/command-executor.d.ts.map +1 -1
  8. package/command-executor.js +2 -2
  9. package/command-executor.js.map +1 -1
  10. package/events/event-emitter.d.ts.map +1 -1
  11. package/events/event-emitter.js.map +1 -1
  12. package/game-engine.d.ts +14 -3
  13. package/game-engine.d.ts.map +1 -1
  14. package/game-engine.js +45 -5
  15. package/game-engine.js.map +1 -1
  16. package/index.d.ts.map +1 -1
  17. package/index.js.map +1 -1
  18. package/language-provider-interface.d.ts.map +1 -1
  19. package/language-provider-interface.js.map +1 -1
  20. package/narrative/index.d.ts.map +1 -1
  21. package/narrative/index.js.map +1 -1
  22. package/narrative/narrative-settings.d.ts.map +1 -1
  23. package/narrative/narrative-settings.js.map +1 -1
  24. package/package.json +12 -12
  25. package/parser-interface.d.ts.map +1 -1
  26. package/parser-interface.js.map +1 -1
  27. package/platform-operations.d.ts.map +1 -1
  28. package/platform-operations.js.map +1 -1
  29. package/prose-pipeline/assemble.d.ts.map +1 -1
  30. package/prose-pipeline/assemble.js.map +1 -1
  31. package/prose-pipeline/decorations/index.d.ts.map +1 -1
  32. package/prose-pipeline/decorations/index.js.map +1 -1
  33. package/prose-pipeline/decorations/parser.d.ts.map +1 -1
  34. package/prose-pipeline/decorations/parser.js.map +1 -1
  35. package/prose-pipeline/decorations/platform-vocabulary.d.ts.map +1 -1
  36. package/prose-pipeline/decorations/platform-vocabulary.js.map +1 -1
  37. package/prose-pipeline/decorations/resolver.d.ts.map +1 -1
  38. package/prose-pipeline/decorations/resolver.js.map +1 -1
  39. package/prose-pipeline/decorations/types.d.ts.map +1 -1
  40. package/prose-pipeline/decorations/types.js.map +1 -1
  41. package/prose-pipeline/handlers/audibility.d.ts.map +1 -1
  42. package/prose-pipeline/handlers/audibility.js +16 -2
  43. package/prose-pipeline/handlers/audibility.js.map +1 -1
  44. package/prose-pipeline/handlers/banner.d.ts +5 -6
  45. package/prose-pipeline/handlers/banner.d.ts.map +1 -1
  46. package/prose-pipeline/handlers/banner.js +4 -4
  47. package/prose-pipeline/handlers/banner.js.map +1 -1
  48. package/prose-pipeline/handlers/client-query.d.ts.map +1 -1
  49. package/prose-pipeline/handlers/client-query.js.map +1 -1
  50. package/prose-pipeline/handlers/command-failed.d.ts.map +1 -1
  51. package/prose-pipeline/handlers/command-failed.js.map +1 -1
  52. package/prose-pipeline/handlers/domain-message.d.ts +5 -0
  53. package/prose-pipeline/handlers/domain-message.d.ts.map +1 -1
  54. package/prose-pipeline/handlers/domain-message.js +33 -14
  55. package/prose-pipeline/handlers/domain-message.js.map +1 -1
  56. package/prose-pipeline/handlers/game.d.ts.map +1 -1
  57. package/prose-pipeline/handlers/game.js.map +1 -1
  58. package/prose-pipeline/handlers/generic.d.ts.map +1 -1
  59. package/prose-pipeline/handlers/generic.js +28 -3
  60. package/prose-pipeline/handlers/generic.js.map +1 -1
  61. package/prose-pipeline/handlers/implicit-take.d.ts.map +1 -1
  62. package/prose-pipeline/handlers/implicit-take.js.map +1 -1
  63. package/prose-pipeline/handlers/index.d.ts +1 -2
  64. package/prose-pipeline/handlers/index.d.ts.map +1 -1
  65. package/prose-pipeline/handlers/index.js +3 -5
  66. package/prose-pipeline/handlers/index.js.map +1 -1
  67. package/prose-pipeline/handlers/platform.d.ts +25 -0
  68. package/prose-pipeline/handlers/platform.d.ts.map +1 -0
  69. package/prose-pipeline/handlers/platform.js +48 -0
  70. package/prose-pipeline/handlers/platform.js.map +1 -0
  71. package/prose-pipeline/handlers/revealed.d.ts.map +1 -1
  72. package/prose-pipeline/handlers/revealed.js.map +1 -1
  73. package/prose-pipeline/handlers/room.d.ts.map +1 -1
  74. package/prose-pipeline/handlers/room.js +15 -1
  75. package/prose-pipeline/handlers/room.js.map +1 -1
  76. package/prose-pipeline/handlers/types.d.ts +11 -0
  77. package/prose-pipeline/handlers/types.d.ts.map +1 -1
  78. package/prose-pipeline/handlers/types.js.map +1 -1
  79. package/prose-pipeline/index.d.ts +4 -3
  80. package/prose-pipeline/index.d.ts.map +1 -1
  81. package/prose-pipeline/index.js +6 -4
  82. package/prose-pipeline/index.js.map +1 -1
  83. package/prose-pipeline/phrase-render.d.ts +54 -0
  84. package/prose-pipeline/phrase-render.d.ts.map +1 -0
  85. package/prose-pipeline/phrase-render.js +103 -0
  86. package/prose-pipeline/phrase-render.js.map +1 -0
  87. package/prose-pipeline/pipeline.d.ts +23 -5
  88. package/prose-pipeline/pipeline.d.ts.map +1 -1
  89. package/prose-pipeline/pipeline.js +57 -10
  90. package/prose-pipeline/pipeline.js.map +1 -1
  91. package/prose-pipeline/render-context.d.ts +108 -0
  92. package/prose-pipeline/render-context.d.ts.map +1 -0
  93. package/prose-pipeline/render-context.js +192 -0
  94. package/prose-pipeline/render-context.js.map +1 -0
  95. package/prose-pipeline/stages/filter.d.ts +9 -2
  96. package/prose-pipeline/stages/filter.d.ts.map +1 -1
  97. package/prose-pipeline/stages/filter.js +10 -3
  98. package/prose-pipeline/stages/filter.js.map +1 -1
  99. package/prose-pipeline/stages/index.d.ts.map +1 -1
  100. package/prose-pipeline/stages/index.js.map +1 -1
  101. package/prose-pipeline/stages/sort.d.ts.map +1 -1
  102. package/prose-pipeline/stages/sort.js.map +1 -1
  103. package/prose-pipeline/types.d.ts +33 -10
  104. package/prose-pipeline/types.d.ts.map +1 -1
  105. package/prose-pipeline/types.js +9 -9
  106. package/prose-pipeline/types.js.map +1 -1
  107. package/save-restore-service.d.ts.map +1 -1
  108. package/save-restore-service.js.map +1 -1
  109. package/scene-evaluation-plugin.d.ts.map +1 -1
  110. package/scene-evaluation-plugin.js.map +1 -1
  111. package/shared-data-keys.d.ts.map +1 -1
  112. package/shared-data-keys.js.map +1 -1
  113. package/sound/dispatcher.d.ts.map +1 -1
  114. package/sound/dispatcher.js.map +1 -1
  115. package/sound/index.d.ts.map +1 -1
  116. package/sound/index.js.map +1 -1
  117. package/sound/propagation.d.ts.map +1 -1
  118. package/sound/propagation.js.map +1 -1
  119. package/story.d.ts.map +1 -1
  120. package/story.js.map +1 -1
  121. package/test-helpers/mock-prose-pipeline.d.ts +6 -4
  122. package/test-helpers/mock-prose-pipeline.d.ts.map +1 -1
  123. package/test-helpers/mock-prose-pipeline.js +5 -1
  124. package/test-helpers/mock-prose-pipeline.js.map +1 -1
  125. package/turn-event-processor.d.ts.map +1 -1
  126. package/turn-event-processor.js.map +1 -1
  127. package/types.d.ts.map +1 -1
  128. package/types.js.map +1 -1
  129. package/vocabulary-manager.d.ts.map +1 -1
  130. package/vocabulary-manager.js.map +1 -1
  131. package/prose-pipeline/handlers/about.d.ts +0 -31
  132. package/prose-pipeline/handlers/about.d.ts.map +0 -1
  133. package/prose-pipeline/handlers/about.js +0 -50
  134. package/prose-pipeline/handlers/about.js.map +0 -1
  135. package/prose-pipeline/handlers/help.d.ts +0 -21
  136. package/prose-pipeline/handlers/help.d.ts.map +0 -1
  137. package/prose-pipeline/handlers/help.js +0 -68
  138. package/prose-pipeline/handlers/help.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/engine/src/prose-pipeline/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGhE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGrE,YAAY,EACV,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v2/packages/engine/src/prose-pipeline/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGhE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/D,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGrE,YAAY,EACV,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * Prose pipeline — internal barrel for the engine package.
4
4
  *
5
5
  * Public interface: `ProsePipeline`, `createProsePipeline`,
6
- * `ITextService`. Plus the decoration primitives and stage utilities
6
+ * `IProsePipeline`. Plus the decoration primitives and stage utilities
7
7
  * the pipeline class composes.
8
8
  *
9
9
  * Owner context: `@sharpee/engine` — internal prose pipeline.
@@ -11,11 +11,15 @@
11
11
  * @see ADR-174 §Engine-internal prose pipeline
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.handleClientQuery = exports.handleCommandFailed = exports.handleImplicitTake = exports.tryProcessDomainEventMessage = exports.handleAudibilityHeard = exports.handleAboutDisplayed = exports.handleHelpDisplayed = exports.handleGameStarted = exports.handleGenericEvent = exports.handleGameMessage = exports.handleRevealed = exports.handleRoomDescription = exports.extractValue = exports.createBlocks = exports.createBlock = exports.getChainMetadata = exports.sortEventsForProse = exports.filterEvents = exports.PLATFORM_VOCABULARY_NAMES = exports.PLATFORM_VOCABULARY = exports.resolveClassName = exports.parseDecorations = exports.createProsePipeline = exports.ProsePipeline = void 0;
14
+ exports.handleClientQuery = exports.handleCommandFailed = exports.handleImplicitTake = exports.tryProcessDomainEventMessage = exports.handleAudibilityHeard = exports.handleGameStarted = exports.handleGenericEvent = exports.handleGameMessage = exports.handleRevealed = exports.handleRoomDescription = exports.extractValue = exports.createBlocks = exports.createBlock = exports.getChainMetadata = exports.sortEventsForProse = exports.filterEvents = exports.PLATFORM_VOCABULARY_NAMES = exports.PLATFORM_VOCABULARY = exports.resolveClassName = exports.parseDecorations = exports.createRenderContextFactory = exports.createRenderWorld = exports.createProsePipeline = exports.ProsePipeline = void 0;
15
15
  // Pipeline class and factory.
16
16
  var pipeline_1 = require("./pipeline");
17
17
  Object.defineProperty(exports, "ProsePipeline", { enumerable: true, get: function () { return pipeline_1.ProsePipeline; } });
18
18
  Object.defineProperty(exports, "createProsePipeline", { enumerable: true, get: function () { return pipeline_1.createProsePipeline; } });
19
+ // Render-context runtime for the phrase pipeline (ADR-192, W2).
20
+ var render_context_1 = require("./render-context");
21
+ Object.defineProperty(exports, "createRenderWorld", { enumerable: true, get: function () { return render_context_1.createRenderWorld; } });
22
+ Object.defineProperty(exports, "createRenderContextFactory", { enumerable: true, get: function () { return render_context_1.createRenderContextFactory; } });
19
23
  // Decoration primitives (re-exported for convenience to engine code
20
24
  // outside the prose-pipeline subdirectory; the canonical types live
21
25
  // in `@sharpee/text-blocks`).
@@ -40,8 +44,6 @@ Object.defineProperty(exports, "handleRevealed", { enumerable: true, get: functi
40
44
  Object.defineProperty(exports, "handleGameMessage", { enumerable: true, get: function () { return handlers_1.handleGameMessage; } });
41
45
  Object.defineProperty(exports, "handleGenericEvent", { enumerable: true, get: function () { return handlers_1.handleGenericEvent; } });
42
46
  Object.defineProperty(exports, "handleGameStarted", { enumerable: true, get: function () { return handlers_1.handleGameStarted; } });
43
- Object.defineProperty(exports, "handleHelpDisplayed", { enumerable: true, get: function () { return handlers_1.handleHelpDisplayed; } });
44
- Object.defineProperty(exports, "handleAboutDisplayed", { enumerable: true, get: function () { return handlers_1.handleAboutDisplayed; } });
45
47
  Object.defineProperty(exports, "handleAudibilityHeard", { enumerable: true, get: function () { return handlers_1.handleAudibilityHeard; } });
46
48
  Object.defineProperty(exports, "tryProcessDomainEventMessage", { enumerable: true, get: function () { return handlers_1.tryProcessDomainEventMessage; } });
47
49
  Object.defineProperty(exports, "handleImplicitTake", { enumerable: true, get: function () { return handlers_1.handleImplicitTake; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/engine/src/prose-pipeline/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,8BAA8B;AAC9B,uCAAgE;AAAvD,yGAAA,aAAa,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAK3C,oEAAoE;AACpE,oEAAoE;AACpE,8BAA8B;AAC9B,6CAQuB;AAPrB,+GAAA,gBAAgB,OAAA;AAChB,+GAAA,gBAAgB,OAAA;AAChB,kHAAA,mBAAmB,OAAA;AACnB,wHAAA,yBAAyB,OAAA;AAM3B,oCAAoC;AACpC,0CAA+C;AAAtC,sGAAA,YAAY,OAAA;AACrB,sCAGuB;AAFrB,0GAAA,kBAAkB,OAAA;AAClB,wGAAA,gBAAgB,OAAA;AAElB,uCAAqE;AAA5D,uGAAA,WAAW,OAAA;AAAE,wGAAA,YAAY,OAAA;AAAE,wGAAA,YAAY,OAAA;AAShD,uCAaoB;AAZlB,iHAAA,qBAAqB,OAAA;AACrB,0GAAA,cAAc,OAAA;AACd,6GAAA,iBAAiB,OAAA;AACjB,8GAAA,kBAAkB,OAAA;AAClB,6GAAA,iBAAiB,OAAA;AACjB,+GAAA,mBAAmB,OAAA;AACnB,gHAAA,oBAAoB,OAAA;AACpB,iHAAA,qBAAqB,OAAA;AACrB,wHAAA,4BAA4B,OAAA;AAC5B,8GAAA,kBAAkB,OAAA;AAClB,+GAAA,mBAAmB,OAAA;AACnB,6GAAA,iBAAiB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v2/packages/engine/src/prose-pipeline/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,8BAA8B;AAC9B,uCAAgE;AAAvD,yGAAA,aAAa,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAK3C,gEAAgE;AAChE,mDAK0B;AAJxB,mHAAA,iBAAiB,OAAA;AACjB,4HAAA,0BAA0B,OAAA;AAK5B,oEAAoE;AACpE,oEAAoE;AACpE,8BAA8B;AAC9B,6CAQuB;AAPrB,+GAAA,gBAAgB,OAAA;AAChB,+GAAA,gBAAgB,OAAA;AAChB,kHAAA,mBAAmB,OAAA;AACnB,wHAAA,yBAAyB,OAAA;AAM3B,oCAAoC;AACpC,0CAA+C;AAAtC,sGAAA,YAAY,OAAA;AACrB,sCAGuB;AAFrB,0GAAA,kBAAkB,OAAA;AAClB,wGAAA,gBAAgB,OAAA;AAElB,uCAAqE;AAA5D,uGAAA,WAAW,OAAA;AAAE,wGAAA,YAAY,OAAA;AAAE,wGAAA,YAAY,OAAA;AAShD,uCAWoB;AAVlB,iHAAA,qBAAqB,OAAA;AACrB,0GAAA,cAAc,OAAA;AACd,6GAAA,iBAAiB,OAAA;AACjB,8GAAA,kBAAkB,OAAA;AAClB,6GAAA,iBAAiB,OAAA;AACjB,iHAAA,qBAAqB,OAAA;AACrB,wHAAA,4BAA4B,OAAA;AAC5B,8GAAA,kBAAkB,OAAA;AAClB,+GAAA,mBAAmB,OAAA;AACnB,6GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Phrase-path rendering helper for the prose pipeline (ADR-192 §6, the cutover).
3
+ *
4
+ * Bridges a handler's `(messageId, params, blockKey)` to the language provider's
5
+ * `renderMessage` phrase pipeline, building the per-message `RenderContext` from
6
+ * the per-turn factory and re-keying the realized blocks to the handler's
7
+ * channel. The legacy `getMessage` string path remains in the handlers only as a
8
+ * fallback for world-less construction (some unit tests); it is removed in W7
9
+ * once nothing constructs the pipeline without a world.
10
+ *
11
+ * Public interface: `phraseAvailable`, `renderViaPhrase`.
12
+ *
13
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
14
+ *
15
+ * @see ADR-192 §6
16
+ */
17
+ import type { ITextBlock } from '@sharpee/text-blocks';
18
+ import type { HandlerContext } from './handlers/types';
19
+ /**
20
+ * Whether the phrase path is wired for this turn: a render-context factory (the
21
+ * pipeline had a world) and a provider that implements the phrase API.
22
+ *
23
+ * @param context the handler context
24
+ * @returns true when `renderViaPhrase` can be used
25
+ */
26
+ export declare function phraseAvailable(context: HandlerContext): boolean;
27
+ /**
28
+ * Render a message through the phrase pipeline and re-key its blocks.
29
+ *
30
+ * Precondition: {@link phraseAvailable} is true.
31
+ *
32
+ * @param context the handler context (carries the render-context factory)
33
+ * @param messageId the message id to render
34
+ * @param params the message params (entity NounPhrases, scalars, …). The reserved
35
+ * key `__slots__` (a `{ [slotKey]: Phrase[] }` map) is not a placeholder binding:
36
+ * its phrases are staged into this message's turn slot store before realization,
37
+ * so an action that knows its target (e.g. examine staging detail clauses) can
38
+ * fill a `{slot:key}` in its own template without holding a render context at
39
+ * report time (ADR-195 S2). Plain phrase data — save/replay-safe.
40
+ * @param blockKey the channel key to stamp on the realized blocks
41
+ * @returns the realized blocks re-keyed to `blockKey`, or `null` when the message
42
+ * id is not registered (the caller applies its inline-text fallback)
43
+ */
44
+ export declare function renderViaPhrase(context: HandlerContext, messageId: string, params: Record<string, unknown>, blockKey: string): ITextBlock[] | null;
45
+ /**
46
+ * Flatten realized blocks to a single plain string (newlines between blocks).
47
+ * Used when a rendered message must be embedded into another message as a
48
+ * `{verbatim:…}` scalar param.
49
+ *
50
+ * @param blocks realized text blocks
51
+ * @returns the concatenated plain text
52
+ */
53
+ export declare function flattenBlocks(blocks: ITextBlock[]): string;
54
+ //# sourceMappingURL=phrase-render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phrase-render.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v2/packages/engine/src/prose-pipeline/phrase-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAOhE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,QAAQ,EAAE,MAAM,GACf,UAAU,EAAE,GAAG,IAAI,CAiCrB;AAQD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAE1D"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ /**
3
+ * Phrase-path rendering helper for the prose pipeline (ADR-192 §6, the cutover).
4
+ *
5
+ * Bridges a handler's `(messageId, params, blockKey)` to the language provider's
6
+ * `renderMessage` phrase pipeline, building the per-message `RenderContext` from
7
+ * the per-turn factory and re-keying the realized blocks to the handler's
8
+ * channel. The legacy `getMessage` string path remains in the handlers only as a
9
+ * fallback for world-less construction (some unit tests); it is removed in W7
10
+ * once nothing constructs the pipeline without a world.
11
+ *
12
+ * Public interface: `phraseAvailable`, `renderViaPhrase`.
13
+ *
14
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
15
+ *
16
+ * @see ADR-192 §6
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.phraseAvailable = phraseAvailable;
20
+ exports.renderViaPhrase = renderViaPhrase;
21
+ exports.flattenBlocks = flattenBlocks;
22
+ /**
23
+ * Whether the phrase path is wired for this turn: a render-context factory (the
24
+ * pipeline had a world) and a provider that implements the phrase API.
25
+ *
26
+ * @param context the handler context
27
+ * @returns true when `renderViaPhrase` can be used
28
+ */
29
+ function phraseAvailable(context) {
30
+ const lp = context.languageProvider;
31
+ return (typeof context.makeRenderContext === 'function' &&
32
+ typeof lp?.renderMessage === 'function' &&
33
+ typeof lp?.getTemplate === 'function');
34
+ }
35
+ /**
36
+ * Render a message through the phrase pipeline and re-key its blocks.
37
+ *
38
+ * Precondition: {@link phraseAvailable} is true.
39
+ *
40
+ * @param context the handler context (carries the render-context factory)
41
+ * @param messageId the message id to render
42
+ * @param params the message params (entity NounPhrases, scalars, …). The reserved
43
+ * key `__slots__` (a `{ [slotKey]: Phrase[] }` map) is not a placeholder binding:
44
+ * its phrases are staged into this message's turn slot store before realization,
45
+ * so an action that knows its target (e.g. examine staging detail clauses) can
46
+ * fill a `{slot:key}` in its own template without holding a render context at
47
+ * report time (ADR-195 S2). Plain phrase data — save/replay-safe.
48
+ * @param blockKey the channel key to stamp on the realized blocks
49
+ * @returns the realized blocks re-keyed to `blockKey`, or `null` when the message
50
+ * id is not registered (the caller applies its inline-text fallback)
51
+ */
52
+ function renderViaPhrase(context, messageId, params, blockKey) {
53
+ const lp = context.languageProvider;
54
+ // Unregistered id: events carry a messageId for semantic association even when
55
+ // no template exists; let the caller fall back to inline data.message/text.
56
+ if (lp.getTemplate(messageId) === undefined) {
57
+ return null;
58
+ }
59
+ const ctx = context.makeRenderContext(params);
60
+ // ADR-195 S2: stage any pre-built slot contributions the emitter attached to
61
+ // `params.__slots__` into this turn's slot store, before the template realizes,
62
+ // so a `{slot:key}` in this message picks them up. Bare content; the slot owns
63
+ // the connective grammar.
64
+ const preStaged = params.__slots__;
65
+ if (preStaged && ctx.contribute) {
66
+ for (const [slotKey, phrases] of Object.entries(preStaged)) {
67
+ for (const phrase of phrases) {
68
+ ctx.contribute(slotKey, phrase);
69
+ }
70
+ }
71
+ }
72
+ let blocks;
73
+ try {
74
+ blocks = lp.renderMessage(messageId, params, ctx);
75
+ }
76
+ catch (e) {
77
+ // A template that fails to parse at render time (unbound param, bad syntax)
78
+ // is an authoring error — warn and degrade to the caller's inline fallback
79
+ // rather than letting it abort the whole turn's prose.
80
+ // eslint-disable-next-line no-console
81
+ console.warn(`[phrase] renderMessage("${messageId}") failed: ${e.message}`);
82
+ return null;
83
+ }
84
+ return blocks.map((b) => (b.key === blockKey ? b : { ...b, key: blockKey }));
85
+ }
86
+ /** Flatten one content node to its plain text (recursing through decorations). */
87
+ function textOf(node) {
88
+ if (typeof node === 'string')
89
+ return node;
90
+ return (node.content ?? []).map(textOf).join('');
91
+ }
92
+ /**
93
+ * Flatten realized blocks to a single plain string (newlines between blocks).
94
+ * Used when a rendered message must be embedded into another message as a
95
+ * `{verbatim:…}` scalar param.
96
+ *
97
+ * @param blocks realized text blocks
98
+ * @returns the concatenated plain text
99
+ */
100
+ function flattenBlocks(blocks) {
101
+ return blocks.map((b) => b.content.map(textOf).join('')).join('\n');
102
+ }
103
+ //# sourceMappingURL=phrase-render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phrase-render.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v2/packages/engine/src/prose-pipeline/phrase-render.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAYH,0CAOC;AAmBD,0CAsCC;AAgBD,sCAEC;AAzFD;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,OAAuB;IACrD,MAAM,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IACpC,OAAO,CACL,OAAO,OAAO,CAAC,iBAAiB,KAAK,UAAU;QAC/C,OAAO,EAAE,EAAE,aAAa,KAAK,UAAU;QACvC,OAAO,EAAE,EAAE,WAAW,KAAK,UAAU,CACtC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,eAAe,CAC7B,OAAuB,EACvB,SAAiB,EACjB,MAA+B,EAC/B,QAAgB;IAEhB,MAAM,EAAE,GAAG,OAAO,CAAC,gBAAiB,CAAC;IACrC,+EAA+E;IAC/E,4EAA4E;IAC5E,IAAI,EAAE,CAAC,WAAY,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAkB,CAAC,MAAM,CAAC,CAAC;IAE/C,6EAA6E;IAC7E,gFAAgF;IAChF,+EAA+E;IAC/E,0BAA0B;IAC1B,MAAM,SAAS,GAAG,MAAM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C,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtE,CAAC"}
@@ -10,7 +10,7 @@
10
10
  * time blocks return here they already carry parsed
11
11
  * bracket decorations and final `className`s.
12
12
  *
13
- * Public interface: `class ProsePipeline implements ITextService`.
13
+ * Public interface: `class ProsePipeline implements IProsePipeline`.
14
14
  * Engine constructs one instance during `setStory()` and calls
15
15
  * `processTurn` per turn (same three call sites as the retiring
16
16
  * `TextService`).
@@ -24,7 +24,8 @@
24
24
  import type { ITextBlock } from '@sharpee/text-blocks';
25
25
  import type { LanguageProvider } from '@sharpee/if-domain';
26
26
  import type { ISemanticEvent } from '@sharpee/core';
27
- import type { ITextService } from './types';
27
+ import { type WorldModelLike } from './render-context';
28
+ import type { IProsePipeline, SlotContributor } from './types';
28
29
  /**
29
30
  * Engine-internal prose pipeline.
30
31
  *
@@ -34,9 +35,26 @@ import type { ITextService } from './types';
34
35
  * the meta-command path (same three sites the retired
35
36
  * `TextService.processTurn` had).
36
37
  */
37
- export declare class ProsePipeline implements ITextService {
38
+ export declare class ProsePipeline implements IProsePipeline {
38
39
  private readonly languageProvider;
39
- constructor(languageProvider: LanguageProvider);
40
+ private readonly world?;
41
+ /** Realize-time slot contributors, run in registration order each turn (ADR-195 §3). */
42
+ private readonly slotContributors;
43
+ /**
44
+ * @param languageProvider the active language provider (template → text)
45
+ * @param world the read-only world model; when supplied, each turn builds a
46
+ * phrase-pipeline render-context factory (ADR-192, W2). Optional so legacy
47
+ * and test construction (string path only) keeps working without a world.
48
+ */
49
+ constructor(languageProvider: LanguageProvider, world?: WorldModelLike);
50
+ /**
51
+ * Register a realize-time slot contributor (ADR-195 §3). Contributors run once
52
+ * per turn at the top of `processTurn`, in registration order; that order feeds
53
+ * the `(order, insertion)` tie-break of the slot store.
54
+ *
55
+ * @param contributor the slot contributor to run each turn.
56
+ */
57
+ registerSlotContributor(contributor: SlotContributor): void;
40
58
  processTurn(events: ISemanticEvent[]): ITextBlock[];
41
59
  /**
42
60
  * Route an event to its handler family.
@@ -54,5 +72,5 @@ export declare class ProsePipeline implements ITextService {
54
72
  * package exposed; callers can swap one for the other without
55
73
  * changing call shapes.
56
74
  */
57
- export declare function createProsePipeline(languageProvider: LanguageProvider): ITextService;
75
+ export declare function createProsePipeline(languageProvider: LanguageProvider, world?: WorldModelLike): IProsePipeline;
58
76
  //# sourceMappingURL=pipeline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/engine/src/prose-pipeline/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAqBpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;GAQG;AACH,qBAAa,aAAc,YAAW,YAAY;IAChD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;gBAExC,gBAAgB,EAAE,gBAAgB;IAS9C,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,UAAU,EAAE;IAgBnD;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;CA6CvB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,gBAAgB,GACjC,YAAY,CAEd"}
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v2/packages/engine/src/prose-pipeline/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAiB1B,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;GAQG;AACH,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAiB;IACxC,wFAAwF;IACxF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyB;IAE1D;;;;;OAKG;gBACS,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,cAAc;IAUtE;;;;;;OAMG;IACH,uBAAuB,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI;IAI3D,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,UAAU,EAAE;IA2CnD;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;CAkDvB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,gBAAgB,EAClC,KAAK,CAAC,EAAE,cAAc,GACrB,cAAc,CAEhB"}
@@ -11,7 +11,7 @@
11
11
  * time blocks return here they already carry parsed
12
12
  * bracket decorations and final `className`s.
13
13
  *
14
- * Public interface: `class ProsePipeline implements ITextService`.
14
+ * Public interface: `class ProsePipeline implements IProsePipeline`.
15
15
  * Engine constructs one instance during `setStory()` and calls
16
16
  * `processTurn` per turn (same three call sites as the retiring
17
17
  * `TextService`).
@@ -27,12 +27,12 @@ exports.ProsePipeline = void 0;
27
27
  exports.createProsePipeline = createProsePipeline;
28
28
  const filter_1 = require("./stages/filter");
29
29
  const sort_1 = require("./stages/sort");
30
+ const render_context_1 = require("./render-context");
30
31
  const room_1 = require("./handlers/room");
31
32
  const revealed_1 = require("./handlers/revealed");
32
33
  const generic_1 = require("./handlers/generic");
33
34
  const game_1 = require("./handlers/game");
34
- const help_1 = require("./handlers/help");
35
- const about_1 = require("./handlers/about");
35
+ const platform_1 = require("./handlers/platform");
36
36
  const audibility_1 = require("./handlers/audibility");
37
37
  const domain_message_1 = require("./handlers/domain-message");
38
38
  const implicit_take_1 = require("./handlers/implicit-take");
@@ -49,18 +49,59 @@ const client_query_1 = require("./handlers/client-query");
49
49
  */
50
50
  class ProsePipeline {
51
51
  languageProvider;
52
- constructor(languageProvider) {
52
+ world;
53
+ /** Realize-time slot contributors, run in registration order each turn (ADR-195 §3). */
54
+ slotContributors = [];
55
+ /**
56
+ * @param languageProvider the active language provider (template → text)
57
+ * @param world the read-only world model; when supplied, each turn builds a
58
+ * phrase-pipeline render-context factory (ADR-192, W2). Optional so legacy
59
+ * and test construction (string path only) keeps working without a world.
60
+ */
61
+ constructor(languageProvider, world) {
53
62
  if (!languageProvider) {
54
63
  throw new Error('ProsePipeline requires a LanguageProvider; got null/undefined.');
55
64
  }
56
65
  this.languageProvider = languageProvider;
66
+ this.world = world;
67
+ }
68
+ /**
69
+ * Register a realize-time slot contributor (ADR-195 §3). Contributors run once
70
+ * per turn at the top of `processTurn`, in registration order; that order feeds
71
+ * the `(order, insertion)` tie-break of the slot store.
72
+ *
73
+ * @param contributor the slot contributor to run each turn.
74
+ */
75
+ registerSlotContributor(contributor) {
76
+ this.slotContributors.push(contributor);
57
77
  }
58
78
  processTurn(events) {
59
79
  const filtered = (0, filter_1.filterEvents)(events);
60
80
  const sorted = (0, sort_1.sortEventsForProse)(filtered);
81
+ const makeRenderContext = this.world
82
+ ? (0, render_context_1.createRenderContextFactory)((0, render_context_1.createRenderWorld)(this.world), this.languageProvider.getLocaleSettings?.() ?? {}, {
83
+ person: this.languageProvider.getNarrativePerson?.() ?? 'third',
84
+ playerId: this.world.getPlayer()?.id,
85
+ },
86
+ // ADR-196: persistent text-state store backed by the world's `textState`
87
+ // capability — survives save/restore, unlike the turn-scoped seams.
88
+ new render_context_1.WorldTextStateStore(this.world))
89
+ : undefined;
61
90
  const context = {
62
91
  languageProvider: this.languageProvider,
92
+ makeRenderContext,
63
93
  };
94
+ // ADR-195 §3: stage realize-time slot contributions BEFORE any message
95
+ // realizes. Each contributor runs once, in registration order, against a turn
96
+ // RenderContext whose `contribute` writes the per-turn store every later
97
+ // message context peeks via `slotContributions`. World-less pipelines have no
98
+ // factory, so there is nothing to stage into — contributors do not run.
99
+ if (makeRenderContext && this.slotContributors.length > 0) {
100
+ const staging = makeRenderContext({});
101
+ for (const contributor of this.slotContributors) {
102
+ contributor(staging);
103
+ }
104
+ }
64
105
  const blocks = [];
65
106
  for (const event of sorted) {
66
107
  blocks.push(...this.routeToHandler(event, context));
@@ -89,10 +130,11 @@ class ProsePipeline {
89
130
  return (0, generic_1.handleGameMessage)(event, context);
90
131
  case 'if.event.revealed':
91
132
  return (0, revealed_1.handleRevealed)(event, context);
92
- case 'if.event.help_displayed':
93
- return (0, help_1.handleHelpDisplayed)(event, context);
94
- case 'if.event.about_displayed':
95
- return (0, about_1.handleAboutDisplayed)(event, context);
133
+ // if.event.help_displayed / if.event.about_displayed carry messageIds
134
+ // with lang-en-us templates (if.action.help.*, if.action.about.success)
135
+ // and render via tryProcessDomainEventMessage above; their dedicated
136
+ // handlers (help.text/about.text blocks MAIN_KEYS never routed) were
137
+ // removed 2026-07-02 (dungeo regression findings P3).
96
138
  case 'sound.audibility.heard':
97
139
  return (0, audibility_1.handleAudibilityHeard)(event, context);
98
140
  case 'if.event.implicit_take':
@@ -102,6 +144,11 @@ class ProsePipeline {
102
144
  case 'client.query':
103
145
  return (0, client_query_1.handleClientQuery)(event, context);
104
146
  default:
147
+ // Platform lifecycle events carry `payload` (not `data`) and render
148
+ // via the message registered under the event type itself.
149
+ if (event.type.startsWith('platform.')) {
150
+ return (0, platform_1.handlePlatformEvent)(event, context);
151
+ }
105
152
  return (0, generic_1.handleGenericEvent)(event, context);
106
153
  }
107
154
  }
@@ -114,7 +161,7 @@ exports.ProsePipeline = ProsePipeline;
114
161
  * package exposed; callers can swap one for the other without
115
162
  * changing call shapes.
116
163
  */
117
- function createProsePipeline(languageProvider) {
118
- return new ProsePipeline(languageProvider);
164
+ function createProsePipeline(languageProvider, world) {
165
+ return new ProsePipeline(languageProvider, world);
119
166
  }
120
167
  //# sourceMappingURL=pipeline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/engine/src/prose-pipeline/pipeline.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AA6HH,kDAIC;AA3HD,4CAA+C;AAC/C,wCAAmD;AAGnD,0CAAwD;AACxD,kDAAqD;AACrD,gDAG4B;AAC5B,0CAAoD;AACpD,0CAAsD;AACtD,4CAAwD;AACxD,sDAA8D;AAC9D,8DAAyE;AACzE,4DAA8D;AAC9D,8DAAgE;AAChE,0DAA4D;AAI5D;;;;;;;;GAQG;AACH,MAAa,aAAa;IACP,gBAAgB,CAAmB;IAEpD,YAAY,gBAAkC;QAC5C,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAED,WAAW,CAAC,MAAwB;QAClC,MAAM,QAAQ,GAAG,IAAA,qBAAY,EAAC,MAAM,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,IAAA,yBAAkB,EAAC,QAAQ,CAAC,CAAC;QAE5C,MAAM,OAAO,GAAmB;YAC9B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;SACxC,CAAC;QAEF,MAAM,MAAM,GAAiB,EAAE,CAAC;QAChC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,CAAC,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,CAAC;YAE3C;gBACE,OAAO,IAAA,4BAAkB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF;AAhFD,sCAgFC;AAED;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,gBAAkC;IAElC,OAAO,IAAI,aAAa,CAAC,gBAAgB,CAAC,CAAC;AAC7C,CAAC"}
1
+ {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v2/packages/engine/src/prose-pipeline/pipeline.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAuLH,kDAKC;AAtLD,4CAA+C;AAC/C,wCAAmD;AACnD,qDAK0B;AAG1B,0CAAwD;AACxD,kDAAqD;AACrD,gDAG4B;AAC5B,0CAAoD;AACpD,kDAA0D;AAC1D,sDAA8D;AAC9D,8DAAyE;AACzE,4DAA8D;AAC9D,8DAAgE;AAChE,0DAA4D;AAI5D;;;;;;;;GAQG;AACH,MAAa,aAAa;IACP,gBAAgB,CAAmB;IACnC,KAAK,CAAkB;IACxC,wFAAwF;IACvE,gBAAgB,GAAsB,EAAE,CAAC;IAE1D;;;;;OAKG;IACH,YAAY,gBAAkC,EAAE,KAAsB;QACpE,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACH,uBAAuB,CAAC,WAA4B;QAClD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;IAED,WAAW,CAAC,MAAwB;QAClC,MAAM,QAAQ,GAAG,IAAA,qBAAY,EAAC,MAAM,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,IAAA,yBAAkB,EAAC,QAAQ,C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AACH,SAAgB,mBAAmB,CACjC,gBAAkC,EAClC,KAAsB;IAEtB,OAAO,IAAI,aAAa,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Per-turn RenderContext runtime for the phrase pipeline (ADR-192 §6, W2).
3
+ *
4
+ * The Assembler realizes a phrase tree against a `RenderContext`: a read-only
5
+ * world, the bound params, locale settings, and the declared seams
6
+ * (`reference` / `textState` / `contribute` + `slotContributions`). This module
7
+ * supplies the engine's runtime for that contract — a thin adapter over the world
8
+ * model, the live turn-scoped slot store (ADR-195), and the live persistent
9
+ * `textState` store (ADR-196). The engine owns this per turn. The ONE sanctioned
10
+ * mutation is the `textState` capability write (ADR-196 §4 — the declared exception
11
+ * ADR-192 §7 reserved for deterministic `Choice` variation); entity and spatial
12
+ * state are never touched here.
13
+ *
14
+ * Public interface: `createRenderWorld`, `createRenderContextFactory`,
15
+ * `WorldTextStateStore`, `WorldModelLike`. The factory binds the per-turn
16
+ * invariants (world, settings, seams) once and yields a per-message
17
+ * `RenderContext` by adding that message's params.
18
+ *
19
+ * Owner context: `@sharpee/engine` — internal prose pipeline.
20
+ *
21
+ * @see ADR-192 §6 (report pipeline / render context)
22
+ * @see ADR-195 (contribute seam) / ADR-196 (textState seam) / ADR-197 (reference seam)
23
+ */
24
+ import type { EntityId, IEntity } from '@sharpee/core';
25
+ import type { LocaleSettings, NarrativeAgreement, RenderContext, RenderWorld, TextStateStore } from '@sharpee/if-domain';
26
+ /**
27
+ * The minimal world surface the render world adapter needs. The engine's
28
+ * `WorldModel` satisfies this structurally; declaring only the methods the
29
+ * pipeline reads keeps it honest. The pipeline never mutates entity/spatial
30
+ * state — the one sanctioned write is the `textState` capability (ADR-196 §4),
31
+ * exposed through the OPTIONAL capability accessors below. They are optional
32
+ * (the ADR-195 optional-seam precedent) so test mocks that wire only the read
33
+ * methods keep compiling; a world without them degrades to an empty text-state
34
+ * store (no persistence, `Choice` starts at counter 0 — AC-9).
35
+ */
36
+ export interface WorldModelLike {
37
+ getEntity(id: EntityId): IEntity | undefined;
38
+ getContents(containerId: EntityId): IEntity[];
39
+ getContainingRoom(entityId: EntityId): IEntity | undefined;
40
+ /** The player entity, for narrative verb-person agreement (ADR-199 §4 B). */
41
+ getPlayer(): IEntity | undefined;
42
+ /** Read a capability's data map (ADR-196 text-state read). */
43
+ getCapability?(name: string): Record<string, unknown> | undefined;
44
+ /** Merge into a capability's data map (ADR-196 text-state write — the one sanctioned mutation). */
45
+ updateCapability?(name: string, updates: Record<string, unknown>): void;
46
+ /** Whether a capability is registered (guards the defensive self-register). */
47
+ hasCapability?(name: string): boolean;
48
+ /** Register a capability if absent (defensive — the engine normally registers `textState` at setup). */
49
+ registerCapability?(name: string, registration?: {
50
+ initialData?: Record<string, unknown>;
51
+ }): void;
52
+ }
53
+ /**
54
+ * Wrap a world model as the read-only `RenderWorld` the Assembler consumes.
55
+ *
56
+ * Supplies the entity→`NounPhrase` bridge (`nounPhraseFor`, ADR-194) by delegating
57
+ * to stdlib's producer — the engine may depend on stdlib, lang-en-us may not, so the
58
+ * bridge crosses here rather than in the Assembler.
59
+ *
60
+ * @param world the live world model (read-only access only)
61
+ * @returns a `RenderWorld` delegating to the model's lookup methods
62
+ */
63
+ export declare function createRenderWorld(world: WorldModelLike): RenderWorld;
64
+ /**
65
+ * The persistent per-`(entityId, messageKey)` text-state store (ADR-196 §4).
66
+ *
67
+ * Backed by the `textState` world capability, which serializes with the world —
68
+ * so a `Choice`'s cycle index / trigger count / sticky pick survives turns and
69
+ * save/restore (S13–S14). The engine registers the capability at setup
70
+ * (`game-engine.ts`); this store also self-registers defensively so it works in
71
+ * tests and standalone render contexts.
72
+ *
73
+ * A world that does not expose the optional capability accessors degrades to the
74
+ * empty-store behavior (no persistence) — AC-9.
75
+ */
76
+ export declare class WorldTextStateStore implements TextStateStore {
77
+ private readonly world;
78
+ constructor(world: WorldModelLike);
79
+ get(entityId: EntityId, messageKey: string): number | undefined;
80
+ set(entityId: EntityId, messageKey: string, value: number): void;
81
+ }
82
+ /**
83
+ * A per-message render-context builder bound to a turn's invariants.
84
+ *
85
+ * @param params the message's parameter/producer bindings
86
+ * @returns a `RenderContext` carrying those params plus the bound world,
87
+ * settings, and per-turn seams
88
+ */
89
+ export type RenderContextFactory = (params: Record<string, unknown>) => RenderContext;
90
+ /**
91
+ * Build the per-turn render-context factory.
92
+ *
93
+ * World, locale settings, and the seams are the turn's invariants and are
94
+ * captured once; only `params` vary per message, so the returned factory is
95
+ * called once per rendered message. The `contribute` / `slotContributions` pair
96
+ * shares one turn-scoped {@link TurnSlotStore} across every message context, so a
97
+ * slot contribution staged while building one message is visible when another
98
+ * message's `{slot:key}` realizes (ADR-195 §2).
99
+ *
100
+ * @param world the read-only render world (see {@link createRenderWorld})
101
+ * @param settings the locale realization settings for this turn
102
+ * @param narrative the player id + narrative person for verb agreement (ADR-199 §4 B)
103
+ * @param textState the persistent text-state store backing `Choice` (ADR-196 §4);
104
+ * defaults to the empty store for world-less / string-path callers
105
+ * @returns a factory that yields a `RenderContext` for a message's params
106
+ */
107
+ export declare function createRenderContextFactory(world: RenderWorld, settings: LocaleSettings, narrative: NarrativeAgreement, textState?: TextStateStore): RenderContextFactory;
108
+ //# sourceMappingURL=render-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-context.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v2/packages/engine/src/prose-pipeline/render-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EACV,cAAc,EAEd,kBAAkB,EAElB,aAAa,EACb,WAAW,EAEX,cAAc,EAEf,MAAM,oBAAoB,CAAC;AAQ5B;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,EAAE,QAAQ,GA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