@umicat/platform-sdk 0.2.1 → 0.2.2

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.
@@ -62,7 +62,23 @@ export class Npc {
62
62
  this.history = [];
63
63
  }
64
64
  async say(playerLine, opts) {
65
- this.history.push({ from: 'player', text: playerLine });
65
+ /**
66
+ * The conversation this turn BELONGS to, captured before the await.
67
+ *
68
+ * `reset()` points `this.history` at a new array. Reading the field again
69
+ * after the round trip therefore appends this answer to whatever
70
+ * conversation is current when it lands — so a game that was reset while
71
+ * an answer was in flight starts its next conversation with the previous
72
+ * one's last sentence already in the model's context. Invisible to the
73
+ * player, since the game has moved on and will not display it, and fully
74
+ * present to the model, which carries on from it.
75
+ *
76
+ * Bound here, a turn that outlives its conversation writes into an array
77
+ * nothing reads again, which is what "forget the conversation" has to
78
+ * mean for a turn already in the air.
79
+ */
80
+ const history = this.history;
81
+ history.push({ from: 'player', text: playerLine });
66
82
  const res = await this.ai.act({
67
83
  playbook: this.config.playbook,
68
84
  persona: {
@@ -73,10 +89,10 @@ export class Npc {
73
89
  },
74
90
  actions: this.config.actions,
75
91
  observation: opts?.observation,
76
- history: this.history,
92
+ history,
77
93
  });
78
94
  if (res.ok && res.say)
79
- this.history.push({ from: 'npc', text: res.say });
95
+ history.push({ from: 'npc', text: res.say });
80
96
  return res;
81
97
  }
82
98
  /** Record a world event the NPC should be aware of next turn (no LLM call). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umicat/platform-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Umicat's platform layer, independent of any rendering engine: identity, cloud saves, shared game data, multiplayer, runtime AI, voice and scripted dialogue. Consumed by @umicat/phaser-sdk and @umicat/three-sdk alike.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",