@sharpee/character 0.9.106 → 0.9.107

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 (137) hide show
  1. package/apply.d.ts +29 -7
  2. package/apply.d.ts.map +1 -1
  3. package/apply.js +15 -7
  4. package/apply.js.map +1 -1
  5. package/character-builder.d.ts +67 -4
  6. package/character-builder.d.ts.map +1 -1
  7. package/character-builder.js +116 -7
  8. package/character-builder.js.map +1 -1
  9. package/conversation/acl.d.ts +62 -0
  10. package/conversation/acl.d.ts.map +1 -0
  11. package/conversation/acl.js +117 -0
  12. package/conversation/acl.js.map +1 -0
  13. package/conversation/builder.d.ts +247 -0
  14. package/conversation/builder.d.ts.map +1 -0
  15. package/conversation/builder.js +324 -0
  16. package/conversation/builder.js.map +1 -0
  17. package/conversation/constraint-evaluator.d.ts +147 -0
  18. package/conversation/constraint-evaluator.d.ts.map +1 -0
  19. package/conversation/constraint-evaluator.js +247 -0
  20. package/conversation/constraint-evaluator.js.map +1 -0
  21. package/conversation/conversation-messages.d.ts +56 -0
  22. package/conversation/conversation-messages.d.ts.map +1 -0
  23. package/conversation/conversation-messages.js +69 -0
  24. package/conversation/conversation-messages.js.map +1 -0
  25. package/conversation/dialogue-extension.d.ts +87 -0
  26. package/conversation/dialogue-extension.d.ts.map +1 -0
  27. package/conversation/dialogue-extension.js +302 -0
  28. package/conversation/dialogue-extension.js.map +1 -0
  29. package/conversation/dialogue-types.d.ts +71 -0
  30. package/conversation/dialogue-types.d.ts.map +1 -0
  31. package/conversation/dialogue-types.js +13 -0
  32. package/conversation/dialogue-types.js.map +1 -0
  33. package/conversation/index.d.ts +19 -0
  34. package/conversation/index.d.ts.map +1 -0
  35. package/conversation/index.js +37 -0
  36. package/conversation/index.js.map +1 -0
  37. package/conversation/lifecycle.d.ts +212 -0
  38. package/conversation/lifecycle.d.ts.map +1 -0
  39. package/conversation/lifecycle.js +348 -0
  40. package/conversation/lifecycle.js.map +1 -0
  41. package/conversation/response-types.d.ts +98 -0
  42. package/conversation/response-types.d.ts.map +1 -0
  43. package/conversation/response-types.js +30 -0
  44. package/conversation/response-types.js.map +1 -0
  45. package/conversation/topic-registry.d.ts +130 -0
  46. package/conversation/topic-registry.d.ts.map +1 -0
  47. package/conversation/topic-registry.js +187 -0
  48. package/conversation/topic-registry.js.map +1 -0
  49. package/goals/builder.d.ts +135 -0
  50. package/goals/builder.d.ts.map +1 -0
  51. package/goals/builder.js +193 -0
  52. package/goals/builder.js.map +1 -0
  53. package/goals/goal-activation.d.ts +99 -0
  54. package/goals/goal-activation.d.ts.map +1 -0
  55. package/goals/goal-activation.js +212 -0
  56. package/goals/goal-activation.js.map +1 -0
  57. package/goals/goal-types.d.ts +138 -0
  58. package/goals/goal-types.d.ts.map +1 -0
  59. package/goals/goal-types.js +20 -0
  60. package/goals/goal-types.js.map +1 -0
  61. package/goals/index.d.ts +15 -0
  62. package/goals/index.d.ts.map +1 -0
  63. package/goals/index.js +24 -0
  64. package/goals/index.js.map +1 -0
  65. package/goals/pathfinding.d.ts +67 -0
  66. package/goals/pathfinding.d.ts.map +1 -0
  67. package/goals/pathfinding.js +134 -0
  68. package/goals/pathfinding.js.map +1 -0
  69. package/goals/step-evaluator.d.ts +52 -0
  70. package/goals/step-evaluator.d.ts.map +1 -0
  71. package/goals/step-evaluator.js +153 -0
  72. package/goals/step-evaluator.js.map +1 -0
  73. package/index.d.ts +6 -1
  74. package/index.d.ts.map +1 -1
  75. package/index.js +60 -1
  76. package/index.js.map +1 -1
  77. package/influence/builder.d.ts +136 -0
  78. package/influence/builder.d.ts.map +1 -0
  79. package/influence/builder.js +198 -0
  80. package/influence/builder.js.map +1 -0
  81. package/influence/index.d.ts +16 -0
  82. package/influence/index.d.ts.map +1 -0
  83. package/influence/index.js +25 -0
  84. package/influence/index.js.map +1 -0
  85. package/influence/influence-duration.d.ts +82 -0
  86. package/influence/influence-duration.d.ts.map +1 -0
  87. package/influence/influence-duration.js +148 -0
  88. package/influence/influence-duration.js.map +1 -0
  89. package/influence/influence-evaluator.d.ts +55 -0
  90. package/influence/influence-evaluator.d.ts.map +1 -0
  91. package/influence/influence-evaluator.js +183 -0
  92. package/influence/influence-evaluator.js.map +1 -0
  93. package/influence/influence-messages.d.ts +30 -0
  94. package/influence/influence-messages.d.ts.map +1 -0
  95. package/influence/influence-messages.js +40 -0
  96. package/influence/influence-messages.js.map +1 -0
  97. package/influence/influence-types.d.ts +123 -0
  98. package/influence/influence-types.d.ts.map +1 -0
  99. package/influence/influence-types.js +12 -0
  100. package/influence/influence-types.js.map +1 -0
  101. package/influence/pc-influence.d.ts +38 -0
  102. package/influence/pc-influence.d.ts.map +1 -0
  103. package/influence/pc-influence.js +56 -0
  104. package/influence/pc-influence.js.map +1 -0
  105. package/package.json +4 -3
  106. package/propagation/builder.d.ts +47 -0
  107. package/propagation/builder.d.ts.map +1 -0
  108. package/propagation/builder.js +46 -0
  109. package/propagation/builder.js.map +1 -0
  110. package/propagation/fact-transfer.d.ts +47 -0
  111. package/propagation/fact-transfer.d.ts.map +1 -0
  112. package/propagation/fact-transfer.js +76 -0
  113. package/propagation/fact-transfer.js.map +1 -0
  114. package/propagation/index.d.ts +16 -0
  115. package/propagation/index.d.ts.map +1 -0
  116. package/propagation/index.js +28 -0
  117. package/propagation/index.js.map +1 -0
  118. package/propagation/propagation-evaluator.d.ts +53 -0
  119. package/propagation/propagation-evaluator.d.ts.map +1 -0
  120. package/propagation/propagation-evaluator.js +231 -0
  121. package/propagation/propagation-evaluator.js.map +1 -0
  122. package/propagation/propagation-messages.d.ts +30 -0
  123. package/propagation/propagation-messages.d.ts.map +1 -0
  124. package/propagation/propagation-messages.js +37 -0
  125. package/propagation/propagation-messages.js.map +1 -0
  126. package/propagation/propagation-types.d.ts +100 -0
  127. package/propagation/propagation-types.d.ts.map +1 -0
  128. package/propagation/propagation-types.js +68 -0
  129. package/propagation/propagation-types.js.map +1 -0
  130. package/propagation/visibility.d.ts +46 -0
  131. package/propagation/visibility.d.ts.map +1 -0
  132. package/propagation/visibility.js +79 -0
  133. package/propagation/visibility.js.map +1 -0
  134. package/tick-phases.d.ts +93 -0
  135. package/tick-phases.d.ts.map +1 -0
  136. package/tick-phases.js +433 -0
  137. package/tick-phases.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goal-types.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/character/src/goals/goal-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AASH,yDAAyD;AAC5C,QAAA,oBAAoB,GAAiC;IAChE,QAAQ,EAAE,GAAG;IACb,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,EAAE;IACV,GAAG,EAAE,EAAE;CACR,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * NPC goal pursuit exports (ADR-145)
