dsh-folia 4.26.0-pre.26 → 4.26.0-pre.28
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 +126 -0
- package/lib/routes/pet-chat.js +56 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -763,6 +763,18 @@ window.__ModuleLoader__.load({
|
|
|
763
763
|
"不显示它": "Hide it",
|
|
764
764
|
"对话": "Chat",
|
|
765
765
|
"可选工作能力(已安装才可用)": "Optional work capabilities (installed only)",
|
|
766
|
+
"能力": "Capabilities",
|
|
767
|
+
"工作能力": "Work",
|
|
768
|
+
"娱乐": "Fun",
|
|
769
|
+
"未安装": "Not installed",
|
|
770
|
+
"详情": "Details",
|
|
771
|
+
"收起": "Collapse",
|
|
772
|
+
"复制安装命令": "Copy install command",
|
|
773
|
+
"已复制": "Copied",
|
|
774
|
+
"怎么用:": "How to use: ",
|
|
775
|
+
"前提:": "Requires: ",
|
|
776
|
+
"读取失败,重开设置页再试": "Failed to load; reopen settings and retry",
|
|
777
|
+
"这些是可选插件:装好后能力是给 DSH 助手的,桌宠本身不受影响。我们不做一键安装,复制命令后自行安装。": "Optional plugins: they add abilities to the DSH assistant, not the pet. No one-click install — copy the command and install it yourself.",
|
|
766
778
|
"正在读取…": "Loading…",
|
|
767
779
|
"冲突提醒:": "Conflict: ",
|
|
768
780
|
"站点上还没有桌宠。": "No pets on the site yet.",
|
|
@@ -18787,6 +18799,111 @@ window.__ModuleLoader__.load({
|
|
|
18787
18799
|
return React.createElement(PetsTabPanel, null);
|
|
18788
18800
|
}
|
|
18789
18801
|
|
|
18802
|
+
// ── 内联模块:src/panel-tabs-work.js —— 「能力」一级设置项:工作能力/娱乐 两区卡片 + 详情 + 复制安装命令(只读展示,不做一键安装)(构建期注入;勿手改本段)──
|
|
18803
|
+
/**
|
|
18804
|
+
* panel-tabs-work.js — 「能力」一级设置项(与「壁纸引擎」并列的第二个 settings.section)。
|
|
18805
|
+
*
|
|
18806
|
+
* 定位:**只做展示与指引,不做一键安装**(用户明确要求)。
|
|
18807
|
+
* · 工作能力 / 娱乐 两片区域
|
|
18808
|
+
* · 每张卡片:名称 + 包名 + 版本 + 状态徽标(已安装 / 未安装)
|
|
18809
|
+
* · 「详情」行内展开:它是什么 / 怎么用 / 前提
|
|
18810
|
+
* · 未安装的给一条可复制的安装命令
|
|
18811
|
+
*
|
|
18812
|
+
* 数据来自宿主 `GET /folia/pet-chat/capabilities`(catalog 写死在宿主侧,前端只渲染)。
|
|
18813
|
+
*/
|
|
18814
|
+
const CAP_STATUS_TEXT = (item) => (item.installed ? weT('已安装') : weT('未安装'));
|
|
18815
|
+
|
|
18816
|
+
function CapabilityCard({ item }) {
|
|
18817
|
+
const [open, setOpen] = React.useState(false);
|
|
18818
|
+
const [copied, setCopied] = React.useState(false);
|
|
18819
|
+
const copy = () => {
|
|
18820
|
+
const text = String(item.command || '');
|
|
18821
|
+
try {
|
|
18822
|
+
if (navigator && navigator.clipboard && navigator.clipboard.writeText) {
|
|
18823
|
+
void navigator.clipboard.writeText(text);
|
|
18824
|
+
}
|
|
18825
|
+
} catch { /* 复制失败不打断 */ }
|
|
18826
|
+
setCopied(true);
|
|
18827
|
+
setTimeout(() => setCopied(false), 1500);
|
|
18828
|
+
};
|
|
18829
|
+
const tail = [];
|
|
18830
|
+
tail.push(React.createElement('div', {
|
|
18831
|
+
key: 'row',
|
|
18832
|
+
style: { display: 'flex', alignItems: 'baseline', gap: '8px', flexWrap: 'wrap' },
|
|
18833
|
+
},
|
|
18834
|
+
React.createElement('span', { style: { fontWeight: 600 } }, item.name),
|
|
18835
|
+
React.createElement('span', { className: 'we-picker__hint' }, item.pkg),
|
|
18836
|
+
item.installedVersion
|
|
18837
|
+
? React.createElement('span', { className: 'we-picker__hint' }, 'v' + item.installedVersion)
|
|
18838
|
+
: null,
|
|
18839
|
+
React.createElement('span', {
|
|
18840
|
+
className: 'we-picker__hint',
|
|
18841
|
+
style: { color: item.installed ? '#4caf7d' : undefined },
|
|
18842
|
+
}, CAP_STATUS_TEXT(item))));
|
|
18843
|
+
tail.push(React.createElement('div', { key: 'sum', className: 'we-picker__hint' }, item.summary));
|
|
18844
|
+
if (open) {
|
|
18845
|
+
tail.push(React.createElement('div', { key: 'usage', className: 'we-picker__hint', style: { marginTop: '4px' } },
|
|
18846
|
+
weT('怎么用:') + item.usage));
|
|
18847
|
+
if (item.requires) {
|
|
18848
|
+
tail.push(React.createElement('div', { key: 'req', className: 'we-picker__hint' }, weT('前提:') + item.requires));
|
|
18849
|
+
}
|
|
18850
|
+
if (!item.installed && item.command) {
|
|
18851
|
+
tail.push(React.createElement('div', {
|
|
18852
|
+
key: 'cmd',
|
|
18853
|
+
style: {
|
|
18854
|
+
marginTop: '6px', padding: '6px 8px', borderRadius: '6px',
|
|
18855
|
+
background: 'rgba(255,255,255,0.06)', fontFamily: 'monospace', fontSize: '11px',
|
|
18856
|
+
wordBreak: 'break-all',
|
|
18857
|
+
},
|
|
18858
|
+
}, item.command));
|
|
18859
|
+
}
|
|
18860
|
+
}
|
|
18861
|
+
tail.push(React.createElement('div', { key: 'btns', style: { display: 'flex', gap: '6px', marginTop: '6px' } },
|
|
18862
|
+
React.createElement('button', {
|
|
18863
|
+
type: 'button', className: 'we-picker__btn', onClick: () => setOpen((v) => !v),
|
|
18864
|
+
}, open ? weT('收起') : weT('详情')),
|
|
18865
|
+
!item.installed && item.command
|
|
18866
|
+
? React.createElement('button', { type: 'button', className: 'we-picker__btn', onClick: copy },
|
|
18867
|
+
copied ? weT('已复制') : weT('复制安装命令'))
|
|
18868
|
+
: null));
|
|
18869
|
+
return React.createElement('div', {
|
|
18870
|
+
style: {
|
|
18871
|
+
border: '1px solid rgba(255,255,255,0.12)', borderRadius: '8px',
|
|
18872
|
+
padding: '8px 10px', margin: '6px 0',
|
|
18873
|
+
},
|
|
18874
|
+
}, tail);
|
|
18875
|
+
}
|
|
18876
|
+
|
|
18877
|
+
function CapabilitiesSection() {
|
|
18878
|
+
const [items, setItems] = React.useState(null);
|
|
18879
|
+
const [error, setError] = React.useState(null);
|
|
18880
|
+
|
|
18881
|
+
React.useEffect(() => {
|
|
18882
|
+
void (async () => {
|
|
18883
|
+
const resp = await apiJson('/pet-chat/capabilities', { parse: 'always' }).catch(() => null);
|
|
18884
|
+
const doc = (resp && resp.data) || null;
|
|
18885
|
+
if (doc && Array.isArray(doc.items)) setItems(doc.items);
|
|
18886
|
+
else setError(weT('读取失败,重开设置页再试'));
|
|
18887
|
+
})();
|
|
18888
|
+
}, []);
|
|
18889
|
+
|
|
18890
|
+
if (error) return React.createElement('div', { className: 'we-picker__hint' }, error);
|
|
18891
|
+
if (!items) return React.createElement('div', { className: 'we-picker__hint' }, weT('正在读取…'));
|
|
18892
|
+
|
|
18893
|
+
const work = items.filter((it) => it.section === 'work');
|
|
18894
|
+
const fun = items.filter((it) => it.section === 'fun');
|
|
18895
|
+
const block = (title, list) => React.createElement('div', { key: title, style: { marginTop: '12px' } },
|
|
18896
|
+
React.createElement('div', { style: { fontWeight: 600, fontSize: '13px', marginBottom: '4px' } }, title),
|
|
18897
|
+
list.map((it) => React.createElement(CapabilityCard, { key: it.pkg, item: it })));
|
|
18898
|
+
|
|
18899
|
+
return React.createElement('div', { style: { padding: '4px 2px' } },
|
|
18900
|
+
React.createElement('div', { style: { fontSize: '13px', fontWeight: 600 } }, weT('能力')),
|
|
18901
|
+
React.createElement('div', { className: 'we-picker__hint', style: { marginTop: '2px' } },
|
|
18902
|
+
weT('这些是可选插件:装好后能力是给 DSH 助手的,桌宠本身不受影响。我们不做一键安装,复制命令后自行安装。')),
|
|
18903
|
+
block(weT('工作能力'), work),
|
|
18904
|
+
block(weT('娱乐'), fun));
|
|
18905
|
+
}
|
|
18906
|
+
|
|
18790
18907
|
// ── 内联模块:src/pet-layer.js —— 桌宠渲染层:canvas 逐帧绘 sprite2d 雪碧图 + 拖动 + 状态机(自渲染,不依赖第三方宠物插件)(构建期注入;勿手改本段)──
|
|
18791
18908
|
/**
|
|
18792
18909
|
* pet-layer.js — 桌宠**渲染层**(自己画,不依赖任何第三方宠物插件)。
|
|
@@ -41097,6 +41214,15 @@ window.__ModuleLoader__.load({
|
|
|
41097
41214
|
),
|
|
41098
41215
|
);
|
|
41099
41216
|
}
|
|
41217
|
+
// 2a. 第二个一级设置项:「能力」(工作能力 / 娱乐;只做展示与安装指引,不做一键安装)
|
|
41218
|
+
if (ctx.slots) {
|
|
41219
|
+
ctx.slots.inject("settings.section", () =>
|
|
41220
|
+
ctx.slots.register(
|
|
41221
|
+
{ name: "settings.section", id: "folia-capabilities", order: 501, label: () => weT("能力") },
|
|
41222
|
+
() => React.createElement(CapabilitiesSection),
|
|
41223
|
+
),
|
|
41224
|
+
);
|
|
41225
|
+
}
|
|
41100
41226
|
|
|
41101
41227
|
// 2b. 设置导航图标:官方 nav 的图标是 shell 里 navIcon(id) 的硬编码映射,第三方
|
|
41102
41228
|
// section 一律拿兜底齿轮 —— 用 DOM 补丁把「壁纸引擎」那格换成自绘 SVG
|
package/lib/routes/pet-chat.js
CHANGED
|
@@ -896,6 +896,54 @@ export function registerPetChatRoutes(webServer, c) {
|
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
898
|
|
|
899
|
+
/**
|
|
900
|
+
* GET /pet-chat/capabilities —— 「能力」页签的数据源。
|
|
901
|
+
* 只读:每个条目的简介 / 用法 / 前提 / 安装命令(不做一键安装),
|
|
902
|
+
* 以及本机是否已安装(扫 profile 的 node_modules)。
|
|
903
|
+
*/
|
|
904
|
+
function handleCapabilities(res) {
|
|
905
|
+
const send = (payload, status = 200) => {
|
|
906
|
+
res.statusCode = status;
|
|
907
|
+
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
908
|
+
res.end(JSON.stringify(payload));
|
|
909
|
+
};
|
|
910
|
+
const profileRoot = join(homedir(), 'AppData', 'Roaming', 'dsh-desktop', 'harness', 'profiles', 'web');
|
|
911
|
+
// ⚠️ ESM 没有 __dirname;这里只拼真实存在的位置(上一版用 __dirname 导致 400)
|
|
912
|
+
const roots = [
|
|
913
|
+
join(profileRoot, 'node_modules'),
|
|
914
|
+
join(profileRoot, 'node_modules', 'dsh-folia', 'node_modules'),
|
|
915
|
+
join(profileRoot, '..', '.generations', 'live'),
|
|
916
|
+
];
|
|
917
|
+
const findPkg = (name) => {
|
|
918
|
+
for (const root of roots) {
|
|
919
|
+
const f = join(root, ...name.split('/'), 'package.json');
|
|
920
|
+
try {
|
|
921
|
+
if (existsSync(f)) {
|
|
922
|
+
const j = JSON.parse(readFileSync(f, 'utf8'));
|
|
923
|
+
return { version: j.version || null };
|
|
924
|
+
}
|
|
925
|
+
} catch { /* ignore */ }
|
|
926
|
+
}
|
|
927
|
+
return null;
|
|
928
|
+
};
|
|
929
|
+
const catalog = [
|
|
930
|
+
{ section: 'work', name: '联网搜索', pkg: '@240xu/dsh-websearch', summary: '让 AI 联网查资料、读网页内容', usage: '跟我说:帮我搜一下今天的 AI 新闻', requires: '装完要在它自己的设置里填搜索 key', command: 'dsh plugin --profile web add @240xu/dsh-websearch' },
|
|
931
|
+
{ section: 'work', name: '文档读取', pkg: '@civilization/dsh-office-reader', summary: '读 PDF / Word / Excel(只读,不修改)', usage: '跟我说:读一下 D:\\报告.pdf 前 5 页,总结要点', requires: '无需配置;大文件建议先让它看目录结构', command: 'dsh plugin --profile web add @civilization/dsh-office-reader' },
|
|
932
|
+
{ section: 'work', name: '定时任务', pkg: '@aiwayds/dsh-cron', summary: '按 cron 表达式或间隔自动跑任务', usage: '跟我说:每天早 9 点生成周报,到年底为止', requires: '无需配置;注意任务有有效期上限(1 年)', command: 'dsh plugin --profile web add @aiwayds/dsh-cron' },
|
|
933
|
+
{ section: 'work', name: 'Outlook 邮件', pkg: '@aryacode/dsh-arya-maildesk', summary: '让 AI 读 / 整理 / 回复本机 Outlook 邮件', usage: '跟我说:把昨天未读邮件列出来,挑重要的回', requires: '本机要装并登录 Outlook(Windows)', command: 'dsh plugin --profile web add @aryacode/dsh-arya-maildesk' },
|
|
934
|
+
{ section: 'work', name: '消息推送', pkg: '@alotop/dsh-notify-hub', summary: '任务完成后推送到手机(Bark/Telegram 等)', usage: '跟我说:这个任务跑完推我手机', requires: '要先配置推送渠道', command: 'dsh plugin --profile web add @alotop/dsh-notify-hub' },
|
|
935
|
+
{ section: 'work', name: '直接改 Office 文档', pkg: '@copylee/dsh-office', summary: '在正开着的 Word/Excel/PPT 里改,实时可见', usage: '跟我说:把这份 Word 的标题改字号、加一张三线表', requires: 'Windows + 本机 Office/WPS;会接管自带 Office 技能', command: 'dsh plugin --profile web add @copylee/dsh-office' },
|
|
936
|
+
{ section: 'fun', name: 'AI 音频', pkg: 'dsh-audiogen', summary: '生成语音 / 音乐 / 音效(多厂商渠道)', usage: '跟我说:用温柔女声读这段话', requires: '要在它自己的设置里配渠道 key', command: 'dsh plugin --profile web add dsh-audiogen' },
|
|
937
|
+
{ section: 'fun', name: '语音对话', pkg: 'dsh-talk', summary: '麦克风说话 → 转文字 → 朗读回答(浏览器端可用)', usage: '在输入框旁点麦克风说话', requires: '要联网 STT/TTS;桌面端麦克风受 DSH 权限限制', command: 'dsh plugin --profile web add dsh-talk' },
|
|
938
|
+
{ section: 'fun', name: '交互卡片', pkg: 'dsh-genui', summary: '让回答里直接出现可点的卡片/表单', usage: '跟我说:用卡片列出三个方案让我选', requires: '无需配置', command: 'dsh plugin --profile web add dsh-genui' },
|
|
939
|
+
{ section: 'fun', name: '皮肤风格', pkg: 'dsh-dream-skin', summary: '给 DSH 界面换一套外观主题', usage: '装完在它自己的设置里挑主题', requires: '和我们自带的皮肤中心可能重叠,二选一', command: 'dsh plugin --profile web add dsh-dream-skin' },
|
|
940
|
+
];
|
|
941
|
+
const items = catalog.map((item) => {
|
|
942
|
+
const hit = findPkg(item.pkg);
|
|
943
|
+
return { ...item, installed: !!hit, installedVersion: hit ? hit.version : null };
|
|
944
|
+
});
|
|
945
|
+
send({ ok: true, items });
|
|
946
|
+
}
|
|
899
947
|
/**
|
|
900
948
|
* GET /pet-chat/work-plugins —— 工作能力插件(聚合携带)的安装状态。
|
|
901
949
|
* 只读探测(不 import 它们,坏插件不拖慢路由):装没装 / 版本 / 要不要配置。
|
|
@@ -914,7 +962,12 @@ export function registerPetChatRoutes(webServer, c) {
|
|
|
914
962
|
{ id: 'notify-hub', pkg: '@alotop/dsh-notify-hub', label: '消息推送', needs: '需要配置推送渠道(Bark/Telegram 等)' },
|
|
915
963
|
];
|
|
916
964
|
const profileRoot = join(homedir(), 'AppData', 'Roaming', 'dsh-desktop', 'harness', 'profiles', 'web');
|
|
917
|
-
|
|
965
|
+
// ⚠️ ESM 没有 __dirname;这里只拼真实存在的位置(上一版用 __dirname 导致 400)
|
|
966
|
+
const roots = [
|
|
967
|
+
join(profileRoot, 'node_modules'),
|
|
968
|
+
join(profileRoot, 'node_modules', 'dsh-folia', 'node_modules'),
|
|
969
|
+
join(profileRoot, '..', '.generations', 'live'),
|
|
970
|
+
];
|
|
918
971
|
const findPkg = (name) => {
|
|
919
972
|
for (const root of roots) {
|
|
920
973
|
const f = join(root, ...name.split('/'), 'package.json');
|
|
@@ -1218,7 +1271,8 @@ export function registerPetChatRoutes(webServer, c) {
|
|
|
1218
1271
|
// 自检:一次性跑「ffmpeg → 设备 → 录音 → 转写」四步,把每步结果原样返回。
|
|
1219
1272
|
// 目的:发版前/真机排查时**一个请求就能看到哪一步坏了**,不用来回猜。
|
|
1220
1273
|
if (tail === '/selftest' && (method === 'GET' || method === 'HEAD')) { void handleSelfTest(res); return; }
|
|
1221
|
-
if (tail === '/
|
|
1274
|
+
if (tail === '/capabilities' && (method === 'GET' || method === 'HEAD')) { handleCapabilities(res); return; }
|
|
1275
|
+
if (tail === '/work-plugins' && (method === 'GET' || method === 'HEAD')) { handleWorkPlugins(res); return; }
|
|
1222
1276
|
if (tail === '/asr' && (method === 'GET' || method === 'HEAD')) { handleAsrStatus(res); return; }
|
|
1223
1277
|
if (tail === '/asr' && method === 'POST') { handleAsrPrepare(res); return; }
|
|
1224
1278
|
// v0.1「零配置」主动搭话:没有开关,只有内部策略 + 语音指令静默
|