@kadaliao/dsh-bots 0.4.0 → 0.6.0
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.md +87 -9
- package/README.zh-CN.md +71 -7
- package/client.js +330 -42
- package/index.js +65 -11
- package/lib/apps.mjs +85 -4
- package/lib/channels/feishu.mjs +1249 -0
- package/lib/channels/slack.mjs +906 -0
- package/lib/channels.mjs +7 -3
- package/lib/logos.mjs +2 -0
- package/lib/skills.mjs +198 -5
- package/lib/store.mjs +22 -3
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -500,6 +500,7 @@ window.__ModuleLoader__.load({
|
|
|
500
500
|
eyeOff: (s = 14) => svg(s, ['M3 3l18 18', 'M10.6 5.1A10.7 10.7 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-3.2 4.1', 'M6.6 6.6A17 17 0 0 0 2 12s3.5 7 10 7a10 10 0 0 0 5.4-1.6', 'M9.9 9.9a3 3 0 0 0 4.2 4.2']),
|
|
501
501
|
team: (s = 14) => svg(s, ['M9 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z', 'M2.5 20a6.5 6.5 0 0 1 13 0', 'M16 4.3a3.5 3.5 0 0 1 0 6.4', 'M18 14.2a6.5 6.5 0 0 1 3.5 5.8']),
|
|
502
502
|
layers: (s = 14) => svg(s, ['M12 3l9 5-9 5-9-5 9-5z', 'M3 13l9 5 9-5']),
|
|
503
|
+
folder: (s = 14) => svg(s, ['M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z']),
|
|
503
504
|
github: (s = 14) => svg(s, ['M9 19c-4 1.5-4-2-6-2.5', 'M15 21v-3.5a3 3 0 0 0-.8-2.3c2.8-.3 5.8-1.4 5.8-6.2a4.8 4.8 0 0 0-1.3-3.3 4.5 4.5 0 0 0-.1-3.3s-1-.3-3.4 1.3a11.6 11.6 0 0 0-6 0C6.8 2.1 5.8 2.4 5.8 2.4a4.5 4.5 0 0 0-.1 3.3A4.8 4.8 0 0 0 4.4 9c0 4.8 3 5.9 5.8 6.2a3 3 0 0 0-.8 2.3V21']),
|
|
504
505
|
wand: (s = 14) => svg(s, ['M4 20l11-11', 'M13 7l4 4', 'M18 3v4', 'M16 5h4', 'M8 3v2', 'M7 4h2']),
|
|
505
506
|
chevron: (s = 12) => svg(s, ['M6 9l6 6 6-6']),
|
|
@@ -1157,7 +1158,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
1157
1158
|
: h(
|
|
1158
1159
|
'span',
|
|
1159
1160
|
{ style: { fontSize: TINY, color: C.faint, display: 'inline-flex', alignItems: 'center', gap: 6 } },
|
|
1160
|
-
m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, 'data-dsh-bots-via': m.via }, t('viaChannel', { app: channelName(m.via), who: str(m.who) || t('you') })) : null,
|
|
1161
|
+
m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, 'data-dsh-bots-via': m.via }, t('viaChannel', { app: channelName(m.via, t), who: str(m.who) || t('you') })) : null,
|
|
1161
1162
|
m.to !== botId && to.kind === 'bot' ? `${t('toName', { name: to.name })} · ${time}` : time,
|
|
1162
1163
|
),
|
|
1163
1164
|
h('div', { style: { maxWidth: '78%', padding: '8px 12px', borderRadius: '14px 14px 4px 14px', background: C.label, color: '#fff', fontSize: FONT } }, h(Clamp, { t, text: m.text, lines: 14, light: true })),
|
|
@@ -1180,7 +1181,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
1180
1181
|
from.kind === 'bot' ? h('span', { style: { color: C.faint } }, `@${from.bot.handle}`) : null,
|
|
1181
1182
|
m.to !== 'user' && to.kind === 'bot' && m.to !== botId ? h('span', { style: { color: C.faint } }, `→ ${to.name}`) : null,
|
|
1182
1183
|
h('span', { style: { color: C.faint } }, time),
|
|
1183
|
-
m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, title: t('sentToChannel', { app: channelName(m.via) }), 'data-dsh-bots-via': m.via }, `→ ${channelName(m.via)}`) : null,
|
|
1184
|
+
m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, title: t('sentToChannel', { app: channelName(m.via, t) }), 'data-dsh-bots-via': m.via }, `→ ${channelName(m.via, t)}`) : null,
|
|
1184
1185
|
),
|
|
1185
1186
|
h('div', { style: { padding: '8px 12px', borderRadius: '4px 14px 14px 14px', background: C.layer2, border: `1px solid ${C.border1}`, fontSize: FONT, minWidth: 0 } }, h(Clamp, { t, text: m.text, lines: 24 })),
|
|
1186
1187
|
h(LinkCards, { t, text: m.text }),
|
|
@@ -1874,7 +1875,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
1874
1875
|
h('span', { style: { color: C.faint, display: 'inline-flex' } }, Icon.arrow(11)),
|
|
1875
1876
|
h('span', { style: { fontWeight: 600 } }, to.name),
|
|
1876
1877
|
h(Badge, { color: m.kind === 'dm' ? C.label : m.kind === 'system' ? C.warn : C.muted }, t(`kind_${m.kind}`) || m.kind),
|
|
1877
|
-
m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, 'data-dsh-bots-via': m.via }, m.from === 'user' && m.who ? `${channelName(m.via)} · ${str(m.who)}` : channelName(m.via)) : null,
|
|
1878
|
+
m.via ? h(Badge, { color: CHANNEL_COLORS[m.via] ?? C.muted, 'data-dsh-bots-via': m.via }, m.from === 'user' && m.who ? `${channelName(m.via, t)} · ${str(m.who)}` : channelName(m.via, t)) : null,
|
|
1878
1879
|
h('span', { style: { marginLeft: 'auto', color: C.faint, fontSize: TINY }, title: fmtDate(toMs(m.at)) }, fmtAgo(t, m.at)),
|
|
1879
1880
|
),
|
|
1880
1881
|
h(Clamp, { t, text: m.text, lines: 3, style: { fontSize: SMALL, color: C.muted } }),
|
|
@@ -2310,10 +2311,46 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2310
2311
|
}
|
|
2311
2312
|
|
|
2312
2313
|
const skillSource = (s) => (s?.source === 'dsh' || s?.source === 'import' ? s.source : 'own');
|
|
2314
|
+
/** A skill linked to a folder on this machine (its origin is a path, not a URL): read live, never copied. */
|
|
2315
|
+
const isLocalSkill = (s) => s?.source === 'import' && typeof s.origin === 'string' && s.origin !== '' && !/^https?:\/\//i.test(s.origin);
|
|
2313
2316
|
const SOURCE_COLOR = { dsh: '#2563eb', import: '#475569', own: '#16a34a' };
|
|
2314
|
-
function SourceBadge({ t, source }) {
|
|
2315
|
-
return h(
|
|
2317
|
+
function SourceBadge({ t, source, local }) {
|
|
2318
|
+
return h(
|
|
2319
|
+
Badge,
|
|
2320
|
+
{ color: SOURCE_COLOR[source] ?? C.muted, 'data-dsh-bots-skill-source': source },
|
|
2321
|
+
source === 'dsh' ? Icon.layers(10) : source === 'import' ? (local ? Icon.folder(10) : Icon.github(10)) : Icon.edit(10),
|
|
2322
|
+
t(local ? 'src_local' : `src_${source}`),
|
|
2323
|
+
);
|
|
2316
2324
|
}
|
|
2325
|
+
/** The bot's skills by lower-cased name: what an import could collide with. */
|
|
2326
|
+
const skillsByName = (bot) => new Map((bot.skills ?? []).map((s) => [str(s.name).toLowerCase(), s]));
|
|
2327
|
+
/**
|
|
2328
|
+
* What importing a skill named like `existing` from `origin` would do:
|
|
2329
|
+
* 'new' adds it, 'update' refreshes the copy made from the same place, 'taken' is refused.
|
|
2330
|
+
*/
|
|
2331
|
+
const importStateOf = (existing, origin) => (!existing ? 'new' : existing.source === 'import' && existing.origin && existing.origin === origin ? 'update' : 'taken');
|
|
2332
|
+
/** One line for what an import did: added, updated, skipped. */
|
|
2333
|
+
function importSummary(t, r) {
|
|
2334
|
+
const n = (k) => (Array.isArray(r?.[k]) ? r[k].length : 0);
|
|
2335
|
+
return [n('added') ? t('importedN', { n: n('added') }) : '', n('updated') ? t('updatedN', { n: n('updated') }) : '', n('skipped') ? t('skippedN', { n: n('skipped') }) : ''].filter(Boolean).join(' ');
|
|
2336
|
+
}
|
|
2337
|
+
/** Run an import and report it; resolves to the rows that failed, or null when nothing came back. */
|
|
2338
|
+
function runImport(t, toast, botId, items) {
|
|
2339
|
+
return postJson('skills/import', { botId, items }).then((r) => {
|
|
2340
|
+
const bad = Array.isArray(r?.failed) ? r.failed : [];
|
|
2341
|
+
const text = importSummary(t, r);
|
|
2342
|
+
if (r?.ok && text) {
|
|
2343
|
+
toast(text);
|
|
2344
|
+
void refreshState();
|
|
2345
|
+
} else if (!bad.length) toast(r?.reason || t('importFailed'), 'error');
|
|
2346
|
+
return { failed: bad, done: Boolean(r?.ok && text) };
|
|
2347
|
+
});
|
|
2348
|
+
}
|
|
2349
|
+
/** The label and tick of a picker row, by what importing it would do. */
|
|
2350
|
+
const importRowProps = (t, state, files) => ({
|
|
2351
|
+
disabled: state === 'taken',
|
|
2352
|
+
meta: state === 'taken' ? t('nameTaken') : state === 'update' ? t('reimport') : t('nFiles', { n: files ?? 0 }),
|
|
2353
|
+
});
|
|
2317
2354
|
/** A search box with a magnifier. */
|
|
2318
2355
|
const SearchBox = ({ value, onChange, placeholder, style, ...rest }) =>
|
|
2319
2356
|
h(
|
|
@@ -2328,7 +2365,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2328
2365
|
'label',
|
|
2329
2366
|
{
|
|
2330
2367
|
...rest,
|
|
2331
|
-
style: { display: 'flex', gap: 10, alignItems: 'flex-start', padding: '9px 12px', borderTop: `1px solid ${C.border1}`, cursor: disabled ? 'default' : 'pointer', opacity: disabled ? 0.55 : 1, background: checked ? tint(C.label, 7) : 'transparent' },
|
|
2368
|
+
style: { display: 'flex', flex: 'none', gap: 10, alignItems: 'flex-start', padding: '9px 12px', borderTop: `1px solid ${C.border1}`, cursor: disabled ? 'default' : 'pointer', opacity: disabled ? 0.55 : 1, background: checked ? tint(C.label, 7) : 'transparent' },
|
|
2332
2369
|
},
|
|
2333
2370
|
h('input', { type: 'checkbox', checked: Boolean(checked) || Boolean(disabled), disabled, onChange: () => onToggle(), style: { marginTop: 3, accentColor: 'var(--dsw-alias-brand-primary)' } }),
|
|
2334
2371
|
h(
|
|
@@ -2373,7 +2410,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2373
2410
|
h(SearchBox, { value: q, onChange: setQ, placeholder: t('searchSkills', { n: (all ?? []).length }), autoFocus: true, 'data-dsh-bots-harness-search': true }),
|
|
2374
2411
|
h(
|
|
2375
2412
|
'div',
|
|
2376
|
-
|
|
2413
|
+
// The list scrolls by itself, so the search box stays in view however many skills there are.
|
|
2414
|
+
{ 'data-dsh-bots-harness-list': true, className: 'dshb-scroll', style: { display: 'flex', flexDirection: 'column', flex: '1 1 auto', minHeight: 120, border: `1px solid ${C.border1}`, borderRadius: 12, marginTop: -4, borderTop: 'none' } },
|
|
2377
2415
|
all === null
|
|
2378
2416
|
? h('div', { style: { padding: 18, fontSize: SMALL, color: C.faint, textAlign: 'center', borderTop: `1px solid ${C.border1}` } }, t('loading'))
|
|
2379
2417
|
: shown.length === 0
|
|
@@ -2405,7 +2443,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2405
2443
|
const [sel, setSel] = useState([]);
|
|
2406
2444
|
const [importing, setImporting] = useState(false);
|
|
2407
2445
|
const [failed, setFailed] = useState([]);
|
|
2408
|
-
const
|
|
2446
|
+
const mine = skillsByName(bot);
|
|
2447
|
+
const stateOf = (s) => importStateOf(mine.get(str(s.name).toLowerCase()), listing ? `https://github.com/${listing.owner}/${listing.repo}/tree/${listing.ref}/${s.path}` : '');
|
|
2409
2448
|
const browse = (spec) => {
|
|
2410
2449
|
const value = str(spec).trim();
|
|
2411
2450
|
if (!value) return;
|
|
@@ -2426,15 +2465,10 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2426
2465
|
const doImport = () => {
|
|
2427
2466
|
if (!listing || sel.length === 0) return;
|
|
2428
2467
|
setImporting(true);
|
|
2429
|
-
|
|
2468
|
+
runImport(t, toast, bot.id, sel.map((path) => ({ repo: `${listing.owner}/${listing.repo}`, ref: listing.ref, path })))
|
|
2430
2469
|
.then((r) => {
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
if (r?.ok && Array.isArray(r.added) && r.added.length) {
|
|
2434
|
-
toast(t('importedN', { n: r.added.length }));
|
|
2435
|
-
void refreshState();
|
|
2436
|
-
if (bad.length === 0) onImported();
|
|
2437
|
-
} else if (!bad.length) toast(r?.reason || t('importFailed'), 'error');
|
|
2470
|
+
setFailed(r.failed);
|
|
2471
|
+
if (r.done && r.failed.length === 0) onImported();
|
|
2438
2472
|
})
|
|
2439
2473
|
.finally(() => setImporting(false));
|
|
2440
2474
|
};
|
|
@@ -2515,7 +2549,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2515
2549
|
h('span', { style: { color: C.faint } }, t('foundSkills', { n: skills.length })),
|
|
2516
2550
|
h('span', { style: { flex: 1 } }),
|
|
2517
2551
|
skills.length
|
|
2518
|
-
? h('button', { type: 'button', className: 'dshb-link', style: { fontSize: TINY }, onClick: () => setSel(sel.length ? [] : skills.filter((s) =>
|
|
2552
|
+
? h('button', { type: 'button', className: 'dshb-link', style: { fontSize: TINY }, onClick: () => setSel(sel.length ? [] : skills.filter((s) => stateOf(s) === 'new').map((s) => s.path)) }, sel.length ? t('selectNone') : t('selectAll'))
|
|
2519
2553
|
: null,
|
|
2520
2554
|
),
|
|
2521
2555
|
h(
|
|
@@ -2527,10 +2561,9 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2527
2561
|
key: s.path,
|
|
2528
2562
|
'data-dsh-bots-github-skill': s.path,
|
|
2529
2563
|
checked: sel.includes(s.path),
|
|
2530
|
-
disabled: have.has(s.name),
|
|
2531
2564
|
onToggle: () => setSel((x) => (x.includes(s.path) ? x.filter((p) => p !== s.path) : [...x, s.path])),
|
|
2532
2565
|
title: s.name,
|
|
2533
|
-
|
|
2566
|
+
...importRowProps(t, stateOf(s), s.files),
|
|
2534
2567
|
description: s.description,
|
|
2535
2568
|
note: bad ? h('span', { style: { color: C.error } }, bad.reason) : null,
|
|
2536
2569
|
});
|
|
@@ -2543,6 +2576,170 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2543
2576
|
);
|
|
2544
2577
|
}
|
|
2545
2578
|
|
|
2579
|
+
/** Import skill folders from this machine: one skill folder, or a folder that holds several. */
|
|
2580
|
+
function LocalPicker({ t, bot, catalog, env, onClose, onImported, toast }) {
|
|
2581
|
+
const places = useLoaded('localPlaces', 'skills/local')?.places;
|
|
2582
|
+
const [path, setPath] = useState('');
|
|
2583
|
+
const [listing, setListing] = useState(null); // {root, skills, truncated}
|
|
2584
|
+
const [loading, setLoading] = useState(false);
|
|
2585
|
+
const [error, setError] = useState('');
|
|
2586
|
+
const [sel, setSel] = useState([]);
|
|
2587
|
+
const [importing, setImporting] = useState(false);
|
|
2588
|
+
const [failed, setFailed] = useState([]);
|
|
2589
|
+
const mine = skillsByName(bot);
|
|
2590
|
+
const inHarness = new Set((Array.isArray(catalog?.skills) ? catalog.skills : []).map((s) => s.name));
|
|
2591
|
+
// A folder already linked has nothing to import again: the bot reads it live.
|
|
2592
|
+
const stateOf = (s) => (importStateOf(mine.get(str(s.name).toLowerCase()), s.path) === 'new' ? 'new' : mine.get(str(s.name).toLowerCase()).origin === s.path ? 'linked' : 'taken');
|
|
2593
|
+
const scan = (spec) => {
|
|
2594
|
+
const value = str(spec).trim();
|
|
2595
|
+
if (!value) return;
|
|
2596
|
+
setLoading(true);
|
|
2597
|
+
setError('');
|
|
2598
|
+
setSel([]);
|
|
2599
|
+
setFailed([]);
|
|
2600
|
+
postJson('skills/local', { path: value })
|
|
2601
|
+
.then((r) => {
|
|
2602
|
+
if (r?.ok && Array.isArray(r.skills)) {
|
|
2603
|
+
setListing(r);
|
|
2604
|
+
// One skill and nothing in its way: ready to import.
|
|
2605
|
+
if (r.skills.length === 1 && !mine.has(str(r.skills[0].name).toLowerCase())) setSel([r.skills[0].path]);
|
|
2606
|
+
} else {
|
|
2607
|
+
setListing(null);
|
|
2608
|
+
setError(r?.reason || t('localFailed'));
|
|
2609
|
+
}
|
|
2610
|
+
})
|
|
2611
|
+
.finally(() => setLoading(false));
|
|
2612
|
+
};
|
|
2613
|
+
const canPick = typeof env?.pickDirectory === 'function' && env.canPickDirectory?.() !== false;
|
|
2614
|
+
const choose = () => {
|
|
2615
|
+
setError('');
|
|
2616
|
+
Promise.resolve()
|
|
2617
|
+
.then(() => env.pickDirectory())
|
|
2618
|
+
.then(
|
|
2619
|
+
(p) => {
|
|
2620
|
+
if (typeof p !== 'string' || p === '') return;
|
|
2621
|
+
setPath(p);
|
|
2622
|
+
scan(p);
|
|
2623
|
+
},
|
|
2624
|
+
() => setError(t('pickFailed')),
|
|
2625
|
+
);
|
|
2626
|
+
};
|
|
2627
|
+
const doImport = () => {
|
|
2628
|
+
if (!listing || sel.length === 0) return;
|
|
2629
|
+
setImporting(true);
|
|
2630
|
+
runImport(t, toast, bot.id, sel.map((p) => ({ local: p })))
|
|
2631
|
+
.then((r) => {
|
|
2632
|
+
setFailed(r.failed);
|
|
2633
|
+
if (r.done && r.failed.length === 0) onImported();
|
|
2634
|
+
})
|
|
2635
|
+
.finally(() => setImporting(false));
|
|
2636
|
+
};
|
|
2637
|
+
const skills = listing?.skills ?? [];
|
|
2638
|
+
return h(
|
|
2639
|
+
Modal,
|
|
2640
|
+
{
|
|
2641
|
+
title: t('localPickerTitle'),
|
|
2642
|
+
closeLabel: t('close'),
|
|
2643
|
+
width: 700,
|
|
2644
|
+
onClose,
|
|
2645
|
+
footer: [
|
|
2646
|
+
importing ? h('span', { key: 'p', style: { flex: 1, alignSelf: 'center', display: 'inline-flex', alignItems: 'center', gap: 8, fontSize: SMALL, color: C.muted } }, h('span', { className: 'dshb-spinner' }), t('importing')) : h('span', { key: 'p', style: { flex: 1, alignSelf: 'center', fontSize: TINY, color: C.faint } }, t('localNote')),
|
|
2647
|
+
h(Btn, { key: 'c', onClick: onClose }, t('cancel')),
|
|
2648
|
+
h(Btn, { key: 'i', kind: 'primary', icon: Icon.folder(12), disabled: sel.length === 0 || importing, onClick: doImport, 'data-dsh-bots-local-import': true }, t('addN', { n: sel.length })),
|
|
2649
|
+
],
|
|
2650
|
+
},
|
|
2651
|
+
h('div', { style: { fontSize: SMALL, color: C.muted, lineHeight: 1.6 } }, t('localHint')),
|
|
2652
|
+
h(
|
|
2653
|
+
'div',
|
|
2654
|
+
{ style: { display: 'flex', gap: 8 } },
|
|
2655
|
+
h(Input, {
|
|
2656
|
+
value: path,
|
|
2657
|
+
mono: true,
|
|
2658
|
+
autoFocus: true,
|
|
2659
|
+
placeholder: '~/skills/my-skill',
|
|
2660
|
+
'data-dsh-bots-local-path': true,
|
|
2661
|
+
onChange: (e) => setPath(e.target.value),
|
|
2662
|
+
onKeyDown: (e) => {
|
|
2663
|
+
if (e.key === 'Enter' && !e.isComposing && !e.nativeEvent?.isComposing) {
|
|
2664
|
+
e.preventDefault();
|
|
2665
|
+
scan(path);
|
|
2666
|
+
}
|
|
2667
|
+
},
|
|
2668
|
+
}),
|
|
2669
|
+
canPick ? h(Btn, { icon: Icon.folder(13), disabled: loading, onClick: choose, 'data-dsh-bots-local-pick': true }, t('chooseFolder')) : null,
|
|
2670
|
+
h(Btn, { disabled: !path.trim() || loading, onClick: () => scan(path), 'data-dsh-bots-local-scan': true }, loading ? t('loading') : t('scan')),
|
|
2671
|
+
),
|
|
2672
|
+
Array.isArray(places) && places.length
|
|
2673
|
+
? h(
|
|
2674
|
+
'div',
|
|
2675
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap', fontSize: TINY, color: C.faint, marginTop: -6 } },
|
|
2676
|
+
t('localPlaces'),
|
|
2677
|
+
places.map((pl) =>
|
|
2678
|
+
h(
|
|
2679
|
+
'button',
|
|
2680
|
+
{
|
|
2681
|
+
key: pl.path,
|
|
2682
|
+
type: 'button',
|
|
2683
|
+
className: 'dshb-chip dshb-mono',
|
|
2684
|
+
'data-dsh-bots-local-place': pl.path,
|
|
2685
|
+
title: pl.path,
|
|
2686
|
+
onClick: () => {
|
|
2687
|
+
setPath(pl.label || pl.path);
|
|
2688
|
+
scan(pl.path);
|
|
2689
|
+
},
|
|
2690
|
+
},
|
|
2691
|
+
pl.label || pl.path,
|
|
2692
|
+
),
|
|
2693
|
+
),
|
|
2694
|
+
)
|
|
2695
|
+
: null,
|
|
2696
|
+
error ? h('div', { 'data-dsh-bots-local-error': true, style: { fontSize: SMALL, color: C.error } }, error) : null,
|
|
2697
|
+
listing
|
|
2698
|
+
? h(
|
|
2699
|
+
'div',
|
|
2700
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
2701
|
+
h(
|
|
2702
|
+
'div',
|
|
2703
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 8, fontSize: SMALL, minWidth: 0 } },
|
|
2704
|
+
Icon.folder(13),
|
|
2705
|
+
h('span', { className: 'dshb-mono', style: { fontWeight: 600, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', direction: 'rtl' }, title: listing.root }, h('bdi', null, listing.root)),
|
|
2706
|
+
h('span', { style: { color: C.faint, flex: 'none' } }, t('foundSkills', { n: skills.length })),
|
|
2707
|
+
h('span', { style: { flex: 1 } }),
|
|
2708
|
+
skills.length > 1
|
|
2709
|
+
? h('button', { type: 'button', className: 'dshb-link', style: { fontSize: TINY, flex: 'none' }, onClick: () => setSel(sel.length ? [] : skills.filter((s) => stateOf(s) === 'new').map((s) => s.path)) }, sel.length ? t('selectNone') : t('selectAll'))
|
|
2710
|
+
: null,
|
|
2711
|
+
),
|
|
2712
|
+
skills.length === 0
|
|
2713
|
+
? h('div', { style: { padding: 18, fontSize: SMALL, color: C.faint, textAlign: 'center', border: `1px dashed ${C.border1}`, borderRadius: 12 } }, t('localNone'))
|
|
2714
|
+
: h(
|
|
2715
|
+
'div',
|
|
2716
|
+
{ 'data-dsh-bots-local-list': true, style: { display: 'flex', flexDirection: 'column', border: `1px solid ${C.border1}`, borderRadius: 12, overflow: 'hidden', borderTop: 'none' } },
|
|
2717
|
+
skills.map((s) => {
|
|
2718
|
+
const bad = failed.find((f) => f.spec?.local === s.path);
|
|
2719
|
+
const state = stateOf(s);
|
|
2720
|
+
const rel = s.path === listing.root ? '' : str(s.path).slice(listing.root.length + 1);
|
|
2721
|
+
return h(PickRow, {
|
|
2722
|
+
key: s.path,
|
|
2723
|
+
'data-dsh-bots-local-skill': s.path,
|
|
2724
|
+
'data-state': state,
|
|
2725
|
+
checked: sel.includes(s.path),
|
|
2726
|
+
onToggle: () => setSel((x) => (x.includes(s.path) ? x.filter((p) => p !== s.path) : [...x, s.path])),
|
|
2727
|
+
title: s.name,
|
|
2728
|
+
disabled: state !== 'new',
|
|
2729
|
+
meta: state === 'linked' ? t('linked') : state === 'taken' ? t('nameTaken') : t('nFiles', { n: s.files ?? 0 }),
|
|
2730
|
+
description: s.description,
|
|
2731
|
+
note: bad ? h('span', { style: { color: C.error } }, bad.reason) : state === 'new' && inHarness.has(s.name) ? t('alsoInHarness') : rel && rel !== s.name ? h('span', { className: 'dshb-mono' }, rel) : null,
|
|
2732
|
+
});
|
|
2733
|
+
}),
|
|
2734
|
+
),
|
|
2735
|
+
listing.truncated ? h('div', { style: { fontSize: TINY, color: C.faint } }, t('localTruncated')) : null,
|
|
2736
|
+
)
|
|
2737
|
+
: loading
|
|
2738
|
+
? h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, fontSize: SMALL, color: C.muted, padding: 8 } }, h('span', { className: 'dshb-spinner' }), t('readingFolder'))
|
|
2739
|
+
: null,
|
|
2740
|
+
);
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2546
2743
|
/** Describe a skill; the bot writes it (with skill-creator) in its own conversation. */
|
|
2547
2744
|
function WriteSkillModal({ t, bot, onClose, onSent, toast }) {
|
|
2548
2745
|
const [text, setText] = useState('');
|
|
@@ -2573,13 +2770,13 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2573
2770
|
);
|
|
2574
2771
|
}
|
|
2575
2772
|
|
|
2576
|
-
function SkillsTab({ t, bot, toast, catalog, setTab }) {
|
|
2773
|
+
function SkillsTab({ t, bot, toast, catalog, setTab, env }) {
|
|
2577
2774
|
const lang = langOf(t);
|
|
2578
2775
|
const skills = Array.isArray(bot.skills) ? bot.skills : [];
|
|
2579
2776
|
const [editing, setEditing] = useState(null); // {id?, name, description, content, enabled}
|
|
2580
2777
|
const [confirm, setConfirm] = useState(null);
|
|
2581
2778
|
const [busy, setBusy] = useState(false);
|
|
2582
|
-
const [picker, setPicker] = useState(null); // 'harness' | 'github' | 'write'
|
|
2779
|
+
const [picker, setPicker] = useState(null); // 'harness' | 'github' | 'local' | 'write'
|
|
2583
2780
|
const commit = (next, okText) => {
|
|
2584
2781
|
setBusy(true);
|
|
2585
2782
|
return saveField(t, toast, bot, { skills: next }, okText).finally(() => setBusy(false));
|
|
@@ -2588,17 +2785,22 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2588
2785
|
const s = editing;
|
|
2589
2786
|
if (!s || !s.name.trim()) return;
|
|
2590
2787
|
const prev = skills.find((x) => x.id === s.id);
|
|
2788
|
+
// Two skills of one name would be told apart by nothing: refuse instead of doubling.
|
|
2789
|
+
if (skills.some((x) => x !== prev && str(x.name).toLowerCase() === s.name.trim().toLowerCase())) {
|
|
2790
|
+
toast(t('skillNameTaken', { name: s.name.trim() }), 'error');
|
|
2791
|
+
return;
|
|
2792
|
+
}
|
|
2591
2793
|
const item = { ...(prev ?? {}), id: s.id || rid('skill'), name: s.name.trim(), source: prev ? skillSource(prev) : 'own', description: s.description.trim(), content: s.content, enabled: s.enabled !== false };
|
|
2592
2794
|
const next = s.id ? skills.map((x) => (x.id === s.id ? item : x)) : [...skills, item];
|
|
2593
2795
|
void commit(next, t('skillSaved')).then((ok) => ok && setEditing(null));
|
|
2594
2796
|
};
|
|
2595
2797
|
const addHarness = (list) => {
|
|
2596
|
-
const have = new Set(skills.map((x) => x.name));
|
|
2597
|
-
const add = list.filter((x) => !have.has(x.name)).map((x) => ({ name: x.name, source: 'dsh', enabled: true, description: str(x.description) }));
|
|
2798
|
+
const have = new Set(skills.map((x) => str(x.name).toLowerCase()));
|
|
2799
|
+
const add = list.filter((x) => !have.has(str(x.name).toLowerCase())).map((x) => ({ name: x.name, source: 'dsh', enabled: true, description: str(x.description) }));
|
|
2598
2800
|
void commit([...skills, ...add], t('addedN', { n: add.length })).then((ok) => ok && setPicker(null));
|
|
2599
2801
|
};
|
|
2600
|
-
const counts = { dsh: 0, import: 0, own: 0 };
|
|
2601
|
-
for (const s of skills) counts[skillSource(s)] += 1;
|
|
2802
|
+
const counts = { dsh: 0, import: 0, local: 0, own: 0 };
|
|
2803
|
+
for (const s of skills) counts[isLocalSkill(s) ? 'local' : skillSource(s)] += 1;
|
|
2602
2804
|
return h(
|
|
2603
2805
|
'div',
|
|
2604
2806
|
{ className: 'dshb-scroll', style: { flex: 1, padding: '20px 24px 28px' } },
|
|
@@ -2610,6 +2812,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2610
2812
|
{ 'data-dsh-bots-skill-actions': true, style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
|
|
2611
2813
|
h(Btn, { kind: 'primary', icon: Icon.layers(13), onClick: () => setPicker('harness'), 'data-dsh-bots-add-harness': true }, t('addFromHarness')),
|
|
2612
2814
|
h(Btn, { icon: Icon.github(13), onClick: () => setPicker('github'), 'data-dsh-bots-add-github': true }, t('importGithub')),
|
|
2815
|
+
h(Btn, { icon: Icon.folder(13), onClick: () => setPicker('local'), 'data-dsh-bots-add-local': true }, t('importLocal')),
|
|
2613
2816
|
h(Btn, { icon: Icon.wand(13), onClick: () => setPicker('write'), 'data-dsh-bots-add-write': true }, t('letBotWrite')),
|
|
2614
2817
|
h('span', { style: { flex: 1 } }),
|
|
2615
2818
|
editing ? null : h('button', { type: 'button', className: 'dshb-link', style: { fontSize: SMALL, color: C.muted }, onClick: () => setEditing({ name: '', description: '', content: '', enabled: true }), 'data-dsh-bots-add-skill': true }, t('writeByHand')),
|
|
@@ -2636,7 +2839,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2636
2839
|
'div',
|
|
2637
2840
|
{ style: { display: 'flex', alignItems: 'center', gap: 8 } },
|
|
2638
2841
|
h('span', { className: 'dshb-mono', style: { fontWeight: 650, flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: s.name }, s.name),
|
|
2639
|
-
h(SourceBadge, { t, source: src }),
|
|
2842
|
+
h(SourceBadge, { t, source: src, local: isLocalSkill(s) }),
|
|
2640
2843
|
h(Switch, { on: s.enabled !== false, disabled: busy, title: s.enabled !== false ? t('disable') : t('enable'), onChange: (on) => void commit(skills.map((x) => (x === s ? { ...x, enabled: on } : x))) }),
|
|
2641
2844
|
),
|
|
2642
2845
|
h('div', { className: 'dshb-clamp2', style: { fontSize: SMALL, color: C.muted, minHeight: 37, lineHeight: 1.5 }, title: s.description }, s.description || h('i', { style: { color: C.faint } }, t('noDescription'))),
|
|
@@ -2646,9 +2849,11 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2646
2849
|
src === 'dsh'
|
|
2647
2850
|
? h('span', { style: { fontSize: TINY, color: C.faint, flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, t('harnessManaged'))
|
|
2648
2851
|
: src === 'import'
|
|
2649
|
-
?
|
|
2852
|
+
? isLocalSkill(s)
|
|
2853
|
+
? h('span', { className: 'dshb-mono', 'data-dsh-bots-skill-origin': s.origin, 'data-missing': s.missing ? true : undefined, style: { fontSize: TINY, color: s.missing ? C.error : C.faint, flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: s.missing ? `${t('folderMissing')} ${s.origin}` : `${t('linkedHint')} ${s.origin}` }, s.missing ? t('folderMissing') : str(s.origin).split(/[\\/]/).filter(Boolean).slice(-2).join('/'))
|
|
2854
|
+
: h('span', { style: { flex: 1, minWidth: 0, overflow: 'hidden' } }, s.origin ? h(ExtLink, { href: s.origin, title: s.origin }, str(s.origin).replace(/^https:\/\/github\.com\//, '').split('/').slice(0, 2).join('/')) : null)
|
|
2650
2855
|
: h('span', { style: { fontSize: TINY, color: C.faint, flex: 1 } }, t('chars', { n: str(s.content).length })),
|
|
2651
|
-
src === 'dsh' ? null : h(Btn, { size: 'sm', kind: 'ghost', icon: Icon.edit(12), title: t('edit'), onClick: () => setEditing({ ...s, description: str(s.description), content: str(s.content) }) }),
|
|
2856
|
+
src === 'dsh' || isLocalSkill(s) ? null : h(Btn, { size: 'sm', kind: 'ghost', icon: Icon.edit(12), title: t('edit'), onClick: () => setEditing({ ...s, description: str(s.description), content: str(s.content) }) }),
|
|
2652
2857
|
h(Btn, { size: 'sm', kind: 'ghost', icon: Icon.trash(12), title: t('remove'), className: 'dshb-btn dshb-btn-sm dshb-btn-icon dshb-btn-ghost dshb-btn-danger', onClick: () => setConfirm(s) }),
|
|
2653
2858
|
),
|
|
2654
2859
|
);
|
|
@@ -2658,6 +2863,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2658
2863
|
),
|
|
2659
2864
|
picker === 'harness' ? h(HarnessPicker, { t, bot, busy, onClose: () => setPicker(null), onAdd: addHarness }) : null,
|
|
2660
2865
|
picker === 'github' ? h(GithubPicker, { t, lang, bot, catalog, toast, onClose: () => setPicker(null), onImported: () => setPicker(null) }) : null,
|
|
2866
|
+
picker === 'local' ? h(LocalPicker, { t, bot, catalog, env, toast, onClose: () => setPicker(null), onImported: () => setPicker(null) }) : null,
|
|
2661
2867
|
picker === 'write'
|
|
2662
2868
|
? h(WriteSkillModal, {
|
|
2663
2869
|
t,
|
|
@@ -3037,19 +3243,21 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3037
3243
|
}
|
|
3038
3244
|
return out;
|
|
3039
3245
|
}
|
|
3040
|
-
// --- chat channels (Telegram, Discord): apps people message the team from
|
|
3246
|
+
// --- chat channels (Telegram, Discord, Feishu, Slack): apps people message the team from --
|
|
3041
3247
|
|
|
3042
|
-
const CHANNEL_NAMES = { telegram: 'Telegram', discord: 'Discord' };
|
|
3043
|
-
const CHANNEL_COLORS = { telegram: '#229ED9', discord: '#5865F2' };
|
|
3044
|
-
const channelName = (kind) => CHANNEL_NAMES[kind] ?? str(kind);
|
|
3248
|
+
const CHANNEL_NAMES = { telegram: 'Telegram', discord: 'Discord', slack: 'Slack', feishu: 'Feishu' };
|
|
3249
|
+
const CHANNEL_COLORS = { telegram: '#229ED9', discord: '#5865F2', slack: '#4a154b', feishu: '#3370ff' };
|
|
3250
|
+
const channelName = (kind, t) => (kind === 'feishu' && langOf(t) === 'zh' ? '飞书' : CHANNEL_NAMES[kind] ?? str(kind));
|
|
3045
3251
|
const isChannelEntry = (entry) => entry?.kind === 'channel';
|
|
3252
|
+
/** Hint codes that read differently per chat app. */
|
|
3253
|
+
const KIND_HINTS = new Set(['slack_scopes', 'feishu_scopes']);
|
|
3046
3254
|
|
|
3047
3255
|
/** Under a chat channel's row: whether it is connected, the pairing code, and who is paired. */
|
|
3048
3256
|
function ChannelPanel({ t, bot, app, entry, view, toast }) {
|
|
3049
3257
|
const [working, setWorking] = useState('');
|
|
3050
3258
|
const v = view && typeof view === 'object' ? view : { state: 'connecting', paired: [] };
|
|
3051
3259
|
const kind = str(v.kind || entry?.channel);
|
|
3052
|
-
const appName = channelName(kind);
|
|
3260
|
+
const appName = channelName(kind, t);
|
|
3053
3261
|
const handle = v.account?.username ? `@${v.account.username}` : appName;
|
|
3054
3262
|
const paired = Array.isArray(v.paired) ? v.paired : [];
|
|
3055
3263
|
const call = (path, body, okText) => {
|
|
@@ -3065,7 +3273,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3065
3273
|
.finally(() => setWorking(''));
|
|
3066
3274
|
};
|
|
3067
3275
|
const state = str(v.state) || 'connecting';
|
|
3068
|
-
const hintText = v.hint ? t(`channelHint_${v.hint}`, { app: appName }) : '';
|
|
3276
|
+
const hintText = v.hint ? t(KIND_HINTS.has(`${kind}_${v.hint}`) ? `channelHint_${kind}_${v.hint}` : `channelHint_${v.hint}`, { app: appName }) : '';
|
|
3069
3277
|
const dot = (color) => h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: color, flex: 'none' } });
|
|
3070
3278
|
const statusLine =
|
|
3071
3279
|
state === 'connected'
|
|
@@ -3078,7 +3286,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3078
3286
|
? [dot(C.faint), h('span', { key: 's', style: { color: C.muted } }, t('channelOff'))]
|
|
3079
3287
|
: [dot('#d97706'), h('span', { key: 's', style: { color: C.muted } }, t('channelMissing', { app: appName }))];
|
|
3080
3288
|
const live = state !== 'off' && state !== 'missing';
|
|
3081
|
-
const step = kind === 'telegram' ? t('pairStepTelegram', { handle }) : kind === 'discord' ? t('pairStepDiscord', { handle }) : t('pairStep', { handle, app: appName });
|
|
3289
|
+
const step = kind === 'telegram' ? t('pairStepTelegram', { handle }) : kind === 'discord' ? t('pairStepDiscord', { handle }) : kind === 'slack' ? t('pairStepSlack', { handle }) : kind === 'feishu' ? t('pairStepFeishu', { handle }) : t('pairStep', { handle, app: appName });
|
|
3082
3290
|
return h(
|
|
3083
3291
|
'div',
|
|
3084
3292
|
{ 'data-dsh-bots-channel': app.id, 'data-state': state, style: { display: 'flex', flexDirection: 'column', gap: 10, margin: '0 14px 12px 62px', padding: '10px 12px', borderRadius: 10, background: C.base, border: `1px solid ${C.border1}`, fontSize: SMALL } },
|
|
@@ -3688,7 +3896,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3688
3896
|
const counts = { skills: (bot.skills ?? []).length, apps: (bot.apps ?? []).length };
|
|
3689
3897
|
let body;
|
|
3690
3898
|
if (tab === 'profile') body = h(ProfileTab, { key: bot.id, t, bot, toast, catalog });
|
|
3691
|
-
else if (tab === 'skills') body = h(SkillsTab, { key: bot.id, t, bot, toast, catalog, setTab });
|
|
3899
|
+
else if (tab === 'skills') body = h(SkillsTab, { key: bot.id, t, bot, toast, catalog, setTab, env });
|
|
3692
3900
|
else if (tab === 'schedules') body = h(SchedulesTab, { key: bot.id, t, bot, toast, catalog });
|
|
3693
3901
|
else if (tab === 'apps') body = h(AppsTab, { key: bot.id, t, bot, toast, catalog });
|
|
3694
3902
|
else body = h(ChatTab, { key: bot.id, t, bot, env, toast });
|
|
@@ -4918,7 +5126,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
4918
5126
|
installedApps: 'Installed apps ({n})',
|
|
4919
5127
|
noApps: 'No apps yet. Add one from the gallery below.',
|
|
4920
5128
|
appGallery: 'App gallery',
|
|
4921
|
-
appGalleryHint: '{n} apps. Most are MCP servers whose tools appear to this bot only; chat apps (Telegram, Discord) let you message the team from your phone.',
|
|
5129
|
+
appGalleryHint: '{n} apps. Most are MCP servers whose tools appear to this bot only; chat apps (Feishu / Lark, Telegram, Slack, Discord) let you message the team from your phone.',
|
|
4922
5130
|
noTemplates: 'No templates.',
|
|
4923
5131
|
featured: 'Featured',
|
|
4924
5132
|
allApps: 'All',
|
|
@@ -5064,6 +5272,28 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5064
5272
|
importN: "Import {n}",
|
|
5065
5273
|
importing: "Importing…",
|
|
5066
5274
|
importedN: "Imported {n} skills.",
|
|
5275
|
+
updatedN: "Updated {n}.",
|
|
5276
|
+
skippedN: "Skipped {n}: a skill of that name is already here.",
|
|
5277
|
+
nameTaken: "Name already used",
|
|
5278
|
+
reimport: "Imported · import again to update",
|
|
5279
|
+
skillNameTaken: "This bot already has a skill named “{name}”.",
|
|
5280
|
+
importLocal: "Add from a folder",
|
|
5281
|
+
localPickerTitle: "Add skills from a local folder",
|
|
5282
|
+
localHint: "Pick a skill folder (one with a SKILL.md), or a folder that holds several.",
|
|
5283
|
+
localNote: "Linked, never copied: edit the folder and the bot uses the new version.",
|
|
5284
|
+
linked: "Linked",
|
|
5285
|
+
linkedHint: "Read from this folder each time; edit it there.",
|
|
5286
|
+
folderMissing: "Folder not found",
|
|
5287
|
+
localFailed: "Could not read that folder.",
|
|
5288
|
+
localNone: "No SKILL.md in this folder or the folders below it.",
|
|
5289
|
+
localTruncated: "The folder is large; only part of it was searched. Pick a folder closer to the skills.",
|
|
5290
|
+
localPlaces: "Found on this machine:",
|
|
5291
|
+
chooseFolder: "Choose folder…",
|
|
5292
|
+
pickFailed: "The folder dialog is unavailable here; type or paste the path instead.",
|
|
5293
|
+
scan: "Scan",
|
|
5294
|
+
readingFolder: "Reading the folder…",
|
|
5295
|
+
alsoInHarness: "A skill of this name is also installed in the Harness (see “Add from Harness”).",
|
|
5296
|
+
src_local: "Local",
|
|
5067
5297
|
importFailed: "Import failed.",
|
|
5068
5298
|
browse: "Browse",
|
|
5069
5299
|
foundSkills: "{n} skills",
|
|
@@ -5083,8 +5313,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5083
5313
|
letBotWrite: "Let the bot write it",
|
|
5084
5314
|
writeByHand: "Write by hand",
|
|
5085
5315
|
skillsHint2: "Instructions {name} loads when a task needs them.",
|
|
5086
|
-
skillMix: "{dsh} Harness · {import} GitHub · {own} own",
|
|
5087
|
-
noSkillsBody2: "Add skills already installed in your Harness, import a folder from GitHub, or describe one and let the bot write it.",
|
|
5316
|
+
skillMix: "{dsh} Harness · {import} GitHub · {local} local · {own} own",
|
|
5317
|
+
noSkillsBody2: "Add skills already installed in your Harness, import a folder from GitHub or from this machine, or describe one and let the bot write it.",
|
|
5088
5318
|
harnessManaged: "Provided by the Harness, kept up to date",
|
|
5089
5319
|
src_dsh: "Harness",
|
|
5090
5320
|
src_import: "GitHub",
|
|
@@ -5119,6 +5349,17 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5119
5349
|
channelHint_intent: 'Turn on Message Content Intent: Developer Portal → your app → Bot → Privileged Gateway Intents. Then reconnect.',
|
|
5120
5350
|
channelHint_conflict: 'Another program is using this bot token. Stop it, or create a separate bot for the team.',
|
|
5121
5351
|
channelHint_duplicate: 'This token is already connected on another bot; one token can run in one place.',
|
|
5352
|
+
channelHint_app_token: 'Slack rejected the app-level token (xapp-…). In your Slack app open Basic Information → App-Level Tokens, generate one with the connections:write scope, paste it and save.',
|
|
5353
|
+
channelHint_app_scope: 'The app-level token lacks the connections:write scope. Generate a new one with it under Basic Information → App-Level Tokens, paste it and save.',
|
|
5354
|
+
channelHint_token_kind: 'The tokens are in the wrong fields: the Bot token starts with xoxb- (OAuth & Permissions), the App-level token with xapp- (Basic Information → App-Level Tokens).',
|
|
5355
|
+
channelHint_slack_scopes: 'The Slack app is missing permissions. Add them under OAuth & Permissions → Bot Token Scopes (or create the app from the manifest), reinstall it to the workspace, then reconnect.',
|
|
5356
|
+
channelHint_socket_mode: 'Socket Mode is off for this Slack app. Turn it on (your app → Socket Mode → Enable Socket Mode), then reconnect.',
|
|
5357
|
+
channelHint_secret: '{app} rejected the App Secret. Copy it again from the developer console (Credentials & Basic Info) and save.',
|
|
5358
|
+
channelHint_appId: 'Neither Feishu nor Lark knows this App ID. Copy it from the developer console (Credentials & Basic Info); it starts with cli_.',
|
|
5359
|
+
channelHint_disabled: '{app} says this app is disabled. Enable it in the developer console (or ask your admin), then reconnect.',
|
|
5360
|
+
channelHint_bot: 'Turn on the bot: developer console → Add Features → Bot, then publish a version. The long connection is already up, so you can set up Events & Callbacks now; this connects by itself once the bot is live.',
|
|
5361
|
+
channelHint_feishu_scopes: 'The app may not send messages. Add the permission im:message:send_as_bot (Permissions & Scopes) and publish a version.',
|
|
5362
|
+
channelHint_connlimit: 'This app already has the most long connections Feishu allows (50). Stop other programs that use this App ID.',
|
|
5122
5363
|
reconnect: 'Reconnect',
|
|
5123
5364
|
pairedPeople: 'Paired people ({n})',
|
|
5124
5365
|
nobodyPaired: 'Nobody yet. Until someone is paired, the bot answers no one in {app}.',
|
|
@@ -5127,6 +5368,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5127
5368
|
unpaired: '{name} removed.',
|
|
5128
5369
|
pairStepTelegram: 'From your own Telegram account, send this code to {handle}, or open the link and press Start. It works once.',
|
|
5129
5370
|
pairStepDiscord: 'From your own Discord account, send this code to {handle} in a direct message. It works once.',
|
|
5371
|
+
pairStepFeishu: 'In Feishu, open a chat with {handle} (search for the app, or use Open in Feishu) and send this code. It works once.',
|
|
5372
|
+
pairStepSlack: 'From your own Slack account, open the app\'s Messages tab (or the link) and send this code. It works once.',
|
|
5130
5373
|
pairStep: 'From your own {app} account, send this code to {handle}. It works once.',
|
|
5131
5374
|
copy: 'Copy',
|
|
5132
5375
|
copied: 'Copied.',
|
|
@@ -5400,7 +5643,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5400
5643
|
installedApps: '已安装的应用({n})',
|
|
5401
5644
|
noApps: '还没有应用。从下方的应用库添加一个。',
|
|
5402
5645
|
appGallery: '应用库',
|
|
5403
|
-
appGalleryHint: '共 {n} 个应用。大多是 MCP 服务器,工具只对这个 Bot
|
|
5646
|
+
appGalleryHint: '共 {n} 个应用。大多是 MCP 服务器,工具只对这个 Bot 可见;聊天应用(飞书、Telegram、Slack、Discord)让你用手机给团队发消息。',
|
|
5404
5647
|
noTemplates: '没有模板。',
|
|
5405
5648
|
featured: '推荐',
|
|
5406
5649
|
allApps: '全部',
|
|
@@ -5545,6 +5788,28 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5545
5788
|
importN: "导入 {n} 个",
|
|
5546
5789
|
importing: "导入中…",
|
|
5547
5790
|
importedN: "已导入 {n} 个技能。",
|
|
5791
|
+
updatedN: "已更新 {n} 个。",
|
|
5792
|
+
skippedN: "跳过 {n} 个:已有同名技能。",
|
|
5793
|
+
nameTaken: "已有同名技能",
|
|
5794
|
+
reimport: "已导入 · 再次导入可更新",
|
|
5795
|
+
skillNameTaken: "这个 Bot 已经有名为“{name}”的技能。",
|
|
5796
|
+
importLocal: "从本地文件夹添加",
|
|
5797
|
+
localPickerTitle: "从本地文件夹添加技能",
|
|
5798
|
+
localHint: "选一个技能文件夹(里面有 SKILL.md),或者一个装着多个技能的文件夹。",
|
|
5799
|
+
localNote: "只引用、不复制:改了原文件夹,Bot 就用新的。",
|
|
5800
|
+
linked: "已引用",
|
|
5801
|
+
linkedHint: "每次都从这个文件夹读取,要改就改那里。",
|
|
5802
|
+
folderMissing: "文件夹找不到了",
|
|
5803
|
+
localFailed: "读取这个文件夹失败。",
|
|
5804
|
+
localNone: "这个文件夹和它的子文件夹里都没有 SKILL.md。",
|
|
5805
|
+
localTruncated: "文件夹太大,只搜索了一部分。请选离技能更近的文件夹。",
|
|
5806
|
+
localPlaces: "本机已有:",
|
|
5807
|
+
chooseFolder: "选择文件夹…",
|
|
5808
|
+
pickFailed: "这里打不开文件夹选择框,请直接输入或粘贴路径。",
|
|
5809
|
+
scan: "扫描",
|
|
5810
|
+
readingFolder: "正在读取文件夹…",
|
|
5811
|
+
alsoInHarness: "Harness 里也安装了同名技能(见“从 Harness 添加”)。",
|
|
5812
|
+
src_local: "本地",
|
|
5548
5813
|
importFailed: "导入失败。",
|
|
5549
5814
|
browse: "浏览",
|
|
5550
5815
|
foundSkills: "{n} 个技能",
|
|
@@ -5564,8 +5829,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5564
5829
|
letBotWrite: "让 Bot 自己写",
|
|
5565
5830
|
writeByHand: "手写",
|
|
5566
5831
|
skillsHint2: "{name} 在任务需要时加载的说明。",
|
|
5567
|
-
skillMix: "Harness {dsh} · GitHub {import} · 自写 {own}",
|
|
5568
|
-
noSkillsBody2: "添加 Harness 里已安装的技能、从 GitHub
|
|
5832
|
+
skillMix: "Harness {dsh} · GitHub {import} · 本地 {local} · 自写 {own}",
|
|
5833
|
+
noSkillsBody2: "添加 Harness 里已安装的技能、从 GitHub 或本地文件夹导入,或者描述一下让 Bot 自己写。",
|
|
5569
5834
|
harnessManaged: "由 Harness 提供,自动保持最新",
|
|
5570
5835
|
src_dsh: "Harness",
|
|
5571
5836
|
src_import: "GitHub",
|
|
@@ -5600,6 +5865,17 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5600
5865
|
channelHint_intent: '请打开 Message Content Intent:开发者后台 → 你的应用 → Bot → Privileged Gateway Intents,然后重新连接。',
|
|
5601
5866
|
channelHint_conflict: '另一个程序正在使用这个 Bot Token。请停掉它,或给团队单独建一个 Bot。',
|
|
5602
5867
|
channelHint_duplicate: '这个 Token 已经在另一个 Bot 上连接了;一个 Token 只能在一处运行。',
|
|
5868
|
+
channelHint_app_token: 'Slack 拒绝了 App 级 Token(xapp-…)。请在 Slack 应用的 Basic Information → App-Level Tokens 里生成一个带 connections:write 权限的 Token,粘贴后保存。',
|
|
5869
|
+
channelHint_app_scope: 'App 级 Token 缺少 connections:write 权限。请在 Basic Information → App-Level Tokens 重新生成一个带该权限的 Token,粘贴后保存。',
|
|
5870
|
+
channelHint_token_kind: 'Token 填错位置了:Bot Token 以 xoxb- 开头(OAuth & Permissions 页),App 级 Token 以 xapp- 开头(Basic Information → App-Level Tokens)。',
|
|
5871
|
+
channelHint_slack_scopes: 'Slack 应用缺少权限。请在 OAuth & Permissions → Bot Token Scopes 里补上(或用清单重新创建应用),重新安装到工作区,然后点重新连接。',
|
|
5872
|
+
channelHint_socket_mode: '这个 Slack 应用没有开启 Socket Mode。请在应用的 Socket Mode 页打开 Enable Socket Mode,然后点重新连接。',
|
|
5873
|
+
channelHint_secret: '{app} 拒绝了这个 App Secret。请到开发者后台「凭证与基础信息」重新复制并保存。',
|
|
5874
|
+
channelHint_appId: '飞书和 Lark 都找不到这个 App ID。请到开发者后台「凭证与基础信息」复制,它以 cli_ 开头。',
|
|
5875
|
+
channelHint_disabled: '{app} 提示这个应用已停用。请在开发者后台启用(或联系管理员),然后重新连接。',
|
|
5876
|
+
channelHint_bot: '请开启机器人:开发者后台 →「添加应用能力」→「机器人」,然后发布版本。长连接已经在线,现在就可以去配置「事件与回调」;机器人生效后会自动连上。',
|
|
5877
|
+
channelHint_feishu_scopes: '应用没有发消息的权限。请在「权限管理」开通 im:message:send_as_bot 并发布版本。',
|
|
5878
|
+
channelHint_connlimit: '这个应用的长连接数已达飞书上限(50 个)。请停掉其他使用这个 App ID 的程序。',
|
|
5603
5879
|
reconnect: '重新连接',
|
|
5604
5880
|
pairedPeople: '已配对的人({n})',
|
|
5605
5881
|
nobodyPaired: '还没有人。配对之前,Bot 在 {app} 里不回复任何人。',
|
|
@@ -5608,6 +5884,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5608
5884
|
unpaired: '已移除 {name}。',
|
|
5609
5885
|
pairStepTelegram: '用你自己的 Telegram 账号把这个配对码发给 {handle},或打开链接后点 Start。只能用一次。',
|
|
5610
5886
|
pairStepDiscord: '用你自己的 Discord 账号私信 {handle},发送这个配对码。只能用一次。',
|
|
5887
|
+
pairStepFeishu: '在飞书里打开和 {handle} 的单聊(搜索应用名,或点「在飞书中打开」),发送这个配对码。只能用一次。',
|
|
5888
|
+
pairStepSlack: '用你自己的 Slack 账号打开这个应用的 Messages 标签页(或点链接),发送这个配对码。只能用一次。',
|
|
5611
5889
|
pairStep: '用你自己的 {app} 账号把这个配对码发给 {handle}。只能用一次。',
|
|
5612
5890
|
copy: '复制',
|
|
5613
5891
|
copied: '已复制。',
|
|
@@ -5677,7 +5955,17 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5677
5955
|
return false;
|
|
5678
5956
|
}
|
|
5679
5957
|
};
|
|
5958
|
+
// The Host's own folder dialog: the desktop shell's when there is one, else the workspace service's.
|
|
5959
|
+
const directoryPicker = () => {
|
|
5960
|
+
const desktop = globalThis.__DSH_DIRECTORY_PICKER__;
|
|
5961
|
+
if (typeof desktop?.pick === 'function') return () => desktop.pick();
|
|
5962
|
+
const ws = service('uiWorkspace');
|
|
5963
|
+
return typeof ws?.pickDirectory === 'function' ? () => ws.pickDirectory() : null;
|
|
5964
|
+
};
|
|
5680
5965
|
const env = {
|
|
5966
|
+
// Asked at use: the workspace service may come up after this client does.
|
|
5967
|
+
canPickDirectory: () => directoryPicker() !== null,
|
|
5968
|
+
pickDirectory: () => (directoryPicker() ?? (() => null))(),
|
|
5681
5969
|
canOpen: () => typeof service('uiWorkspace')?.openSession === 'function',
|
|
5682
5970
|
canPanel: () => typeof service('layout')?.selectPanel === 'function',
|
|
5683
5971
|
/** Ensure the bot's home conversation, then show it; false on failure. */
|