@linxin666/dsh-pet 0.4.5 → 0.4.6
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 +28 -2
- package/README.zh.md +28 -2
- package/lib/client.js +76 -39
- package/lib/client.js.map +1 -1
- package/lib/index.js +280 -25
- package/lib/types/announce.d.ts +16 -0
- package/lib/types/announce.d.ts.map +1 -1
- package/lib/types/announce.js +16 -0
- package/lib/types/client/PetDockEntry.d.ts +6 -0
- package/lib/types/client/PetDockEntry.d.ts.map +1 -1
- package/lib/types/client/PetDockEntry.js +1 -1
- package/lib/types/client/PetSettingsCard.d.ts +4 -0
- package/lib/types/client/PetSettingsCard.d.ts.map +1 -1
- package/lib/types/client/PetSettingsCard.js +16 -1
- package/lib/types/client/PetSprite.d.ts +7 -0
- package/lib/types/client/PetSprite.d.ts.map +1 -1
- package/lib/types/client/PetSprite.js +23 -13
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +42 -10
- package/lib/types/client/locales.d.ts +4 -0
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js +4 -0
- package/lib/types/index.d.ts +14 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +15 -2
- package/lib/types/panel-actions.d.ts +96 -0
- package/lib/types/panel-actions.d.ts.map +1 -0
- package/lib/types/panel-actions.js +134 -0
- package/lib/types/routes.d.ts.map +1 -1
- package/lib/types/routes.js +10 -0
- package/lib/types/service.d.ts +137 -9
- package/lib/types/service.d.ts.map +1 -1
- package/lib/types/service.js +151 -19
- package/package.json +1 -1
- package/src/announce.ts +17 -0
- package/src/client/PetDockEntry.test.tsx +1 -0
- package/src/client/PetDockEntry.tsx +7 -0
- package/src/client/PetSettingsCard.test.tsx +88 -0
- package/src/client/PetSettingsCard.tsx +31 -0
- package/src/client/PetSprite.test.tsx +197 -0
- package/src/client/PetSprite.tsx +56 -12
- package/src/client/index.test.tsx +74 -4
- package/src/client/index.ts +42 -10
- package/src/client/locales.ts +4 -0
- package/src/index.test.ts +22 -0
- package/src/index.ts +28 -2
- package/src/panel-actions.test.ts +130 -0
- package/src/panel-actions.ts +182 -0
- package/src/routes.ts +9 -0
- package/src/service.test.ts +128 -0
- package/src/service.ts +206 -22
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# node scripts/verify-docs.mjs --write <dir>
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 6167cf9133204ac9c9df28ee08b5b1c722f440bf
|
|
6
|
+
README.zh.md: d7238f47aa9d1de79ccdd87b9e0cea24b381a9f0
|
package/README.md
CHANGED
|
@@ -36,10 +36,11 @@ Re-engineered from desktop companion concepts into an official DSH cordis bundle
|
|
|
36
36
|
| Dragging | Hold and drag the pet to reposition; position persisted |
|
|
37
37
|
| Hide/Summon | The hover panel sits below the pet (lifted above the status bubbles when there is no room below) and provides 隐藏 (Hide); after hiding, a 召唤{name} (Summon {name}) button appears |
|
|
38
38
|
| Witty remarks | Built-in remark library (10 lines per event) plus per-pet custom lines; success lines rotate by persisted success counts and cooldown lines by persisted rejection counts |
|
|
39
|
-
| Status bubbles | Only one top-level session speaks by default — the session the GUI is currently on when it is reported, otherwise the most recently active one — and the rest collapse behind a +N badge on the main bubble instead of stacking a tall column; hover the bubble (or tap the badge, for touch) to fan every session's bubble out above it and click one to jump to its session; subagent sessions report through their spawning conversation and never occupy a bubble of their own; transient interaction feedback temporarily takes priority. Bubble copy comes from generous rotating pools per scene (waiting / thinking / writing / done / failed...), tool calls map onto per-family witty lines carrying the real argument hint (e.g. 跑跑 npm test), and a long-lived scene re-phrases itself every few seconds |
|
|
39
|
+
| Status bubbles | Only one top-level session speaks by default — the session the GUI is currently on when it is reported, otherwise the most recently active one — and the rest collapse behind a +N badge on the main bubble instead of stacking a tall column; hover the bubble (or tap the badge, for touch) to fan every session's bubble out above it and click one to jump to its session; subagent sessions report through their spawning conversation and never occupy a bubble of their own; transient interaction feedback temporarily takes priority. Bubble copy comes from generous rotating pools per scene (waiting / thinking / writing / done / failed...), tool calls map onto per-family witty lines carrying the real argument hint (e.g. 跑跑 npm test), and a long-lived scene re-phrases itself every few seconds. The pet's own status bubbles can be silenced in Settings > Pet > Status bubbles, which leaves the row to a plugin driving its own bubble surface; announcements pushed through `pet.announce` keep rendering either way |
|
|
40
40
|
| Inner whispers | 碎碎念: while a session streams, the pet occasionally speaks its inner voice through that session's own bubble — a fresh whisper takes over the bubble and marks it with 「」 quotes — sharing the same DeepSeek-blue glass as every status bubble, so stacked bubbles never clash — instead of stacking a second bubble — category lines woken by the SITUATION (thinking / writing / the running tool family) plus outcome lines woken only by structured results (test green from a passed test tool, error from a failed tool result, completion from a completed turn) — never from the model's words, so a discussion that merely mentions a keyword cannot wake a mood, and a whisper never quotes real content (no tool names, paths or model text); paced by cooldowns (9 s category, 5 s outcome) and an 8 s display TTL, the status copy returns after a few seconds |
|
|
41
41
|
| Multi-session activity | The pet is host-global: the most recent meaningful event drives the sprite animation while every active top-level session reports its own state in a separate bubble; completed turns from every session (subagents included) contribute affinity and treats |
|
|
42
42
|
| Voice packs and panel DIY | A per-pet voice.json plus the global $DSH_HOME/pets/.voice.json override replace every bubble word and the hover panel (button labels, stat formats, button visibility); merge precedence per-pet > global > built-in, broken packs warn and never reject a pet |
|
|
43
|
+
| Plugin panel actions | A sibling plugin registers its own action into the hover panel's action row through the in-process pet service (`ctx.pet.registerPanelAction({ id, label, onSelect })`); the pet renders the button and dispatches the click back to the plugin's own callback, and the action goes away with the registration |
|
|
43
44
|
|
|
44
45
|
## Pet contract
|
|
45
46
|
|
|
@@ -213,7 +214,32 @@ A status bubble can carry a small ornament ahead of its text (built-in: the spou
|
|
|
213
214
|
- Switch: Settings > Pet > Status decoration (on by default). The built-in whale derives from the DeepSeek wordmark (MIT); see THIRD_PARTY_NOTICES.md.
|
|
214
215
|
## Announcement bubbles (pet.announce)
|
|
215
216
|
|
|
216
|
-
Host-side sibling plugins can push one structured announcement through the `pet` cordis service (`ctx.pet.announce({ source, kind, title, ... })`); the browser half renders it as a dedicated, specially styled bubble riding the top of the session bubble stack — its own glass style with a tone accent (`ok`/`warn`/`low`), an amount pill for balance or today-spend kinds, a mini meter for plan-percent windows, and the reset instant. The payload is validated into a bounded shape (src/announce.ts): unknown fields drop, text truncates, TTL clamps to 1 s - 2 h (default 10 s; a repeating announcer declares its poll cadence so an always-mode bubble stays continuous, and the ceiling still unmounts a dead source's bubble within one missed refresh), and a malformed announcement is dropped silently. Announcements are in-memory only:
|
|
217
|
+
Host-side sibling plugins can push one structured announcement through the `pet` cordis service (`ctx.pet.announce({ source, kind, title, ... })`); the browser half renders it as a dedicated, specially styled bubble riding the top of the session bubble stack — its own glass style with a tone accent (`ok`/`warn`/`low`), an amount pill for balance or today-spend kinds, a mini meter for plan-percent windows, and the reset instant. The payload is validated into a bounded shape (src/announce.ts): unknown fields drop, text truncates, TTL clamps to 1 s - 2 h (default 10 s; a repeating announcer declares its poll cadence so an always-mode bubble stays continuous, and the ceiling still unmounts a dead source's bubble within one missed refresh), and a malformed announcement is dropped silently. Announcements are in-memory only: each publisher holds its own slot keyed by `source`, an expired one stops rendering, and neither pet.json nor the ledger is touched. There is deliberately no HTTP surface — the API is the in-process service, per the cross-plugin collaboration rule.
|
|
218
|
+
|
|
219
|
+
**Several publishers on one pet.** The contract started with a single slot, so a second announcing plugin displaced the first; `source` is now the slot key — the payload already carried it — and each publisher keeps its own TTL. Every fresh slot renders as its own bubble, stacked above the session bubbles in the order each publisher first arrived: a repeating publisher refreshes its own bubble in place, so two publishers on different cadences never swap positions and the stack never flickers. The table is bounded (`MAX_ANNOUNCEMENTS`, 4). A lapsed publisher frees its own slot; a genuinely full table hands its oldest slot to the arriving publisher rather than refusing it, so a publisher that keeps refreshing is never the one evicted. For a rolling upgrade the freshest slot is also served under the original singular `announcement` field, so a browser half predating the array keeps rendering one bubble instead of none.
|
|
220
|
+
|
|
221
|
+
## Plugin panel actions (pet.registerPanelAction)
|
|
222
|
+
|
|
223
|
+
Host-side sibling plugins can add their own button to the pet's hover panel action row, next to the built-in Feed / Rename / Hide:
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
ctx.effect(() => ctx.pet.registerPanelAction({
|
|
227
|
+
id: 'pet-quota-swap', // kebab id; a click dispatches back on it
|
|
228
|
+
label: '换装', // bounded label (the row wraps past it)
|
|
229
|
+
title: '切换到下一只宠物', // optional tooltip
|
|
230
|
+
order: 0, // optional sort key within the registered block
|
|
231
|
+
onSelect: async ({ petId }) => { /* the plugin does the work */ },
|
|
232
|
+
}))
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
- The pet owns the row and the plugin owns the button: the host validates every registration (src/panel-actions.ts), serves the registered actions in the state snapshot (`panelActions`), and dispatches a click from `POST /api/pet/panel-action` back to `onSelect`. Extensions render after the built-in buttons, so they survive a voice pack that hides the built-in row.
|
|
236
|
+
- Lifecycle: registering the same id again replaces the earlier action (a superseded disposer no longer owns the row), and the disposer `registerPanelAction` returns removes it — bind it to the registering plugin's fiber with `ctx.effect` as above. At most `MAX_PANEL_ACTIONS` (8) registrations fit in the row.
|
|
237
|
+
- Failures stay the plugin's: a malformed registration throws at the registering plugin's own apply (a click could not be dispatched back to it), a throwing callback answers `{ ok: false, error: 'panel-action-failed' }`, and a click on an action the plugin already disposed is a stale click (`{ ok: false, error: 'unknown-panel-action' }`). None of them surfaces as pet breakage.
|
|
238
|
+
- Like `pet.announce`, registration is a host-side (in-process) contract. A browser-half plugin drives the pet through the existing `/api/pet/*` endpoints instead.
|
|
239
|
+
|
|
240
|
+
## Status bubble switch (statusBubbles)
|
|
241
|
+
|
|
242
|
+
Settings > Pet > Status bubbles (`auto` by default, `off` to silence the pet). `off` hides ONLY the pet's own session/status bubbles — the per-session stack (正在思考 / 正在使用 ...) and the legacy single status bubble — while the interaction feedback bubble and a sibling plugin's announcement bubble keep rendering, which is what a plugin that drives its own bubble surface needs. The state snapshot still carries the bubble facts either way: only the rendering is gated, so switching it back on restores them immediately, and a host that predates the field serves no mode at all, which reads as `auto`.
|
|
217
243
|
|
|
218
244
|
## Built-in pets
|
|
219
245
|
|
package/README.zh.md
CHANGED
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
| 拖动 | 按住拖动宠物换位置;位置持久化 |
|
|
37
37
|
| 隐藏/召唤 | 悬浮面板位于宠物下方(下方空间不足时上移到状态气泡之上)并提供 隐藏;隐藏后出现 召唤{name} 按钮 |
|
|
38
38
|
| 妙语库 | 内置默认妙语库(每类事件 10 句)+ 宠物自定义台词;成功文案按持久化成功次数轮换,冷却文案按持久化拒绝次数轮换 |
|
|
39
|
-
| 状态气泡 | 默认只有一个顶层会话说话——上报 GUI 当前会话时优先它,否则是最近活动的一个——其余会话收进主气泡右上角的 +N 角标,不再叠出一长列;悬停气泡(触屏点按角标)即可向上展开所有会话的气泡,点击任一气泡跳转到对应会话;子代理会话借由其发起会话体现,不占用独立气泡;瞬时互动反馈临时优先。气泡文案按场景准备了大量轮换词库(等待 / 思考 / 整理 / 完成 / 失败……),工具调用按工具族映射俏皮文案并带上真实参数(如 跑跑 npm test
|
|
39
|
+
| 状态气泡 | 默认只有一个顶层会话说话——上报 GUI 当前会话时优先它,否则是最近活动的一个——其余会话收进主气泡右上角的 +N 角标,不再叠出一长列;悬停气泡(触屏点按角标)即可向上展开所有会话的气泡,点击任一气泡跳转到对应会话;子代理会话借由其发起会话体现,不占用独立气泡;瞬时互动反馈临时优先。气泡文案按场景准备了大量轮换词库(等待 / 思考 / 整理 / 完成 / 失败……),工具调用按工具族映射俏皮文案并带上真实参数(如 跑跑 npm test),同一场景持续数秒会自动换一种说法。宠物自带的这些状态气泡可在 设置 → 宠物 → 状态气泡 关掉,此时整行气泡留给自建气泡面的插件;通过 `pet.announce` 推送的公告气泡两种模式下都照常渲染 |
|
|
40
40
|
| 碎碎念 | 会话流式输出期间,宠物会偶尔借该会话自己的气泡说出内心独白——新鲜的碎碎念接管所属会话的气泡并以「」引号标记——与状态气泡共用同一片 DeepSeek 蓝黑玻璃,气泡栈内颜色统一不再色差——不再叠出第二只气泡——分类台词由「正在干什么」触发(思考 / 写回复 / 正在跑的工具族),结果台词只由结构化结果触发(测试工具通过 → 全绿、工具失败 → 报错、回合完成 → 收工)——决不读模型说的话,讨论里提到关键词也不会误触发心境;碎碎念也从不引用真实内容(无工具名、路径、模型原文);分类冷却 9 秒、结果冷却 5 秒,展示 8 秒后气泡恢复状态文案 |
|
|
41
41
|
| 多会话活动 | 宠物是宿主全局的:最近一次有意义事件驱动精灵动画,同时每个活动的顶层会话用自己的气泡报告各自状态;每个会话(含子代理)完成的轮次都计入亲密度与小鱼干 |
|
|
42
42
|
| 语音包与面板 DIY | 宠物目录 voice.json + 全局 $DSH_HOME/pets/.voice.json 覆盖气泡全部文案与悬浮面板(按钮标签/统计格式/按钮显隐);合并优先级 宠物自带 > 全局 > 内置,坏包警告不拒载 |
|
|
43
|
+
| 面板动作扩展点 | 兄弟插件通过进程内 pet 服务(`ctx.pet.registerPanelAction({ id, label, onSelect })`)把自己的动作注册进悬浮面板的动作行;宠物渲染按钮并把点击派发回插件自己的回调,动作随注册一起回收 |
|
|
43
44
|
|
|
44
45
|
## 宠物契约
|
|
45
46
|
|
|
@@ -213,7 +214,32 @@ frames2d 宠物可声明 `gameplay` 块——从 miku 桌宠泛化而来的可
|
|
|
213
214
|
- 开关:设置 → 宠物 → 状态装饰(默认开)。内置鲸鱼素材派生自 DeepSeek wordmark(MIT),完整声明见 THIRD_PARTY_NOTICES.md。
|
|
214
215
|
## 公告气泡(pet.announce)
|
|
215
216
|
|
|
216
|
-
宿主侧的兄弟插件可通过 `pet` cordis 服务推送一条结构化公告(`ctx.pet.announce({ source, kind, title, ... })`);客户端半区将其渲染为一只专用、特别设计的气泡,挂在会话气泡栈顶部——独立玻璃样式与色调描边(`ok`/`warn`/`low`)、余额与今日消费类金额胶囊、套餐百分比窗口带微型计量条、展示重置时间。载荷经有界校验(src/announce.ts):未知字段丢弃、超长文本截断、TTL 收敛到 1 秒 - 2 小时(默认 10 秒;周期型发布方按自身轮询节奏声明 TTL
|
|
217
|
+
宿主侧的兄弟插件可通过 `pet` cordis 服务推送一条结构化公告(`ctx.pet.announce({ source, kind, title, ... })`);客户端半区将其渲染为一只专用、特别设计的气泡,挂在会话气泡栈顶部——独立玻璃样式与色调描边(`ok`/`warn`/`low`)、余额与今日消费类金额胶囊、套餐百分比窗口带微型计量条、展示重置时间。载荷经有界校验(src/announce.ts):未知字段丢弃、超长文本截断、TTL 收敛到 1 秒 - 2 小时(默认 10 秒;周期型发布方按自身轮询节奏声明 TTL,常驻气泡因此跨轮询连续,上限仍保证失活来源的气泡至多一个刷新周期内消失),畸形公告静默丢弃。公告仅存内存:每个发布方按 `source` 各占一个槽位,各自持有自己的 TTL,过期即不再渲染,不触碰 pet.json 与台账。刻意不提供 HTTP 面——按跨插件协作规则,API 就是进程内服务。
|
|
218
|
+
|
|
219
|
+
**一只宠物上的多个发布方。** 该契约最初只有一个槽位,第二个公告插件会把第一个顶掉;现在 `source`(载荷本来就带)就是槽位键,各发布方 TTL 独立。每条新鲜槽位各渲染一只气泡,按各发布方首次到达的顺序叠在会话气泡之上——周期型发布方就地刷新自己那只,两个节奏不同的发布方不会互换位置,气泡栈也不会抖动。槽位表有上限(`MAX_ANNOUNCEMENTS` = 4):过期发布方的槽位自动释放;表真的满时,新来的发布方拿走沉默最久的那只而不是被拒绝,因此持续刷新的发布方永远不会被挤掉。为兼容灰度升级,最新鲜的那条同时仍以旧的单数字段 `announcement` 下发,旧浏览器半区照常渲染一只气泡而不会空白。
|
|
220
|
+
|
|
221
|
+
## 面板动作扩展点(pet.registerPanelAction)
|
|
222
|
+
|
|
223
|
+
宿主侧的兄弟插件可以往宠物悬浮面板的动作行里追加自己的按钮,与内置的喂食 / 改名 / 隐藏并存:
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
ctx.effect(() => ctx.pet.registerPanelAction({
|
|
227
|
+
id: 'pet-quota-swap', // kebab id,点击按它派发回插件
|
|
228
|
+
label: '换装', // 有界标签(超过就会撑换行)
|
|
229
|
+
title: '切换到下一只宠物', // 可选 tooltip
|
|
230
|
+
order: 0, // 可选:在已注册动作块内的排序键
|
|
231
|
+
onSelect: async ({ petId }) => { /* 插件自己做事 */ },
|
|
232
|
+
}))
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
- 宠物拥有这一行,插件拥有这个按钮:宿主对每次注册做校验(src/panel-actions.ts),把已注册动作放进状态快照(`panelActions`)下发,点击经 `POST /api/pet/panel-action` 派发回 `onSelect`。扩展动作渲染在内置按钮之后,因此语音包隐藏内置动作行时它们依然可见。
|
|
236
|
+
- 生命周期:同一 id 再次注册会替换旧动作(被替换的 disposer 不再拥有这一行),`registerPanelAction` 返回的 disposer 负责移除它——按上面的写法用 `ctx.effect` 绑到注册插件自己的 fiber 上即可。动作行最多容纳 `MAX_PANEL_ACTIONS`(8)个注册。
|
|
237
|
+
- 失败只算插件自己的问题:畸形注册会在注册插件自己的 apply 里抛错(点击无法派发回它),回调抛错返回 `{ ok: false, error: 'panel-action-failed' }`,点击一个插件已经注销的动作属于过期点击(`{ ok: false, error: 'unknown-panel-action' }`),都不会表现为宠物故障。
|
|
238
|
+
- 与 `pet.announce` 一样,注册是宿主侧(进程内)契约;浏览器半区的插件走既有的 `/api/pet/*` 端点驱动宠物即可。
|
|
239
|
+
|
|
240
|
+
## 状态气泡开关(statusBubbles)
|
|
241
|
+
|
|
242
|
+
设置 → 宠物 → 状态气泡(默认 `auto`,改为 `off` 即让宠物闭嘴)。`off` 只隐藏宠物自带的会话/状态气泡——每个会话的气泡栈(正在思考 / 正在使用……)与旧式单状态气泡——互动反馈气泡与兄弟插件通过公告契约推送的气泡照常渲染,这正是自建气泡面的插件需要的。两种模式下状态快照都照常携带气泡数据:只有渲染被关掉,随时切回即刻恢复;早于该字段的宿主不带模式,读取时按 `auto` 处理。
|
|
217
243
|
|
|
218
244
|
## 内置宠物
|
|
219
245
|
|
package/lib/client.js
CHANGED
|
@@ -784,13 +784,15 @@ window.__ModuleLoader__.load({
|
|
|
784
784
|
spriteWidth
|
|
785
785
|
]);
|
|
786
786
|
const bubbleScale = bubbleScaleFor(display);
|
|
787
|
-
const
|
|
787
|
+
const statusBubblesOn = (snapshot?.statusBubbles ?? "auto") !== "off";
|
|
788
|
+
const sessionBubbles = statusBubblesOn ? snapshot?.sessions ?? [] : [];
|
|
788
789
|
const stackOpen = stackPeek || stackPinned;
|
|
789
790
|
const visibleSessions = !stackOpen && sessionBubbles.length > 1 ? sessionBubbles.slice(0, 1) : sessionBubbles;
|
|
790
|
-
const statusBubble = feedback === null && sessionBubbles.length === 0 ? snapshot?.bubble : void 0;
|
|
791
|
-
const
|
|
792
|
-
const
|
|
793
|
-
const
|
|
791
|
+
const statusBubble = statusBubblesOn && feedback === null && sessionBubbles.length === 0 ? snapshot?.bubble : void 0;
|
|
792
|
+
const announced = snapshot?.announcements ?? (snapshot?.announcement !== void 0 ? [snapshot.announcement] : []);
|
|
793
|
+
const now = Date.now();
|
|
794
|
+
const usageAnnouncements = feedback === null ? announced.filter((entry) => announcementFresh(entry, now)) : [];
|
|
795
|
+
const bubblePresent = feedback !== null || sessionBubbles.length > 0 || statusBubble !== void 0 || usageAnnouncements.length > 0;
|
|
794
796
|
const displayName = snapshot?.name ?? definition.displayName;
|
|
795
797
|
const decoration = snapshot?.decoration;
|
|
796
798
|
(0, react.useEffect)(() => {
|
|
@@ -889,7 +891,7 @@ window.__ModuleLoader__.load({
|
|
|
889
891
|
className: clsx(pet_module_css_default.bubble, feedback.kind === "feed" ? pet_module_css_default.bubbleFeed : pet_module_css_default.bubblePet),
|
|
890
892
|
children: feedback.text
|
|
891
893
|
}, feedback.at),
|
|
892
|
-
feedback === null && (sessionBubbles.length > 0 || statusBubble !== void 0 ||
|
|
894
|
+
feedback === null && (sessionBubbles.length > 0 || statusBubble !== void 0 || usageAnnouncements.length > 0) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
893
895
|
ref: bubbleRef,
|
|
894
896
|
className: pet_module_css_default.bubbleStack,
|
|
895
897
|
onPointerEnter: () => setStackPeek(true),
|
|
@@ -935,7 +937,7 @@ window.__ModuleLoader__.load({
|
|
|
935
937
|
phase
|
|
936
938
|
}), statusBubble]
|
|
937
939
|
}, "status"),
|
|
938
|
-
|
|
940
|
+
usageAnnouncements.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UsageAnnouncementBubble, { announcement: entry }, entry.source))
|
|
939
941
|
]
|
|
940
942
|
}),
|
|
941
943
|
hovered && dragRef.current === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1039,7 +1041,17 @@ window.__ModuleLoader__.load({
|
|
|
1039
1041
|
className: pet_module_css_default.action,
|
|
1040
1042
|
onClick: props.onGameplayMenu,
|
|
1041
1043
|
children: props.t("pet.gameplay.menu")
|
|
1042
|
-
})
|
|
1044
|
+
}),
|
|
1045
|
+
(snapshot?.panelActions ?? []).map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1046
|
+
type: "button",
|
|
1047
|
+
className: pet_module_css_default.action,
|
|
1048
|
+
"data-dsh-pet-panel-action": action.id,
|
|
1049
|
+
...action.title === void 0 ? {} : { title: action.title },
|
|
1050
|
+
onClick: () => {
|
|
1051
|
+
props.onPanelAction(action.id);
|
|
1052
|
+
},
|
|
1053
|
+
children: action.label
|
|
1054
|
+
}, action.id))
|
|
1043
1055
|
]
|
|
1044
1056
|
})
|
|
1045
1057
|
] })
|
|
@@ -1992,6 +2004,7 @@ window.__ModuleLoader__.load({
|
|
|
1992
2004
|
onHide: props.hide,
|
|
1993
2005
|
onDragEnd: props.dragEnd,
|
|
1994
2006
|
onRename: props.rename,
|
|
2007
|
+
onPanelAction: props.panelAction,
|
|
1995
2008
|
onOpenSession: props.openSession,
|
|
1996
2009
|
onFeedbackDone: props.feedbackDone,
|
|
1997
2010
|
portalTarget: props.portalTarget,
|
|
@@ -3525,6 +3538,12 @@ window.__ModuleLoader__.load({
|
|
|
3525
3538
|
var settings_section_module_css_default = { "sectionList": "c5M8OW_sectionList" };
|
|
3526
3539
|
//#endregion
|
|
3527
3540
|
//#region src/client/PetSettingsCard.tsx
|
|
3541
|
+
/**
|
|
3542
|
+
* The bubble modes this card can write, in render order. Mirrors the host
|
|
3543
|
+
* schema's union (see PetStatusBubbleMode); the browser half never imports the
|
|
3544
|
+
* host module for a value, so the accepted set is spelled here as literals.
|
|
3545
|
+
*/
|
|
3546
|
+
const STATUS_BUBBLE_CHOICES = ["auto", "off"];
|
|
3528
3547
|
/** Fetch the registry list (the same data the sprite renders from). */
|
|
3529
3548
|
async function fetchPetChoices() {
|
|
3530
3549
|
const response = await fetch("/api/pet/pets");
|
|
@@ -3564,6 +3583,7 @@ window.__ModuleLoader__.load({
|
|
|
3564
3583
|
this.form = new CardForm(scope, [
|
|
3565
3584
|
booleanField("enabled"),
|
|
3566
3585
|
booleanField("decorationEnabled"),
|
|
3586
|
+
choiceField("statusBubbles", STATUS_BUBBLE_CHOICES),
|
|
3567
3587
|
booleanField("visible"),
|
|
3568
3588
|
numberField("size"),
|
|
3569
3589
|
numberField("right"),
|
|
@@ -3689,6 +3709,7 @@ window.__ModuleLoader__.load({
|
|
|
3689
3709
|
petSelectionFallback: fallback,
|
|
3690
3710
|
enabled: this.form.field("enabled"),
|
|
3691
3711
|
decorationEnabled: this.form.field("decorationEnabled"),
|
|
3712
|
+
statusBubbles: this.form.field("statusBubbles"),
|
|
3692
3713
|
visible: fallback ? this.fallbackVisible() : this.form.field("visible"),
|
|
3693
3714
|
size: this.form.field("size"),
|
|
3694
3715
|
right: this.form.field("right"),
|
|
@@ -3816,6 +3837,27 @@ window.__ModuleLoader__.load({
|
|
|
3816
3837
|
props.resetField("decorationEnabled");
|
|
3817
3838
|
}
|
|
3818
3839
|
}),
|
|
3840
|
+
state.petSelectionFallback ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChoiceField, {
|
|
3841
|
+
id: "settings-pet-status-bubbles",
|
|
3842
|
+
label: t("settings.statusBubbles"),
|
|
3843
|
+
hint: t("settings.statusBubblesHint"),
|
|
3844
|
+
inheritLabel: t("settings.inherit"),
|
|
3845
|
+
...fieldProps,
|
|
3846
|
+
...state.statusBubbles,
|
|
3847
|
+
choices: [{
|
|
3848
|
+
value: STATUS_BUBBLE_CHOICES[0],
|
|
3849
|
+
label: t("settings.on")
|
|
3850
|
+
}, {
|
|
3851
|
+
value: STATUS_BUBBLE_CHOICES[1],
|
|
3852
|
+
label: t("settings.off")
|
|
3853
|
+
}],
|
|
3854
|
+
onEdit: (text) => {
|
|
3855
|
+
props.edit("statusBubbles", text);
|
|
3856
|
+
},
|
|
3857
|
+
onReset: () => {
|
|
3858
|
+
props.resetField("statusBubbles");
|
|
3859
|
+
}
|
|
3860
|
+
}),
|
|
3819
3861
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChoiceField, {
|
|
3820
3862
|
id: "settings-pet-pet",
|
|
3821
3863
|
label: t("settings.pet"),
|
|
@@ -3979,6 +4021,8 @@ window.__ModuleLoader__.load({
|
|
|
3979
4021
|
"settings.enabledHint": "关闭后隐藏宠物并停止轮询,可在设置里重新启用。",
|
|
3980
4022
|
"settings.decoration": "状态装饰",
|
|
3981
4023
|
"settings.decorationHint": "在宠物状态气泡里显示喷水鲸鱼等状态装饰;关闭后气泡只剩文字。",
|
|
4024
|
+
"settings.statusBubbles": "状态气泡",
|
|
4025
|
+
"settings.statusBubblesHint": "宠物自带的会话/状态气泡(正在思考、正在使用 xxx)。关掉后只剩第三方插件通过公告契约推送的气泡与互动反馈气泡;默认开启。",
|
|
3982
4026
|
"settings.visible": "显示宠物",
|
|
3983
4027
|
"settings.visibleHint": "关闭后宠物隐藏,可从聊天输入区重新召唤。",
|
|
3984
4028
|
"settings.size": "大小(px)",
|
|
@@ -4061,6 +4105,8 @@ window.__ModuleLoader__.load({
|
|
|
4061
4105
|
"settings.enabledHint": "When off, the pet hides and polling stops; re-enable it here.",
|
|
4062
4106
|
"settings.decoration": "Status decoration",
|
|
4063
4107
|
"settings.decorationHint": "Show ornaments like the spouting whale inside the pet status bubbles; when off, bubbles stay text-only.",
|
|
4108
|
+
"settings.statusBubbles": "Status bubbles",
|
|
4109
|
+
"settings.statusBubblesHint": "The pet's own session/status bubbles (thinking, using ...). Turning them off leaves only bubbles a third-party plugin pushes through the announcement contract, plus the interaction feedback bubble; on by default.",
|
|
4064
4110
|
"settings.visible": "Show the pet",
|
|
4065
4111
|
"settings.visibleHint": "When off, the pet hides; summon it again from the input row.",
|
|
4066
4112
|
"settings.size": "Size (px)",
|
|
@@ -4087,28 +4133,6 @@ window.__ModuleLoader__.load({
|
|
|
4087
4133
|
"settings.saveFailed": "The deployment did not accept these values; they were left for you to correct.",
|
|
4088
4134
|
"settings.invalidNumber": "Enter a number, or leave blank to use the default."
|
|
4089
4135
|
};
|
|
4090
|
-
/**
|
|
4091
|
-
* Active dictionary, picked by the document language at call time. The pet
|
|
4092
|
-
* mounts as a global floating surface (not a session-scoped slot), so it has
|
|
4093
|
-
* no framework locale seat and resolves its copy the same tiny way the
|
|
4094
|
-
* task-board's DOM-injected surface does.
|
|
4095
|
-
*/
|
|
4096
|
-
function dictionary() {
|
|
4097
|
-
return (typeof document !== "undefined" ? document.documentElement.lang : "zh").toLowerCase().startsWith("en") ? en : zh;
|
|
4098
|
-
}
|
|
4099
|
-
/**
|
|
4100
|
-
* Translate a key with optional `{name}` template params. Mirrors the slot
|
|
4101
|
-
* `Translate` contract `(key, params?) => string` so it can be handed to the
|
|
4102
|
-
* same components that used to receive the framework-injected `t` seat. The
|
|
4103
|
-
* key is typed loosely (`string`) so the function is assignable to the slot's
|
|
4104
|
-
* `TranslateNS<'pet'>` (whose key domain also spans the shared common
|
|
4105
|
-
* vocabulary); a missing key degrades to the key itself rather than throwing.
|
|
4106
|
-
*/
|
|
4107
|
-
function t(key, params) {
|
|
4108
|
-
let text = dictionary()[key] ?? key;
|
|
4109
|
-
if (params !== void 0) for (const [name, value] of Object.entries(params)) text = text.replaceAll(`{${name}}`, String(value));
|
|
4110
|
-
return text;
|
|
4111
|
-
}
|
|
4112
4136
|
//#endregion
|
|
4113
4137
|
//#region src/client/main-session.ts
|
|
4114
4138
|
/**
|
|
@@ -4132,7 +4156,7 @@ window.__ModuleLoader__.load({
|
|
|
4132
4156
|
/** The building package's version, when the bundle carries it. */
|
|
4133
4157
|
function bakedVersion() {
|
|
4134
4158
|
try {
|
|
4135
|
-
return "0.4.
|
|
4159
|
+
return "0.4.6";
|
|
4136
4160
|
} catch {
|
|
4137
4161
|
return;
|
|
4138
4162
|
}
|
|
@@ -4215,6 +4239,7 @@ window.__ModuleLoader__.load({
|
|
|
4215
4239
|
setConfig: (patch) => petFetch("/api/pet/set-config", patch),
|
|
4216
4240
|
setName: (name) => petFetch("/api/pet/set-name", { name }),
|
|
4217
4241
|
setPet: (petId) => petFetch("/api/pet/set-pet", { petId }),
|
|
4242
|
+
panelAction: (id) => petFetch("/api/pet/panel-action", { id }),
|
|
4218
4243
|
setSkin: (skin) => petFetch("/api/pet/set-skin", skin === void 0 ? {} : { skin }),
|
|
4219
4244
|
gameplayTouch: (zone) => petFetch("/api/pet/gameplay/touch", zone === void 0 ? {} : { zone }),
|
|
4220
4245
|
gameplaySetMode: (mode) => petFetch("/api/pet/gameplay/mode", { mode }),
|
|
@@ -4291,13 +4316,19 @@ window.__ModuleLoader__.load({
|
|
|
4291
4316
|
else if (this.current === void 0) this.adoptFallback();
|
|
4292
4317
|
}
|
|
4293
4318
|
/**
|
|
4294
|
-
* True
|
|
4295
|
-
*
|
|
4296
|
-
*
|
|
4319
|
+
* True only once the shared mirror answers for the pet namespace itself.
|
|
4320
|
+
*
|
|
4321
|
+
* 'ready' is the only state that answers (#1813). A host-persisted row starts
|
|
4322
|
+
* out as 'loading' — the mirror has published no view yet — and that is not
|
|
4323
|
+
* an answer: adopting it on sight drops the retry window, and under the
|
|
4324
|
+
* aggregate, which serves only the renamed 'web-ui-pet' row, the form then
|
|
4325
|
+
* settles into 'unavailable' and the page stays "not exposed" for good. So
|
|
4326
|
+
* 'loading' and 'unavailable' both keep the window open and let the binder be
|
|
4327
|
+
* adopted the moment the aggregate publishes it.
|
|
4297
4328
|
*/
|
|
4298
4329
|
fallbackSettled() {
|
|
4299
4330
|
try {
|
|
4300
|
-
return this.fallback.getSnapshot().status
|
|
4331
|
+
return this.fallback.getSnapshot().status === "ready";
|
|
4301
4332
|
} catch {
|
|
4302
4333
|
return false;
|
|
4303
4334
|
}
|
|
@@ -4342,9 +4373,10 @@ window.__ModuleLoader__.load({
|
|
|
4342
4373
|
return true;
|
|
4343
4374
|
}
|
|
4344
4375
|
/**
|
|
4345
|
-
* Adopt the shared per-entry form. It is used immediately unless it
|
|
4346
|
-
*
|
|
4347
|
-
* and the retry window takes over
|
|
4376
|
+
* Adopt the shared per-entry form. It is used immediately unless it cannot
|
|
4377
|
+
* answer yet (still loading, or reporting the namespace unavailable), in which
|
|
4378
|
+
* case the binder may still be on its way and the retry window takes over
|
|
4379
|
+
* (see scheduleRetry).
|
|
4348
4380
|
*/
|
|
4349
4381
|
adoptFallback() {
|
|
4350
4382
|
this.current = this.fallback;
|
|
@@ -4583,6 +4615,11 @@ window.__ModuleLoader__.load({
|
|
|
4583
4615
|
if (result.ok) pollNow();
|
|
4584
4616
|
}, () => {});
|
|
4585
4617
|
},
|
|
4618
|
+
panelAction: (id) => {
|
|
4619
|
+
petApi.panelAction(id).then((result) => {
|
|
4620
|
+
if (result.ok) pollNow();
|
|
4621
|
+
}, () => {});
|
|
4622
|
+
},
|
|
4586
4623
|
feedbackDone: () => {
|
|
4587
4624
|
setFeedback(null);
|
|
4588
4625
|
},
|
|
@@ -4615,7 +4652,7 @@ window.__ModuleLoader__.load({
|
|
|
4615
4652
|
const petRoot = (0, react_dom_client.createRoot)(container);
|
|
4616
4653
|
petRoot.render((0, react.createElement)(PetDockEntry, {
|
|
4617
4654
|
...injected(),
|
|
4618
|
-
t,
|
|
4655
|
+
t: ctx.locale.bind("pet"),
|
|
4619
4656
|
portalTarget: container
|
|
4620
4657
|
}));
|
|
4621
4658
|
let uiGone = false;
|