@linxin666/dsh-pet 0.1.3 → 0.1.7
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/lib/client.js +63 -53
- package/lib/client.js.map +1 -1
- package/lib/types/client/PetDockEntry.d.ts +5 -6
- package/lib/types/client/PetDockEntry.d.ts.map +1 -1
- package/lib/types/client/PetDockEntry.js +4 -5
- package/lib/types/client/WhalePet.d.ts.map +1 -1
- package/lib/types/client/WhalePet.js +15 -3
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +7 -6
- package/lib/types/index.d.ts +14 -13
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client/PetDockEntry.tsx +5 -6
- package/src/client/WhalePet.tsx +16 -3
- package/src/client/index.ts +7 -6
- package/src/client/pet.module.css +1 -1
- package/lib/state-7ChK99mH.js +0 -217
- package/lib/state-CKh9f_dF.js +0 -196
- package/lib/state-DMgOYVFT.js +0 -198
- package/lib/types/client/DockPetDockEntry.d.ts +0 -23
- package/lib/types/client/DockPetDockEntry.d.ts.map +0 -1
- package/lib/types/client/DockPetDockEntry.js +0 -10
- package/lib/types/client/slots-augment.d.ts +0 -19
- package/lib/types/client/slots-augment.d.ts.map +0 -1
- package/lib/types/client/slots-augment.js +0 -1
- package/src/client/slots-augment.ts +0 -27
package/lib/state-DMgOYVFT.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
//#region src/affinity.ts
|
|
2
|
-
const AFFINITY_MAX = 100;
|
|
3
|
-
/** Affinity ranks by points; the pet visibly grows with its rank. */
|
|
4
|
-
const AFFINITY_RANKS = [
|
|
5
|
-
{
|
|
6
|
-
min: 0,
|
|
7
|
-
name: "幼鲸",
|
|
8
|
-
emoji: "🐣"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
min: 25,
|
|
12
|
-
name: "伙伴",
|
|
13
|
-
emoji: "🐬"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
min: 50,
|
|
17
|
-
name: "挚友",
|
|
18
|
-
emoji: "🐳"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
min: 80,
|
|
22
|
-
name: "深海羁绊",
|
|
23
|
-
emoji: "💙"
|
|
24
|
-
}
|
|
25
|
-
];
|
|
26
|
-
const defaultAffinityConfig = {
|
|
27
|
-
turnReward: 1,
|
|
28
|
-
petReward: 1,
|
|
29
|
-
petCooldownMs: 1e4,
|
|
30
|
-
feedReward: 5,
|
|
31
|
-
feedCooldownMs: 3e4
|
|
32
|
-
};
|
|
33
|
-
function emptyAffinity() {
|
|
34
|
-
return {
|
|
35
|
-
points: 0,
|
|
36
|
-
lastPetAt: 0,
|
|
37
|
-
lastFeedAt: 0,
|
|
38
|
-
pets: 0,
|
|
39
|
-
feeds: 0,
|
|
40
|
-
turns: 0
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/** Rank for a point total. */
|
|
44
|
-
function rankOf(points) {
|
|
45
|
-
let rank = AFFINITY_RANKS[0];
|
|
46
|
-
for (const candidate of AFFINITY_RANKS) if (points >= candidate.min) rank = candidate;
|
|
47
|
-
return rank;
|
|
48
|
-
}
|
|
49
|
-
function clamp(points) {
|
|
50
|
-
return Math.min(100, Math.max(0, points));
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Apply one interaction to a copy of the state (immutable style: returns a
|
|
54
|
-
* new object; the caller replaces the persisted state). Cooldowns only
|
|
55
|
-
* apply once the pet has been interacted with at least once (last*At === 0
|
|
56
|
-
* means "never", so the first pet/feed always lands).
|
|
57
|
-
*/
|
|
58
|
-
function applyInteraction(state, kind, nowMs, config = defaultAffinityConfig) {
|
|
59
|
-
const next = { ...state };
|
|
60
|
-
if (kind === "pet") {
|
|
61
|
-
if (state.lastPetAt !== 0 && nowMs - state.lastPetAt < config.petCooldownMs) return {
|
|
62
|
-
affinity: state,
|
|
63
|
-
delta: 0,
|
|
64
|
-
reaction: "摸过头啦,让鲸鱼娘歇口气~",
|
|
65
|
-
accepted: false
|
|
66
|
-
};
|
|
67
|
-
next.lastPetAt = nowMs;
|
|
68
|
-
next.pets += 1;
|
|
69
|
-
next.points = clamp(state.points + config.petReward);
|
|
70
|
-
return {
|
|
71
|
-
affinity: next,
|
|
72
|
-
delta: config.petReward,
|
|
73
|
-
reaction: "咕噜咕噜~被摸摸好舒服!",
|
|
74
|
-
accepted: true
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
if (kind === "feed") {
|
|
78
|
-
if (state.lastFeedAt !== 0 && nowMs - state.lastFeedAt < config.feedCooldownMs) return {
|
|
79
|
-
affinity: state,
|
|
80
|
-
delta: 0,
|
|
81
|
-
reaction: "吃饱啦,晚点再喂~",
|
|
82
|
-
accepted: false
|
|
83
|
-
};
|
|
84
|
-
next.lastFeedAt = nowMs;
|
|
85
|
-
next.feeds += 1;
|
|
86
|
-
next.points = clamp(state.points + config.feedReward);
|
|
87
|
-
return {
|
|
88
|
-
affinity: next,
|
|
89
|
-
delta: config.feedReward,
|
|
90
|
-
reaction: "呜哇!小鱼干好好吃!",
|
|
91
|
-
accepted: true
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
affinity: state,
|
|
96
|
-
delta: 0,
|
|
97
|
-
reaction: "",
|
|
98
|
-
accepted: false
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/** Reward one completed turn (called by the host on `done`). */
|
|
102
|
-
function applyTurnReward(state, config = defaultAffinityConfig) {
|
|
103
|
-
const next = { ...state };
|
|
104
|
-
next.turns += 1;
|
|
105
|
-
next.points = clamp(state.points + config.turnReward);
|
|
106
|
-
return next;
|
|
107
|
-
}
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/state.ts
|
|
110
|
-
const defaultPetStateConfig = { celebrateMs: 2400 };
|
|
111
|
-
/**
|
|
112
|
-
* Map one activity phase onto the animation contract.
|
|
113
|
-
* - thinking / tool → `running` (focused work), with `running-right` as the
|
|
114
|
-
* side-alternating variant the client may use for tool activity.
|
|
115
|
-
* - waiting → `waiting` (expectant pose, needs user input).
|
|
116
|
-
* - done → `jumping` (celebration), then back to `idle` after the window.
|
|
117
|
-
* - idle → `idle` (calm breathing loop).
|
|
118
|
-
* `failed` has no DSH phase source yet; the machine keeps the mapping table
|
|
119
|
-
* so a future error event can light it up.
|
|
120
|
-
*/
|
|
121
|
-
function animationForPhase(phase) {
|
|
122
|
-
switch (phase) {
|
|
123
|
-
case "thinking": return "running";
|
|
124
|
-
case "tool": return "running-right";
|
|
125
|
-
case "waiting": return "waiting";
|
|
126
|
-
case "done": return "jumping";
|
|
127
|
-
case "idle": return "idle";
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/** The spritesheet row index for one animation track. */
|
|
131
|
-
function rowOf(animation) {
|
|
132
|
-
return {
|
|
133
|
-
"idle": 0,
|
|
134
|
-
"running-right": 1,
|
|
135
|
-
"running-left": 2,
|
|
136
|
-
"waving": 3,
|
|
137
|
-
"jumping": 4,
|
|
138
|
-
"failed": 5,
|
|
139
|
-
"waiting": 6,
|
|
140
|
-
"running": 7,
|
|
141
|
-
"review": 8
|
|
142
|
-
}[animation];
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* PetStateMachine — one instance per host process. Holds only the latest
|
|
146
|
-
* input snapshot and the celebration timing; no storage, no side effects.
|
|
147
|
-
*/
|
|
148
|
-
var PetStateMachine = class {
|
|
149
|
-
config;
|
|
150
|
-
now;
|
|
151
|
-
phase = "idle";
|
|
152
|
-
line;
|
|
153
|
-
phrase;
|
|
154
|
-
sessionActive = false;
|
|
155
|
-
doneAt;
|
|
156
|
-
constructor(config = defaultPetStateConfig, now = Date.now) {
|
|
157
|
-
this.config = config;
|
|
158
|
-
this.now = now;
|
|
159
|
-
}
|
|
160
|
-
/** Consume one `activity/status` session event. */
|
|
161
|
-
onActivityStatus(input) {
|
|
162
|
-
this.phase = input.phase;
|
|
163
|
-
this.line = input.line;
|
|
164
|
-
this.phrase = input.phrase;
|
|
165
|
-
if (input.phase === "done") this.doneAt = this.now();
|
|
166
|
-
}
|
|
167
|
-
/** A session became the active one (or a fresh session started). */
|
|
168
|
-
onSessionActive() {
|
|
169
|
-
this.sessionActive = true;
|
|
170
|
-
}
|
|
171
|
-
/** The active session was disposed (or none left). */
|
|
172
|
-
onSessionDisposed() {
|
|
173
|
-
this.sessionActive = false;
|
|
174
|
-
this.phase = "idle";
|
|
175
|
-
this.line = void 0;
|
|
176
|
-
this.phrase = void 0;
|
|
177
|
-
this.doneAt = void 0;
|
|
178
|
-
}
|
|
179
|
-
/** Render the current animation decision. */
|
|
180
|
-
render() {
|
|
181
|
-
const nowMs = this.now();
|
|
182
|
-
let animation = animationForPhase(this.phase);
|
|
183
|
-
if (this.phase === "done" && this.doneAt !== void 0) {
|
|
184
|
-
if (nowMs - this.doneAt < this.config.celebrateMs) animation = "jumping";
|
|
185
|
-
else animation = "idle";
|
|
186
|
-
}
|
|
187
|
-
const bubble = this.phrase ?? this.line;
|
|
188
|
-
return {
|
|
189
|
-
animation,
|
|
190
|
-
...bubble === void 0 ? {} : { bubble },
|
|
191
|
-
animationStartedAt: nowMs,
|
|
192
|
-
phase: this.phase,
|
|
193
|
-
sessionActive: this.sessionActive
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
//#endregion
|
|
198
|
-
export { AFFINITY_MAX as a, applyTurnReward as c, rankOf as d, rowOf as i, defaultAffinityConfig as l, animationForPhase as n, AFFINITY_RANKS as o, defaultPetStateConfig as r, applyInteraction as s, PetStateMachine as t, emptyAffinity as u };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dock-band fallback seat for the pet.
|
|
3
|
-
*
|
|
4
|
-
* Current dsh web shells declare `conversation.input.dock` (the composer dock
|
|
5
|
-
* band, a list slot) instead of the legacy `conversation.input.selector.context`
|
|
6
|
-
* hole this plugin was written against. The dock band renders only for an
|
|
7
|
-
* active session, so on shells that carry it the pet follows the session seat
|
|
8
|
-
* — an acceptable degradation until the upstream shell restores the context
|
|
9
|
-
* hole. The underlying entry ignores owner props (it reads only injected
|
|
10
|
-
* actions and the locale), so this wrapper is a pure props re-cast.
|
|
11
|
-
*/
|
|
12
|
-
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
13
|
-
import { type PetInjected } from './PetDockEntry.tsx';
|
|
14
|
-
import { NS } from './locales.ts';
|
|
15
|
-
/** Composed props of the dock-band fallback seat. */
|
|
16
|
-
export type DockPetDockEntryProps = PropsRuntime<'conversation.input.dock'> & PetInjected & PropsLocale<typeof NS>;
|
|
17
|
-
/**
|
|
18
|
-
* Render the pet dock from the composer dock band.
|
|
19
|
-
* @param props - composed slot props (dock band seat).
|
|
20
|
-
* @returns the dock entry element tree.
|
|
21
|
-
*/
|
|
22
|
-
export declare function DockPetDockEntry(props: DockPetDockEntryProps): import("react").JSX.Element;
|
|
23
|
-
//# sourceMappingURL=DockPetDockEntry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DockPetDockEntry.d.ts","sourceRoot":"","sources":["../../../src/client/DockPetDockEntry.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAEjF,OAAO,EAAwC,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC3F,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AAEjC,qDAAqD;AACrD,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC,yBAAyB,CAAC,GAAG,WAAW,GAAG,WAAW,CAAC,OAAO,EAAE,CAAC,CAAA;AAElH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,+BAE5D"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PetDockEntry } from "./PetDockEntry.js";
|
|
3
|
-
/**
|
|
4
|
-
* Render the pet dock from the composer dock band.
|
|
5
|
-
* @param props - composed slot props (dock band seat).
|
|
6
|
-
* @returns the dock entry element tree.
|
|
7
|
-
*/
|
|
8
|
-
export function DockPetDockEntry(props) {
|
|
9
|
-
return _jsx(PetDockEntry, { ...props });
|
|
10
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
2
|
-
interface SlotMap {
|
|
3
|
-
/**
|
|
4
|
-
* The input selector context-chip hole: feature chips rendered right
|
|
5
|
-
* after the workspace selector. Session-maybe: entries stay mounted
|
|
6
|
-
* without a session and hide themselves when their data source is absent.
|
|
7
|
-
*/
|
|
8
|
-
'conversation.input.selector.context': {
|
|
9
|
-
kind: 'list';
|
|
10
|
-
scope: 'session-maybe';
|
|
11
|
-
owner: InputSelectorContextOwnerProps;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
/** Owner share of the input selector context-chip hole (empty by contract). */
|
|
15
|
-
interface InputSelectorContextOwnerProps {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=slots-augment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slots-augment.d.ts","sourceRoot":"","sources":["../../../src/client/slots-augment.ts"],"names":[],"mappings":"AAUA,OAAO,QAAQ,kCAAkC,CAAC;IAChD,UAAU,OAAO;QACf;;;;WAIG;QACH,qCAAqC,EAAE;YACrC,IAAI,EAAE,MAAM,CAAA;YACZ,KAAK,EAAE,eAAe,CAAA;YACtB,KAAK,EAAE,8BAA8B,CAAA;SACtC,CAAA;KACF;IAED,+EAA+E;IAC/E,UAAU,8BAA8B;KAAG;CAC5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Local slot-table augmentation for slots the official NPM SDK
|
|
3
|
-
* (ui-conversation rc.6) does not publish yet, but the running dsh worktree
|
|
4
|
-
* boots with (`conversation.input.selector.*`). Type-only supplement — the
|
|
5
|
-
* runtime surface comes from the dsh profile. Module form (with an import)
|
|
6
|
-
* so TS merges into the package declarations instead of shadowing them.
|
|
7
|
-
* Remove once the SDK ships these slots.
|
|
8
|
-
*/
|
|
9
|
-
import type {} from '@deepseek-ai/dsh-client-ui-slots'
|
|
10
|
-
|
|
11
|
-
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
12
|
-
interface SlotMap {
|
|
13
|
-
/**
|
|
14
|
-
* The input selector context-chip hole: feature chips rendered right
|
|
15
|
-
* after the workspace selector. Session-maybe: entries stay mounted
|
|
16
|
-
* without a session and hide themselves when their data source is absent.
|
|
17
|
-
*/
|
|
18
|
-
'conversation.input.selector.context': {
|
|
19
|
-
kind: 'list'
|
|
20
|
-
scope: 'session-maybe'
|
|
21
|
-
owner: InputSelectorContextOwnerProps
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** Owner share of the input selector context-chip hole (empty by contract). */
|
|
26
|
-
interface InputSelectorContextOwnerProps {}
|
|
27
|
-
}
|