@sharpee/engine 0.9.65-beta → 0.9.66-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/package.json +6 -24
  2. package/dist-npm/action-context-factory.d.ts +0 -11
  3. package/dist-npm/action-context-factory.d.ts.map +0 -1
  4. package/dist-npm/action-context-factory.js +0 -258
  5. package/dist-npm/action-context-factory.js.map +0 -1
  6. package/dist-npm/capability-dispatch-helper.d.ts +0 -106
  7. package/dist-npm/capability-dispatch-helper.d.ts.map +0 -1
  8. package/dist-npm/capability-dispatch-helper.js +0 -269
  9. package/dist-npm/capability-dispatch-helper.js.map +0 -1
  10. package/dist-npm/command-executor.d.ts +0 -53
  11. package/dist-npm/command-executor.d.ts.map +0 -1
  12. package/dist-npm/command-executor.js +0 -329
  13. package/dist-npm/command-executor.js.map +0 -1
  14. package/dist-npm/event-adapter.d.ts +0 -44
  15. package/dist-npm/event-adapter.d.ts.map +0 -1
  16. package/dist-npm/event-adapter.js +0 -127
  17. package/dist-npm/event-adapter.js.map +0 -1
  18. package/dist-npm/event-sequencer.d.ts +0 -73
  19. package/dist-npm/event-sequencer.d.ts.map +0 -1
  20. package/dist-npm/event-sequencer.js +0 -134
  21. package/dist-npm/event-sequencer.js.map +0 -1
  22. package/dist-npm/events/event-emitter.d.ts +0 -34
  23. package/dist-npm/events/event-emitter.d.ts.map +0 -1
  24. package/dist-npm/events/event-emitter.js +0 -67
  25. package/dist-npm/events/event-emitter.js.map +0 -1
  26. package/dist-npm/game-engine.d.ts +0 -292
  27. package/dist-npm/game-engine.d.ts.map +0 -1
  28. package/dist-npm/game-engine.js +0 -1597
  29. package/dist-npm/game-engine.js.map +0 -1
  30. package/dist-npm/index.d.ts +0 -27
  31. package/dist-npm/index.d.ts.map +0 -1
  32. package/dist-npm/index.js +0 -63
  33. package/dist-npm/index.js.map +0 -1
  34. package/dist-npm/narrative/index.d.ts +0 -5
  35. package/dist-npm/narrative/index.d.ts.map +0 -1
  36. package/dist-npm/narrative/index.js +0 -10
  37. package/dist-npm/narrative/index.js.map +0 -1
  38. package/dist-npm/narrative/narrative-settings.d.ts +0 -73
  39. package/dist-npm/narrative/narrative-settings.d.ts.map +0 -1
  40. package/dist-npm/narrative/narrative-settings.js +0 -28
  41. package/dist-npm/narrative/narrative-settings.js.map +0 -1
  42. package/dist-npm/parser-interface.d.ts +0 -77
  43. package/dist-npm/parser-interface.d.ts.map +0 -1
  44. package/dist-npm/parser-interface.js +0 -48
  45. package/dist-npm/parser-interface.js.map +0 -1
  46. package/dist-npm/platform-operations.d.ts +0 -83
  47. package/dist-npm/platform-operations.d.ts.map +0 -1
  48. package/dist-npm/platform-operations.js +0 -218
  49. package/dist-npm/platform-operations.js.map +0 -1
  50. package/dist-npm/save-restore-service.d.ts +0 -125
  51. package/dist-npm/save-restore-service.d.ts.map +0 -1
  52. package/dist-npm/save-restore-service.js +0 -405
  53. package/dist-npm/save-restore-service.js.map +0 -1
  54. package/dist-npm/scheduler/index.d.ts +0 -9
  55. package/dist-npm/scheduler/index.d.ts.map +0 -1
  56. package/dist-npm/scheduler/index.js +0 -25
  57. package/dist-npm/scheduler/index.js.map +0 -1
  58. package/dist-npm/scheduler/scheduler-service.d.ts +0 -75
  59. package/dist-npm/scheduler/scheduler-service.d.ts.map +0 -1
  60. package/dist-npm/scheduler/scheduler-service.js +0 -310
  61. package/dist-npm/scheduler/scheduler-service.js.map +0 -1
  62. package/dist-npm/scheduler/seeded-random.d.ts +0 -7
  63. package/dist-npm/scheduler/seeded-random.d.ts.map +0 -1
  64. package/dist-npm/scheduler/seeded-random.js +0 -11
  65. package/dist-npm/scheduler/seeded-random.js.map +0 -1
  66. package/dist-npm/scheduler/types.d.ts +0 -134
  67. package/dist-npm/scheduler/types.d.ts.map +0 -1
  68. package/dist-npm/scheduler/types.js +0 -9
  69. package/dist-npm/scheduler/types.js.map +0 -1
  70. package/dist-npm/shared-data-keys.d.ts +0 -53
  71. package/dist-npm/shared-data-keys.d.ts.map +0 -1
  72. package/dist-npm/shared-data-keys.js +0 -29
  73. package/dist-npm/shared-data-keys.js.map +0 -1
  74. package/dist-npm/story.d.ts +0 -216
  75. package/dist-npm/story.d.ts.map +0 -1
  76. package/dist-npm/story.js +0 -60
  77. package/dist-npm/story.js.map +0 -1
  78. package/dist-npm/test-helpers/mock-text-service.d.ts +0 -11
  79. package/dist-npm/test-helpers/mock-text-service.d.ts.map +0 -1
  80. package/dist-npm/test-helpers/mock-text-service.js +0 -47
  81. package/dist-npm/test-helpers/mock-text-service.js.map +0 -1
  82. package/dist-npm/turn-event-processor.d.ts +0 -89
  83. package/dist-npm/turn-event-processor.d.ts.map +0 -1
  84. package/dist-npm/turn-event-processor.js +0 -144
  85. package/dist-npm/turn-event-processor.js.map +0 -1
  86. package/dist-npm/types.d.ts +0 -214
  87. package/dist-npm/types.d.ts.map +0 -1
  88. package/dist-npm/types.js +0 -8
  89. package/dist-npm/types.js.map +0 -1
  90. package/dist-npm/vocabulary-manager.d.ts +0 -35
  91. package/dist-npm/vocabulary-manager.d.ts.map +0 -1
  92. package/dist-npm/vocabulary-manager.js +0 -74
  93. package/dist-npm/vocabulary-manager.js.map +0 -1
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@sharpee/engine",
3
- "version": "0.9.65-beta",
3
+ "version": "0.9.66-beta",
4
4
  "description": "Runtime engine for Sharpee IF Platform - game loop, command execution, and turn management",
