@sharpee/engine 1.5.0 → 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.
Files changed (120) 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.map +1 -1
  4. package/capability-dispatch-helper.js.map +1 -1
  5. package/command-executor.d.ts.map +1 -1
  6. package/command-executor.js.map +1 -1
  7. package/events/event-emitter.d.ts.map +1 -1
  8. package/events/event-emitter.js.map +1 -1
  9. package/game-engine.d.ts +14 -3
  10. package/game-engine.d.ts.map +1 -1
  11. package/game-engine.js +20 -1
  12. package/game-engine.js.map +1 -1
  13. package/index.d.ts.map +1 -1
  14. package/index.js.map +1 -1
  15. package/language-provider-interface.d.ts.map +1 -1
  16. package/language-provider-interface.js.map +1 -1
  17. package/narrative/index.d.ts.map +1 -1
  18. package/narrative/index.js.map +1 -1
  19. package/narrative/narrative-settings.d.ts.map +1 -1
  20. package/narrative/narrative-settings.js.map +1 -1
  21. package/package.json +12 -12
  22. package/parser-interface.d.ts.map +1 -1
  23. package/parser-interface.js.map +1 -1
  24. package/platform-operations.d.ts.map +1 -1
  25. package/platform-operations.js.map +1 -1
  26. package/prose-pipeline/assemble.d.ts.map +1 -1
  27. package/prose-pipeline/assemble.js.map +1 -1
  28. package/prose-pipeline/decorations/index.d.ts.map +1 -1
  29. package/prose-pipeline/decorations/index.js.map +1 -1
  30. package/prose-pipeline/decorations/parser.d.ts.map +1 -1
  31. package/prose-pipeline/decorations/parser.js.map +1 -1
  32. package/prose-pipeline/decorations/platform-vocabulary.d.ts.map +1 -1
  33. package/prose-pipeline/decorations/platform-vocabulary.js.map +1 -1
  34. package/prose-pipeline/decorations/resolver.d.ts.map +1 -1
  35. package/prose-pipeline/decorations/resolver.js.map +1 -1
  36. package/prose-pipeline/decorations/types.d.ts.map +1 -1
  37. package/prose-pipeline/decorations/types.js.map +1 -1
  38. package/prose-pipeline/handlers/about.d.ts.map +1 -1
  39. package/prose-pipeline/handlers/about.js.map +1 -1
  40. package/prose-pipeline/handlers/audibility.d.ts.map +1 -1
  41. package/prose-pipeline/handlers/audibility.js +16 -2
  42. package/prose-pipeline/handlers/audibility.js.map +1 -1
  43. package/prose-pipeline/handlers/banner.d.ts.map +1 -1
  44. package/prose-pipeline/handlers/banner.js.map +1 -1
  45. package/prose-pipeline/handlers/client-query.d.ts.map +1 -1
  46. package/prose-pipeline/handlers/client-query.js.map +1 -1
  47. package/prose-pipeline/handlers/command-failed.d.ts.map +1 -1
  48. package/prose-pipeline/handlers/command-failed.js.map +1 -1
  49. package/prose-pipeline/handlers/domain-message.d.ts.map +1 -1
  50. package/prose-pipeline/handlers/domain-message.js +21 -14
  51. package/prose-pipeline/handlers/domain-message.js.map +1 -1
  52. package/prose-pipeline/handlers/game.d.ts.map +1 -1
  53. package/prose-pipeline/handlers/game.js.map +1 -1
  54. package/prose-pipeline/handlers/generic.d.ts.map +1 -1
  55. package/prose-pipeline/handlers/generic.js +28 -3
  56. package/prose-pipeline/handlers/generic.js.map +1 -1
  57. package/prose-pipeline/handlers/help.d.ts.map +1 -1
  58. package/prose-pipeline/handlers/help.js.map +1 -1
  59. package/prose-pipeline/handlers/implicit-take.d.ts.map +1 -1
  60. package/prose-pipeline/handlers/implicit-take.js.map +1 -1
  61. package/prose-pipeline/handlers/index.d.ts.map +1 -1
  62. package/prose-pipeline/handlers/index.js.map +1 -1
  63. package/prose-pipeline/handlers/revealed.d.ts.map +1 -1
  64. package/prose-pipeline/handlers/revealed.js.map +1 -1
  65. package/prose-pipeline/handlers/room.d.ts.map +1 -1
  66. package/prose-pipeline/handlers/room.js +15 -1
  67. package/prose-pipeline/handlers/room.js.map +1 -1
  68. package/prose-pipeline/handlers/types.d.ts +11 -0
  69. package/prose-pipeline/handlers/types.d.ts.map +1 -1
  70. package/prose-pipeline/handlers/types.js.map +1 -1
  71. package/prose-pipeline/index.d.ts +3 -2
  72. package/prose-pipeline/index.d.ts.map +1 -1
  73. package/prose-pipeline/index.js +6 -2
  74. package/prose-pipeline/index.js.map +1 -1
  75. package/prose-pipeline/phrase-render.d.ts +54 -0
  76. package/prose-pipeline/phrase-render.d.ts.map +1 -0
  77. package/prose-pipeline/phrase-render.js +103 -0
  78. package/prose-pipeline/phrase-render.js.map +1 -0
  79. package/prose-pipeline/pipeline.d.ts +23 -5
  80. package/prose-pipeline/pipeline.d.ts.map +1 -1
  81. package/prose-pipeline/pipeline.js +46 -4
  82. package/prose-pipeline/pipeline.js.map +1 -1
  83. package/prose-pipeline/render-context.d.ts +108 -0
  84. package/prose-pipeline/render-context.d.ts.map +1 -0
  85. package/prose-pipeline/render-context.js +192 -0
  86. package/prose-pipeline/render-context.js.map +1 -0
  87. package/prose-pipeline/stages/filter.d.ts.map +1 -1
  88. package/prose-pipeline/stages/filter.js.map +1 -1
  89. package/prose-pipeline/stages/index.d.ts.map +1 -1
  90. package/prose-pipeline/stages/index.js.map +1 -1
  91. package/prose-pipeline/stages/sort.d.ts.map +1 -1
  92. package/prose-pipeline/stages/sort.js.map +1 -1
  93. package/prose-pipeline/types.d.ts +33 -10
  94. package/prose-pipeline/types.d.ts.map +1 -1
  95. package/prose-pipeline/types.js +9 -9
  96. package/prose-pipeline/types.js.map +1 -1
  97. package/save-restore-service.d.ts.map +1 -1
  98. package/save-restore-service.js.map +1 -1
  99. package/scene-evaluation-plugin.d.ts.map +1 -1
  100. package/scene-evaluation-plugin.js.map +1 -1
  101. package/shared-data-keys.d.ts.map +1 -1
  102. package/shared-data-keys.js.map +1 -1
  103. package/sound/dispatcher.d.ts.map +1 -1
  104. package/sound/dispatcher.js.map +1 -1
  105. package/sound/index.d.ts.map +1 -1
  106. package/sound/index.js.map +1 -1
  107. package/sound/propagation.d.ts.map +1 -1
  108. package/sound/propagation.js.map +1 -1
  109. package/story.d.ts.map +1 -1
  110. package/story.js.map +1 -1
  111. package/test-helpers/mock-prose-pipeline.d.ts +6 -4
  112. package/test-helpers/mock-prose-pipeline.d.ts.map +1 -1
  113. package/test-helpers/mock-prose-pipeline.js +5 -1
  114. package/test-helpers/mock-prose-pipeline.js.map +1 -1
  115. package/turn-event-processor.d.ts.map +1 -1
  116. package/turn-event-processor.js.map +1 -1
  117. package/types.d.ts.map +1 -1
  118. package/types.js.map +1 -1
  119. package/vocabulary-manager.d.ts.map +1 -1
  120. package/vocabulary-manager.js.map +1 -1
