@umicat/platform-sdk 0.2.0 → 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.
- package/dist/ai/AiModule.js +19 -3
- package/dist/protocol.d.ts +16 -0
- package/package.json +2 -2
package/dist/ai/AiModule.js
CHANGED
|
@@ -62,7 +62,23 @@ export class Npc {
|
|
|
62
62
|
this.history = [];
|
|
63
63
|
}
|
|
64
64
|
async say(playerLine, opts) {
|
|
65
|
-
|
|
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
|
|
92
|
+
history,
|
|
77
93
|
});
|
|
78
94
|
if (res.ok && res.say)
|
|
79
|
-
|
|
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/dist/protocol.d.ts
CHANGED
|
@@ -202,6 +202,20 @@ export interface AiActSuccess {
|
|
|
202
202
|
export interface AiActFailure {
|
|
203
203
|
ok: false;
|
|
204
204
|
reason: AiReason;
|
|
205
|
+
/**
|
|
206
|
+
* The platform's own sentence about why, when it has one worth reading.
|
|
207
|
+
*
|
|
208
|
+
* Set by the host for a deliberate 4xx the backend explained — today that
|
|
209
|
+
* is overwhelmingly `UNAVAILABLE` from a 403 because the game has not
|
|
210
|
+
* declared the `ai` capability in its Settings. It exists because the
|
|
211
|
+
* reason codes are for the GAME to branch on, and none of them can tell a
|
|
212
|
+
* creator what to go and fix.
|
|
213
|
+
*
|
|
214
|
+
* Human-readable, English, written by the platform for the person holding
|
|
215
|
+
* the device — not localized, not a stable identifier, and never something
|
|
216
|
+
* to branch on. Show it when you have nothing better to say.
|
|
217
|
+
*/
|
|
218
|
+
detail?: string;
|
|
205
219
|
}
|
|
206
220
|
export type AiActResult = AiActSuccess | AiActFailure;
|
|
207
221
|
export interface AiCompleteParams {
|
|
@@ -225,6 +239,8 @@ export interface AiCompleteSuccess {
|
|
|
225
239
|
export interface AiCompleteFailure {
|
|
226
240
|
ok: false;
|
|
227
241
|
reason: AiReason;
|
|
242
|
+
/** As `AiActFailure.detail`. */
|
|
243
|
+
detail?: string;
|
|
228
244
|
}
|
|
229
245
|
export type AiCompleteResult = AiCompleteSuccess | AiCompleteFailure;
|
|
230
246
|
export interface RealtimeGetTokenParams {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umicat/platform-sdk",
|
|
3
|
-
"version": "0.2.
|
|
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",
|
|
@@ -45,4 +45,4 @@
|
|
|
45
45
|
"type": "git",
|
|
46
46
|
"url": "umicat-platform-sdk"
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|