3
+ *
4
+ * Goal definitions, activation/lifecycle management, step evaluation,
5
+ * and pathfinding for NPC behavior sequences.
6
+ *
7
+ * Public interface: All re-exported types, classes, and functions.
8
+ * Owner context: @sharpee/character / goals
9
+ */
10
+ export { type GoalPriority, type PursuitMode, type GoalStep, type SeekStep, type AcquireStep, type WaitForStep, type MoveToStep, type ActStep, type SayStep, type GiveStep, type DropStep, type GoalDef, type ActiveGoal, type MovementProfile, type StepResult, GOAL_PRIORITY_VALUES, } from './goal-types';
11
+ export { type ActiveGoalState, GoalManager, } from './goal-activation';
12
+ export { type GoalStepContext, evaluateGoalStep, } from './step-evaluator';
13
+ export { type RoomConnection, type RoomGraph, SimpleRoomGraph, findNextRoom, } from './pathfinding';
14
+ export { GoalBuilder } from './builder';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee/packages/character/src/goals/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,KAAK,eAAe,EACpB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,KAAK,eAAe,EACpB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,eAAe,EACf,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
package/goals/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * NPC goal pursuit exports (ADR-145)
4
+ *
5
+ * Goal definitions, activation/lifecycle management, step evaluation,
6
+ * and pathfinding for NPC behavior sequences.
7
+ *
8
+ * Public interface: All re-exported types, classes, and functions.
9
+ * Owner context: @sharpee/character / goals
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GoalBuilder = exports.findNextRoom = exports.SimpleRoomGraph = exports.evaluateGoalStep = exports.GoalManager = exports.GOAL_PRIORITY_VALUES = void 0;
13
+ var goal_types_1 = require("./goal-types");
14
+ Object.defineProperty(exports, "GOAL_PRIORITY_VALUES", { enumerable: true, get: function () { return goal_types_1.GOAL_PRIORITY_VALUES; } });
15
+ var goal_activation_1 = require("./goal-activation");
16
+ Object.defineProperty(exports, "GoalManager", { enumerable: true, get: function () { return goal_activation_1.GoalManager; } });
17
+ var step_evaluator_1 = require("./step-evaluator");
18
+ Object.defineProperty(exports, "evaluateGoalStep", { enumerable: true, get: function () { return step_evaluator_1.evaluateGoalStep; } });
19
+ var pathfinding_1 = require("./pathfinding");
20
+ Object.defineProperty(exports, "SimpleRoomGraph", { enumerable: true, get: function () { return pathfinding_1.SimpleRoomGraph; } });
21
+ Object.defineProperty(exports, "findNextRoom", { enumerable: true, get: function () { return pathfinding_1.findNextRoom; } });
22
+ var builder_1 = require("./builder");
23
+ Object.defineProperty(exports, "GoalBuilder", { enumerable: true, get: function () { return builder_1.GoalBuilder; } });
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/character/src/goals/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,2CAiBsB;AADpB,kHAAA,oBAAoB,OAAA;AAGtB,qDAG2B;AADzB,8GAAA,WAAW,OAAA;AAGb,mDAG0B;AADxB,kHAAA,gBAAgB,OAAA;AAGlB,6CAKuB;AAFrB,8GAAA,eAAe,OAAA;AACf,2GAAA,YAAY,OAAA;AAGd,qCAAwC;AAA/B,sGAAA,WAAW,OAAA"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * NPC pathfinding (ADR-145)
3
+ *
4
+ * BFS over room connection graph filtered by NPC movement profile.
5
+ * NPCs can only pathfind through rooms they know and passages they
6
+ * have access to.
7
+ *
8
+ * Public interface: findNextRoom, RoomGraph, RoomConnection.
9
+ * Owner context: @sharpee/character / goals
10
+ */
11
+ import { MovementProfile } from './goal-types';
12
+ /** A connection between two rooms. */
13
+ export interface RoomConnection {
14
+ /** Source room ID. */
15
+ from: string;
16
+ /** Destination room ID. */
17
+ to: string;
18
+ /** Optional passage/connection ID (for access checking). */
19
+ passageId?: string;
20
+ }
21
+ /**
22
+ * A room graph — adjacency list representation.
23
+ * The caller (NpcService or test harness) provides this from the world model.
24
+ */
25
+ export interface RoomGraph {
26
+ /** Get all connections from a room. */
27
+ getConnections(roomId: string): RoomConnection[];
28
+ }
29
+ /**
30
+ * Simple room graph implementation for testing.
31
+ * Production code can implement the RoomGraph interface directly.
32
+ */
33
+ export declare class SimpleRoomGraph implements RoomGraph {
34
+ private readonly connections;
35
+ /**
36
+ * Add a bidirectional connection between two rooms.
37
+ *
38
+ * @param from - Source room ID
39
+ * @param to - Destination room ID
40
+ * @param passageId - Optional passage ID
41
+ */
42
+ addConnection(from: string, to: string, passageId?: string): void;
43
+ /**
44
+ * Add a one-way connection.
45
+ *
46
+ * @param from - Source room ID
47
+ * @param to - Destination room ID
48
+ * @param passageId - Optional passage ID
49
+ */
50
+ addDirected(from: string, to: string, passageId?: string): void;
51
+ getConnections(roomId: string): RoomConnection[];
52
+ }
53
+ /**
54
+ * Find the next room the NPC should move to on the shortest path
55
+ * toward a target room, filtered by movement profile.
56
+ *
57
+ * Uses BFS (breadth-first search) over the room graph. Only traverses
58
+ * rooms the NPC knows about and passages the NPC has access to.
59
+ *
60
+ * @param currentRoom - The NPC's current room ID
61
+ * @param targetRoom - The destination room ID
62
+ * @param graph - The room connection graph
63
+ * @param movement - The NPC's movement profile
64
+ * @returns The next room ID to move to, or null if unreachable
65
+ */
66
+ export declare function findNextRoom(currentRoom: string, targetRoom: string, graph: RoomGraph, movement: MovementProfile): string | null;
67
+ //# sourceMappingURL=pathfinding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathfinding.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee/packages/character/src/goals/pathfinding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAM/C,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IAEb,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IAEX,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,uCAAuC;IACvC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,CAAC;CAClD;AAED;;;GAGG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4C;IAExE;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAKjE;;;;;;OAMG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAM/D,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE;CAGjD;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,eAAe,GACxB,MAAM,GAAG,IAAI,CAoCf"}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ /**
3
+ * NPC pathfinding (ADR-145)
4
+ *
5
+ * BFS over room connection graph filtered by NPC movement profile.
6
+ * NPCs can only pathfind through rooms they know and passages they
7
+ * have access to.
8
+ *
9
+ * Public interface: findNextRoom, RoomGraph, RoomConnection.
10
+ * Owner context: @sharpee/character / goals
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.SimpleRoomGraph = void 0;
14
+ exports.findNextRoom = findNextRoom;
15
+ /**
16
+ * Simple room graph implementation for testing.
17
+ * Production code can implement the RoomGraph interface directly.
18
+ */
19
+ class SimpleRoomGraph {
20
+ connections = new Map();
21
+ /**
22
+ * Add a bidirectional connection between two rooms.
23
+ *
24
+ * @param from - Source room ID
25
+ * @param to - Destination room ID
26
+ * @param passageId - Optional passage ID
27
+ */
28
+ addConnection(from, to, passageId) {
29
+ this.addDirected(from, to, passageId);
30
+ this.addDirected(to, from, passageId); // Reverse direction for bidirectional edge
31
+ }
32
+ /**
33
+ * Add a one-way connection.
34
+ *
35
+ * @param from - Source room ID
36
+ * @param to - Destination room ID
37
+ * @param passageId - Optional passage ID
38
+ */
39
+ addDirected(from, to, passageId) {
40
+ const existing = this.connections.get(from) ?? [];
41
+ existing.push({ from, to, passageId });
42
+ this.connections.set(from, existing);
43
+ }
44
+ getConnections(roomId) {
45
+ return this.connections.get(roomId) ?? [];
46
+ }
47
+ }
48
+ exports.SimpleRoomGraph = SimpleRoomGraph;
49
+ // ---------------------------------------------------------------------------
50
+ // Pathfinding
51
+ // ---------------------------------------------------------------------------
52
+ /**
53
+ * Find the next room the NPC should move to on the shortest path
54
+ * toward a target room, filtered by movement profile.
55
+ *
56
+ * Uses BFS (breadth-first search) over the room graph. Only traverses
57
+ * rooms the NPC knows about and passages the NPC has access to.
58
+ *
59
+ * @param currentRoom - The NPC's current room ID
60
+ * @param targetRoom - The destination room ID
61
+ * @param graph - The room connection graph
62
+ * @param movement - The NPC's movement profile
63
+ * @returns The next room ID to move to, or null if unreachable
64
+ */
65
+ function findNextRoom(currentRoom, targetRoom, graph, movement) {
66
+ if (currentRoom === targetRoom)
67
+ return null; // Already there
68
+ // BFS
69
+ const visited = new Set();
70
+ // Queue entries: [roomId, firstStepFromCurrent]
71
+ const queue = [];
72
+ visited.add(currentRoom);
73
+ // Seed with adjacent rooms
74
+ for (const conn of graph.getConnections(currentRoom)) {
75
+ if (!isAccessible(conn, movement))
76
+ continue;
77
+ if (conn.to === targetRoom)
78
+ return conn.to;
79
+ visited.add(conn.to);
80
+ queue.push([conn.to, conn.to]); // firstStep is this neighbor
81
+ }
82
+ // BFS loop
83
+ while (queue.length > 0) {
84
+ const [room, firstStep] = queue.shift();
85
+ for (const conn of graph.getConnections(room)) {
86
+ if (visited.has(conn.to))
87
+ continue;
88
+ if (!isAccessible(conn, movement))
89
+ continue;
90
+ if (conn.to === targetRoom)
91
+ return firstStep;
92
+ visited.add(conn.to);
93
+ queue.push([conn.to, firstStep]);
94
+ }
95
+ }
96
+ return null; // Unreachable
97
+ }
98
+ // ---------------------------------------------------------------------------
99
+ // Movement profile checks
100
+ // ---------------------------------------------------------------------------
101
+ /**
102
+ * Check if a connection is accessible: the NPC can traverse the passage
103
+ * and knows the destination room.
104
+ *
105
+ * Combines passage access and room knowledge into a single check,
106
+ * used by both the BFS seed loop and the main traversal loop.
107
+ *
108
+ * @param conn - The room connection to check
109
+ * @param movement - The NPC's movement profile
110
+ * @returns true if the NPC can use this connection
111
+ */
112
+ function isAccessible(conn, movement) {
113
+ return canTraverse(conn, movement) && knowsRoom(conn.to, movement);
114
+ }
115
+ /**
116
+ * Check if the NPC can traverse a connection.
117
+ * If the connection has a passageId, the NPC must have access to it.
118
+ */
119
+ function canTraverse(conn, movement) {
120
+ if (!conn.passageId)
121
+ return true; // No passage restriction
122
+ if (movement.access === 'all')
123
+ return true;
124
+ return movement.access.includes(conn.passageId);
125
+ }
126
+ /**
127
+ * Check if the NPC knows about a room.
128
+ */
129
+ function knowsRoom(roomId, movement) {
130
+ if (movement.knows === 'all')
131
+ return true;
132
+ return movement.knows.includes(roomId);
133
+ }
134
+ //# sourceMappingURL=pathfinding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathfinding.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/character/src/goals/pathfinding.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAmFH,oCAyCC;AA/FD;;;GAGG;AACH,MAAa,eAAe;IACT,WAAW,GAAkC,IAAI,GAAG,EAAE,CAAC;IAExE;;;;;;OAMG;IACH,aAAa,CAAC,IAAY,EAAE,EAAU,EAAE,SAAkB;QACxD,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,2CAA2C;IACpF,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,IAAY,EAAE,EAAU,EAAE,SAAkB;QACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,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,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Goal step evaluator (ADR-145)
3
+ *
4
+ * Evaluates the current step of an active goal each NPC turn.
5
+ * Pure evaluation logic — returns step results that the caller applies.
6
+ *
7
+ * Public interface: evaluateGoalStep, GoalStepContext.
8
+ * Owner context: @sharpee/character / goals
9
+ */
10
+ import { CharacterModelTrait } from "../../world-model/index";
11
+ import { ActiveGoal, StepResult, MovementProfile } from './goal-types';
12
+ import { RoomGraph } from './pathfinding';
13
+ /** Context needed to evaluate a goal step. */
14
+ export interface GoalStepContext {
15
+ /** The NPC's entity ID. */
16
+ npcId: string;
17
+ /** The NPC's current room ID. */
18
+ currentRoom: string;
19
+ /** The NPC's CharacterModelTrait. */
20
+ trait: CharacterModelTrait;
21
+ /** The NPC's movement profile. */
22
+ movement: MovementProfile;
23
+ /** The room connection graph. */
24
+ roomGraph: RoomGraph;
25
+ /** Whether the player is in the same room as the NPC. */
26
+ playerPresent: boolean;
27
+ /**
28
+ * Function to check if an entity is in the same room as the NPC.
29
+ * Used for acquire/give/drop steps.
30
+ */
31
+ isInRoom: (entityId: string, roomId: string) => boolean;
32
+ /**
33
+ * Function to get an entity's current room.
34
+ * Used for seek steps targeting entities.
35
+ */
36
+ getEntityRoom?: (entityId: string) => string | undefined;
37
+ }
38
+ /**
39
+ * Evaluate a single goal step for an NPC.
40
+ *
41
+ * Each step type produces a StepResult:
42
+ * - completed: step is done, advance to next
43
+ * - in-progress: step partially done (e.g., moving toward target)
44
+ * - waiting: conditions not met, hold this turn
45
+ * - blocked: cannot proceed (e.g., unreachable target)
46
+ *
47
+ * @param goal - The active goal
48
+ * @param ctx - The evaluation context
49
+ * @returns The step evaluation result
50
+ */
51
+ export declare function evaluateGoalStep(goal: ActiveGoal, ctx: GoalStepContext): StepResult;
52
+ //# sourceMappingURL=step-evaluator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-evaluator.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee/packages/character/src/goals/step-evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAEL,UAAU,EACV,UAAU,EACV,eAAe,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAgB,SAAS,EAAE,MAAM,eAAe,CAAC;AAMxD,8CAA8C;AAC9C,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IAEd,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IAEpB,qCAAqC;IACrC,KAAK,EAAE,mBAAmB,CAAC;IAE3B,kCAAkC;IAClC,QAAQ,EAAE,eAAe,CAAC;IAE1B,iCAAiC;IACjC,SAAS,EAAE,SAAS,CAAC;IAErB,yDAAyD;IACzD,aAAa,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAExD;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAC1D;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,eAAe,GACnB,UAAU,CAmBZ"}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ /**
3
+ * Goal step evaluator (ADR-145)
4
+ *
5
+ * Evaluates the current step of an active goal each NPC turn.
6
+ * Pure evaluation logic — returns step results that the caller applies.
7
+ *
8
+ * Public interface: evaluateGoalStep, GoalStepContext.
9
+ * Owner context: @sharpee/character / goals
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.evaluateGoalStep = evaluateGoalStep;
13
+ const pathfinding_1 = require("./pathfinding");
14
+ // ---------------------------------------------------------------------------
15
+ // Step evaluation
16
+ // ---------------------------------------------------------------------------
17
+ /**
18
+ * Evaluate a single goal step for an NPC.
19
+ *
20
+ * Each step type produces a StepResult:
21
+ * - completed: step is done, advance to next
22
+ * - in-progress: step partially done (e.g., moving toward target)
23
+ * - waiting: conditions not met, hold this turn
24
+ * - blocked: cannot proceed (e.g., unreachable target)
25
+ *
26
+ * @param goal - The active goal
27
+ * @param ctx - The evaluation context
28
+ * @returns The step evaluation result
29
+ */
30
+ function evaluateGoalStep(goal, ctx) {
31
+ // Opportunistic mode — no steps, just check act conditions
32
+ if (goal.def.mode === 'opportunistic') {
33
+ return evaluateOpportunistic(goal, ctx);
34
+ }
35
+ // Prepared mode with all prep steps done — switch to opportunistic
36
+ if (goal.def.mode === 'prepared' && goal.prepared) {
37
+ return evaluateOpportunistic(goal, ctx);
38
+ }
39
+ // Sequential/prepared mode — execute current step
40
+ const steps = goal.def.steps;
41
+ if (!steps || goal.currentStep >= steps.length) {
42
+ return { status: 'completed' };
43
+ }
44
+ const step = steps[goal.currentStep];
45
+ return evaluateStep(step, ctx);
46
+ }
47
+ // ---------------------------------------------------------------------------
48
+ // Individual step type evaluators
49
+ // ---------------------------------------------------------------------------
50
+ function evaluateStep(step, ctx) {
51
+ switch (step.type) {
52
+ case 'seek':
53
+ return evaluateSeek(step.target, step.from, step.witnessed, ctx);
54
+ case 'moveTo':
55
+ return evaluateSeek(step.target, undefined, step.witnessed, ctx);
56
+ case 'acquire':
57
+ return evaluateAcquire(step.target, step.witnessed, ctx);
58
+ case 'waitFor':
59
+ return evaluateWaitFor(step.conditions, ctx);
60
+ case 'act':
61
+ case 'say':
62
+ return {
63
+ status: 'completed',
64
+ witnessed: ctx.playerPresent ? step.witnessed ?? step.messageId : undefined,
65
+ };
66
+ case 'give':
67
+ return evaluateGive(step.item, step.target, step.witnessed, ctx);
68
+ case 'drop':
69
+ return evaluateDrop(step.item, step.witnessed, ctx);
70
+ }
71
+ }
72
+ function evaluateSeek(target, from, witnessed, ctx) {
73
+ // Resolve target room — could be a room ID or an entity ID
74
+ let targetRoom = target;
75
+ if (ctx.getEntityRoom) {
76
+ const entityRoom = ctx.getEntityRoom(target);
77
+ if (entityRoom)
78
+ targetRoom = entityRoom;
79
+ }
80
+ // Use 'from' hint if provided and NPC is not already moving
81
+ if (from && ctx.currentRoom !== from) {
82
+ targetRoom = from;
83
+ }
84
+ // Already at target
85
+ if (ctx.currentRoom === targetRoom) {
86
+ return { status: 'completed' };
87
+ }
88
+ // Find next room toward target
89
+ const nextRoom = (0, pathfinding_1.findNextRoom)(ctx.currentRoom, targetRoom, ctx.roomGraph, ctx.movement);
90
+ if (nextRoom === null) {
91
+ return { status: 'blocked', reason: `Cannot reach ${targetRoom}` };
92
+ }
93
+ return {
94
+ status: 'in-progress',
95
+ witnessed: ctx.playerPresent ? witnessed : undefined,
96
+ };
97
+ }
98
+ /**
99
+ * Shared logic for steps that complete when a target entity is in the NPC's room.
100
+ * Used by both 'acquire' and 'give' step types.
101
+ *
102
+ * @param target - Entity ID to check for room co-location
103
+ * @param witnessed - Optional message ID when player observes
104
+ * @param ctx - The goal step evaluation context
105
+ * @returns Completed if target is in room, waiting otherwise
106
+ */
107
+ function evaluateTargetInRoom(target, witnessed, ctx) {
108
+ if (ctx.isInRoom(target, ctx.currentRoom)) {
109
+ return {
110
+ status: 'completed',
111
+ witnessed: ctx.playerPresent ? witnessed : undefined,
112
+ };
113
+ }
114
+ return { status: 'waiting' };
115
+ }
116
+ function evaluateAcquire(target, witnessed, ctx) {
117
+ return evaluateTargetInRoom(target, witnessed, ctx);
118
+ }
119
+ function evaluateWaitFor(conditions, ctx) {
120
+ const allMet = conditions.every(cond => ctx.trait.evaluate(cond));
121
+ if (allMet) {
122
+ return { status: 'completed' };
123
+ }
124
+ return { status: 'waiting' };
125
+ }
126
+ function evaluateGive(_item, target, witnessed, ctx) {
127
+ return evaluateTargetInRoom(target, witnessed, ctx);
128
+ }
129
+ function evaluateDrop(_item, witnessed, ctx) {
130
+ return {
131
+ status: 'completed',
132
+ witnessed: ctx.playerPresent ? witnessed : undefined,
133
+ };
134
+ }
135
+ // ---------------------------------------------------------------------------
136
+ // Opportunistic evaluation
137
+ // ---------------------------------------------------------------------------
138
+ function evaluateOpportunistic(goal, ctx) {
139
+ if (!goal.def.actsWhen) {
140
+ return { status: 'waiting' };
141
+ }
142
+ const allMet = goal.def.actsWhen.every(cond => ctx.trait.evaluate(cond));
143
+ if (allMet) {
144
+ return {
145
+ status: 'completed',
146
+ witnessed: ctx.playerPresent
147
+ ? goal.def.actMessageId
148
+ : undefined,
149
+ };
150
+ }
151
+ return { status: 'waiting' };
152
+ }
153
+ //# sourceMappingURL=step-evaluator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-evaluator.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/character/src/goals/step-evaluator.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAiEH,4CAsBC;AA9ED,+CAAwD;AAuCxD,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;;;;;;GAYG;AACH,SAAgB,gBAAgB,CAC9B,IAAgB,EAChB,GAAoB;IAEpB,2DAA2D;IAC3D,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACtC,OAAO,qBAAqB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,mEAAmE;IACnE,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClD,OAAO,qBAAqB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,kDAAkD;IAClD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;IAC7B,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAC/C,OA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,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzE,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;YACL,MAAM,EAAE,WAAW;YACnB,SAAS,EAAE,GAAG,CAAC,aAAa;gBAC1B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY;gBACvB,CAAC,CAAC,SAAS;SACd,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC/B,CAAC"}
package/index.d.ts CHANGED
@@ -12,5 +12,10 @@
12
12
  export { CharacterBuilder, TriggerBuilder, type CompiledCharacter, type CompiledTrigger, type TriggerMutation, } from './character-builder';