5
- "main": "./dist-npm/index.js",
5
+ "main": "./index.js",
6
6
  "module": "dist-npm/index.js",
7
- "types": "./dist-npm/index.d.ts",
7
+ "types": "./index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist-npm/index.d.ts",
11
- "require": "./dist-npm/index.js"
10
+ "types": "./index.d.ts",
11
+ "require": "./index.js",
12
+ "default": "./index.js"
12
13
  }
13
14
  },
14
15
  "scripts": {
@@ -21,25 +22,6 @@
21
22
  "clean": "rimraf dist",
22
23
  "build:npm": "tsc --outDir dist-npm"
23
24
  },
24
- "dependencies": {
25
- "@sharpee/core": "workspace:*",
26
- "@sharpee/event-processor": "workspace:*",
27
- "@sharpee/plugins": "workspace:*",
28
- "@sharpee/if-domain": "workspace:*",
29
- "@sharpee/if-services": "workspace:*",
30
- "@sharpee/lang-en-us": "workspace:*",
31
- "@sharpee/parser-en-us": "workspace:*",
32
- "@sharpee/stdlib": "workspace:*",
33
- "@sharpee/text-blocks": "workspace:*",
34
- "@sharpee/text-service": "workspace:*",
35
- "@sharpee/world-model": "workspace:*"
36
- },
37
- "devDependencies": {
38
- "@types/node": "^20.11.19",
39
- "cross-env": "^7.0.3",
40
- "rimraf": "^5.0.5",
41
- "typescript": "^5.3.3"
42
- },
43
25
  "files": [
44
26
  "dist-npm"
45
27
  ],
