@istarry/spoon-companion 0.9.3 → 0.9.5
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 +33 -6
- package/lib/state.js +8 -4
- package/package.json +1 -1
- package/plugin.js +2 -2
package/lib/client.js
CHANGED
|
@@ -835,8 +835,8 @@ function SpeakerButton(props) {
|
|
|
835
835
|
}
|
|
836
836
|
);
|
|
837
837
|
}
|
|
838
|
-
function SettingsRow() {
|
|
839
|
-
const [open, setOpen] = (0, import_react.useState)(
|
|
838
|
+
function SettingsRow({ defaultOpen = false } = {}) {
|
|
839
|
+
const [open, setOpen] = (0, import_react.useState)(defaultOpen);
|
|
840
840
|
const [state, setState] = (0, import_react.useState)(void 0);
|
|
841
841
|
const [busy, setBusy] = (0, import_react.useState)("");
|
|
842
842
|
const [msg, setMsg] = (0, import_react.useState)("");
|
|
@@ -1176,10 +1176,6 @@ function apply(ctx) {
|
|
|
1176
1176
|
"conversation.chat.assistant-actions",
|
|
1177
1177
|
() => ctx.slots.register({ name: "conversation.chat.assistant-actions", id: "companion-voice-speak", order: 40 }, SpeakerButton)
|
|
1178
1178
|
);
|
|
1179
|
-
ctx.slots.inject(
|
|
1180
|
-
"settings.general.item",
|
|
1181
|
-
() => ctx.slots.register({ name: "settings.general.item", id: "companion-voice-settings", order: 40 }, SettingsRow)
|
|
1182
|
-
);
|
|
1183
1179
|
}
|
|
1184
1180
|
|
|
1185
1181
|
// src/client/mic.tsx
|
|
@@ -1701,6 +1697,37 @@ function ScreenSettingsSection() {
|
|
|
1701
1697
|
] }) : null
|
|
1702
1698
|
] })
|
|
1703
1699
|
] }),
|
|
1700
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: group, children: [
|
|
1701
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: rowTitle, children: "\u4E3B\u52A8\u8BF4" }),
|
|
1702
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: hint, children: "\u547D\u4E2D\u300C\u503C\u5F97\u8BF4\u300D\u7684\u94A9\u5B50\u65F6\uFF1A\u5173 = \u53EA\u770B\u4E0D\u8BF4\uFF1B\u6512\u7740 = \u7559\u4E0B\u4E00\u6761\u51B2\u52A8\uFF0C\u7B49\u4E0B\u6B21\u5F00\u53E3\u5E26\u51FA\u6765\uFF1B\u76F4\u63A5\u8BF4 = \u5F00\u4E00\u4E2A\u65B0\u7A97\u53E3\u8BF4\u4E00\u53E5\u3002" }),
|
|
1703
|
+
cfg ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { display: "flex", gap: 8, flexWrap: "wrap" }, children: [
|
|
1704
|
+
["never", "\u53EA\u770B\u4E0D\u8BF4"],
|
|
1705
|
+
["urge", "\u6512\u7740"],
|
|
1706
|
+
["always", "\u76F4\u63A5\u8BF4"]
|
|
1707
|
+
].map(([value, label]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1708
|
+
"button",
|
|
1709
|
+
{
|
|
1710
|
+
type: "button",
|
|
1711
|
+
disabled: busy,
|
|
1712
|
+
onClick: () => void save({ speak: value }),
|
|
1713
|
+
style: {
|
|
1714
|
+
padding: "4px 12px",
|
|
1715
|
+
borderRadius: 8,
|
|
1716
|
+
border: "1px solid rgba(128,128,128,0.35)",
|
|
1717
|
+
background: cfg.speak === value ? "rgba(128,128,128,0.22)" : "transparent",
|
|
1718
|
+
cursor: "pointer",
|
|
1719
|
+
fontSize: 12.5
|
|
1720
|
+
},
|
|
1721
|
+
children: label
|
|
1722
|
+
},
|
|
1723
|
+
value
|
|
1724
|
+
)) }) : null
|
|
1725
|
+
] }),
|
|
1726
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: group, children: [
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: rowTitle, children: "\u8BED\u97F3" }),
|
|
1728
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: hint, children: "\u5F15\u64CE\u3001Key\u3001\u97F3\u8272\u3001\u81EA\u52A8\u6717\u8BFB\u90FD\u5728\u8FD9\u91CC\u3002" }),
|
|
1729
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SettingsRow, { defaultOpen: true })
|
|
1730
|
+
] }),
|
|
1704
1731
|
error ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { color: "#d0563a", fontSize: 12 }, children: error }) : null
|
|
1705
1732
|
] });
|
|
1706
1733
|
}
|
package/lib/state.js
CHANGED
|
@@ -301,7 +301,9 @@ function tickDrives(state, now) {
|
|
|
301
301
|
const { missed, hour } = mealState(now)
|
|
302
302
|
const base = circadian(new Date(now))
|
|
303
303
|
const awake = !(hour >= SLEEP.from && hour < SLEEP.to)
|
|
304
|
-
|
|
304
|
+
// 从没记过"上次说话"时,不能当成"刚刚才说过" —— 那会让独处加成永远不触发。
|
|
305
|
+
const lastSocialAt = Number(drives.lastSocialAt) || 0
|
|
306
|
+
const idle = lastSocialAt > 0 ? (now - lastSocialAt) / HOUR : 24
|
|
305
307
|
|
|
306
308
|
if (awake) {
|
|
307
309
|
// 馋:只在下午茶和夜宵两个口子上来一点,其他时候几乎不动
|
|
@@ -310,9 +312,9 @@ function tickDrives(state, now) {
|
|
|
310
312
|
// 饿只是嘴馋的子项:涨得慢、封顶 0.85,不会再顶满一整天
|
|
311
313
|
drives.hunger = clamp01(Math.min(0.85, (drives.hunger ?? 0.1) + dt * (0.02 + missed * 0.015)))
|
|
312
314
|
}
|
|
313
|
-
//
|
|
315
|
+
// 困:醒着按作息涨,睡着了是真的在恢复(不是继续涨)
|
|
314
316
|
if (awake) drives.fatigue = clamp01(drives.fatigue + dt * (0.05 + base.sleepy * 0.12))
|
|
315
|
-
else drives.fatigue = clamp01(drives.fatigue
|
|
317
|
+
else drives.fatigue = clamp01(drives.fatigue - dt * 0.14)
|
|
316
318
|
|
|
317
319
|
// 黏:清醒时慢慢涨,六个小时没消息就涨得更快
|
|
318
320
|
if (awake) {
|
|
@@ -550,7 +552,9 @@ export function applyImpulse(state, impulse, now = Date.now()) {
|
|
|
550
552
|
const emoDef = emotionOf(impulse.key)
|
|
551
553
|
if (!emoDef || emoDef.key === 'calm') return null
|
|
552
554
|
const habit = habituation(state, impulse.stimulus, now)
|
|
553
|
-
|
|
555
|
+
// 单次冲量封顶:一句话能把情绪推到很浓,但不该一上来就是满格。
|
|
556
|
+
// 满格留给"连着来三次"那种情况(见下面的 streak 升级)。
|
|
557
|
+
let intensity = clamp((Number(impulse.intensity) || 0) * habit, 0, 88)
|
|
554
558
|
if (intensity < 8) return null
|
|
555
559
|
|
|
556
560
|
const cur = state.emotion
|
package/package.json
CHANGED