13
13
  export { COGNITIVE_PRESETS, isCognitivePreset, type CognitivePresetName, } from './cognitive-presets';
14
14
  export { VocabularyExtension, type CustomMoodDef, type CustomPersonalityDef, } from './vocabulary-extension';
15
- export { applyCharacter } from './apply';
15
+ export { applyCharacter, type AppliedCharacter } from './apply';
16
+ export { type ResponseAction, type ResponseCandidate, type ResponseIntent, type ConversationRecord, type ConversationEntry, type EvidenceRecord, type EvidenceEntry, type TopicDef, type TopicResolution, type Contradiction, type ConstraintEvaluatorState, evaluateConstraints, ConstraintEvaluator, createConversationRecord, createEvidenceRecord, type ConversationIntent, type ConversationStrength, type RedirectResult, type ConversationContext, type ContinuationEntry, type InitiativeTrigger, type ConversationLifecycleState, DEFAULT_DECAY_THRESHOLDS, BETWEEN_TURN_DEFAULTS, ConversationLifecycle, buildResponseIntent, selectMoodVariant, applyCognitiveColoring, TopicRegistry, type DialogueExtension, type DialogueResult, type ConversationData, type AuthoredResponse, type OffscreenScene, type WitnessedScene, createConversationData, ConversationBuilder, ResponseChainBuilder, CharacterModelDialogue, ConversationMessages, type ConversationMessageId, } from './conversation';
17
+ export { type PropagationTendency, type PropagationAudience, type PropagationPace, type PropagationColoring, type ReceivesAs, type SpreadsVersion, type PropagationProfile, type PropagationTransfer, type RoomOccupant, type PropagationContext, type TransferResult, AlreadyToldRecord, evaluatePropagation, transferFact, applyTransfers, type PlayerPresence, type PropagationVisibilityResult, PROPAGATION_WITNESSED_DEFAULTS, getVisibilityResult, getVisibilityResults, type PropagationOptions, buildPropagationProfile, PropagationMessages, type PropagationMessageId, } from './propagation';
18
+ export { type GoalPriority, type PursuitMode, type GoalStep, type GoalDef, type ActiveGoal, type MovementProfile, type StepResult, type ActiveGoalState, type GoalStepContext, type RoomConnection, type RoomGraph, GOAL_PRIORITY_VALUES, GoalManager, evaluateGoalStep, SimpleRoomGraph, findNextRoom, GoalBuilder, } from './goals';
19
+ export { type InfluenceMode, type InfluenceRange, type InfluenceDuration, type InfluenceEffect, type InfluenceSchedule, type InfluenceDef, type ResistanceDef, type ActiveInfluenceEffect, type InfluenceResult, type InfluenceRoomEntity, checkResistance, evaluatePassiveInfluences, evaluateActiveInfluence, InfluenceTracker, type PcInfluenceResult, evaluatePcInfluence, InfluenceBuilder, InfluenceMessages, type InfluenceMessageId, } from './influence';
20
+ export { type CharacterPhaseConfig, CharacterPhaseRegistry, createPropagationPhase, createGoalPhase, createInfluencePhase, } from './tick-phases';
16
21
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../repos/sharpee/packages/character/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,oBAAoB,GAC1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../repos/sharpee/packages/character/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,oBAAoB,GAC1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhE,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,aAAa,EAElB,KAAK,QAAQ,EACb,KAAK,eAAe,EAEpB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,mBAAmB,EACnB,mBAAmB,EAEnB,wBAAwB,EACxB,oBAAoB,EAEpB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EAErB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EAEtB,aAAa,EAEb,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EAEpB,sBAAsB,EAEtB,oBAAoB,EACpB,KAAK,qBAAqB,GAC3B,MAAM,g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rB,MAAM,eAAe,CAAC"}
package/index.js CHANGED
@@ -11,7 +11,7 @@
11
11
  * Owner context: @sharpee/character package
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.applyCharacter = exports.VocabularyExtension = exports.isCognitivePreset = exports.COGNITIVE_PRESETS = exports.TriggerBuilder = exports.CharacterBuilder = void 0;
14
+ exports.createInfluencePhase = exports.createGoalPhase = exports.createPropagationPhase = exports.CharacterPhaseRegistry = exports.InfluenceMessages = exports.InfluenceBuilder = exports.evaluatePcInfluence = exports.InfluenceTracker = exports.evaluateActiveInfluence = exports.evaluatePassiveInfluences = exports.checkResistance = exports.GoalBuilder = exports.findNextRoom = exports.SimpleRoomGraph = exports.evaluateGoalStep = exports.GoalManager = exports.GOAL_PRIORITY_VALUES = exports.PropagationMessages = exports.buildPropagationProfile = exports.getVisibilityResults = exports.getVisibilityResult = exports.PROPAGATION_WITNESSED_DEFAULTS = exports.applyTransfers = exports.transferFact = exports.evaluatePropagation = exports.AlreadyToldRecord = exports.ConversationMessages = exports.CharacterModelDialogue = exports.ResponseChainBuilder = exports.ConversationBuilder = exports.createConversationData = exports.TopicRegistry = exports.applyCognitiveColoring = exports.selectMoodVariant = exports.buildResponseIntent = exports.ConversationLifecycle = exports.BETWEEN_TURN_DEFAULTS = exports.DEFAULT_DECAY_THRESHOLDS = exports.createEvidenceRecord = exports.createConversationRecord = exports.ConstraintEvaluator = exports.evaluateConstraints = exports.applyCharacter = exports.VocabularyExtension = exports.isCognitivePreset = exports.COGNITIVE_PRESETS = exports.TriggerBuilder = exports.CharacterBuilder = void 0;
15
15
  var character_builder_1 = require("./character-builder");