@@ -1,11 +0,0 @@
1
- /**
2
- * Action Context Factory - Creates ActionContext for action execution
3
- */
4
- import { ActionContext, Action, ScopeResolver, ValidatedCommand } from "../../stdlib/dist-npm/src/index";
5
- import { WorldModel } from "../../world-model/dist-npm/src/index";
6
- import { GameContext } from './types';
7
- /**
8
- * Create an ActionContext for action execution
9
- */
10
- export declare function createActionContext(world: WorldModel, gameContext: GameContext, command: ValidatedCommand, action: Action, scopeResolver: ScopeResolver): ActionContext;
11
- //# sourceMappingURL=action-context-factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action-context-factory.d.ts","sourceRoot":"","sources":["../../../../src/action-context-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAA+E,MAAM,iBAAiB,CAAC;AACtK,OAAO,EAAE,UAAU,EAAuB,MAAM,sBAAsB,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA+CtC;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,GAC3B,aAAa,CAuPf"}
@@ -1,258 +0,0 @@
1
- "use strict";
2
- /**
3
- * Action Context Factory - Creates ActionContext for action execution
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createActionContext = createActionContext;
7
- const stdlib_1 = require("../../stdlib/dist-npm/src/index.js");
8
- const world_model_1 = require("../../world-model/dist-npm/src/index.js");
9
- const core_1 = require("../../core/dist-npm/src/index.js");
10
- const shared_data_keys_1 = require("./shared-data-keys");
11
- /**
12
- * Helper to get entity from command slot
13
- */
14
- function getEntityFromSlot(command, slot) {
15
- switch (slot) {
16
- case 'target':
17
- case 'directObject':
18
- case 'item':
19
- return command.directObject?.entity ?? null;
20
- case 'container':
21
- case 'recipient':
22
- case 'instrument':
23
- case 'indirectObject':
24
- return command.indirectObject?.entity ?? null;
25
- default:
26
- return command.directObject?.entity ?? null;
27
- }
28
- }
29
- /**
30
- * Generate appropriate scope error based on requirement and actual scope
31
- */
32
- function getScopeError(required, actual, entity) {
33
- const params = { item: entity.name };
34
- if (actual === stdlib_1.ScopeLevel.UNAWARE) {
35
- return { valid: false, error: stdlib_1.ScopeErrors.NOT_KNOWN, params };
36
- }
37
- if (required >= stdlib_1.ScopeLevel.VISIBLE && actual < stdlib_1.ScopeLevel.VISIBLE) {
38
- return { valid: false, error: stdlib_1.ScopeErrors.NOT_VISIBLE, params };
39
- }
40
- if (required >= stdlib_1.ScopeLevel.REACHABLE && actual < stdlib_1.ScopeLevel.REACHABLE) {
41
- return { valid: false, error: stdlib_1.ScopeErrors.NOT_REACHABLE, params };
42
- }
43
- if (required >= stdlib_1.ScopeLevel.CARRIED && actual < stdlib_1.ScopeLevel.CARRIED) {
44
- return { valid: false, error: stdlib_1.ScopeErrors.NOT_CARRIED, params };
45
- }
46
- return { valid: false, error: stdlib_1.ScopeErrors.OUT_OF_SCOPE, params };
47
- }
48
- /**
49
- * Create an ActionContext for action execution
50
- */
51
- function createActionContext(world, gameContext, command, action, scopeResolver) {
52
- const player = gameContext.player;
53
- const currentLocation = world.getLocation(player.id)
54
- ? world.getEntity(world.getLocation(player.id))
55
- : player;
56
- // Create sharedData object separately so it can be referenced in closures
57
- const sharedData = {};
58
- // Create the event method
59
- const event = (type, data) => {
60
- // Add standard entities
61
- const entities = {
62
- actor: player.id,
63
- location: currentLocation?.id || player.id
64
- };
65
- // Add entities from command
66
- if (command.directObject?.entity) {
67
- entities.target = command.directObject.entity.id;
68
- }
69
- if (command.indirectObject?.entity) {
70
- entities.indirect = command.indirectObject.entity.id;
71
- }
72
- // Create the event
73
- return {
74
- id: `evt_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
75
- type,
76
- timestamp: Date.now(),
77
- data: {
78
- ...data,
79
- // Include action context in data instead of metadata
80
- actionId: action.id,
81
- turn: gameContext.currentTurn
82
- },
83
- entities
84
- };
85
- };
86
- return {
87
- // World querying
88
- world,
89
- player,
90
- currentLocation: currentLocation,
91
- command,
92
- scopeResolver,
93
- action,
94
- // Shared data for passing information between phases
95
- sharedData,
96
- // Validation result - set by CommandExecutor after validate() phase
97
- validationResult: undefined,
98
- // Scope checking methods (delegate to scopeResolver)
99
- canSee: (entity) => {
100
- return scopeResolver.canSee(player, entity);
101
- },
102
- canReach: (entity) => {
103
- return scopeResolver.canReach(player, entity);
104
- },
105
- canTake: (entity) => {
106
- // Basic implementation - can be enhanced
107
- return !entity.has('if.trait.scenery') &&
108
- !entity.has('if.trait.fixed') &&
109
- entity.type !== 'room' &&
110
- entity.type !== 'location';
111
- },
112
- isInScope: (entity) => {
113
- const level = scopeResolver.getScope(player, entity);
114
- return level >= stdlib_1.ScopeLevel.AWARE;
115
- },
116
- getVisible: () => {
117
- return scopeResolver.getVisible(player);
118
- },
119
- getInScope: () => {
120
- // Get all entities and filter by scope
121
- const allEntities = world.getAllEntities();
122
- return allEntities.filter(entity => {
123
- const level = scopeResolver.getScope(player, entity);
124
- return level >= stdlib_1.ScopeLevel.AWARE;
125
- });
126
- },
127
- // Scope validation methods (Phase 4 parser refactor)
128
- getEntityScope: (entity) => {
129
- return scopeResolver.getScope(player, entity);
130
- },
131
- getSlotScope: (slot) => {
132
- const entity = getEntityFromSlot(command, slot);
133
- if (!entity) {
134
- return stdlib_1.ScopeLevel.UNAWARE;
135
- }
136
- return scopeResolver.getScope(player, entity);
137
- },
138
- requireScope: (entity, required) => {
139
- const actualScope = scopeResolver.getScope(player, entity);
140
- if (actualScope >= required) {
141
- return { ok: true, actualScope };
142
- }
143
- const error = getScopeError(required, actualScope, entity);
144
- return { ok: false, error, actualScope };
145
- },
146
- requireSlotScope: (slot, required) => {
147
- const entity = getEntityFromSlot(command, slot);
148
- if (!entity) {
149
- return {
150
- ok: false,
151
- error: { valid: false, error: 'no_target', params: { slot } }
152
- };
153
- }
154
- const actualScope = scopeResolver.getScope(player, entity);
155
- if (actualScope >= required) {
156
- return { ok: true, actualScope };
157
- }
158
- const error = getScopeError(required, actualScope, entity);
159
- return { ok: false, error, actualScope };
160
- },
161
- requireCarriedOrImplicitTake: (entity) => {
162
- const actualScope = scopeResolver.getScope(player, entity);
163
- // Case 1: Already carried - success, no implicit take needed
164
- if (actualScope >= stdlib_1.ScopeLevel.CARRIED) {
165
- return { ok: true };
166
- }
167
- // Case 2: Not reachable - can't take it, return scope error
168
- if (actualScope < stdlib_1.ScopeLevel.REACHABLE) {
169
- const error = getScopeError(stdlib_1.ScopeLevel.REACHABLE, actualScope, entity);
170
- return { ok: false, error };
171
- }
172
- // Case 3: Reachable but not carried - attempt implicit take
173
- // Check if implicit take is disabled at story level (ADR-104)
174
- if (gameContext.implicitActions?.implicitTake === false) {
175
- return {
176
- ok: false,
177
- error: { valid: false, error: stdlib_1.ScopeErrors.NOT_CARRIED, params: { item: entity.name } }
178
- };
179
- }
180
- // Check if implicit take is disabled at action level (ADR-104)
181
- if (action.allowImplicitTake === false) {
182
- return {
183
- ok: false,
184
- error: { valid: false, error: stdlib_1.ScopeErrors.NOT_CARRIED, params: { item: entity.name } }
185
- };
186
- }
187
- // Check if entity can be taken (not scenery, room, door)
188
- if (entity.has(world_model_1.TraitType.SCENERY) || entity.has(world_model_1.TraitType.ROOM) || entity.has(world_model_1.TraitType.DOOR)) {
189
- return {
190
- ok: false,
191
- error: { valid: false, error: 'fixed_in_place', params: { item: entity.name } }
192
- };
193
- }
194
- // Create a synthetic command for the taking action
195
- const takeCommand = {
196
- parsed: {
197
- rawInput: `take ${entity.name}`,
198
- action: stdlib_1.takingAction.id,
199
- tokens: [],
200
- structure: { verb: { tokens: [0], text: 'take', head: 'take' } },
201
- pattern: 'VERB_NOUN',
202
- confidence: 1.0
203
- },
204
- actionId: stdlib_1.takingAction.id,
205
- directObject: {
206
- entity,
207
- parsed: {
208
- text: entity.name,
209
- candidates: [entity.name]
210
- }
211
- }
212
- };
213
- // Create a sub-context for the taking action
214
- const takeContext = createActionContext(world, gameContext, takeCommand, stdlib_1.takingAction, scopeResolver);
215
- // Run the taking action's validate phase
216
- const validation = stdlib_1.takingAction.validate(takeContext);
217
- if (!validation.valid) {
218
- // Take validation failed - return the error
219
- return {
220
- ok: false,
221
- error: {
222
- valid: false,
223
- error: validation.error || 'cannot_take',
224
- params: validation.params
225
- }
226
- };
227
- }
228
- // Execute the taking action
229
- stdlib_1.takingAction.execute(takeContext);
230
- // Get the report events from the taking action
231
- const takeEvents = stdlib_1.takingAction.report ? stdlib_1.takingAction.report(takeContext) : [];
232
- // Filter out action.success events - the implicit_take message replaces them
233
- // Keep if.event.taken for state tracking
234
- const filteredTakeEvents = takeEvents.filter(e => e.type !== 'action.success');
235
- // Create the implicit take event (for "(first taking the X)" message)
236
- const implicitTakeEvent = (0, core_1.createEvent)('if.event.implicit_take', {
237
- item: entity.id,
238
- itemName: entity.name
239
- }, {
240
- actor: player.id,
241
- target: entity.id,
242
- location: currentLocation?.id || player.id
243
- });
244
- // Combine: implicit take notification + state change events (no success message)
245
- const implicitTakeEvents = [implicitTakeEvent, ...filteredTakeEvents];
246
- // Store in sharedData for the report phase to access
247
- const existingEvents = sharedData[shared_data_keys_1.SharedDataKeys.IMPLICIT_TAKE_EVENTS] ?? [];
248
- sharedData[shared_data_keys_1.SharedDataKeys.IMPLICIT_TAKE_EVENTS] = [...existingEvents, ...implicitTakeEvents];
249
- return {
250
- ok: true,
251
- implicitTakeEvents
252
- };
253
- },
254
- // Event creation
255
- event
256
- };
257
- }
258
- //# sourceMappingURL=action-context-factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action-context-factory.js","sourceRoot":"","sources":["../../../../src/action-context-factory.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAuDH,kDA6PC;AAlTD,4CAAsK;AACtK,sDAAuE;AACvE,wCAA+E;AAE/E,yDAAsE;AAEtE;;GAEG;AACH,SAAS,iBAAiB,CAAC,OAAyB,EAAE,IAAY;IAChE,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ,CAAC;QACd,KAAK,cAAc,CAAC;QACpB,KAAK,MAAM;YACT,OAAO,OAAO,CAAC,YAAY,EAAE,MAAM,IAAI,IAAI,CAAC;QAC9C,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW,CAAC;QACjB,KAAK,YAAY,CAAC;QAClB,KAAK,gBAAgB;YACnB,OAAO,OAAO,CAAC,cAAc,EAAE,MAAM,IAAI,IAAI,CAAC;QAChD;YACE,OAAO,OAAO,CAAC,YAAY,EAAE,MAAM,IAAI,IAAI,CAAC;IAChD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CACpB,QAAoB,EACpB,MAAkB,EAClB,MAAgB;IAEhB,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAErC,IAAI,MAAM,KAAK,mBAAU,CAAC,OAAO,EAAE,CAAC;QAClC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAW,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAChE,CAAC;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AA4B;YAC5B,qBAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAElC,+CAA+C;YAC/C,MAAM,UAAU,GAAG,qBAAY,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAE/E,6EAA6E;YAC7E,yCAAyC;YACzC,MAAM,kBAAkB,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC;YAE/E,sEAAsE;YACtE,MAAM,iBAAiB,GAAG,IAAA,kBAAe,EAAC,wBAAwB,EAAE;gBAClE,IAAI,EAAE,MAAM,CAAC,EAAE;gBACf,QAAQ,EAAE,MAAM,CAAC,IAAI;aACtB,EAAE;gBACD,KAAK,EAAE,MAAM,CAAC,EAAE;gBAChB,MAAM,EAAE,MAAM,CAAC,EAAE;gBACjB,QAAQ,EAAE,eAAe,EAAE,EAAE,IAAI,MAAM,CAAC,EAAE;aAC3C,CAAC,CAAC;YAEH,iFAAiF;YACjF,MAAM,kBAAkB,GAAG,CAAC,iBAAiB,EAAE,GAAG,kBAAkB,CAAC,CAAC;YAEtE,qDAAqD;YACrD,MAAM,cAAc,GAAG,UAAU,CAAC,iCAAc,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC;YAC7E,UAAU,CAAC,iCAAc,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,cAAc,EAAE,GAAG,kBAAkB,CAAC,CAAC;YAE7F,OAAO;gBACL,EAAE,EAAE,IAAI;gBACR,kBAAkB;aACnB,CAAC;QACJ,CAAC;QAED,iBAAiB;QACjB,KAAK;KACN,CAAC;AACJ,CAAC"}
@@ -1,106 +0,0 @@
1
- /**
2
- * Capability Dispatch Helper for Universal Dispatch
3
- *
4
- * Enables capability dispatch for ALL stdlib actions, not just specialized verbs.
5
- * When an entity's trait declares a capability for an action, the trait's behavior
6
- * handles the action instead of the stdlib default.
7
- *
8
- * This enables patterns like:
9
- * - Troll blocking: TrollTrait handles 'if.action.going' to block passage
10
- * - Custom containers: ChestTrait handles 'if.action.opening' for locked chest
11
- * - Guardian items: AxeTrait handles 'if.action.taking' while troll guards it
12
- *
13
- * Resolution modes (ADR-090 extension):
14
- * - first-wins: First entity with capability determines result
15
- * - any-blocks: Any entity returning valid: false blocks
16
- * - all-must-pass: All entities must return valid: true
17
- * - highest-priority: Only highest priority entity is checked
18
- */
19
- import { ISemanticEvent } from "../../core/dist-npm/src/index";
20
- import { IFEntity, CapabilityBehavior, CapabilitySharedData, ITrait, CapabilityResolution } from "../../world-model/dist-npm/src/index";
21
- import { ActionContext, ValidationResult } from "../../stdlib/dist-npm/src/index";
22
- /**
23
- * A single capability claim from an entity.
24
- */
25
- export interface CapabilityClaim {
26
- /** The entity making the claim */
27
- entity: IFEntity;
28
- /** The trait claiming the capability */
29
- trait: ITrait;
30
- /** The behavior to use */
31
- behavior: CapabilityBehavior;
32
- /** Priority for resolution ordering */
33
- priority: number;
34
- /** Resolution override from binding (if any) */
35
- resolutionOverride?: CapabilityResolution;
36
- }
37
- /**
38
- * Result of checking for capability dispatch.
39
- */
40
- export interface CapabilityDispatchCheck {
41
- /** Whether capability dispatch should be used */
42
- shouldDispatch: boolean;
43
- /** The trait claiming the capability (if found) - for single dispatch */
44
- trait?: ITrait;
45
- /** The behavior to use (if found) - for single dispatch */
46
- behavior?: CapabilityBehavior;
47
- /** The entity with the capability - for single dispatch */
48
- entity?: IFEntity;
49
- /** All claims found (for multi-entity resolution) */
50
- claims?: CapabilityClaim[];
51
- /** Resolution mode to use */
52
- resolution?: CapabilityResolution;
53
- }
54
- /**
55
- * Data stored for capability dispatch between phases.
56
- */
57
- export interface CapabilityDispatchData {
58
- trait: ITrait;
59
- behavior: CapabilityBehavior;
60
- entityId: string;
61
- entityName: string;
62
- sharedData: CapabilitySharedData;
63
- }
64
- /**
65
- * Check if capability dispatch should be used for this action and target.
66
- *
67
- * @param actionId - The action being executed
68
- * @param target - The target entity (directObject) - for backward compatibility
69
- * @returns Check result with trait and behavior if dispatch should be used
70
- */
71
- export declare function checkCapabilityDispatch(actionId: string, target: IFEntity | undefined): CapabilityDispatchCheck;
72
- /**
73
- * Check if capability dispatch should be used for this action across multiple entities.
74
- *
75
- * Collects all capability claims from the provided entities, sorts by priority,
76
- * and returns the appropriate dispatch information based on resolution config.
77
- *
78
- * @param actionId - The action being executed
79
- * @param entities - All entities involved in the action (directObject, indirectObject, etc.)
80
- * @returns Check result with claims and resolution mode
81
- */
82
- export declare function checkCapabilityDispatchMulti(actionId: string, entities: (IFEntity | undefined)[]): CapabilityDispatchCheck;
83
- /**
84
- * Execute capability dispatch validation phase.
85
- *
86
- * Handles resolution modes:
87
- * - first-wins/highest-priority: Single behavior validates
88
- * - any-blocks: All behaviors validate, any false blocks
89
- * - all-must-pass: All behaviors must return true
90
- *
91
- * @returns ValidationResult with dispatch data if valid
92
- */
93
- export declare function executeCapabilityValidate(check: CapabilityDispatchCheck, context: ActionContext): ValidationResult;
94
- /**
95
- * Execute capability dispatch execute phase.
96
- */
97
- export declare function executeCapabilityExecute(context: ActionContext): void;
98
- /**
99
- * Execute capability dispatch report phase.
100
- */
101
- export declare function executeCapabilityReport(context: ActionContext): ISemanticEvent[];
102
- /**
103
- * Execute capability dispatch blocked phase.
104
- */
105
- export declare function executeCapabilityBlocked(context: ActionContext, result: ValidationResult, actionId: string): ISemanticEvent[];
106
- //# sourceMappingURL=capability-dispatch-helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capability-dispatch-helper.d.ts","sourceRoot":"","sources":["../../../../src/capability-dispatch-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,QAAQ,EAKR,kBAAkB,EAClB,oBAAoB,EAEpB,MAAM,EAEN,oBAAoB,EACrB,MAAM,sBAAs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