@sharpee/stdlib 2.2.0 → 3.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.
- package/actions/base/snapshot-utils.js +2 -2
- package/actions/base/snapshot-utils.js.map +1 -1
- package/actions/constants.d.ts +2 -0
- package/actions/constants.d.ts.map +1 -1
- package/actions/constants.js +3 -0
- package/actions/constants.js.map +1 -1
- package/actions/index.d.ts +2 -0
- package/actions/index.d.ts.map +1 -1
- package/actions/index.js +6 -0
- package/actions/index.js.map +1 -1
- package/actions/lifecycle/descriptor.d.ts +111 -0
- package/actions/lifecycle/descriptor.d.ts.map +1 -0
- package/actions/lifecycle/descriptor.js +22 -0
- package/actions/lifecycle/descriptor.js.map +1 -0
- package/actions/lifecycle/index.d.ts +14 -0
- package/actions/lifecycle/index.d.ts.map +1 -0
- package/actions/lifecycle/index.js +27 -0
- package/actions/lifecycle/index.js.map +1 -0
- package/actions/lifecycle/lifecycle-engine.d.ts +173 -0
- package/actions/lifecycle/lifecycle-engine.d.ts.map +1 -0
- package/actions/lifecycle/lifecycle-engine.js +247 -0
- package/actions/lifecycle/lifecycle-engine.js.map +1 -0
- package/actions/lifecycle/multi-object-lifecycle.d.ts +105 -0
- package/actions/lifecycle/multi-object-lifecycle.d.ts.map +1 -0
- package/actions/lifecycle/multi-object-lifecycle.js +136 -0
- package/actions/lifecycle/multi-object-lifecycle.js.map +1 -0
- package/actions/lifecycle/registry.d.ts +39 -0
- package/actions/lifecycle/registry.d.ts.map +1 -0
- package/actions/lifecycle/registry.js +128 -0
- package/actions/lifecycle/registry.js.map +1 -0
- package/actions/standard/asking/asking.d.ts +25 -0
- package/actions/standard/asking/asking.d.ts.map +1 -0
- package/actions/standard/asking/asking.js +114 -0
- package/actions/standard/asking/asking.js.map +1 -0
- package/actions/standard/asking/index.d.ts +5 -0
- package/actions/standard/asking/index.d.ts.map +1 -0
- package/actions/standard/asking/index.js +10 -0
- package/actions/standard/asking/index.js.map +1 -0
- package/actions/standard/attacking/attacking.d.ts +14 -0
- package/actions/standard/attacking/attacking.d.ts.map +1 -1
- package/actions/standard/attacking/attacking.js +138 -94
- package/actions/standard/attacking/attacking.js.map +1 -1
- package/actions/standard/attacking/index.d.ts +1 -1
- package/actions/standard/attacking/index.d.ts.map +1 -1
- package/actions/standard/attacking/index.js +2 -1
- package/actions/standard/attacking/index.js.map +1 -1
- package/actions/standard/climbing/climbing.d.ts +10 -0
- package/actions/standard/climbing/climbing.d.ts.map +1 -1
- package/actions/standard/climbing/climbing.js +51 -11
- package/actions/standard/climbing/climbing.js.map +1 -1
- package/actions/standard/closing/closing.d.ts +6 -0
- package/actions/standard/closing/closing.d.ts.map +1 -1
- package/actions/standard/closing/closing.js +37 -31
- package/actions/standard/closing/closing.js.map +1 -1
- package/actions/standard/cutting/cutting-messages.d.ts +17 -0
- package/actions/standard/cutting/cutting-messages.d.ts.map +1 -0
- package/actions/standard/cutting/cutting-messages.js +22 -0
- package/actions/standard/cutting/cutting-messages.js.map +1 -0
- package/actions/standard/cutting/cutting.d.ts +35 -0
- package/actions/standard/cutting/cutting.d.ts.map +1 -0
- package/actions/standard/cutting/cutting.js +228 -0
- package/actions/standard/cutting/cutting.js.map +1 -0
- package/actions/standard/cutting/index.d.ts +7 -0
- package/actions/standard/cutting/index.d.ts.map +1 -0
- package/actions/standard/cutting/index.js +12 -0
- package/actions/standard/cutting/index.js.map +1 -0
- package/actions/standard/deadly-room-death/deadly-room-death.d.ts +16 -0
- package/actions/standard/deadly-room-death/deadly-room-death.d.ts.map +1 -0
- package/actions/standard/deadly-room-death/deadly-room-death.js +44 -0
- package/actions/standard/deadly-room-death/deadly-room-death.js.map +1 -0
- package/actions/standard/deadly-room-death/index.d.ts +2 -0
- package/actions/standard/deadly-room-death/index.d.ts.map +1 -0
- package/actions/standard/deadly-room-death/index.js +6 -0
- package/actions/standard/deadly-room-death/index.js.map +1 -0
- package/actions/standard/digging/digging-messages.d.ts +17 -0
- package/actions/standard/digging/digging-messages.d.ts.map +1 -0
- package/actions/standard/digging/digging-messages.js +22 -0
- package/actions/standard/digging/digging-messages.js.map +1 -0
- package/actions/standard/digging/digging.d.ts +35 -0
- package/actions/standard/digging/digging.d.ts.map +1 -0
- package/actions/standard/digging/digging.js +228 -0
- package/actions/standard/digging/digging.js.map +1 -0
- package/actions/standard/digging/index.d.ts +7 -0
- package/actions/standard/digging/index.d.ts.map +1 -0
- package/actions/standard/digging/index.js +12 -0
- package/actions/standard/digging/index.js.map +1 -0
- package/actions/standard/drinking/drinking.d.ts +9 -0
- package/actions/standard/drinking/drinking.d.ts.map +1 -1
- package/actions/standard/drinking/drinking.js +40 -2
- package/actions/standard/drinking/drinking.js.map +1 -1
- package/actions/standard/dropping/dropping-types.d.ts +10 -18
- package/actions/standard/dropping/dropping-types.d.ts.map +1 -1
- package/actions/standard/dropping/dropping-types.js.map +1 -1
- package/actions/standard/dropping/dropping.d.ts +6 -0
- package/actions/standard/dropping/dropping.d.ts.map +1 -1
- package/actions/standard/dropping/dropping.js +86 -108
- package/actions/standard/dropping/dropping.js.map +1 -1
- package/actions/standard/eating/eating.d.ts +9 -0
- package/actions/standard/eating/eating.d.ts.map +1 -1
- package/actions/standard/eating/eating.js +40 -2
- package/actions/standard/eating/eating.js.map +1 -1
- package/actions/standard/entering/entering.d.ts +14 -5
- package/actions/standard/entering/entering.d.ts.map +1 -1
- package/actions/standard/entering/entering.js +45 -67
- package/actions/standard/entering/entering.js.map +1 -1
- package/actions/standard/examining/examining.d.ts +6 -0
- package/actions/standard/examining/examining.d.ts.map +1 -1
- package/actions/standard/examining/examining.js +39 -3
- package/actions/standard/examining/examining.js.map +1 -1
- package/actions/standard/exiting/exiting.d.ts +6 -0
- package/actions/standard/exiting/exiting.d.ts.map +1 -1
- package/actions/standard/exiting/exiting.js +54 -3
- package/actions/standard/exiting/exiting.js.map +1 -1
- package/actions/standard/giving/giving.d.ts +21 -0
- package/actions/standard/giving/giving.d.ts.map +1 -1
- package/actions/standard/giving/giving.js +78 -2
- package/actions/standard/giving/giving.js.map +1 -1
- package/actions/standard/going/going.d.ts +10 -16
- package/actions/standard/going/going.d.ts.map +1 -1
- package/actions/standard/going/going.js +134 -140
- package/actions/standard/going/going.js.map +1 -1
- package/actions/standard/hiding/hiding.d.ts +10 -1
- package/actions/standard/hiding/hiding.d.ts.map +1 -1
- package/actions/standard/hiding/hiding.js +43 -4
- package/actions/standard/hiding/hiding.js.map +1 -1
- package/actions/standard/index.d.ts +5 -0
- package/actions/standard/index.d.ts.map +1 -1
- package/actions/standard/index.js +19 -4
- package/actions/standard/index.js.map +1 -1
- package/actions/standard/inserting/inserting.d.ts +12 -0
- package/actions/standard/inserting/inserting.d.ts.map +1 -1
- package/actions/standard/inserting/inserting.js +70 -5
- package/actions/standard/inserting/inserting.js.map +1 -1
- package/actions/standard/listening/listening.d.ts +12 -1
- package/actions/standard/listening/listening.d.ts.map +1 -1
- package/actions/standard/listening/listening.js +45 -4
- package/actions/standard/listening/listening.js.map +1 -1
- package/actions/standard/locking/locking.d.ts +9 -0
- package/actions/standard/locking/locking.d.ts.map +1 -1
- package/actions/standard/locking/locking.js +62 -3
- package/actions/standard/locking/locking.js.map +1 -1
- package/actions/standard/looking/index.d.ts +1 -0
- package/actions/standard/looking/index.d.ts.map +1 -1
- package/actions/standard/looking/index.js +5 -1
- package/actions/standard/looking/index.js.map +1 -1
- package/actions/standard/looking/snippet-gate-registry.d.ts +55 -0
- package/actions/standard/looking/snippet-gate-registry.d.ts.map +1 -0
- package/actions/standard/looking/snippet-gate-registry.js +63 -0
- package/actions/standard/looking/snippet-gate-registry.js.map +1 -0
- package/actions/standard/looking/snippet-resolver.d.ts +9 -3
- package/actions/standard/looking/snippet-resolver.d.ts.map +1 -1
- package/actions/standard/looking/snippet-resolver.js +75 -4
- package/actions/standard/looking/snippet-resolver.js.map +1 -1
- package/actions/standard/opening/opening-messages.d.ts +3 -0
- package/actions/standard/opening/opening-messages.d.ts.map +1 -1
- package/actions/standard/opening/opening-messages.js +4 -0
- package/actions/standard/opening/opening-messages.js.map +1 -1
- package/actions/standard/opening/opening.d.ts +8 -0
- package/actions/standard/opening/opening.d.ts.map +1 -1
- package/actions/standard/opening/opening.js +73 -39
- package/actions/standard/opening/opening.js.map +1 -1
- package/actions/standard/pulling/pulling.d.ts +9 -0
- package/actions/standard/pulling/pulling.d.ts.map +1 -1
- package/actions/standard/pulling/pulling.js +40 -2
- package/actions/standard/pulling/pulling.js.map +1 -1
- package/actions/standard/pushing/pushing-types.d.ts +3 -6
- package/actions/standard/pushing/pushing-types.d.ts.map +1 -1
- package/actions/standard/pushing/pushing-types.js +3 -1
- package/actions/standard/pushing/pushing-types.js.map +1 -1
- package/actions/standard/pushing/pushing.d.ts +14 -5
- package/actions/standard/pushing/pushing.d.ts.map +1 -1
- package/actions/standard/pushing/pushing.js +51 -71
- package/actions/standard/pushing/pushing.js.map +1 -1
- package/actions/standard/putting/putting-types.d.ts +10 -21
- package/actions/standard/putting/putting-types.d.ts.map +1 -1
- package/actions/standard/putting/putting-types.js +0 -1
- package/actions/standard/putting/putting-types.js.map +1 -1
- package/actions/standard/putting/putting.d.ts +10 -0
- package/actions/standard/putting/putting.d.ts.map +1 -1
- package/actions/standard/putting/putting.js +133 -151
- package/actions/standard/putting/putting.js.map +1 -1
- package/actions/standard/reading/reading.d.ts +6 -0
- package/actions/standard/reading/reading.d.ts.map +1 -1
- package/actions/standard/reading/reading.js +39 -3
- package/actions/standard/reading/reading.js.map +1 -1
- package/actions/standard/removing/removing-types.d.ts +10 -16
- package/actions/standard/removing/removing-types.d.ts.map +1 -1
- package/actions/standard/removing/removing-types.js.map +1 -1
- package/actions/standard/removing/removing.d.ts +13 -0
- package/actions/standard/removing/removing.d.ts.map +1 -1
- package/actions/standard/removing/removing.js +147 -88
- package/actions/standard/removing/removing.js.map +1 -1
- package/actions/standard/searching/searching.d.ts +10 -0
- package/actions/standard/searching/searching.d.ts.map +1 -1
- package/actions/standard/searching/searching.js +44 -8
- package/actions/standard/searching/searching.js.map +1 -1
- package/actions/standard/showing/showing.d.ts +14 -0
- package/actions/standard/showing/showing.d.ts.map +1 -1
- package/actions/standard/showing/showing.js +62 -2
- package/actions/standard/showing/showing.js.map +1 -1
- package/actions/standard/smelling/smelling.d.ts +10 -0
- package/actions/standard/smelling/smelling.d.ts.map +1 -1
- package/actions/standard/smelling/smelling.js +41 -2
- package/actions/standard/smelling/smelling.js.map +1 -1
- package/actions/standard/switching_off/switching_off.d.ts +11 -1
- package/actions/standard/switching_off/switching_off.d.ts.map +1 -1
- package/actions/standard/switching_off/switching_off.js +44 -4
- package/actions/standard/switching_off/switching_off.js.map +1 -1
- package/actions/standard/switching_on/switching_on.d.ts +14 -5
- package/actions/standard/switching_on/switching_on.d.ts.map +1 -1
- package/actions/standard/switching_on/switching_on.js +45 -57
- package/actions/standard/switching_on/switching_on.js.map +1 -1
- package/actions/standard/taking/taking-types.d.ts +14 -32
- package/actions/standard/taking/taking-types.d.ts.map +1 -1
- package/actions/standard/taking/taking-types.js.map +1 -1
- package/actions/standard/taking/taking.d.ts +11 -0
- package/actions/standard/taking/taking.d.ts.map +1 -1
- package/actions/standard/taking/taking.js +107 -111
- package/actions/standard/taking/taking.js.map +1 -1
- package/actions/standard/taking_off/taking-off.d.ts +6 -0
- package/actions/standard/taking_off/taking-off.d.ts.map +1 -1
- package/actions/standard/taking_off/taking-off.js +57 -21
- package/actions/standard/taking_off/taking-off.js.map +1 -1
- package/actions/standard/talking/talking.d.ts +15 -0
- package/actions/standard/talking/talking.d.ts.map +1 -1
- package/actions/standard/talking/talking.js +52 -3
- package/actions/standard/talking/talking.js.map +1 -1
- package/actions/standard/telling/index.d.ts +5 -0
- package/actions/standard/telling/index.d.ts.map +1 -0
- package/actions/standard/telling/index.js +10 -0
- package/actions/standard/telling/index.js.map +1 -0
- package/actions/standard/telling/telling.d.ts +25 -0
- package/actions/standard/telling/telling.d.ts.map +1 -0
- package/actions/standard/telling/telling.js +114 -0
- package/actions/standard/telling/telling.js.map +1 -0
- package/actions/standard/throwing/throwing.d.ts +11 -0
- package/actions/standard/throwing/throwing.d.ts.map +1 -1
- package/actions/standard/throwing/throwing.js +69 -70
- package/actions/standard/throwing/throwing.js.map +1 -1
- package/actions/standard/tool-shared.d.ts +38 -0
- package/actions/standard/tool-shared.d.ts.map +1 -0
- package/actions/standard/tool-shared.js +74 -0
- package/actions/standard/tool-shared.js.map +1 -0
- package/actions/standard/touching/touching.d.ts +9 -0
- package/actions/standard/touching/touching.d.ts.map +1 -1
- package/actions/standard/touching/touching.js +40 -4
- package/actions/standard/touching/touching.js.map +1 -1
- package/actions/standard/turning/index.d.ts +5 -0
- package/actions/standard/turning/index.d.ts.map +1 -0
- package/actions/standard/turning/index.js +9 -0
- package/actions/standard/turning/index.js.map +1 -0
- package/actions/standard/turning/turning.d.ts +17 -0
- package/actions/standard/turning/turning.d.ts.map +1 -0
- package/actions/standard/turning/turning.js +25 -0
- package/actions/standard/turning/turning.js.map +1 -0
- package/actions/standard/unlocking/unlocking.d.ts +9 -0
- package/actions/standard/unlocking/unlocking.d.ts.map +1 -1
- package/actions/standard/unlocking/unlocking.js +62 -3
- package/actions/standard/unlocking/unlocking.js.map +1 -1
- package/actions/standard/wearing/wearing.d.ts +11 -1
- package/actions/standard/wearing/wearing.d.ts.map +1 -1
- package/actions/standard/wearing/wearing.js +57 -12
- package/actions/standard/wearing/wearing.js.map +1 -1
- package/channels/standard.d.ts +13 -10
- package/channels/standard.d.ts.map +1 -1
- package/channels/standard.js +14 -10
- package/channels/standard.js.map +1 -1
- package/death/deadly-room-transformer.d.ts +37 -0
- package/death/deadly-room-transformer.d.ts.map +1 -0
- package/death/deadly-room-transformer.js +79 -0
- package/death/deadly-room-transformer.js.map +1 -0
- package/death/index.d.ts +18 -0
- package/death/index.d.ts.map +1 -0
- package/death/index.js +28 -0
- package/death/index.js.map +1 -0
- package/death/kill-player.d.ts +49 -0
- package/death/kill-player.d.ts.map +1 -0
- package/death/kill-player.js +55 -0
- package/death/kill-player.js.map +1 -0
- package/death/player-death-events.d.ts +40 -0
- package/death/player-death-events.d.ts.map +1 -0
- package/death/player-death-events.js +27 -0
- package/death/player-death-events.js.map +1 -0
- package/death/probabilistic-death.d.ts +23 -0
- package/death/probabilistic-death.d.ts.map +1 -0
- package/death/probabilistic-death.js +27 -0
- package/death/probabilistic-death.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/npc/behaviors.d.ts.map +1 -1
- package/npc/behaviors.js +9 -8
- package/npc/behaviors.js.map +1 -1
- package/npc/npc-service.d.ts +8 -0
- package/npc/npc-service.d.ts.map +1 -1
- package/npc/npc-service.js +19 -18
- package/npc/npc-service.js.map +1 -1
- package/package.json +7 -7
|
@@ -8,15 +8,35 @@
|
|
|
8
8
|
* Uses four-phase pattern:
|
|
9
9
|
* 1. validate: Always succeeds (no preconditions for listening)
|
|
10
10
|
* 2. execute: Analyze sounds (no world mutations)
|
|
11
|
-
* 3. blocked: Handle validation failures (
|
|
11
|
+
* 3. blocked: Handle validation failures (only interceptor vetoes)
|
|
12
12
|
* 4. report: Emit listened event and success message
|
|
13
|
+
*
|
|
14
|
+
* Interceptor consultation (ADR-118) runs through the shared lifecycle
|
|
15
|
+
* engine (ADR-228) via `listeningLifecycle` — no hand-rolled hook plumbing.
|
|
13
16
|
*/
|
|
14
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.listeningAction = void 0;
|
|
18
|
+
exports.listeningAction = exports.listeningLifecycle = void 0;
|
|
16
19
|
const world_model_1 = require("@sharpee/world-model");
|
|
17
20
|
const constants_1 = require("../../constants");
|
|
18
21
|
const scope_1 = require("../../../scope");
|
|
19
22
|
const utils_1 = require("../../../utils");
|
|
23
|
+
const lifecycle_1 = require("../../lifecycle");
|
|
24
|
+
/**
|
|
25
|
+
* Interceptor surface (ADR-228): the listened-to target is the only
|
|
26
|
+
* consultable entity of a LISTEN command. Listening to the environment
|
|
27
|
+
* ("listen") has no direct object, so the slot resolves to undefined —
|
|
28
|
+
* zero consultations.
|
|
29
|
+
*/
|
|
30
|
+
exports.listeningLifecycle = {
|
|
31
|
+
actionId: constants_1.IFActions.LISTENING,
|
|
32
|
+
slots: [
|
|
33
|
+
{
|
|
34
|
+
id: 'target',
|
|
35
|
+
actionIds: [constants_1.IFActions.LISTENING],
|
|
36
|
+
resolve: (ctx) => ctx.command.directObject?.entity
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
};
|
|
20
40
|
function getListeningSharedData(context) {
|
|
21
41
|
return context.sharedData;
|
|
22
42
|
}
|
|
@@ -125,7 +145,15 @@ exports.listeningAction = {
|
|
|
125
145
|
directObjectScope: scope_1.ScopeLevel.AWARE
|
|
126
146
|
},
|
|
127
147
|
validate(context) {
|
|
128
|
-
|
|
148
|
+
const state = (0, lifecycle_1.resolveLifecycle)(context, exports.listeningLifecycle);
|
|
149
|
+
const preVeto = (0, lifecycle_1.runPreValidate)(context, state);
|
|
150
|
+
if (preVeto)
|
|
151
|
+
return preVeto;
|
|
152
|
+
// Listening always succeeds - no standard preconditions.
|
|
153
|
+
// Canonical placement (ADR-228): postValidate runs after ALL standard validation
|
|
154
|
+
const postVeto = (0, lifecycle_1.runPostValidate)(context, state);
|
|
155
|
+
if (postVeto)
|
|
156
|
+
return postVeto;
|
|
129
157
|
return { valid: true };
|
|
130
158
|
},
|
|
131
159
|
execute(context) {
|
|
@@ -136,11 +164,15 @@ exports.listeningAction = {
|
|
|
136
164
|
sharedData.messageId = analysis.messageId;
|
|
137
165
|
sharedData.params = analysis.params;
|
|
138
166
|
sharedData.eventData = analysis.eventData;
|
|
167
|
+
const state = (0, lifecycle_1.getLifecycleState)(context);
|
|
168
|
+
if (state)
|
|
169
|
+
(0, lifecycle_1.runPostExecute)(context, state);
|
|
139
170
|
},
|
|
140
171
|
blocked(context, result) {
|
|
141
172
|
// Listening always succeeds, but include blocked for consistency
|
|
173
|
+
// (interceptor preValidate/postValidate vetoes land here)
|
|
142
174
|
const target = context.command.directObject?.entity;
|
|
143
|
-
|
|
175
|
+
const events = [context.event('if.event.listen_blocked', {
|
|
144
176
|
blocked: true,
|
|
145
177
|
messageId: `${context.action.id}.${result.error}`,
|
|
146
178
|
// params carry EntityInfo for the formatter chain (ADR-158)
|
|
@@ -152,6 +184,12 @@ exports.listeningAction = {
|
|
|
152
184
|
targetId: target?.id,
|
|
153
185
|
targetName: target?.name
|
|
154
186
|
})];
|
|
187
|
+
if (result.error) {
|
|
188
|
+
const state = (0, lifecycle_1.getLifecycleState)(context);
|
|
189
|
+
if (state)
|
|
190
|
+
(0, lifecycle_1.runOnBlocked)(context, state, events, 'if.event.listen_blocked', result.error);
|
|
191
|
+
}
|
|
192
|
+
return events;
|
|
155
193
|
},
|
|
156
194
|
report(context) {
|
|
157
195
|
const events = [];
|
|
@@ -162,6 +200,9 @@ exports.listeningAction = {
|
|
|
162
200
|
params: sharedData.params,
|
|
163
201
|
...sharedData.eventData
|
|
164
202
|
}));
|
|
203
|
+
const state = (0, lifecycle_1.getLifecycleState)(context);
|
|
204
|
+
if (state)
|
|
205
|
+
(0, lifecycle_1.runPostReport)(context, state, events, 'if.event.listened');
|
|
165
206
|
return events;
|
|
166
207
|
}
|
|
167
208
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listening.js","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/listening/listening.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"listening.js","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/listening/listening.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAKH,sDAA8D;AAC9D,+CAA4C;AAC5C,0CAA4C;AAE5C,0CAA+C;AAC/C,+CASyB;AAEzB;;;;;GAKG;AACU,QAAA,kBAAkB,GAA8B;IAC3D,QAAQ,EAAE,qBAAS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{ Action } from '../../enhanced-types';
|
|
13
13
|
import { ActionMetadata } from '../../../validation';
|
|
14
|
+
import { ActionLifecycleDescriptor } from '../../lifecycle';
|
|
15
|
+
/**
|
|
16
|
+
* Interceptor surface (ADR-228/229 R2): the locked target and the
|
|
17
|
+
* explicit key are the consultable entities of a LOCK command,
|
|
18
|
+
* published order target → key (D3-B). Explicit keys only — an
|
|
19
|
+
* auto-inferred key is not a command entity (same documented rule as
|
|
20
|
+
* attacking's inferred weapons). Symmetric seedData mirrors putting.
|
|
21
|
+
*/
|
|
22
|
+
export declare const lockingLifecycle: ActionLifecycleDescriptor;
|
|
14
23
|
export declare const lockingAction: Action & {
|
|
15
24
|
metadata: ActionMetadata;
|
|
16
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locking.d.ts","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/locking/locking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAmC,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"locking.d.ts","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/locking/locking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAmC,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AASrD,OAAO,EACL,yBAAyB,EAQ1B,MAAM,iBAAiB,CAAC;AAEzB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,yBA6B9B,CAAC;AAwBF,eAAO,MAAM,aAAa,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,cAAc,CAAA;CAwP9D,CAAC"}
|
|
@@ -11,13 +11,51 @@
|
|
|
11
11
|
* 3. report: Generate events from sharedData
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.lockingAction = void 0;
|
|
14
|
+
exports.lockingAction = exports.lockingLifecycle = void 0;
|
|
15
15
|
const world_model_1 = require("@sharpee/world-model");
|
|
16
16
|
const constants_1 = require("../../constants");
|
|
17
17
|
const scope_1 = require("../../../scope");
|
|
18
18
|
const lock_shared_1 = require("../lock-shared");
|
|
19
19
|
const locking_messages_1 = require("./locking-messages");
|
|
20
20
|
const utils_1 = require("../../../utils");
|
|
21
|
+
const lifecycle_1 = require("../../lifecycle");
|
|
22
|
+
/**
|
|
23
|
+
* Interceptor surface (ADR-228/229 R2): the locked target and the
|
|
24
|
+
* explicit key are the consultable entities of a LOCK command,
|
|
25
|
+
* published order target → key (D3-B). Explicit keys only — an
|
|
26
|
+
* auto-inferred key is not a command entity (same documented rule as
|
|
27
|
+
* attacking's inferred weapons). Symmetric seedData mirrors putting.
|
|
28
|
+
*/
|
|
29
|
+
exports.lockingLifecycle = {
|
|
30
|
+
actionId: constants_1.IFActions.LOCKING,
|
|
31
|
+
slots: [
|
|
32
|
+
{
|
|
33
|
+
id: 'target',
|
|
34
|
+
actionIds: [constants_1.IFActions.LOCKING],
|
|
35
|
+
resolve: (ctx) => ctx.command.directObject?.entity,
|
|
36
|
+
seedData: (ctx, entity) => {
|
|
37
|
+
const key = ctx.command.instrument?.entity ?? ctx.command.indirectObject?.entity;
|
|
38
|
+
return {
|
|
39
|
+
targetId: entity.id,
|
|
40
|
+
targetName: entity.name,
|
|
41
|
+
keyId: key?.id,
|
|
42
|
+
keyName: key?.name
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'key',
|
|
48
|
+
actionIds: [constants_1.IFActions.LOCKING],
|
|
49
|
+
resolve: (ctx) => ctx.command.instrument?.entity ?? ctx.command.indirectObject?.entity,
|
|
50
|
+
seedData: (ctx, entity) => ({
|
|
51
|
+
keyId: entity.id,
|
|
52
|
+
keyName: entity.name,
|
|
53
|
+
targetId: ctx.command.directObject?.entity?.id,
|
|
54
|
+
targetName: ctx.command.directObject?.entity?.name
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
};
|
|
21
59
|
function getLockingSharedData(context) {
|
|
22
60
|
return context.sharedData;
|
|
23
61
|
}
|
|
@@ -56,6 +94,10 @@ exports.lockingAction = {
|
|
|
56
94
|
error: locking_messages_1.MESSAGES.NO_TARGET
|
|
57
95
|
};
|
|
58
96
|
}
|
|
97
|
+
const state = (0, lifecycle_1.resolveLifecycle)(context, exports.lockingLifecycle);
|
|
98
|
+
const preVeto = (0, lifecycle_1.runPreValidate)(context, state);
|
|
99
|
+
if (preVeto)
|
|
100
|
+
return preVeto;
|
|
59
101
|
// Check scope - must be able to reach the target
|
|
60
102
|
const scopeCheck = context.requireScope(noun, scope_1.ScopeLevel.REACHABLE);
|
|
61
103
|
if (!scopeCheck.ok) {
|
|
@@ -92,6 +134,10 @@ exports.lockingAction = {
|
|
|
92
134
|
if (keyValidation) {
|
|
93
135
|
return keyValidation;
|
|
94
136
|
}
|
|
137
|
+
// Canonical placement (ADR-228): postValidate runs after ALL standard validation
|
|
138
|
+
const postVeto = (0, lifecycle_1.runPostValidate)(context, state);
|
|
139
|
+
if (postVeto)
|
|
140
|
+
return postVeto;
|
|
95
141
|
return { valid: true };
|
|
96
142
|
},
|
|
97
143
|
/**
|
|
@@ -163,6 +209,9 @@ exports.lockingAction = {
|
|
|
163
209
|
if (withKey) {
|
|
164
210
|
sharedData.params.key = (0, utils_1.nounPhraseFor)(withKey);
|
|
165
211
|
}
|
|
212
|
+
const state = (0, lifecycle_1.getLifecycleState)(context);
|
|
213
|
+
if (state)
|
|
214
|
+
(0, lifecycle_1.runPostExecute)(context, state);
|
|
166
215
|
},
|
|
167
216
|
/**
|
|
168
217
|
* Report phase - generates events after successful execution
|
|
@@ -184,7 +233,7 @@ exports.lockingAction = {
|
|
|
184
233
|
})];
|
|
185
234
|
}
|
|
186
235
|
// Emit domain event with messageId (simplified pattern - ADR-097)
|
|
187
|
-
|
|
236
|
+
const events = [
|
|
188
237
|
context.event('if.event.locked', {
|
|
189
238
|
// Rendering data (messageId + params for text-service)
|
|
190
239
|
messageId: `${context.action.id}.${sharedData.messageId}`,
|
|
@@ -200,6 +249,10 @@ exports.lockingAction = {
|
|
|
200
249
|
sound: sharedData.sound
|
|
201
250
|
})
|
|
202
251
|
];
|
|
252
|
+
const state = (0, lifecycle_1.getLifecycleState)(context);
|
|
253
|
+
if (state)
|
|
254
|
+
(0, lifecycle_1.runPostReport)(context, state, events, 'if.event.locked');
|
|
255
|
+
return events;
|
|
203
256
|
},
|
|
204
257
|
/**
|
|
205
258
|
* Generate events when validation fails
|
|
@@ -208,7 +261,7 @@ exports.lockingAction = {
|
|
|
208
261
|
*/
|
|
209
262
|
blocked(context, result) {
|
|
210
263
|
const noun = context.command.directObject?.entity;
|
|
211
|
-
|
|
264
|
+
const events = [context.event('if.event.lock_blocked', {
|
|
212
265
|
// Rendering data
|
|
213
266
|
messageId: `${context.action.id}.${result.error}`,
|
|
214
267
|
params: result.params || {},
|
|
@@ -217,6 +270,12 @@ exports.lockingAction = {
|
|
|
217
270
|
targetName: noun?.name,
|
|
218
271
|
reason: result.error
|
|
219
272
|
})];
|
|
273
|
+
if (result.error) {
|
|
274
|
+
const state = (0, lifecycle_1.getLifecycleState)(context);
|
|
275
|
+
if (state)
|
|
276
|
+
(0, lifecycle_1.runOnBlocked)(context, state, events, 'if.event.lock_blocked', result.error);
|
|
277
|
+
}
|
|
278
|
+
return events;
|
|
220
279
|
},
|
|
221
280
|
metadata: {
|
|
222
281
|
requiresDirectObject: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locking.js","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/locking/locking.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAKH,sDAAkG;AAClG,+CAA4C;AAC5C,0CAA4C;AAE5C,gDAAmG;AACnG,yDAA8C;AAC9C,0CAA+C;
|
|
1
|
+
{"version":3,"file":"locking.js","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/locking/locking.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAKH,sDAAkG;AAClG,+CAA4C;AAC5C,0CAA4C;AAE5C,gDAAmG;AACnG,yDAA8C;AAC9C,0CAA+C;AAC/C,+CASyB;AAEzB;;;;;;GAMG;AACU,QAAA,gBAAgB,GAA8B;IACzD,QAAQ,EAAE,qBAAS,CAAC,OAAO;IAC3B,KAAK,EAAE;QACL;YACE,EAAE,EAAE,QAAQ;YACZ,SAAS,EAAE,CAAC,qBAAS,CAAC,OAAO,CAAC;YAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM;YAClD,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;gBACxB,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC;gBACjF,OAAO;oBACL,QAAQ,EAAE,MAAM,CAAC,EAAE;oBACnB,UAAU,EAAE,MAAM,CAAC,IAAI;oBACvB,KAAK,EAAE,GAAG,EAAE,EAAE;oBACd,OAAO,EAAE,GAAG,EAAE,IAAI;iBACnB,CAAC;YACJ,CAAC;SACF;QACD;YACE,EAAE,EAAE,KAAK;YACT,SAAS,EAAE,CAAC,qBAAS,CAAC,OAAO,CAAC;YAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,MAAM;YACtF,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,E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CAAC,KAAK,CAAC,CAAC;QACzF,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,QAAQ,EAAE;QACR,oBAAoB,EAAE,IAAI;QAC1B,sBAAsB,EAAE,KAAK;QAC7B,iBAAiB,EAAE,kBAAU,CAAC,SAAS;KACxC;CACF,CAAC"}
|
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
export { lookingAction } from './looking';
|
|
6
6
|
export * from './looking-events';
|
|
7
7
|
export { resolveSnippetDescription, SnippetWorldQueries } from './snippet-resolver';
|
|
8
|
+
export { registerSnippetGate, lookupSnippetGate, clearSnippetGates, SnippetGate, } from './snippet-gate-registry';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/looking/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/looking/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACpF,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,GACZ,MAAM,yBAAyB,CAAC"}
|
|
@@ -18,10 +18,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.resolveSnippetDescription = exports.lookingAction = void 0;
|
|
21
|
+
exports.clearSnippetGates = exports.lookupSnippetGate = exports.registerSnippetGate = exports.resolveSnippetDescription = exports.lookingAction = void 0;
|
|
22
22
|
var looking_1 = require("./looking");
|
|
23
23
|
Object.defineProperty(exports, "lookingAction", { enumerable: true, get: function () { return looking_1.lookingAction; } });
|
|
24
24
|
__exportStar(require("./looking-events"), exports);
|
|
25
25
|
var snippet_resolver_1 = require("./snippet-resolver");
|
|
26
26
|
Object.defineProperty(exports, "resolveSnippetDescription", { enumerable: true, get: function () { return snippet_resolver_1.resolveSnippetDescription; } });
|
|
27
|
+
var snippet_gate_registry_1 = require("./snippet-gate-registry");
|
|
28
|
+
Object.defineProperty(exports, "registerSnippetGate", { enumerable: true, get: function () { return snippet_gate_registry_1.registerSnippetGate; } });
|
|
29
|
+
Object.defineProperty(exports, "lookupSnippetGate", { enumerable: true, get: function () { return snippet_gate_registry_1.lookupSnippetGate; } });
|
|
30
|
+
Object.defineProperty(exports, "clearSnippetGates", { enumerable: true, get: function () { return snippet_gate_registry_1.clearSnippetGates; } });
|
|
27
31
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/looking/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,mDAAiC;AACjC,uDAAoF;AAA3E,6HAAA,yBAAyB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/looking/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,mDAAiC;AACjC,uDAAoF;AAA3E,6HAAA,yBAAyB,OAAA;AAClC,iEAKiC;AAJ/B,4HAAA,mBAAmB,OAAA;AACnB,0HAAA,iBAAiB,OAAA;AACjB,0HAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registered snippet-gate seam (ADR-211 Decision 3 / Q4) — non-presence
|
|
3
|
+
* `while` conditions on description fragments.
|
|
4
|
+
*
|
|
5
|
+
* Purpose: presence gates compile to serializable `mentions` data; every OTHER
|
|
6
|
+
* fragment condition is a predicate only its owning runtime (the Chord loader,
|
|
7
|
+
* package 2) can evaluate. This registry is the seam between the two: the
|
|
8
|
+
* runtime registers a thunk per `(roomId, marker)` at story load, and the
|
|
9
|
+
* snippet resolver consults it alongside — never replacing — the `mentions`
|
|
10
|
+
* data gate.
|
|
11
|
+
*
|
|
12
|
+
* Public interface: `registerSnippetGate`, `clearSnippetGates` (loader/test
|
|
13
|
+
* lifecycle), `lookupSnippetGate` (the resolver's read side).
|
|
14
|
+
*
|
|
15
|
+
* Owner context: `@sharpee/stdlib` — stdlib owns the scan and the gate
|
|
16
|
+
* (ADR-209 boundary resolution); this file sits beside `snippet-resolver.ts`,
|
|
17
|
+
* its one consumer. Modeled on the world-model state-clauses registry SHAPE
|
|
18
|
+
* (Map-based, idempotent-last-wins) with its own keying and lifecycle.
|
|
19
|
+
*
|
|
20
|
+
* LIFECYCLE CONTRACT (Q4): nothing here is serialized — a gate is a live
|
|
21
|
+
* closure and never touches a save file. Callers re-register every story load;
|
|
22
|
+
* that is what makes save/restore a non-event for gated fragments (the loader
|
|
23
|
+
* re-registers on the fresh process's load, and an in-game RESTORE reuses the
|
|
24
|
+
* registrations already in place). A story switch in one process clears first.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* A registered fragment gate: returns true while the fragment may render.
|
|
28
|
+
* A thunk, not a world-taking function — the registering runtime closes over
|
|
29
|
+
* its own world access and condition evaluator.
|
|
30
|
+
*/
|
|
31
|
+
export type SnippetGate = () => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Register (or replace) the gate for one `(roomId, marker)` site. Idempotent —
|
|
34
|
+
* the latest registration wins, so a loader re-registering on a fresh load is
|
|
35
|
+
* a no-op rather than a stack of stale closures.
|
|
36
|
+
*
|
|
37
|
+
* @param roomId the room whose description carries the marker
|
|
38
|
+
* @param marker the marker name inside that room's description
|
|
39
|
+
* @param gate returns true while the fragment may render
|
|
40
|
+
*/
|
|
41
|
+
export declare function registerSnippetGate(roomId: string, marker: string, gate: SnippetGate): void;
|
|
42
|
+
/**
|
|
43
|
+
* The resolver's read side: the registered gate for a site, if any.
|
|
44
|
+
*
|
|
45
|
+
* @param roomId the room being resolved
|
|
46
|
+
* @param marker the marker being resolved
|
|
47
|
+
* @returns the gate, or undefined when the site is ungated (the common case)
|
|
48
|
+
*/
|
|
49
|
+
export declare function lookupSnippetGate(roomId: string, marker: string): SnippetGate | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Drop every registration — for tests and for a same-process story switch
|
|
52
|
+
* (a new story's load must not inherit another story's gates).
|
|
53
|
+
*/
|
|
54
|
+
export declare function clearSnippetGates(): void;
|
|
55
|
+
//# sourceMappingURL=snippet-gate-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet-gate-registry.d.ts","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/looking/snippet-gate-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC;AAOxC;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAE3F;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEzF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Registered snippet-gate seam (ADR-211 Decision 3 / Q4) — non-presence
|
|
4
|
+
* `while` conditions on description fragments.
|
|
5
|
+
*
|
|
6
|
+
* Purpose: presence gates compile to serializable `mentions` data; every OTHER
|
|
7
|
+
* fragment condition is a predicate only its owning runtime (the Chord loader,
|
|
8
|
+
* package 2) can evaluate. This registry is the seam between the two: the
|
|
9
|
+
* runtime registers a thunk per `(roomId, marker)` at story load, and the
|
|
10
|
+
* snippet resolver consults it alongside — never replacing — the `mentions`
|
|
11
|
+
* data gate.
|
|
12
|
+
*
|
|
13
|
+
* Public interface: `registerSnippetGate`, `clearSnippetGates` (loader/test
|
|
14
|
+
* lifecycle), `lookupSnippetGate` (the resolver's read side).
|
|
15
|
+
*
|
|
16
|
+
* Owner context: `@sharpee/stdlib` — stdlib owns the scan and the gate
|
|
17
|
+
* (ADR-209 boundary resolution); this file sits beside `snippet-resolver.ts`,
|
|
18
|
+
* its one consumer. Modeled on the world-model state-clauses registry SHAPE
|
|
19
|
+
* (Map-based, idempotent-last-wins) with its own keying and lifecycle.
|
|
20
|
+
*
|
|
21
|
+
* LIFECYCLE CONTRACT (Q4): nothing here is serialized — a gate is a live
|
|
22
|
+
* closure and never touches a save file. Callers re-register every story load;
|
|
23
|
+
* that is what makes save/restore a non-event for gated fragments (the loader
|
|
24
|
+
* re-registers on the fresh process's load, and an in-game RESTORE reuses the
|
|
25
|
+
* registrations already in place). A story switch in one process clears first.
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.registerSnippetGate = registerSnippetGate;
|
|
29
|
+
exports.lookupSnippetGate = lookupSnippetGate;
|
|
30
|
+
exports.clearSnippetGates = clearSnippetGates;
|
|
31
|
+
/** `(roomId, marker)` → gate. The `\0` join cannot collide with entity ids. */
|
|
32
|
+
const gates = new Map();
|
|
33
|
+
const keyOf = (roomId, marker) => `${roomId}\0${marker}`;
|
|
34
|
+
/**
|
|
35
|
+
* Register (or replace) the gate for one `(roomId, marker)` site. Idempotent —
|
|
36
|
+
* the latest registration wins, so a loader re-registering on a fresh load is
|
|
37
|
+
* a no-op rather than a stack of stale closures.
|
|
38
|
+
*
|
|
39
|
+
* @param roomId the room whose description carries the marker
|
|
40
|
+
* @param marker the marker name inside that room's description
|
|
41
|
+
* @param gate returns true while the fragment may render
|
|
42
|
+
*/
|
|
43
|
+
function registerSnippetGate(roomId, marker, gate) {
|
|
44
|
+
gates.set(keyOf(roomId, marker), gate);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The resolver's read side: the registered gate for a site, if any.
|
|
48
|
+
*
|
|
49
|
+
* @param roomId the room being resolved
|
|
50
|
+
* @param marker the marker being resolved
|
|
51
|
+
* @returns the gate, or undefined when the site is ungated (the common case)
|
|
52
|
+
*/
|
|
53
|
+
function lookupSnippetGate(roomId, marker) {
|
|
54
|
+
return gates.get(keyOf(roomId, marker));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Drop every registration — for tests and for a same-process story switch
|
|
58
|
+
* (a new story's load must not inherit another story's gates).
|
|
59
|
+
*/
|
|
60
|
+
function clearSnippetGates() {
|
|
61
|
+
gates.clear();
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=snippet-gate-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet-gate-registry.js","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/looking/snippet-gate-registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;AAuBH,kDAEC;AASD,8CAEC;AAMD,8CAEC;AAnCD,+EAA+E;AAC/E,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;AAE7C,MAAM,KAAK,GAAG,CAAC,MAAc,EAAE,MAAc,EAAU,EAAE,CAAC,GAAG,MAAM,KAAK,MAAM,EAAE,CAAC;AAEjF;;;;;;;;GAQG;AACH,SAAgB,mBAAmB,CAAC,MAAc,EAAE,MAAc,EAAE,IAAiB;IACnF,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,MAAc,EAAE,MAAc;IAC9D,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Room-description snippet resolver (ADR-209
|
|
2
|
+
* Room-description snippet resolver (ADR-209 machinery, ADR-211 join rule) —
|
|
3
|
+
* the scan/gate/resolve pass.
|
|
3
4
|
*
|
|
4
5
|
* Splits a room description at `{snippet:name}` markers and builds the spliced
|
|
5
6
|
* `Sequence` phrase: `Verbatim` prose segments interleaved with each marker's
|
|
6
7
|
* resolved value (`Literal` for a fixed text, `Choice` for a variant list,
|
|
7
|
-
* `Empty` for a gated-out / empty entry)
|
|
8
|
-
*
|
|
8
|
+
* `Empty` for a gated-out / empty entry), each wrapped in a mode-annotated
|
|
9
|
+
* `Spliced` computed from the AUTHORED marker site (ADR-211 Decision 2).
|
|
10
|
+
* Fragments are BARE — this resolver emits no separator characters, ever; the
|
|
11
|
+
* join characters (`', '` / `' '`) are locale realization and belong to the
|
|
12
|
+
* Assembler. Boundary sites (start of text, paragraph edge) never wrap in
|
|
13
|
+
* `Spliced` at all: their separator is always empty, so the content phrase is
|
|
14
|
+
* emitted directly.
|
|
9
15
|
*
|
|
10
16
|
* Public interface: `resolveSnippetDescription`, `SnippetWorldQueries`.
|
|
11
17
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snippet-resolver.d.ts","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/looking/snippet-resolver.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"snippet-resolver.d.ts","sourceRoot":"","sources":["../../../../../../../../../repos/sharpee_v2/packages/stdlib/src/actions/standard/looking/snippet-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAEV,QAAQ,EAER,UAAU,EAEX,MAAM,oBAAoB,CAAC;AAI5B;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACjD,0DAA0D;IAC1D,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CACjE;AAoFD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,UAAU,EACpB,KAAK,EAAE,mBAAmB,EAC1B,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GACzD,QAAQ,CA+FV"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Room-description snippet resolver (ADR-209
|
|
3
|
+
* Room-description snippet resolver (ADR-209 machinery, ADR-211 join rule) —
|
|
4
|
+
* the scan/gate/resolve pass.
|
|
4
5
|
*
|
|
5
6
|
* Splits a room description at `{snippet:name}` markers and builds the spliced
|
|
6
7
|
* `Sequence` phrase: `Verbatim` prose segments interleaved with each marker's
|
|
7
8
|
* resolved value (`Literal` for a fixed text, `Choice` for a variant list,
|
|
8
|
-
* `Empty` for a gated-out / empty entry)
|
|
9
|
-
*
|
|
9
|
+
* `Empty` for a gated-out / empty entry), each wrapped in a mode-annotated
|
|
10
|
+
* `Spliced` computed from the AUTHORED marker site (ADR-211 Decision 2).
|
|
11
|
+
* Fragments are BARE — this resolver emits no separator characters, ever; the
|
|
12
|
+
* join characters (`', '` / `' '`) are locale realization and belong to the
|
|
13
|
+
* Assembler. Boundary sites (start of text, paragraph edge) never wrap in
|
|
14
|
+
* `Spliced` at all: their separator is always empty, so the content phrase is
|
|
15
|
+
* emitted directly.
|
|
10
16
|
*
|
|
11
17
|
* Public interface: `resolveSnippetDescription`, `SnippetWorldQueries`.
|
|
12
18
|
*
|
|
@@ -20,6 +26,7 @@
|
|
|
20
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
27
|
exports.resolveSnippetDescription = resolveSnippetDescription;
|
|
22
28
|
const if_domain_1 = require("@sharpee/if-domain");
|
|
29
|
+
const snippet_gate_registry_1 = require("./snippet-gate-registry");
|
|
23
30
|
/** Normalize the four `SnippetEntry` forms (ADR-209 Interface contracts). */
|
|
24
31
|
function normalizeEntry(entry) {
|
|
25
32
|
if (typeof entry === 'string') {
|
|
@@ -51,8 +58,41 @@ function resolveText(item, roomId, marker, resolveMessage) {
|
|
|
51
58
|
console.warn(`[snippet] room "${roomId}": message '${item.messageId}' for marker '${marker}' not found`);
|
|
52
59
|
return '';
|
|
53
60
|
}
|
|
61
|
+
// Bare-fragment rule on RESOLVED texts (ADR-211 AC-10): literal texts are
|
|
62
|
+
// gated at load; a messageId resolves at render, so enforcement here is the
|
|
63
|
+
// broken-build log posture — warn and join as-is, never throw mid-turn.
|
|
64
|
+
if (resolved !== '' && SEPARATOR_LED.test(resolved)) {
|
|
65
|
+
// eslint-disable-next-line no-console
|
|
66
|
+
console.warn(`[snippet] room "${roomId}": message '${item.messageId}' for marker '${marker}' is not a bare fragment ` +
|
|
67
|
+
`(leads with punctuation/whitespace) — the separator is platform-owned; joining as-is`);
|
|
68
|
+
}
|
|
54
69
|
return resolved;
|
|
55
70
|
}
|
|
71
|
+
/** Separator-shaped leading characters a bare fragment must not carry (ADR-211). */
|
|
72
|
+
const SEPARATOR_LED = /^[\s,.;:?!]/;
|
|
73
|
+
/**
|
|
74
|
+
* Classify one marker site from the authored prose PRECEDING it (ADR-211
|
|
75
|
+
* Decision 2 edge rules). Markers are transparent — `precedingProse` is the
|
|
76
|
+
* concatenation of prose segments only, so an adjacent marker contributes no
|
|
77
|
+
* characters and the mode comes from the nearest real prose character.
|
|
78
|
+
*/
|
|
79
|
+
function classifySite(precedingProse) {
|
|
80
|
+
let i = precedingProse.length - 1;
|
|
81
|
+
let newlines = 0;
|
|
82
|
+
while (i >= 0 && /\s/.test(precedingProse[i])) {
|
|
83
|
+
if (precedingProse[i] === '\n')
|
|
84
|
+
newlines++;
|
|
85
|
+
i--;
|
|
86
|
+
}
|
|
87
|
+
if (i < 0)
|
|
88
|
+
return 'boundary'; // start of text
|
|
89
|
+
if (newlines >= 2)
|
|
90
|
+
return 'boundary'; // paragraph edge
|
|
91
|
+
// `.?!` end a sentence; `;:` don't, but they already ARE the join — a comma
|
|
92
|
+
// after them is never English, so they take the space-join too (the
|
|
93
|
+
// concealment-test dust site pinned this; ADR-211 Decision 2 amended).
|
|
94
|
+
return /[.?!;:]/.test(precedingProse[i]) ? 'sentence' : 'clause';
|
|
95
|
+
}
|
|
56
96
|
/**
|
|
57
97
|
* Resolve the description text of a snippet-bearing room to its spliced
|
|
58
98
|
* `Sequence` (ADR-209).
|
|
@@ -98,6 +138,24 @@ function resolveSnippetDescription(text, roomId, snippets, world, resolveMessage
|
|
|
98
138
|
if (!present)
|
|
99
139
|
return { kind: 'empty' };
|
|
100
140
|
}
|
|
141
|
+
// Registered gate (ADR-211 Decision 3 / Q4): a non-presence `while`
|
|
142
|
+
// condition registered per (roomId, marker) by the runtime that owns it.
|
|
143
|
+
// Applied alongside — never replacing — the `mentions` data gate above;
|
|
144
|
+
// both must hold. A throwing gate follows the render-graceful posture:
|
|
145
|
+
// log, splice nothing, never abort the turn.
|
|
146
|
+
const gate = (0, snippet_gate_registry_1.lookupSnippetGate)(roomId, name);
|
|
147
|
+
if (gate !== undefined) {
|
|
148
|
+
let holds = false;
|
|
149
|
+
try {
|
|
150
|
+
holds = gate();
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
// eslint-disable-next-line no-console
|
|
154
|
+
console.warn(`[snippet] room "${roomId}": gate for marker '${name}' threw: ${err}`);
|
|
155
|
+
}
|
|
156
|
+
if (!holds)
|
|
157
|
+
return { kind: 'empty' };
|
|
158
|
+
}
|
|
101
159
|
const texts = norm.texts.map((t) => resolveText(t, roomId, name, resolveMessage));
|
|
102
160
|
// Single fixed text (string / SnippetText form): Literal, every render.
|
|
103
161
|
if (norm.selector === undefined) {
|
|
@@ -116,11 +174,15 @@ function resolveSnippetDescription(text, roomId, snippets, world, resolveMessage
|
|
|
116
174
|
messageKey: name,
|
|
117
175
|
};
|
|
118
176
|
};
|
|
177
|
+
// The authored prose seen so far — the site classifier's input. Markers are
|
|
178
|
+
// transparent (they contribute no characters), so only prose accrues.
|
|
179
|
+
let precedingProse = '';
|
|
119
180
|
for (let i = 0; i < pieces.length; i++) {
|
|
120
181
|
if (i % 2 === 0) {
|
|
121
182
|
// Prose segment — opaque author text, exempt from whitespace collapse.
|
|
122
183
|
if (pieces[i] !== '')
|
|
123
184
|
parts.push({ kind: 'verbatim', text: pieces[i] });
|
|
185
|
+
precedingProse += pieces[i];
|
|
124
186
|
}
|
|
125
187
|
else {
|
|
126
188
|
const name = pieces[i];
|
|
@@ -129,7 +191,16 @@ function resolveSnippetDescription(text, roomId, snippets, world, resolveMessage
|
|
|
129
191
|
phrase = resolveMarker(name);
|
|
130
192
|
resolved.set(name, phrase);
|
|
131
193
|
}
|
|
132
|
-
|
|
194
|
+
// ADR-211 Decision 2: the SITE decides the join mode — per occurrence,
|
|
195
|
+
// so a duplicate marker shares its resolved phrase (AC-8: one Choice
|
|
196
|
+
// node, one counter advance) but each site wraps it in its own mode.
|
|
197
|
+
// Boundary sites emit the content directly (their separator is always
|
|
198
|
+
// empty; `Spliced.mode` stays a true two-value enum), and a resolved
|
|
199
|
+
// `Empty` (gated-out / unbound / empty text) needs no wrapper — there
|
|
200
|
+
// is nothing to join.
|
|
201
|
+
const mode = classifySite(precedingProse);
|
|
202
|
+
const wrap = mode !== 'boundary' && phrase.kind !== 'empty';
|
|
203
|
+
parts.push(wrap ? { kind: 'spliced', mode, content: phrase } : phrase);
|
|
133
204
|
}
|
|
134
205
|
}
|
|
135
206
|
return { kind: 'seq', parts };
|