16
16
  Object.defineProperty(exports, "CharacterBuilder", { enumerable: true, get: function () { return character_builder_1.CharacterBuilder; } });
17
17
  Object.defineProperty(exports, "TriggerBuilder", { enumerable: true, get: function () { return character_builder_1.TriggerBuilder; } });
@@ -22,4 +22,63 @@ var vocabulary_extension_1 = require("./vocabulary-extension");
22
22
  Object.defineProperty(exports, "VocabularyExtension", { enumerable: true, get: function () { return vocabulary_extension_1.VocabularyExtension; } });
23
23
  var apply_1 = require("./apply");
24
24
  Object.defineProperty(exports, "applyCharacter", { enumerable: true, get: function () { return apply_1.applyCharacter; } });
25
+ // Conversation system (ADR-142)
26
+ var conversation_1 = require("./conversation");
27
+ Object.defineProperty(exports, "evaluateConstraints", { enumerable: true, get: function () { return conversation_1.evaluateConstraints; } });
28
+ Object.defineProperty(exports, "ConstraintEvaluator", { enumerable: true, get: function () { return conversation_1.ConstraintEvaluator; } });
29
+ // Factories
30
+ Object.defineProperty(exports, "createConversationRecord", { enumerable: true, get: function () { return conversation_1.createConversationRecord; } });
31
+ Object.defineProperty(exports, "createEvidenceRecord", { enumerable: true, get: function () { return conversation_1.createEvidenceRecord; } });
32
+ Object.defineProperty(exports, "DEFAULT_DECAY_THRESHOLDS", { enumerable: true, get: function () { return conversation_1.DEFAULT_DECAY_THRESHOLDS; } });
33
+ Object.defineProperty(exports, "BETWEEN_TURN_DEFAULTS", { enumerable: true, get: function () { return conversation_1.BETWEEN_TURN_DEFAULTS; } });
34
+ Object.defineProperty(exports, "ConversationLifecycle", { enumerable: true, get: function () { return conversation_1.ConversationLifecycle; } });
35
+ // ACL
36
+ Object.defineProperty(exports, "buildResponseIntent", { enumerable: true, get: function () { return conversation_1.buildResponseIntent; } });
37
+ Object.defineProperty(exports, "selectMoodVariant", { enumerable: true, get: function () { return conversation_1.selectMoodVariant; } });
38
+ Object.defineProperty(exports, "applyCognitiveColoring", { enumerable: true, get: function () { return conversation_1.applyCognitiveColoring; } });
39
+ // Topic registry
40
+ Object.defineProperty(exports, "TopicRegistry", { enumerable: true, get: function () { return conversation_1.TopicRegistry; } });
41
+ Object.defineProperty(exports, "createConversationData", { enumerable: true, get: function () { return conversation_1.createConversationData; } });
42
+ Object.defineProperty(exports, "ConversationBuilder", { enumerable: true, get: function () { return conversation_1.ConversationBuilder; } });
43
+ Object.defineProperty(exports, "ResponseChainBuilder", { enumerable: true, get: function () { return conversation_1.ResponseChainBuilder; } });
44
+ // DialogueExtension implementation
45
+ Object.defineProperty(exports, "CharacterModelDialogue", { enumerable: true, get: function () { return conversation_1.CharacterModelDialogue; } });
46
+ // Conversation message IDs
47
+ Object.defineProperty(exports, "ConversationMessages", { enumerable: true, get: function () { return conversation_1.ConversationMessages; } });
48
+ // Information propagation (ADR-144)
49
+ var propagation_1 = require("./propagation");
50
+ Object.defineProperty(exports, "AlreadyToldRecord", { enumerable: true, get: function () { return propagation_1.AlreadyToldRecord; } });
51
+ Object.defineProperty(exports, "evaluatePropagation", { enumerable: true, get: function () { return propagation_1.evaluatePropagation; } });
52
+ Object.defineProperty(exports, "transferFact", { enumerable: true, get: function () { return propagation_1.transferFact; } });
53
+ Object.defineProperty(exports, "applyTransfers", { enumerable: true, get: function () { return propagation_1.applyTransfers; } });
54
+ Object.defineProperty(exports, "PROPAGATION_WITNESSED_DEFAULTS", { enumerable: true, get: function () { return propagation_1.PROPAGATION_WITNESSED_DEFAULTS; } });
55
+ Object.defineProperty(exports, "getVisibilityResult", { enumerable: true, get: function () { return propagation_1.getVisibilityResult; } });
56
+ Object.defineProperty(exports, "getVisibilityResults", { enumerable: true, get: function () { return propagation_1.getVisibilityResults; } });
57
+ Object.defineProperty(exports, "buildPropagationProfile", { enumerable: true, get: function () { return propagation_1.buildPropagationProfile; } });
58
+ // Propagation message IDs
59
+ Object.defineProperty(exports, "PropagationMessages", { enumerable: true, get: function () { return propagation_1.PropagationMessages; } });
60
+ // NPC goal pursuit (ADR-145)
61
+ var goals_1 = require("./goals");
62
+ Object.defineProperty(exports, "GOAL_PRIORITY_VALUES", { enumerable: true, get: function () { return goals_1.GOAL_PRIORITY_VALUES; } });
63
+ Object.defineProperty(exports, "GoalManager", { enumerable: true, get: function () { return goals_1.GoalManager; } });
64
+ Object.defineProperty(exports, "evaluateGoalStep", { enumerable: true, get: function () { return goals_1.evaluateGoalStep; } });
65
+ Object.defineProperty(exports, "SimpleRoomGraph", { enumerable: true, get: function () { return goals_1.SimpleRoomGraph; } });
66
+ Object.defineProperty(exports, "findNextRoom", { enumerable: true, get: function () { return goals_1.findNextRoom; } });
67
+ Object.defineProperty(exports, "GoalBuilder", { enumerable: true, get: function () { return goals_1.GoalBuilder; } });
68
+ // NPC influence (ADR-146)
69
+ var influence_1 = require("./influence");
70
+ Object.defineProperty(exports, "checkResistance", { enumerable: true, get: function () { return influence_1.checkResistance; } });
71
+ Object.defineProperty(exports, "evaluatePassiveInfluences", { enumerable: true, get: function () { return influence_1.evaluatePassiveInfluences; } });
72
+ Object.defineProperty(exports, "evaluateActiveInfluence", { enumerable: true, get: function () { return influence_1.evaluateActiveInfluence; } });
73
+ Object.defineProperty(exports, "InfluenceTracker", { enumerable: true, get: function () { return influence_1.InfluenceTracker; } });
74
+ Object.defineProperty(exports, "evaluatePcInfluence", { enumerable: true, get: function () { return influence_1.evaluatePcInfluence; } });
75
+ Object.defineProperty(exports, "InfluenceBuilder", { enumerable: true, get: function () { return influence_1.InfluenceBuilder; } });
76
+ // Influence message IDs
77
+ Object.defineProperty(exports, "InfluenceMessages", { enumerable: true, get: function () { return influence_1.InfluenceMessages; } });
78
+ // NPC tick phase handlers (ADR-142/144/145/146)
79
+ var tick_phases_1 = require("./tick-phases");
80
+ Object.defineProperty(exports, "CharacterPhaseRegistry", { enumerable: true, get: function () { return tick_phases_1.CharacterPhaseRegistry; } });
81
+ Object.defineProperty(exports, "createPropagationPhase", { enumerable: true, get: function () { return tick_phases_1.createPropagationPhase; } });
82
+ Object.defineProperty(exports, "createGoalPhase", { enumerable: true, get: function () { return tick_phases_1.createGoalPhase; } });
83
+ Object.defineProperty(exports, "createInfluencePhase", { enumerable: true, get: function () { return tick_phases_1.createInfluencePhase; } });
25
84
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../repos/sharpee/packages/character/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,yDAM6B;AAL3B,qHAAA,gBAAgB,OAAA;AAChB,mHAAA,cAAc,OAAA;AAMhB,yDAI6B;AAH3B,sHAAA,iBAAiB,OAAA;AACjB,sHAAA,iBAAiB,OAAA;AAInB,+DAIgC;AAH9B,2HAAA,mBAAmB,OAAA;AAKrB,iCAAyC;AAAhC,uGAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../repos/sharpee/packages/character/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAEH,yDAM6B;AAL3B,qHAAA,gBAAgB,OAAA;AAChB,mHAAA,cAAc,OAAA;AAMhB,yDAI6B;AAH3B,sHAAA,iBAAiB,OAAA;AACjB,sHAAA,iBAAiB,OAAA;AAInB,+DAIgC;AAH9B,2HAAA,mBAAmB,OAAA;AAKrB,iCAAgE;AAAvD,uGAAA,cAAc,OAAA;AAEvB,gCAAgC;AAChC,+CAqDwB;AAtCtB,mHAAA,mBAAmB,OAAA;AACnB,mHAAA,mBAAmB,OAAA;AACnB,YAAY;AACZ,wHAAA,wBAAwB,OAAA;AACxB,oHAAA,oBAAoB,OAAA;AASpB,wHAAA,wBAAwB,OAAA;AACxB,qHAAA,qBAAqB,OAAA;AACrB,qHAAA,qBAAqB,OAAA;AACrB,MAAM;AACN,mHAAA,mBAAmB,OAAA;AACnB,iHAAA,iBAAiB,OAAA;AACjB,sHAAA,sBAAsB,OAAA;AACtB,iBAAiB;AACjB,6GAAA,aAAa,OAAA;AASb,sHAAA,sBAAsB,OAAA;AACtB,mHAAA,mBAAmB,OAAA;AACnB,oHAAA,oBAAoB,OAAA;AACpB,mCAAmC;AACnC,sHAAA,sBAAsB,OAAA;AACtB,2BAA2B;AAC3B,oHAAA,oBAAoB,OAAA;AAItB,oCAAoC;AACpC,6CA4BuB;AAhBrB,gHAAA,iBAAiB,OAAA;AACjB,kHAAA,mBAAmB,OAAA;AACnB,2GAAA,YAAY,OAAA;AAC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