@@ -20,6 +20,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.handleRoomDescription = handleRoomDescription;
21
21
  const text_blocks_1 = require("@sharpee/text-blocks");
22
22
  const assemble_1 = require("../assemble");
23
+ const phrase_render_1 = require("../phrase-render");
24
+ /**
25
+ * Core template id for the room description body (ADR-195). Realized through the
26
+ * phrase pipeline so its `{slot:here}` room-occupant channel fills with the
27
+ * presence clauses staged this turn. Registered in `@sharpee/lang-en-us`.
28
+ */
29
+ const ROOM_DESCRIPTION_BODY_ID = 'if.room.description_body';
23
30
  /**
24
31
  * Handle room description events.
25
32
  */
@@ -62,7 +69,14 @@ function handleRoomDescription(event, context) {
62
69
  if (description) {
63
70
  const resolvedDesc = (0, assemble_1.extractValue)(description);
64
71
  if (resolvedDesc) {
65
- const descBlocks = (0, assemble_1.createBlocks)(text_blocks_1.BLOCK_KEYS.ROOM_DESCRIPTION, resolvedDesc);
72
+ // ADR-192/195: realize the description body through the phrase pipeline so
73
+ // its `{slot:here}` occupant channel fills with the presence clauses staged
74
+ // this turn. The room's prose is bound as a `{verbatim:description}` param;
75
+ // the slot owns the connective grammar. Degrade to literal blocks only when
76
+ // the pipeline has no world (the legacy string path, e.g. some unit tests).
77
+ const descBlocks = (0, phrase_render_1.phraseAvailable)(context)
78
+ ? (0, phrase_render_1.renderViaPhrase)(context, ROOM_DESCRIPTION_BODY_ID, { description: resolvedDesc }, text_blocks_1.BLOCK_KEYS.ROOM_DESCRIPTION) ?? (0, assemble_1.createBlocks)(text_blocks_1.BLOCK_KEYS.ROOM_DESCRIPTION, resolvedDesc)
79
+ : (0, assemble_1.createBlocks)(text_blocks_1.BLOCK_KEYS.ROOM_DESCRIPTION, resolvedDesc);
66
80
  // When the room name was emitted in this packet, the description's
67
81
  // first block continues the room "heading" visually — mark it tight
68
82
  // so the renderer collapses the inter-paragraph margin and the
@@ -1 +1 @@
1
- {"version":3,"file":"room.js","sourceRoot":"","sources":["../../../../../../../../repos/sharpee_v1/packages/engine/src/prose-pipeline/handlers/room.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;AAkCH,sDAiEC;AAhGD,sDAAkD;AAGlD,0CAAsE;AAyBtE;;GAEG;AACH,SAAgB,qBAAqB,CACnC,KAAqB,EACrB,OAAuB;IAEvB,MAAM,IAAI,GAAG,KAAK,CAAC,IAA2B,CAAC;IAC/C,MAAM,MAAM,GAAiB,EAAE,CAAC;IAEhC,0BAA0B;IAC1B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,IAAI,IAAwB,CAAC;QAE7B,wCAAwC;QACxC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;QACpD,IAAI,MAAM,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACjE,IAAI,QAAQ,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;gBACpC,IAAI,GAAG,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC;QAC1C,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,YAAY,GAAG,IAAA,uBAAY,EAAC,IAAI,CAAC,CAAC;YACxC,IAAI,YAAY,EAAE,CAAC;gBACj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M,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"room.js","sourceRoot":"","sources":["../../../../../../../../repos/sharpee_v2/packages/engine/src/prose-pipeline/handlers/room.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;AA0CH,sDA6EC;AApHD,sDAAkD;AAGlD,0CAAsE;AACtE,oDAAoE;AAEpE;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAyB5D;;GAEG;AACH,SAAgB,qBAAqB,CACnC,KAAqB,EACrB,OAAuB;IAEvB,MAAM,IAAI,GAAG,KAAK,CAAC,IAA2B,CAAC;IAC/C,MAAM,MAAM,GAAiB,EAAE,CAAC;IAEhC,0BAA0B;IAC1B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,IAAI,IAAwB,CAAC;QAE7B,wCAAwC;QACxC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;QACpD,IAAI,MAAM,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;YACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACjE,IAAI,QAAQ,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;gBACpC,IAAI,GAAG,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC;QAC1C,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,YAAY,GAAG,IAAA,uBAAY,EAAC,IAAI,CAAC,CAAC;YACxC,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,CAAC,IAAI,CACT,IAAA,sBAAW,EAAC,wBAAU,CAAC,SAAS,EAAE,SAAS,YAAY,GAAG,CAAC,CAC5D,CAAC;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C;gBAC/C,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACpD,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -13,12 +13,23 @@
13
13
  import type { ITextBlock } from '@sharpee/text-blocks';
14
14
  import type { LanguageProvider } from '@sharpee/if-domain';
15
15
  import type { ISemanticEvent } from '@sharpee/core';
16
+ import type { RenderContextFactory } from '../render-context';
16
17
  /**
17
18
  * Context passed to event handlers.
18
19
  */
19
20
  export interface HandlerContext {
20
21
  /** Language provider for template resolution. */
21
22
  languageProvider?: LanguageProvider;
23
+ /**
24
+ * Per-turn render-context factory for the phrase pipeline (ADR-192, W2).
25
+ *
26
+ * Present when the pipeline was constructed with a world model; a handler on
27
+ * the phrase path builds its per-message `RenderContext` by calling this with
28
+ * the message's params, then passes it to `languageProvider.renderMessage`.
29
+ * Absent in legacy/world-less construction (the old string path needs no
30
+ * render context).
31
+ */
32
+ makeRenderContext?: RenderContextFactory;
22
33
  }
23
34
  /**
24
35
  * Event handler function signature.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../repos/sharpee_v1/packages/engine/src/prose-pipeline/handlers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;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;AAEpD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,cAAc,KACpB,UAAU,EAAE,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../repos/sharpee_v2/packages/engine/src/prose-pipeline/handlers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;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;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;CAC1C;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,cAAc,KACpB,UAAU,EAAE,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../repos/sharpee_v1/packages/engine/src/prose-pipeline/handlers/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../repos/sharpee_v2/packages/engine/src/prose-pipeline/handlers/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG"}
@@ -2,7 +2,7 @@
2
2
  * Prose pipeline — internal barrel for the engine package.
3
3
  *
4
4
  * Public interface: `ProsePipeline`, `createProsePipeline`,
5
- * `ITextService`. Plus the decoration primitives and stage utilities
5
+ * `IProsePipeline`. Plus the decoration primitives and stage utilities
6
6
  * the pipeline class composes.
7
7
  *
8
8
  * Owner context: `@sharpee/engine` — internal prose pipeline.
@@ -10,7 +10,8 @@
10
10
  * @see ADR-174 §Engine-internal prose pipeline
11
11
  */
12
12
  export { ProsePipeline, createProsePipeline } from './pipeline';
13
- export type { ITextService } from './types';
13
+ export type { IProsePipeline, SlotContributor } from './types';
14
+ export { createRenderWorld, createRenderContextFactory, type RenderContextFactory, type WorldModelLike, } from './render-context';
14
15
  export { parseDecorations, resolveClassName, PLATFORM_VOCABULARY, PLATFORM_VOCABULARY_NAMES, type PlatformVocabularyName, type IDecoration, type TextContent, } from './decorations';
15
16
  export { filterEvents } from './stages/filter';
16
17
  export { sortEventsForProse, getChainMetadata, } from './stages/sort';
@@ -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,mBAAmB,EACnB,oBAAoB,EACpB,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.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.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`).
@@ -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,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"}
@@ -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,CAAC,SAAkD,CAAC;IAC5E,IAAI,SAAS,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;QAChC,KAAK,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3D,KAA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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;AAkB1B,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;CA6CvB;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,6 +27,7 @@ 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");
@@ -49,18 +50,59 @@ const client_query_1 = require("./handlers/client-query");
49
50
  */
50
51
  class ProsePipeline {
51
52
  languageProvider;
52
- constructor(languageProvider) {
53
+ world;
54
+ /** Realize-time slot contributors, run in registration order each turn (ADR-195 §3). */
55
+ slotContributors = [];
56
+ /**
57
+ * @param languageProvider the active language provider (template → text)
58
+ * @param world the read-only world model; when supplied, each turn builds a
59
+ * phrase-pipeline render-context factory (ADR-192, W2). Optional so legacy
60
+ * and test construction (string path only) keeps working without a world.
61
+ */
62
+ constructor(languageProvider, world) {
53
63
  if (!languageProvider) {
54
64
  throw new Error('ProsePipeline requires a LanguageProvider; got null/undefined.');
55
65
  }
56
66
  this.languageProvider = languageProvider;
67
+ this.world = world;
68
+ }
69
+ /**
70
+ * Register a realize-time slot contributor (ADR-195 §3). Contributors run once
71
+ * per turn at the top of `processTurn`, in registration order; that order feeds
72
+ * the `(order, insertion)` tie-break of the slot store.
73
+ *
74
+ * @param contributor the slot contributor to run each turn.
75
+ */
76
+ registerSlotContributor(contributor) {
77
+ this.slotContributors.push(contributor);
57
78
  }
58
79
  processTurn(events) {
59
80
  const filtered = (0, filter_1.filterEvents)(events);
60
81
  const sorted = (0, sort_1.sortEventsForProse)(filtered);
82
+ const makeRenderContext = this.world
83
+ ? (0, render_context_1.createRenderContextFactory)((0, render_context_1.createRenderWorld)(this.world), this.languageProvider.getLocaleSettings?.() ?? {}, {
84
+ person: this.languageProvider.getNarrativePerson?.() ?? 'third',
85
+ playerId: this.world.getPlayer()?.id,
86
+ },
87
+ // ADR-196: persistent text-state store backed by the world's `textState`
88
+ // capability — survives save/restore, unlike the turn-scoped seams.
89
+ new render_context_1.WorldTextStateStore(this.world))
90
+ : undefined;
61
91
  const context = {
62
92
  languageProvider: this.languageProvider,
93
+ makeRenderContext,
63
94
  };
95
+ // ADR-195 §3: stage realize-time slot contributions BEFORE any message
96
+ // realizes. Each contributor runs once, in registration order, against a turn
97
+ // RenderContext whose `contribute` writes the per-turn store every later
98
+ // message context peeks via `slotContributions`. World-less pipelines have no
99
+ // factory, so there is nothing to stage into — contributors do not run.
100
+ if (makeRenderContext && this.slotContributors.length > 0) {
101
+ const staging = makeRenderContext({});
102
+ for (const contributor of this.slotContributors) {
103
+ contributor(staging);
104
+ }
105
+ }
64
106
  const blocks = [];
65
107
  for (const event of sorted) {
66
108
  blocks.push(...this.routeToHandler(event, context));
@@ -114,7 +156,7 @@ exports.ProsePipeline = ProsePipeline;
114
156
  * package exposed; callers can swap one for the other without
115
157
  * changing call shapes.
116
158
  */
117
- function createProsePipeline(languageProvider) {
118
- return new ProsePipeline(languageProvider);
159
+ function createProsePipeline(languageProvider, world) {
160
+ return new ProsePipeline(languageProvider, world);
119
161
  }
120
162
  //# 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,GAA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,CAAC;YAE7C,KAAK,cAAc;gBACjB,OAAO,IAAA,gCAAiB,EAAC,KAAK,EAAE,OAAO,CAAC,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;;;AAmLH,kDAKC;AAlLD,4CAA+C;AAC/C,wCAAmD;AACnD,qDAK0B;AAG1B,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;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,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ED;;;;;;GAMG;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,E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