@linxin666/dsh-pet 0.4.8 → 0.4.10
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/README.i18n.yaml +2 -2
- package/README.md +7 -2
- package/README.zh.md +7 -2
- package/contracts/voice-pack-v1.schema.json +27 -0
- package/lib/client.js +24 -13
- package/lib/client.js.map +1 -1
- package/lib/index.js +160 -28
- package/lib/types/affinity.d.ts +26 -3
- package/lib/types/affinity.d.ts.map +1 -1
- package/lib/types/affinity.js +27 -4
- package/lib/types/client/PetDockEntry.d.ts +5 -0
- package/lib/types/client/PetDockEntry.d.ts.map +1 -1
- package/lib/types/client/PetDockEntry.js +1 -1
- package/lib/types/client/PetSprite.d.ts +5 -0
- package/lib/types/client/PetSprite.d.ts.map +1 -1
- package/lib/types/client/PetSprite.js +20 -8
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +15 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/ledger.d.ts +10 -1
- package/lib/types/ledger.d.ts.map +1 -1
- package/lib/types/ledger.js +11 -1
- package/lib/types/pair-access.d.ts.map +1 -1
- package/lib/types/pair-access.js +26 -3
- package/lib/types/service.d.ts +14 -12
- package/lib/types/service.d.ts.map +1 -1
- package/lib/types/service.js +22 -17
- package/lib/types/voice-pack.d.ts +20 -1
- package/lib/types/voice-pack.d.ts.map +1 -1
- package/lib/types/voice-pack.js +86 -3
- package/package.json +24 -24
- package/src/affinity.test.ts +42 -0
- package/src/affinity.ts +46 -3
- package/src/client/PetDockEntry.tsx +6 -0
- package/src/client/PetSprite.test.tsx +42 -0
- package/src/client/PetSprite.tsx +24 -8
- package/src/client/index.test.tsx +4 -0
- package/src/client/index.ts +15 -1
- package/src/index.ts +2 -0
- package/src/ledger.test.ts +19 -0
- package/src/ledger.ts +15 -1
- package/src/pair-access.ts +26 -3
- package/src/service.test.ts +61 -0
- package/src/service.ts +27 -18
- package/src/voice-pack.test.ts +112 -0
- package/src/voice-pack.ts +101 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../src/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAA;AACtB,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,iDAAiD;AACjD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAC7B,mFAAmF;IACnF,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,mEAAmE;IACnE,YAAY,CAAC,EAAE,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../src/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAA;AACtB,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,iDAAiD;AACjD,MAAM,WAAW,YAAY;IAC3B,QAA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
|
20
20
|
/** Round-robin reaction picker; rebuilt when the selected pet changes. */
|
|
21
21
|
picker;
|
|
22
|
+
/** Declared rank ladder; undefined keeps the built-in whale ladder. */
|
|
23
|
+
rankLadder;
|
|
22
24
|
current;
|
|
23
25
|
/** Completed turns already rewarded, per session (turn numbers are per-session). */
|
|
24
26
|
rewardedTurns = new Map();
|
|
@@ -28,6 +30,7 @@ export class PetLedger {
|
|
|
28
30
|
this.affinityConfig = { ...defaultAffinityConfig, ...(config.affinity ?? {}) };
|
|
29
31
|
this.treatConfig = { ...defaultTreatConfig, ...(config.treats ?? {}) };
|
|
30
32
|
this.picker = new RemarkPicker(config.remarks, config.voiceRemarks);
|
|
33
|
+
this.rankLadder = config.rankLadder;
|
|
31
34
|
this.current = persist;
|
|
32
35
|
}
|
|
33
36
|
/** Affinity cooldown/rank tuning (read-only). */
|
|
@@ -109,6 +112,13 @@ export class PetLedger {
|
|
|
109
112
|
setRemarks(remarks, voiceRemarks) {
|
|
110
113
|
this.picker = new RemarkPicker(remarks, voiceRemarks);
|
|
111
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Swap the display-only rank ladder to the selected pet's declared one
|
|
117
|
+
* (called on pet selection). Undefined restores the built-in ladder.
|
|
118
|
+
*/
|
|
119
|
+
setRankLadder(ladder) {
|
|
120
|
+
this.rankLadder = ladder;
|
|
121
|
+
}
|
|
112
122
|
/**
|
|
113
123
|
* Settle the treat economy (work + time output since the last settlement).
|
|
114
124
|
* A zero-gain first settlement still starts the time clock (anchor write),
|
|
@@ -229,6 +239,6 @@ export class PetLedger {
|
|
|
229
239
|
}
|
|
230
240
|
/** Current affinity view for the RPC snapshot. */
|
|
231
241
|
affinityView(nowMs) {
|
|
232
|
-
return affinityViewOf(this.current.affinity, nowMs, this.affinityConfig);
|
|
242
|
+
return affinityViewOf(this.current.affinity, nowMs, this.affinityConfig, this.rankLadder);
|
|
233
243
|
}
|
|
234
244
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pair-access.d.ts","sourceRoot":"","sources":["../../src/pair-access.ts"],"names":[],"mappings":"AACA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAGhD,0EAA0E;AAC1E,UAAU,aAAa;IACrB,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAA;CAClD;AAED;;;;;GAKG;AACH,UAAU,SAAS;IACjB,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAC7C,kBAAkB,CAAC,EAAE,aAAa,CAAA;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"pair-access.d.ts","sourceRoot":"","sources":["../../src/pair-access.ts"],"names":[],"mappings":"AACA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAGhD,0EAA0E;AAC1E,UAAU,aAAa;IACrB,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAA;CAClD;AAED;;;;;GAKG;AACH,UAAU,SAAS;IACjB,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAC7C,kBAAkB,CAAC,EAAE,aAAa,CAAA;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAG3F"}
|
package/lib/types/pair-access.js
CHANGED
|
@@ -8,9 +8,32 @@ import { isLoopbackRequest } from "./loopback.js";
|
|
|
8
8
|
export function isPairedOrLoopbackAllowed(ctx, request) {
|
|
9
9
|
if (isLoopbackRequest(request))
|
|
10
10
|
return true;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
return lookupPairing(ctx)?.isPairedDevice(request) === true;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The pairing service, or undefined when this composition does not expose it.
|
|
15
|
+
*
|
|
16
|
+
* Two lookups exist because the fence is shared with test harnesses that hand
|
|
17
|
+
* over a bare object: a real cordis context resolves services through `get`, a
|
|
18
|
+
* harness may carry the property directly. `get(name, false)` is the
|
|
19
|
+
* non-strict form, so an unloaded service answers undefined rather than
|
|
20
|
+
* throwing. Reading an un-injected service as a PROPERTY throws instead
|
|
21
|
+
* (`cannot get property "remoteWebUiPairing" without inject`); a trust fence
|
|
22
|
+
* must answer "not paired" in that case, never leak the error into the route
|
|
23
|
+
* handler, where the host web server turns it into an empty-body 400 (#1942).
|
|
24
|
+
*/
|
|
25
|
+
function lookupPairing(ctx) {
|
|
26
|
+
if (typeof ctx.get === 'function') {
|
|
27
|
+
const viaGet = ctx.get('remoteWebUiPairing', false);
|
|
28
|
+
return isPairingAccess(viaGet) ? viaGet : undefined;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const viaProperty = ctx.remoteWebUiPairing;
|
|
32
|
+
return isPairingAccess(viaProperty) ? viaProperty : undefined;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
14
37
|
}
|
|
15
38
|
function isPairingAccess(value) {
|
|
16
39
|
return value !== undefined
|
package/lib/types/service.d.ts
CHANGED
|
@@ -309,19 +309,21 @@ export declare class PetService extends Service {
|
|
|
309
309
|
/** Whether the pet service consumes session activity while enabled. */
|
|
310
310
|
isEnabled(): boolean;
|
|
311
311
|
/**
|
|
312
|
-
* The
|
|
313
|
-
* first, then the voice packs (a pet directory's voice.json over the
|
|
314
|
-
* `$DSH_HOME/pets/.voice.json`).
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
312
|
+
* The voice layers one pet contributes to the ledger: its manifest remark
|
|
313
|
+
* pools first, then the voice packs (a pet directory's voice.json over the
|
|
314
|
+
* global `$DSH_HOME/pets/.voice.json`). The voice pack's `panel.ranks`
|
|
315
|
+
* ladder rides the same merge, so a ladder declared by either layer applies
|
|
316
|
+
* with the documented precedence. Every path that seats these layers
|
|
317
|
+
* resolves them here, so no call site can apply the manifest pools and
|
|
318
|
+
* silently drop the voice layer: doing that reverted a pet whose lines a
|
|
319
|
+
* voice pack had translated back to the built-in pools the moment the
|
|
320
|
+
* settings surface applied.
|
|
321
|
+
* @param entry - the pet whose layers apply.
|
|
322
|
+
* @returns the layers `PetLedger` takes.
|
|
321
323
|
*/
|
|
322
|
-
private
|
|
323
|
-
/** Re-seat the ledger's remark pools from one pet's layers. */
|
|
324
|
-
private
|
|
324
|
+
private voiceLayers;
|
|
325
|
+
/** Re-seat the ledger's remark pools and rank ladder from one pet's layers. */
|
|
326
|
+
private applyVoiceLayers;
|
|
325
327
|
/** RPC: current pet state snapshot. */
|
|
326
328
|
state(currentSessionId?: string): Promise<PetStateView>;
|
|
327
329
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGtD,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGtD,OAAO,KAAK,EAAE,cAAc,EAAoB,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACtG,OAAO,EAA2D,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAC7G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,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,IAAI,CAAC;QAAC,OAAO,EAAE,gBAAgB,CAAA;KAAE,CAAC;IAOpF;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAMrB;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAc5G,6GAA6G;IACvG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,OAAO,EAAE,gBAAgB,CAAA;KAAE,CAAC;IAYnG,2EAA2E;IACrE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAS/F;;;;;OAKG;IACH,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IA4BvD,oFAAoF;IACpF,OAAO,CAAC,mBAAmB;IAgB3B,qFAAqF;IACrF,OAAO,CAAC,UAAU;IAIlB,8EAA8E;IAC9E,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,IAAI;IAkGZ,OAAO,CAAC,KAAK;CAOd"}
|
package/lib/types/service.js
CHANGED
|
@@ -125,7 +125,7 @@ export class PetService extends Service {
|
|
|
125
125
|
const ledgerConfig = {
|
|
126
126
|
affinity: config.affinity,
|
|
127
127
|
treats: config.treats,
|
|
128
|
-
...this.
|
|
128
|
+
...this.voiceLayers(selected),
|
|
129
129
|
};
|
|
130
130
|
this.ledger = new PetLedger(persist, ledgerConfig);
|
|
131
131
|
this.stateConfig = { ...defaultPetStateConfig, ...(config.state ?? {}) };
|
|
@@ -156,26 +156,31 @@ export class PetService extends Service {
|
|
|
156
156
|
return this.enabled;
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
|
-
* The
|
|
160
|
-
* first, then the voice packs (a pet directory's voice.json over the
|
|
161
|
-
* `$DSH_HOME/pets/.voice.json`).
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
159
|
+
* The voice layers one pet contributes to the ledger: its manifest remark
|
|
160
|
+
* pools first, then the voice packs (a pet directory's voice.json over the
|
|
161
|
+
* global `$DSH_HOME/pets/.voice.json`). The voice pack's `panel.ranks`
|
|
162
|
+
* ladder rides the same merge, so a ladder declared by either layer applies
|
|
163
|
+
* with the documented precedence. Every path that seats these layers
|
|
164
|
+
* resolves them here, so no call site can apply the manifest pools and
|
|
165
|
+
* silently drop the voice layer: doing that reverted a pet whose lines a
|
|
166
|
+
* voice pack had translated back to the built-in pools the moment the
|
|
167
|
+
* settings surface applied.
|
|
168
|
+
* @param entry - the pet whose layers apply.
|
|
169
|
+
* @returns the layers `PetLedger` takes.
|
|
168
170
|
*/
|
|
169
|
-
|
|
171
|
+
voiceLayers(entry) {
|
|
172
|
+
const voice = mergeVoicePacks(this.registry.globalVoice, entry.voice);
|
|
170
173
|
return {
|
|
171
174
|
remarks: entry.remarks,
|
|
172
|
-
voiceRemarks:
|
|
175
|
+
voiceRemarks: voice?.remarks,
|
|
176
|
+
rankLadder: voice?.panel?.ranks,
|
|
173
177
|
};
|
|
174
178
|
}
|
|
175
|
-
/** Re-seat the ledger's remark pools from one pet's layers. */
|
|
176
|
-
|
|
177
|
-
const layers = this.
|
|
179
|
+
/** Re-seat the ledger's remark pools and rank ladder from one pet's layers. */
|
|
180
|
+
applyVoiceLayers(entry) {
|
|
181
|
+
const layers = this.voiceLayers(entry);
|
|
178
182
|
this.ledger.setRemarks(layers.remarks, layers.voiceRemarks);
|
|
183
|
+
this.ledger.setRankLadder(layers.rankLadder);
|
|
179
184
|
}
|
|
180
185
|
/** RPC: current pet state snapshot. */
|
|
181
186
|
async state(currentSessionId) {
|
|
@@ -314,7 +319,7 @@ export class PetService extends Service {
|
|
|
314
319
|
if (entry === undefined)
|
|
315
320
|
return { ok: false, error: 'unknown-pet' };
|
|
316
321
|
this.ledger.setPetId(entry.id);
|
|
317
|
-
this.
|
|
322
|
+
this.applyVoiceLayers(entry);
|
|
318
323
|
this.flush();
|
|
319
324
|
this.syncSettingsFromPet();
|
|
320
325
|
return { ok: true, petId: entry.id };
|
|
@@ -720,7 +725,7 @@ export class PetService extends Service {
|
|
|
720
725
|
const selected = typeof section.petId === 'string' ? this.registry.byId(section.petId) : undefined;
|
|
721
726
|
if (selected !== undefined) {
|
|
722
727
|
this.ledger.setPetId(selected.id);
|
|
723
|
-
this.
|
|
728
|
+
this.applyVoiceLayers(selected);
|
|
724
729
|
}
|
|
725
730
|
else if (section.petId !== undefined) {
|
|
726
731
|
// The stored selection names a pet the registry no longer has: keep the
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
*/
|
|
30
30
|
import { type VoicePackOverrides, type WhisperCategory, type WhisperResult } from './chatter.ts';
|
|
31
31
|
import { type PetRemarks } from './remarks.ts';
|
|
32
|
+
import type { AffinityRankName } from './affinity.ts';
|
|
32
33
|
/** Schema version this module normalizes (optional field; missing = 1). */
|
|
33
34
|
export declare const VOICE_PACK_V1: 1;
|
|
34
35
|
/** Hover-panel action buttons a pack can show or hide (canonical order). */
|
|
@@ -48,6 +49,11 @@ export interface PetPanelView {
|
|
|
48
49
|
stats?: Partial<Record<PanelStatKey, string>>;
|
|
49
50
|
/** Actions to render in canonical order; absent = all three; [] = none. */
|
|
50
51
|
actions?: PanelAction[];
|
|
52
|
+
/**
|
|
53
|
+
* Display-only affinity ladder: replaces the built-in tier names for this
|
|
54
|
+
* pet. Points, rewards, cooldowns and the persisted ledger are untouched.
|
|
55
|
+
*/
|
|
56
|
+
ranks?: readonly AffinityRankName[];
|
|
51
57
|
}
|
|
52
58
|
/** One normalized voice pack (a pet's voice.json or the global override). */
|
|
53
59
|
export interface VoicePack {
|
|
@@ -65,6 +71,10 @@ export declare const VOICE_POOL_LINES_MAX = 64;
|
|
|
65
71
|
export declare const VOICE_LINE_MAX = 160;
|
|
66
72
|
export declare const VOICE_LABEL_MAX = 40;
|
|
67
73
|
export declare const VOICE_STAT_MAX = 80;
|
|
74
|
+
/** Hard cap on a pet-declared affinity ladder (entries). */
|
|
75
|
+
export declare const RANK_LADDER_MAX = 16;
|
|
76
|
+
/** Longest accepted rank name in a pet-declared ladder (characters). */
|
|
77
|
+
export declare const RANK_NAME_MAX = 24;
|
|
68
78
|
type PoolKind = 'status' | 'tools' | 'toolRemaining' | 'whisperCategory' | 'whisperResult' | 'label' | 'stat';
|
|
69
79
|
/**
|
|
70
80
|
* Normalize one pool slot. Accepts a single line or an array; non-string
|
|
@@ -79,7 +89,16 @@ export declare function normalizePool(raw: unknown, kind: PoolKind, onWarning?:
|
|
|
79
89
|
export declare function normalizeWhisperCategories(raw: unknown, onWarning?: (message: string) => void): Partial<Record<WhisperCategory, readonly string[]>> | undefined;
|
|
80
90
|
/** Normalize whisper outcome pools; a key replaces that outcome's built-in pool (an explicit empty pool mutes it). */
|
|
81
91
|
export declare function normalizeWhisperResults(raw: unknown, onWarning?: (message: string) => void): Partial<Record<WhisperResult, readonly string[]>> | undefined;
|
|
82
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Normalize one pet-declared affinity ladder (`panel.ranks`). A ladder is
|
|
94
|
+
* all-or-nothing: it must be an array of 1-{@link RANK_LADDER_MAX} entries,
|
|
95
|
+
* start at min 0, sort ascending with unique minima, and carry names of
|
|
96
|
+
* 1-{@link RANK_NAME_MAX} characters. Any violation warns and drops the
|
|
97
|
+
* whole ladder, so the pet keeps the built-in names instead of a half-broken
|
|
98
|
+
* ladder; a bad ladder never rejects the pet.
|
|
99
|
+
*/
|
|
100
|
+
export declare function normalizeRankLadder(raw: unknown, onWarning?: (message: string) => void): AffinityRankName[] | undefined;
|
|
101
|
+
/** Normalize the panel block (labels / stats / actions / ranks; warn-and-drop). */
|
|
83
102
|
export declare function normalizePanel(raw: unknown, onWarning?: (message: string) => void): PetPanelView | undefined;
|
|
84
103
|
/** Voice-pack top-level fields ('$schema' mirrors the schema twin; drift-locked in tests). */
|
|
85
104
|
export declare const VOICE_PACK_KEYS: Set<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voice-pack.d.ts","sourceRoot":"","sources":["../../src/voice-pack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"voice-pack.d.ts","sourceRoot":"","sources":["../../src/voice-pack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,2EAA2E;AAC3E,eAAO,MAAM,aAAa,EAAG,CAAU,CAAA;AAEvC,4EAA4E;AAC5E,eAAO,MAAM,aAAa,qCAAsC,CAAA;AAChE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;AAExD,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,gDAAiD,CAAA;AAC9E,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAA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"}
|
package/lib/types/voice-pack.js
CHANGED
|
@@ -42,6 +42,10 @@ export const VOICE_POOL_LINES_MAX = 64;
|
|
|
42
42
|
export const VOICE_LINE_MAX = 160;
|
|
43
43
|
export const VOICE_LABEL_MAX = 40;
|
|
44
44
|
export const VOICE_STAT_MAX = 80;
|
|
45
|
+
/** Hard cap on a pet-declared affinity ladder (entries). */
|
|
46
|
+
export const RANK_LADDER_MAX = 16;
|
|
47
|
+
/** Longest accepted rank name in a pet-declared ladder (characters). */
|
|
48
|
+
export const RANK_NAME_MAX = 24;
|
|
45
49
|
/** Any '{token}' placeholder (no nesting, no newlines). */
|
|
46
50
|
const PLACEHOLDER_PATTERN = /{[^{}]*}/g;
|
|
47
51
|
/** Allowed placeholder tokens per pool kind (absent kind = none allowed). */
|
|
@@ -150,7 +154,72 @@ export function normalizeWhisperResults(raw, onWarning = () => { }) {
|
|
|
150
154
|
}
|
|
151
155
|
return Object.keys(pools).length > 0 ? pools : undefined;
|
|
152
156
|
}
|
|
153
|
-
/**
|
|
157
|
+
/** Validate one rank name slot of a declared ladder. */
|
|
158
|
+
function rankName(raw, index, field, onWarning) {
|
|
159
|
+
if (typeof raw !== 'string') {
|
|
160
|
+
onWarning('panel.ranks[' + index + '].' + field + ' must be a string');
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
const trimmed = raw.trim();
|
|
164
|
+
if (trimmed === '' || trimmed.length > RANK_NAME_MAX) {
|
|
165
|
+
onWarning('panel.ranks[' + index + '].' + field + ' must be 1-' + RANK_NAME_MAX + ' characters');
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
return trimmed;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Normalize one pet-declared affinity ladder (`panel.ranks`). A ladder is
|
|
172
|
+
* all-or-nothing: it must be an array of 1-{@link RANK_LADDER_MAX} entries,
|
|
173
|
+
* start at min 0, sort ascending with unique minima, and carry names of
|
|
174
|
+
* 1-{@link RANK_NAME_MAX} characters. Any violation warns and drops the
|
|
175
|
+
* whole ladder, so the pet keeps the built-in names instead of a half-broken
|
|
176
|
+
* ladder; a bad ladder never rejects the pet.
|
|
177
|
+
*/
|
|
178
|
+
export function normalizeRankLadder(raw, onWarning = () => { }) {
|
|
179
|
+
if (!Array.isArray(raw)) {
|
|
180
|
+
onWarning('panel.ranks must be an array');
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
if (raw.length === 0 || raw.length > RANK_LADDER_MAX) {
|
|
184
|
+
onWarning('panel.ranks must contain 1-' + RANK_LADDER_MAX + ' entries');
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
const ladder = [];
|
|
188
|
+
let previousMin = -1;
|
|
189
|
+
for (let index = 0; index < raw.length; index++) {
|
|
190
|
+
const entry = raw[index];
|
|
191
|
+
if (!isRecord(entry)) {
|
|
192
|
+
onWarning('panel.ranks[' + index + '] must be an object');
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
const min = entry.min;
|
|
196
|
+
if (typeof min !== 'number' || !Number.isSafeInteger(min) || min < 0) {
|
|
197
|
+
onWarning('panel.ranks[' + index + '].min must be a non-negative integer');
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
if (index === 0 && min !== 0) {
|
|
201
|
+
onWarning('panel.ranks must start at min 0');
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
if (min <= previousMin) {
|
|
205
|
+
onWarning('panel.ranks must be sorted ascending with unique min values');
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
previousMin = min;
|
|
209
|
+
const defaultName = rankName(entry.name, index, 'name', onWarning);
|
|
210
|
+
if (defaultName === undefined)
|
|
211
|
+
return undefined;
|
|
212
|
+
let nameEn;
|
|
213
|
+
if (entry.nameEn !== undefined) {
|
|
214
|
+
nameEn = rankName(entry.nameEn, index, 'nameEn', onWarning);
|
|
215
|
+
if (nameEn === undefined)
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
ladder.push({ min, name: defaultName, ...(nameEn === undefined ? {} : { nameEn }) });
|
|
219
|
+
}
|
|
220
|
+
return ladder;
|
|
221
|
+
}
|
|
222
|
+
/** Normalize the panel block (labels / stats / actions / ranks; warn-and-drop). */
|
|
154
223
|
export function normalizePanel(raw, onWarning = () => { }) {
|
|
155
224
|
if (!isRecord(raw)) {
|
|
156
225
|
onWarning('panel must be an object');
|
|
@@ -221,7 +290,14 @@ export function normalizePanel(raw, onWarning = () => { }) {
|
|
|
221
290
|
panel.actions = PANEL_ACTIONS.filter(action => seen.has(action));
|
|
222
291
|
}
|
|
223
292
|
}
|
|
224
|
-
|
|
293
|
+
const ranksRaw = raw.ranks;
|
|
294
|
+
if (ranksRaw !== undefined) {
|
|
295
|
+
const ladder = normalizeRankLadder(ranksRaw, onWarning);
|
|
296
|
+
if (ladder !== undefined)
|
|
297
|
+
panel.ranks = ladder;
|
|
298
|
+
}
|
|
299
|
+
if (panel.labels === undefined && panel.stats === undefined
|
|
300
|
+
&& panel.actions === undefined && panel.ranks === undefined)
|
|
225
301
|
return undefined;
|
|
226
302
|
return panel;
|
|
227
303
|
}
|
|
@@ -364,6 +440,7 @@ export function mergeVoicePacks(...layers) {
|
|
|
364
440
|
const stats = {};
|
|
365
441
|
let remarks;
|
|
366
442
|
let ranks;
|
|
443
|
+
let panelRanks;
|
|
367
444
|
let actions;
|
|
368
445
|
let panelSeen = false;
|
|
369
446
|
let any = false;
|
|
@@ -390,6 +467,10 @@ export function mergeVoicePacks(...layers) {
|
|
|
390
467
|
Object.assign(stats, layer.panel.stats);
|
|
391
468
|
if (layer.panel.actions !== undefined)
|
|
392
469
|
actions = layer.panel.actions;
|
|
470
|
+
// A ladder is atomic: a declaring layer replaces the previous ladder
|
|
471
|
+
// whole instead of merging tiers across layers.
|
|
472
|
+
if (layer.panel.ranks !== undefined)
|
|
473
|
+
panelRanks = layer.panel.ranks;
|
|
393
474
|
}
|
|
394
475
|
if (layer.remarks !== undefined) {
|
|
395
476
|
remarks = { ...(remarks ?? {}), ...layer.remarks };
|
|
@@ -404,8 +485,10 @@ export function mergeVoicePacks(...layers) {
|
|
|
404
485
|
...(Object.keys(labels).length > 0 ? { labels } : {}),
|
|
405
486
|
...(Object.keys(stats).length > 0 ? { stats } : {}),
|
|
406
487
|
...(actions === undefined ? {} : { actions }),
|
|
488
|
+
...(panelRanks === undefined ? {} : { ranks: panelRanks }),
|
|
407
489
|
};
|
|
408
|
-
const panelEmpty = panel.labels === undefined && panel.stats === undefined
|
|
490
|
+
const panelEmpty = panel.labels === undefined && panel.stats === undefined
|
|
491
|
+
&& panel.actions === undefined && panel.ranks === undefined;
|
|
409
492
|
return {
|
|
410
493
|
overrides,
|
|
411
494
|
...(panelSeen && !panelEmpty ? { panel } : {}),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-pet",
|
|
3
3
|
"description": "Multi-pet companion plugin for the dsh web GUI: a registry-driven floating pet that reacts to model activity, with per-pet naming, petting/feeding interactions and an affinity score",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.10",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"license": "Apache-2.0",
|
|
51
51
|
"dsh": {
|
|
52
52
|
"engines": {
|
|
53
|
-
"dsh": ">=0.2.1-rc.
|
|
53
|
+
"dsh": ">=0.2.1-rc.3"
|
|
54
54
|
},
|
|
55
55
|
"bundle": {
|
|
56
56
|
"patch": "./cordis.patch.yml"
|
|
@@ -71,33 +71,33 @@
|
|
|
71
71
|
"clsx": "^2.1.1"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@deepseek-ai/dsh": ">=0.2.1-rc.
|
|
74
|
+
"@deepseek-ai/dsh": ">=0.2.1-rc.3",
|
|
75
75
|
"react": "^18.2.0",
|
|
76
76
|
"react-dom": "^18.2.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@deepseek-ai/cordis": "~4.0.5",
|
|
80
|
-
"@deepseek-ai/dsh-agent": "^0.2.1-rc.
|
|
81
|
-
"@deepseek-ai/dsh-api-remotes": "^0.2.1-rc.
|
|
82
|
-
"@deepseek-ai/dsh-api-session-controller": "^0.2.1-rc.
|
|
83
|
-
"@deepseek-ai/dsh-api-workspace-controller": "^0.2.1-rc.
|
|
84
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.1-rc.
|
|
85
|
-
"@deepseek-ai/dsh-client-store": "^0.2.1-rc.
|
|
86
|
-
"@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-rc.
|
|
87
|
-
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.
|
|
88
|
-
"@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.
|
|
89
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.
|
|
90
|
-
"@deepseek-ai/dsh-client-ui-workspace": "^0.2.1-rc.
|
|
91
|
-
"@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.
|
|
92
|
-
"@deepseek-ai/dsh-llm": "^0.2.1-rc.
|
|
93
|
-
"@deepseek-ai/dsh-scope": "^0.2.1-rc.
|
|
94
|
-
"@deepseek-ai/dsh-session": "^0.2.1-rc.
|
|
95
|
-
"@deepseek-ai/dsh-settings": "^0.2.1-rc.
|
|
96
|
-
"@deepseek-ai/dsh-subagent": "^0.2.1-rc.
|
|
97
|
-
"@deepseek-ai/dsh-timeout": "^0.2.1-rc.
|
|
98
|
-
"@deepseek-ai/dsh-tools": "^0.2.1-rc.
|
|
99
|
-
"@deepseek-ai/dsh-util-time": "^0.2.1-rc.
|
|
100
|
-
"@deepseek-ai/dsh-util-values": "^0.2.1-rc.
|
|
80
|
+
"@deepseek-ai/dsh-agent": "^0.2.1-rc.3",
|
|
81
|
+
"@deepseek-ai/dsh-api-remotes": "^0.2.1-rc.3",
|
|
82
|
+
"@deepseek-ai/dsh-api-session-controller": "^0.2.1-rc.3",
|
|
83
|
+
"@deepseek-ai/dsh-api-workspace-controller": "^0.2.1-rc.3",
|
|
84
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.1-rc.3",
|
|
85
|
+
"@deepseek-ai/dsh-client-store": "^0.2.1-rc.3",
|
|
86
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-rc.3",
|
|
87
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.3",
|
|
88
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.2.1-rc.3",
|
|
89
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.3",
|
|
90
|
+
"@deepseek-ai/dsh-client-ui-workspace": "^0.2.1-rc.3",
|
|
91
|
+
"@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.3",
|
|
92
|
+
"@deepseek-ai/dsh-llm": "^0.2.1-rc.3",
|
|
93
|
+
"@deepseek-ai/dsh-scope": "^0.2.1-rc.3",
|
|
94
|
+
"@deepseek-ai/dsh-session": "^0.2.1-rc.3",
|
|
95
|
+
"@deepseek-ai/dsh-settings": "^0.2.1-rc.3",
|
|
96
|
+
"@deepseek-ai/dsh-subagent": "^0.2.1-rc.3",
|
|
97
|
+
"@deepseek-ai/dsh-timeout": "^0.2.1-rc.3",
|
|
98
|
+
"@deepseek-ai/dsh-tools": "^0.2.1-rc.3",
|
|
99
|
+
"@deepseek-ai/dsh-util-time": "^0.2.1-rc.3",
|
|
100
|
+
"@deepseek-ai/dsh-util-values": "^0.2.1-rc.3",
|
|
101
101
|
"@testing-library/dom": "^10.4.1",
|
|
102
102
|
"@testing-library/react": "^16.3.2",
|
|
103
103
|
"@types/node": "^22.20.0",
|
package/src/affinity.test.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'
|
|
|
2
2
|
import {
|
|
3
3
|
AFFINITY_MAX,
|
|
4
4
|
AFFINITY_RANKS,
|
|
5
|
+
affinityViewOf,
|
|
5
6
|
applyInteraction,
|
|
6
7
|
applyTurnReward,
|
|
7
8
|
defaultAffinityConfig,
|
|
@@ -82,6 +83,47 @@ describe('rankOf', () => {
|
|
|
82
83
|
expect(rankOf(-1).name).toBe(AFFINITY_RANKS[0]!.name)
|
|
83
84
|
})
|
|
84
85
|
|
|
86
|
+
it('maps points onto a declared ladder while keeping the built-in marker', () => {
|
|
87
|
+
const ladder = [
|
|
88
|
+
{ min: 0, name: '小煤球', nameEn: 'Little Coal Ball' },
|
|
89
|
+
{ min: 25, name: '火星伙伴', nameEn: 'Martian Buddy' },
|
|
90
|
+
{ min: 50, name: '煤球挚友' },
|
|
91
|
+
]
|
|
92
|
+
expect(rankOf(0, ladder).name).toBe('小煤球')
|
|
93
|
+
expect(rankOf(24, ladder).name).toBe('小煤球')
|
|
94
|
+
expect(rankOf(25, ladder).name).toBe('火星伙伴')
|
|
95
|
+
expect(rankOf(100_000, ladder).name).toBe('煤球挚友')
|
|
96
|
+
// Display-only: the built-in tier still supplies the marker glyph.
|
|
97
|
+
expect(rankOf(0, ladder).emoji).toBe(AFFINITY_RANKS[0]!.emoji)
|
|
98
|
+
expect(rankOf(100_000, ladder).emoji).toBe(AFFINITY_RANKS[AFFINITY_RANKS.length - 1]!.emoji)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('keeps the built-in names for a pet that declares no ladder', () => {
|
|
102
|
+
expect(rankOf(0).name).toBe('幼鲸')
|
|
103
|
+
expect(rankOf(100_000).name).toBe('鲸生共渡')
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('carries nameEn into the affinity view only when the ladder declares it', () => {
|
|
107
|
+
const state = { ...emptyAffinity(), points: 25 }
|
|
108
|
+
const declared = affinityViewOf(state, 0, defaultAffinityConfig, [
|
|
109
|
+
{ min: 0, name: '小煤球', nameEn: 'Little Coal Ball' },
|
|
110
|
+
{ min: 25, name: '火星伙伴', nameEn: 'Martian Buddy' },
|
|
111
|
+
])
|
|
112
|
+
expect(declared.rank).toBe('火星伙伴')
|
|
113
|
+
expect(declared.rankEn).toBe('Martian Buddy')
|
|
114
|
+
expect(declared.points).toBe(25)
|
|
115
|
+
expect(declared.rankEmoji).toBe(rankOf(25).emoji)
|
|
116
|
+
|
|
117
|
+
const chineseOnly = affinityViewOf(state, 0, defaultAffinityConfig, [{ min: 0, name: '小煤球' }])
|
|
118
|
+
expect(chineseOnly.rank).toBe('小煤球')
|
|
119
|
+
expect(chineseOnly.rankEn).toBeUndefined()
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('does not change the point economy', () => {
|
|
123
|
+
const outcome = applyInteraction(emptyAffinity(), 'feed', 1_000_000)
|
|
124
|
+
expect(outcome.affinity.points).toBe(defaultAffinityConfig.feedReward)
|
|
125
|
+
})
|
|
126
|
+
|
|
85
127
|
it('extends past the removed 100 cap with higher tiers', () => {
|
|
86
128
|
// The original four tiers keep their thresholds; the ladder now reaches
|
|
87
129
|
// into the 999,999,999 range instead of freezing at 80 points.
|