@kadaliao/dsh-bots 0.3.3 → 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 +142 -4
- package/README.zh-CN.md +119 -3
- package/client.js +564 -43
- package/index.js +186 -25
- package/lib/apps.mjs +150 -5
- package/lib/channels/discord.mjs +590 -0
- package/lib/channels/feishu.mjs +1249 -0
- package/lib/channels/slack.mjs +906 -0
- package/lib/channels/telegram.mjs +300 -0
- package/lib/channels.mjs +893 -0
- package/lib/logos.mjs +54 -0
- package/lib/prompt.mjs +9 -1
- package/lib/skills.mjs +199 -6
- package/lib/store.mjs +22 -3
- package/logos/amap.png +0 -0
- package/logos/anthropic.png +0 -0
- package/logos/baidu-map.png +0 -0
- package/logos/brave.png +0 -0
- package/logos/context7.png +0 -0
- package/logos/discord.png +0 -0
- package/logos/exa.png +0 -0
- package/logos/feishu.png +0 -0
- package/logos/firecrawl.png +0 -0
- package/logos/git.png +0 -0
- package/logos/github.png +0 -0
- package/logos/hubspot.png +0 -0
- package/logos/mcp.png +0 -0
- package/logos/notion.png +0 -0
- package/logos/playwright.png +0 -0
- package/logos/postgres.png +0 -0
- package/logos/sentry.png +0 -0
- package/logos/slack.png +0 -0
- package/logos/sqlite.png +0 -0
- package/logos/stripe.png +0 -0
- package/logos/supabase.png +0 -0
- package/logos/tavily.png +0 -0
- package/logos/telegram.png +0 -0
- package/package.json +3 -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']),
|
|
@@ -1112,7 +1113,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
1112
1113
|
);
|
|
1113
1114
|
}
|
|
1114
1115
|
const prev = items[i - 1];
|
|
1115
|
-
const grouped = prev && prev.from === m.from && prev.to === m.to && prev.kind === m.kind && at - toMs(prev.at) < 5 * 60_000;
|
|
1116
|
+
const grouped = prev && prev.from === m.from && prev.to === m.to && prev.kind === m.kind && prev.via === m.via && at - toMs(prev.at) < 5 * 60_000;
|
|
1116
1117
|
rows.push(h(MessageRow, { key: m.id ?? i, t, m, botId, grouped }));
|
|
1117
1118
|
});
|
|
1118
1119
|
return h('div', { style: { display: 'flex', flexDirection: 'column', gap: 4, padding: '8px 0', maxWidth: 880, margin: '0 auto' } }, rows, h('div', { ref: end }));
|
|
@@ -1152,7 +1153,14 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
1152
1153
|
return h(
|
|
1153
1154
|
'div',
|
|
1154
1155
|
{ 'data-dsh-bots-msg': 'user', className: 'dshb-fade', style: { display: 'flex', flexDirection: 'column', alignItems: 'flex-end', gap: 3, marginTop: grouped ? 0 : 6 } },
|
|
1155
|
-
grouped
|
|
1156
|
+
grouped
|
|
1157
|
+
? null
|
|
1158
|
+
: h(
|
|
1159
|
+
'span',
|
|
1160
|
+
{ style: { fontSize: TINY, color: C.faint, display: 'inline-flex', alignItems: 'center', gap: 6 } },
|
|
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,
|
|
1162
|
+
m.to !== botId && to.kind === 'bot' ? `${t('toName', { name: to.name })} · ${time}` : time,
|
|
1163
|
+
),
|
|
1156
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 })),
|
|
1157
1165
|
h('div', { style: { width: 'min(480px, 78%)', display: 'flex', justifyContent: 'flex-end' } }, h(LinkCards, { t, text: m.text, align: 'flex-end' })),
|
|
1158
1166
|
);
|
|
@@ -1173,6 +1181,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
1173
1181
|
from.kind === 'bot' ? h('span', { style: { color: C.faint } }, `@${from.bot.handle}`) : null,
|
|
1174
1182
|
m.to !== 'user' && to.kind === 'bot' && m.to !== botId ? h('span', { style: { color: C.faint } }, `→ ${to.name}`) : null,
|
|
1175
1183
|
h('span', { style: { color: C.faint } }, time),
|
|
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,
|
|
1176
1185
|
),
|
|
1177
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 })),
|
|
1178
1187
|
h(LinkCards, { t, text: m.text }),
|
|
@@ -1866,6 +1875,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
1866
1875
|
h('span', { style: { color: C.faint, display: 'inline-flex' } }, Icon.arrow(11)),
|
|
1867
1876
|
h('span', { style: { fontWeight: 600 } }, to.name),
|
|
1868
1877
|
h(Badge, { color: m.kind === 'dm' ? C.label : m.kind === 'system' ? C.warn : C.muted }, t(`kind_${m.kind}`) || m.kind),
|
|
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,
|
|
1869
1879
|
h('span', { style: { marginLeft: 'auto', color: C.faint, fontSize: TINY }, title: fmtDate(toMs(m.at)) }, fmtAgo(t, m.at)),
|
|
1870
1880
|
),
|
|
1871
1881
|
h(Clamp, { t, text: m.text, lines: 3, style: { fontSize: SMALL, color: C.muted } }),
|
|
@@ -2301,10 +2311,46 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2301
2311
|
}
|
|
2302
2312
|
|
|
2303
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);
|
|
2304
2316
|
const SOURCE_COLOR = { dsh: '#2563eb', import: '#475569', own: '#16a34a' };
|
|
2305
|
-
function SourceBadge({ t, source }) {
|
|
2306
|
-
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
|
+
);
|
|
2307
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
|
+
});
|
|
2308
2354
|
/** A search box with a magnifier. */
|
|
2309
2355
|
const SearchBox = ({ value, onChange, placeholder, style, ...rest }) =>
|
|
2310
2356
|
h(
|
|
@@ -2319,7 +2365,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2319
2365
|
'label',
|
|
2320
2366
|
{
|
|
2321
2367
|
...rest,
|
|
2322
|
-
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' },
|
|
2323
2369
|
},
|
|
2324
2370
|
h('input', { type: 'checkbox', checked: Boolean(checked) || Boolean(disabled), disabled, onChange: () => onToggle(), style: { marginTop: 3, accentColor: 'var(--dsw-alias-brand-primary)' } }),
|
|
2325
2371
|
h(
|
|
@@ -2364,7 +2410,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2364
2410
|
h(SearchBox, { value: q, onChange: setQ, placeholder: t('searchSkills', { n: (all ?? []).length }), autoFocus: true, 'data-dsh-bots-harness-search': true }),
|
|
2365
2411
|
h(
|
|
2366
2412
|
'div',
|
|
2367
|
-
|
|
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' } },
|
|
2368
2415
|
all === null
|
|
2369
2416
|
? h('div', { style: { padding: 18, fontSize: SMALL, color: C.faint, textAlign: 'center', borderTop: `1px solid ${C.border1}` } }, t('loading'))
|
|
2370
2417
|
: shown.length === 0
|
|
@@ -2396,7 +2443,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2396
2443
|
const [sel, setSel] = useState([]);
|
|
2397
2444
|
const [importing, setImporting] = useState(false);
|
|
2398
2445
|
const [failed, setFailed] = useState([]);
|
|
2399
|
-
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}` : '');
|
|
2400
2448
|
const browse = (spec) => {
|
|
2401
2449
|
const value = str(spec).trim();
|
|
2402
2450
|
if (!value) return;
|
|
@@ -2417,15 +2465,10 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2417
2465
|
const doImport = () => {
|
|
2418
2466
|
if (!listing || sel.length === 0) return;
|
|
2419
2467
|
setImporting(true);
|
|
2420
|
-
|
|
2468
|
+
runImport(t, toast, bot.id, sel.map((path) => ({ repo: `${listing.owner}/${listing.repo}`, ref: listing.ref, path })))
|
|
2421
2469
|
.then((r) => {
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
if (r?.ok && Array.isArray(r.added) && r.added.length) {
|
|
2425
|
-
toast(t('importedN', { n: r.added.length }));
|
|
2426
|
-
void refreshState();
|
|
2427
|
-
if (bad.length === 0) onImported();
|
|
2428
|
-
} else if (!bad.length) toast(r?.reason || t('importFailed'), 'error');
|
|
2470
|
+
setFailed(r.failed);
|
|
2471
|
+
if (r.done && r.failed.length === 0) onImported();
|
|
2429
2472
|
})
|
|
2430
2473
|
.finally(() => setImporting(false));
|
|
2431
2474
|
};
|
|
@@ -2462,7 +2505,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2462
2505
|
},
|
|
2463
2506
|
style: { flex: '1 1 260px', flexDirection: 'row', alignItems: 'center', gap: 12, cursor: 'pointer', textAlign: 'left', font: 'inherit', color: 'inherit', background: `linear-gradient(135deg, ${tint('#d97706', 10)}, ${C.layer1} 70%)` },
|
|
2464
2507
|
},
|
|
2465
|
-
h(AppIcon, { entry: { icon: 'A', color: '#c2410c' }, size: 38 }),
|
|
2508
|
+
h(AppIcon, { entry: { icon: 'A', color: '#c2410c', logo: src.logo }, size: 38 }),
|
|
2466
2509
|
h(
|
|
2467
2510
|
'span',
|
|
2468
2511
|
{ style: { display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0, flex: 1 } },
|
|
@@ -2506,7 +2549,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2506
2549
|
h('span', { style: { color: C.faint } }, t('foundSkills', { n: skills.length })),
|
|
2507
2550
|
h('span', { style: { flex: 1 } }),
|
|
2508
2551
|
skills.length
|
|
2509
|
-
? 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'))
|
|
2510
2553
|
: null,
|
|
2511
2554
|
),
|
|
2512
2555
|
h(
|
|
@@ -2518,10 +2561,9 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2518
2561
|
key: s.path,
|
|
2519
2562
|
'data-dsh-bots-github-skill': s.path,
|
|
2520
2563
|
checked: sel.includes(s.path),
|
|
2521
|
-
disabled: have.has(s.name),
|
|
2522
2564
|
onToggle: () => setSel((x) => (x.includes(s.path) ? x.filter((p) => p !== s.path) : [...x, s.path])),
|
|
2523
2565
|
title: s.name,
|
|
2524
|
-
|
|
2566
|
+
...importRowProps(t, stateOf(s), s.files),
|
|
2525
2567
|
description: s.description,
|
|
2526
2568
|
note: bad ? h('span', { style: { color: C.error } }, bad.reason) : null,
|
|
2527
2569
|
});
|
|
@@ -2534,6 +2576,170 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2534
2576
|
);
|
|
2535
2577
|
}
|
|
2536
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
|
+
|
|
2537
2743
|
/** Describe a skill; the bot writes it (with skill-creator) in its own conversation. */
|
|
2538
2744
|
function WriteSkillModal({ t, bot, onClose, onSent, toast }) {
|
|
2539
2745
|
const [text, setText] = useState('');
|
|
@@ -2564,13 +2770,13 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2564
2770
|
);
|
|
2565
2771
|
}
|
|
2566
2772
|
|
|
2567
|
-
function SkillsTab({ t, bot, toast, catalog, setTab }) {
|
|
2773
|
+
function SkillsTab({ t, bot, toast, catalog, setTab, env }) {
|
|
2568
2774
|
const lang = langOf(t);
|
|
2569
2775
|
const skills = Array.isArray(bot.skills) ? bot.skills : [];
|
|
2570
2776
|
const [editing, setEditing] = useState(null); // {id?, name, description, content, enabled}
|
|
2571
2777
|
const [confirm, setConfirm] = useState(null);
|
|
2572
2778
|
const [busy, setBusy] = useState(false);
|
|
2573
|
-
const [picker, setPicker] = useState(null); // 'harness' | 'github' | 'write'
|
|
2779
|
+
const [picker, setPicker] = useState(null); // 'harness' | 'github' | 'local' | 'write'
|
|
2574
2780
|
const commit = (next, okText) => {
|
|
2575
2781
|
setBusy(true);
|
|
2576
2782
|
return saveField(t, toast, bot, { skills: next }, okText).finally(() => setBusy(false));
|
|
@@ -2579,17 +2785,22 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2579
2785
|
const s = editing;
|
|
2580
2786
|
if (!s || !s.name.trim()) return;
|
|
2581
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
|
+
}
|
|
2582
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 };
|
|
2583
2794
|
const next = s.id ? skills.map((x) => (x.id === s.id ? item : x)) : [...skills, item];
|
|
2584
2795
|
void commit(next, t('skillSaved')).then((ok) => ok && setEditing(null));
|
|
2585
2796
|
};
|
|
2586
2797
|
const addHarness = (list) => {
|
|
2587
|
-
const have = new Set(skills.map((x) => x.name));
|
|
2588
|
-
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) }));
|
|
2589
2800
|
void commit([...skills, ...add], t('addedN', { n: add.length })).then((ok) => ok && setPicker(null));
|
|
2590
2801
|
};
|
|
2591
|
-
const counts = { dsh: 0, import: 0, own: 0 };
|
|
2592
|
-
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;
|
|
2593
2804
|
return h(
|
|
2594
2805
|
'div',
|
|
2595
2806
|
{ className: 'dshb-scroll', style: { flex: 1, padding: '20px 24px 28px' } },
|
|
@@ -2601,6 +2812,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2601
2812
|
{ 'data-dsh-bots-skill-actions': true, style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
|
|
2602
2813
|
h(Btn, { kind: 'primary', icon: Icon.layers(13), onClick: () => setPicker('harness'), 'data-dsh-bots-add-harness': true }, t('addFromHarness')),
|
|
2603
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')),
|
|
2604
2816
|
h(Btn, { icon: Icon.wand(13), onClick: () => setPicker('write'), 'data-dsh-bots-add-write': true }, t('letBotWrite')),
|
|
2605
2817
|
h('span', { style: { flex: 1 } }),
|
|
2606
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')),
|
|
@@ -2627,7 +2839,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2627
2839
|
'div',
|
|
2628
2840
|
{ style: { display: 'flex', alignItems: 'center', gap: 8 } },
|
|
2629
2841
|
h('span', { className: 'dshb-mono', style: { fontWeight: 650, flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: s.name }, s.name),
|
|
2630
|
-
h(SourceBadge, { t, source: src }),
|
|
2842
|
+
h(SourceBadge, { t, source: src, local: isLocalSkill(s) }),
|
|
2631
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))) }),
|
|
2632
2844
|
),
|
|
2633
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'))),
|
|
@@ -2637,9 +2849,11 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2637
2849
|
src === 'dsh'
|
|
2638
2850
|
? h('span', { style: { fontSize: TINY, color: C.faint, flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, t('harnessManaged'))
|
|
2639
2851
|
: src === 'import'
|
|
2640
|
-
?
|
|
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)
|
|
2641
2855
|
: h('span', { style: { fontSize: TINY, color: C.faint, flex: 1 } }, t('chars', { n: str(s.content).length })),
|
|
2642
|
-
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) }) }),
|
|
2643
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) }),
|
|
2644
2858
|
),
|
|
2645
2859
|
);
|
|
@@ -2649,6 +2863,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2649
2863
|
),
|
|
2650
2864
|
picker === 'harness' ? h(HarnessPicker, { t, bot, busy, onClose: () => setPicker(null), onAdd: addHarness }) : null,
|
|
2651
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,
|
|
2652
2867
|
picker === 'write'
|
|
2653
2868
|
? h(WriteSkillModal, {
|
|
2654
2869
|
t,
|
|
@@ -2954,8 +3169,31 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2954
3169
|
return n;
|
|
2955
3170
|
}
|
|
2956
3171
|
|
|
2957
|
-
/**
|
|
3172
|
+
/** The app's logo, or a coloured rounded square with its letters (or one CJK character) in white. */
|
|
2958
3173
|
function AppIcon({ entry, size = 36 }) {
|
|
3174
|
+
const logo = str(entry?.logo);
|
|
3175
|
+
const [broken, setBroken] = useState('');
|
|
3176
|
+
if (logo && broken !== logo) {
|
|
3177
|
+
return h(
|
|
3178
|
+
'span',
|
|
3179
|
+
{
|
|
3180
|
+
'data-dsh-bots-app-icon': entry?.id ?? true,
|
|
3181
|
+
'data-dsh-bots-app-logo': logo,
|
|
3182
|
+
style: {
|
|
3183
|
+
width: size,
|
|
3184
|
+
height: size,
|
|
3185
|
+
borderRadius: Math.round(size * 0.26),
|
|
3186
|
+
display: 'inline-flex',
|
|
3187
|
+
flex: 'none',
|
|
3188
|
+
overflow: 'hidden',
|
|
3189
|
+
background: '#fff',
|
|
3190
|
+
boxShadow: '0 0 0 1px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.12)',
|
|
3191
|
+
userSelect: 'none',
|
|
3192
|
+
},
|
|
3193
|
+
},
|
|
3194
|
+
h('img', { src: `${R}logo/${encodeURIComponent(logo)}.png`, alt: '', draggable: false, onError: () => setBroken(logo), style: { width: '100%', height: '100%', display: 'block', objectFit: 'cover' } }),
|
|
3195
|
+
);
|
|
3196
|
+
}
|
|
2959
3197
|
const icon = str(entry?.icon) || '?';
|
|
2960
3198
|
const color = str(entry?.color) || '#475569';
|
|
2961
3199
|
const n = [...icon].length;
|
|
@@ -2991,6 +3229,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2991
3229
|
const RUNTIME_WORD = { node: 'npx', uv: 'uvx' };
|
|
2992
3230
|
function runtimeLabel(t, entry) {
|
|
2993
3231
|
if (!entry) return '';
|
|
3232
|
+
if (isChannelEntry(entry)) return t('chatChannel');
|
|
2994
3233
|
if (entry.transport === 'streamable-http') return t('runtimeRemote');
|
|
2995
3234
|
return RUNTIME_WORD[entry.runtime] ?? (entry.runtime === 'binary' ? t('runtimeBinary') : str(entry.command));
|
|
2996
3235
|
}
|
|
@@ -3004,6 +3243,122 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3004
3243
|
}
|
|
3005
3244
|
return out;
|
|
3006
3245
|
}
|
|
3246
|
+
// --- chat channels (Telegram, Discord, Feishu, Slack): apps people message the team from --
|
|
3247
|
+
|
|
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));
|
|
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']);
|
|
3254
|
+
|
|
3255
|
+
/** Under a chat channel's row: whether it is connected, the pairing code, and who is paired. */
|
|
3256
|
+
function ChannelPanel({ t, bot, app, entry, view, toast }) {
|
|
3257
|
+
const [working, setWorking] = useState('');
|
|
3258
|
+
const v = view && typeof view === 'object' ? view : { state: 'connecting', paired: [] };
|
|
3259
|
+
const kind = str(v.kind || entry?.channel);
|
|
3260
|
+
const appName = channelName(kind, t);
|
|
3261
|
+
const handle = v.account?.username ? `@${v.account.username}` : appName;
|
|
3262
|
+
const paired = Array.isArray(v.paired) ? v.paired : [];
|
|
3263
|
+
const call = (path, body, okText) => {
|
|
3264
|
+
setWorking(path);
|
|
3265
|
+
return postJson(path, { botId: bot.id, appId: app.id, ...body })
|
|
3266
|
+
.then((r) => {
|
|
3267
|
+
if (r?.ok) {
|
|
3268
|
+
if (okText) toast(okText);
|
|
3269
|
+
void refreshState();
|
|
3270
|
+
} else toast(r?.reason || t('actionFailed'), 'error');
|
|
3271
|
+
return r;
|
|
3272
|
+
})
|
|
3273
|
+
.finally(() => setWorking(''));
|
|
3274
|
+
};
|
|
3275
|
+
const state = str(v.state) || 'connecting';
|
|
3276
|
+
const hintText = v.hint ? t(KIND_HINTS.has(`${kind}_${v.hint}`) ? `channelHint_${kind}_${v.hint}` : `channelHint_${v.hint}`, { app: appName }) : '';
|
|
3277
|
+
const dot = (color) => h('span', { style: { width: 8, height: 8, borderRadius: '50%', background: color, flex: 'none' } });
|
|
3278
|
+
const statusLine =
|
|
3279
|
+
state === 'connected'
|
|
3280
|
+
? [dot(C.ok), h('span', { key: 's', style: { fontWeight: 600 } }, t('channelConnected', { handle }))]
|
|
3281
|
+
: state === 'connecting'
|
|
3282
|
+
? [h('span', { key: 'sp', className: 'dshb-spinner', style: { width: 12, height: 12 } }), h('span', { key: 's' }, t('channelConnecting', { app: appName }))]
|
|
3283
|
+
: state === 'error'
|
|
3284
|
+
? [h('span', { key: 'i', style: { color: C.error, display: 'inline-flex' } }, Icon.alert(13)), h('span', { key: 's', style: { color: C.error, fontWeight: 600 } }, hintText || str(v.detail) || t('channelError'))]
|
|
3285
|
+
: state === 'off'
|
|
3286
|
+
? [dot(C.faint), h('span', { key: 's', style: { color: C.muted } }, t('channelOff'))]
|
|
3287
|
+
: [dot('#d97706'), h('span', { key: 's', style: { color: C.muted } }, t('channelMissing', { app: appName }))];
|
|
3288
|
+
const live = state !== 'off' && state !== 'missing';
|
|
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 });
|
|
3290
|
+
return h(
|
|
3291
|
+
'div',
|
|
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 } },
|
|
3293
|
+
h(
|
|
3294
|
+
'div',
|
|
3295
|
+
{ 'data-dsh-bots-channel-status': state, style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }, title: str(v.detail) || undefined },
|
|
3296
|
+
statusLine,
|
|
3297
|
+
h('span', { style: { flex: 1 } }),
|
|
3298
|
+
state === 'error' || state === 'connecting'
|
|
3299
|
+
? h(Btn, { size: 'sm', kind: 'ghost', icon: Icon.refresh(12), disabled: Boolean(working), onClick: () => void call('channels/reconnect', {}), 'data-dsh-bots-channel-reconnect': app.id }, t('reconnect'))
|
|
3300
|
+
: null,
|
|
3301
|
+
),
|
|
3302
|
+
state === 'error' && hintText && v.detail ? h('div', { style: { fontSize: TINY, color: C.faint, marginTop: -6 } }, str(v.detail)) : null,
|
|
3303
|
+
live
|
|
3304
|
+
? h(
|
|
3305
|
+
'div',
|
|
3306
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
3307
|
+
h('div', { style: { fontSize: TINY, fontWeight: 700, color: C.muted, textTransform: 'uppercase', letterSpacing: '.02em' } }, t('pairedPeople', { n: paired.length })),
|
|
3308
|
+
paired.length === 0
|
|
3309
|
+
? h('div', { style: { color: C.faint } }, t('nobodyPaired', { app: appName }))
|
|
3310
|
+
: paired.map((p, i) =>
|
|
3311
|
+
h(
|
|
3312
|
+
'div',
|
|
3313
|
+
{ key: p.id, 'data-dsh-bots-paired': p.id, style: { display: 'flex', alignItems: 'center', gap: 8 } },
|
|
3314
|
+
h('span', { style: { color: C.muted, display: 'inline-flex' } }, Icon.user(13)),
|
|
3315
|
+
h('span', { style: { fontWeight: 600 } }, str(p.name) || str(p.id)),
|
|
3316
|
+
i === 0 ? h(Badge, { color: C.muted }, t('pairedFirst')) : null,
|
|
3317
|
+
h('span', { style: { color: C.faint, fontSize: TINY } }, t('pairedSince', { when: fmtDate(toMs(p.at)) })),
|
|
3318
|
+
h('span', { style: { flex: 1 } }),
|
|
3319
|
+
h(Btn, { size: 'sm', kind: 'ghost', className: 'dshb-btn dshb-btn-sm dshb-btn-ghost dshb-btn-danger', disabled: Boolean(working), onClick: () => void call('channels/unpair', { userId: p.id }, t('unpaired', { name: str(p.name) })), 'data-dsh-bots-unpair': p.id }, t('remove')),
|
|
3320
|
+
),
|
|
3321
|
+
),
|
|
3322
|
+
)
|
|
3323
|
+
: null,
|
|
3324
|
+
live && v.code
|
|
3325
|
+
? h(
|
|
3326
|
+
'div',
|
|
3327
|
+
{ 'data-dsh-bots-pairing': app.id, style: { display: 'flex', flexDirection: 'column', gap: 6, padding: '8px 10px', borderRadius: 9, background: tint(CHANNEL_COLORS[kind] ?? C.label, 8), border: `1px solid ${tint(CHANNEL_COLORS[kind] ?? C.label, 25)}` } },
|
|
3328
|
+
h('div', { style: { color: C.muted, lineHeight: 1.5 } }, step),
|
|
3329
|
+
h(
|
|
3330
|
+
'div',
|
|
3331
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
|
|
3332
|
+
h('span', { className: 'dshb-mono', 'data-dsh-bots-pair-code': str(v.code.code), style: { fontSize: 20, fontWeight: 700, letterSpacing: '.18em', color: C.primary } }, str(v.code.code)),
|
|
3333
|
+
h(Btn, { size: 'sm', kind: 'ghost', onClick: () => (copyText(kind === 'telegram' ? `/start ${v.code.code}` : str(v.code.code)), toast(t('copied'))) }, t('copy')),
|
|
3334
|
+
v.link ? h(ExtLink, { href: v.link, 'data-dsh-bots-pair-link': true }, t('openIn', { app: appName })) : null,
|
|
3335
|
+
h('span', { style: { flex: 1 } }),
|
|
3336
|
+
h('span', { style: { fontSize: TINY, color: C.faint } }, t('codeExpires', { when: fmtAgo(t, v.code.expiresAt) })),
|
|
3337
|
+
h(Btn, { size: 'sm', disabled: Boolean(working), onClick: () => void call('channels/code', {}), 'data-dsh-bots-new-code': app.id }, t('newCode')),
|
|
3338
|
+
),
|
|
3339
|
+
)
|
|
3340
|
+
: live
|
|
3341
|
+
? h(
|
|
3342
|
+
'div',
|
|
3343
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
|
|
3344
|
+
h(Btn, { size: 'sm', kind: paired.length ? 'default' : 'primary', icon: Icon.plus(12), disabled: Boolean(working) || state !== 'connected', onClick: () => void call('channels/code', {}), 'data-dsh-bots-new-code': app.id }, paired.length ? t('pairAnother') : t('pairSomeone')),
|
|
3345
|
+
state !== 'connected' ? h('span', { style: { fontSize: TINY, color: C.faint } }, t('pairWhenConnected')) : null,
|
|
3346
|
+
)
|
|
3347
|
+
: null,
|
|
3348
|
+
live && v.invite ? h('div', null, h(ExtLink, { href: v.invite, 'data-dsh-bots-invite': true }, t('inviteDiscord'))) : null,
|
|
3349
|
+
live && paired.length
|
|
3350
|
+
? h(
|
|
3351
|
+
'div',
|
|
3352
|
+
{ style: { display: 'flex', alignItems: 'center', gap: 8 } },
|
|
3353
|
+
h(Switch, { on: v.scheduleReplies !== false, disabled: Boolean(working), title: t('channelSchedules', { name: str(paired[0].name), app: appName }), onChange: (on) => void call('channels/options', { scheduleReplies: on }), 'data-dsh-bots-channel-schedules': app.id }),
|
|
3354
|
+
h('span', { style: { color: C.muted } }, t('channelSchedules', { name: str(paired[0].name), app: appName })),
|
|
3355
|
+
)
|
|
3356
|
+
: null,
|
|
3357
|
+
live && v.ignored?.count ? h('div', { 'data-dsh-bots-ignored': v.ignored.count, style: { fontSize: TINY, color: C.faint } }, t('channelIgnored', { n: v.ignored.count, name: str(v.ignored.lastName) })) : null,
|
|
3358
|
+
h('div', { style: { fontSize: TINY, color: C.faint, lineHeight: 1.5 } }, t('channelPrivate', { app: appName })),
|
|
3359
|
+
);
|
|
3360
|
+
}
|
|
3361
|
+
|
|
3007
3362
|
const missingFields = (entry, values) => (entry?.fields ?? []).filter((f) => f.required && str(values?.[f.key]).trim() === '').map((f) => f.key);
|
|
3008
3363
|
const needsForm = (entry) => (entry?.fields ?? []).some((f) => f.required);
|
|
3009
3364
|
|
|
@@ -3151,10 +3506,11 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3151
3506
|
const entry = entryOf(app);
|
|
3152
3507
|
const issue = str(issues[app.id]);
|
|
3153
3508
|
const custom = !entry || entry.custom;
|
|
3509
|
+
const channel = isChannelEntry(entry);
|
|
3154
3510
|
const detail = custom ? (isHttp(app, entry) ? str(app.config?.url) : [app.config?.command, ...(app.config?.args ?? [])].filter(Boolean).join(' ')) : pick(entry.description, lang);
|
|
3155
|
-
|
|
3511
|
+
const row = h(
|
|
3156
3512
|
'div',
|
|
3157
|
-
{ key: app.id, 'data-dsh-bots-app': app.id, style: { display: 'flex', alignItems: 'center', gap: 12, padding: '11px 14px', borderTop: i ? `1px solid ${C.border1}` : 'none', opacity: app.enabled === false ? 0.6 : 1 } },
|
|
3513
|
+
{ key: app.id, 'data-dsh-bots-app': app.id, style: { display: 'flex', alignItems: 'center', gap: 12, padding: '11px 14px', borderTop: i && !channel ? `1px solid ${C.border1}` : 'none', opacity: app.enabled === false ? 0.6 : 1 } },
|
|
3158
3514
|
h(AppIcon, { entry: entry ?? { icon: '{ }', color: '#475569' }, size: 36 }),
|
|
3159
3515
|
h(
|
|
3160
3516
|
'div',
|
|
@@ -3163,7 +3519,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3163
3519
|
'div',
|
|
3164
3520
|
{ style: { display: 'flex', alignItems: 'center', gap: 8, minWidth: 0, flexWrap: 'wrap' } },
|
|
3165
3521
|
h('span', { style: { fontWeight: 600 } }, nameOf(app, entry)),
|
|
3166
|
-
h('span', { className: 'dshb-mono', style: { fontSize: 11.5, color: C.faint } }, `mcp__${app.serverName}__*`),
|
|
3522
|
+
channel ? h(Badge, { color: entry.color || C.label }, Icon.chat(10), t('chatChannel')) : h('span', { className: 'dshb-mono', style: { fontSize: 11.5, color: C.faint } }, `mcp__${app.serverName}__*`),
|
|
3167
3523
|
issue ? h(Badge, { color: '#d97706', title: issue, 'data-dsh-bots-app-issue': app.id }, Icon.alert(11), t('needsSetup')) : null,
|
|
3168
3524
|
),
|
|
3169
3525
|
issue
|
|
@@ -3174,6 +3530,13 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3174
3530
|
h(Btn, { size: 'sm', kind: issue ? 'primary' : 'default', icon: Icon.edit(12), onClick: () => configure(app), 'data-dsh-bots-configure': app.id }, t('configure')),
|
|
3175
3531
|
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(app) }),
|
|
3176
3532
|
);
|
|
3533
|
+
if (!channel) return row;
|
|
3534
|
+
return h(
|
|
3535
|
+
'div',
|
|
3536
|
+
{ key: app.id, style: { borderTop: i ? `1px solid ${C.border1}` : 'none' } },
|
|
3537
|
+
row,
|
|
3538
|
+
h(ChannelPanel, { t, bot, app, entry, view: bot.channels?.[app.id], toast }),
|
|
3539
|
+
);
|
|
3177
3540
|
}),
|
|
3178
3541
|
),
|
|
3179
3542
|
),
|
|
@@ -3332,7 +3695,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3332
3695
|
h(
|
|
3333
3696
|
'div',
|
|
3334
3697
|
{ style: { display: 'flex', alignItems: 'center', gap: 10, marginTop: 'auto' } },
|
|
3335
|
-
entry.keyUrl ? h(ExtLink, { href: entry.keyUrl }, t('getKey')) : entry.homepage ? h(ExtLink, { href: entry.homepage, style: { color: C.faint } }, t('docs')) : null,
|
|
3698
|
+
entry.keyUrl ? h(ExtLink, { href: entry.keyUrl }, isChannelEntry(entry) ? t('createChatBot') : t('getKey')) : entry.homepage ? h(ExtLink, { href: entry.homepage, style: { color: C.faint } }, t('docs')) : null,
|
|
3336
3699
|
h('span', { style: { flex: 1 } }),
|
|
3337
3700
|
h(
|
|
3338
3701
|
Btn,
|
|
@@ -3399,6 +3762,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3399
3762
|
const fields = Array.isArray(entry.fields) ? entry.fields : [];
|
|
3400
3763
|
const setV = (key, v) => onChange({ ...value, values: { ...value.values, [key]: v } });
|
|
3401
3764
|
const missing = missingFields(entry, value.values);
|
|
3765
|
+
const channel = isChannelEntry(entry);
|
|
3402
3766
|
const sErr = value.serverName && !SERVER_RE.test(value.serverName) ? t('serverNameInvalid') : '';
|
|
3403
3767
|
return h(
|
|
3404
3768
|
Modal,
|
|
@@ -3408,7 +3772,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3408
3772
|
width: 560,
|
|
3409
3773
|
onClose,
|
|
3410
3774
|
footer: [
|
|
3411
|
-
h('span', { key: 'n', style: { flex: 1, fontSize: TINY, color: C.faint, alignSelf: 'center' } }, t('appsNote')),
|
|
3775
|
+
h('span', { key: 'n', style: { flex: 1, fontSize: TINY, color: C.faint, alignSelf: 'center' } }, channel ? t('channelSaveNote') : t('appsNote')),
|
|
3412
3776
|
h(Btn, { key: 'c', onClick: onClose }, t('cancel')),
|
|
3413
3777
|
h(Btn, { key: 's', kind: 'primary', disabled: busy || missing.length > 0 || Boolean(sErr), onClick: onSave, 'data-dsh-bots-app-save': true }, busy ? t('saving') : app ? t('save') : t('add')),
|
|
3414
3778
|
],
|
|
@@ -3421,9 +3785,10 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3421
3785
|
'div',
|
|
3422
3786
|
{ style: { flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
3423
3787
|
h('div', { style: { fontSize: SMALL, color: C.muted, lineHeight: 1.55 } }, pick(entry.description, lang)),
|
|
3424
|
-
h('div', { style: { display: 'flex', gap: 14, flexWrap: 'wrap' } }, h(ExtLink, { href: entry.homepage }, t('docs')), h(ExtLink, { href: entry.keyUrl }, t('getKey'))),
|
|
3788
|
+
h('div', { style: { display: 'flex', gap: 14, flexWrap: 'wrap' } }, h(ExtLink, { href: entry.homepage }, t('docs')), h(ExtLink, { href: entry.keyUrl }, channel ? t('createChatBot') : t('getKey'))),
|
|
3425
3789
|
),
|
|
3426
3790
|
),
|
|
3791
|
+
channel ? h('div', { 'data-dsh-bots-channel-how': entry.id, style: { fontSize: SMALL, color: C.muted, lineHeight: 1.6, padding: '9px 11px', borderRadius: 9, background: tint(entry.color || C.label, 8) } }, t('channelHow', { app: pick(entry.name, lang) })) : null,
|
|
3427
3792
|
fields.length === 0 ? h('div', { style: { fontSize: SMALL, color: C.faint } }, t('noSettings')) : null,
|
|
3428
3793
|
fields.map((f) => {
|
|
3429
3794
|
const v = str(value.values[f.key]);
|
|
@@ -3452,7 +3817,9 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3452
3817
|
else control = h(Input, { ...common, mono: f.kind === 'path' });
|
|
3453
3818
|
return h(Field, { key: f.key, label, hint: pick(f.help, lang) || (f.kind === 'path' && !f.multi ? t('pathHint') : '') }, control);
|
|
3454
3819
|
}),
|
|
3455
|
-
|
|
3820
|
+
channel
|
|
3821
|
+
? null
|
|
3822
|
+
: h(
|
|
3456
3823
|
'details',
|
|
3457
3824
|
{ style: { fontSize: SMALL, color: C.muted } },
|
|
3458
3825
|
h('summary', { style: { cursor: 'pointer', userSelect: 'none' } }, t('advanced')),
|
|
@@ -3529,7 +3896,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
3529
3896
|
const counts = { skills: (bot.skills ?? []).length, apps: (bot.apps ?? []).length };
|
|
3530
3897
|
let body;
|
|
3531
3898
|
if (tab === 'profile') body = h(ProfileTab, { key: bot.id, t, bot, toast, catalog });
|
|
3532
|
-
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 });
|
|
3533
3900
|
else if (tab === 'schedules') body = h(SchedulesTab, { key: bot.id, t, bot, toast, catalog });
|
|
3534
3901
|
else if (tab === 'apps') body = h(AppsTab, { key: bot.id, t, bot, toast, catalog });
|
|
3535
3902
|
else body = h(ChatTab, { key: bot.id, t, bot, env, toast });
|
|
@@ -4759,7 +5126,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
4759
5126
|
installedApps: 'Installed apps ({n})',
|
|
4760
5127
|
noApps: 'No apps yet. Add one from the gallery below.',
|
|
4761
5128
|
appGallery: 'App gallery',
|
|
4762
|
-
appGalleryHint: '{n} apps.
|
|
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.',
|
|
4763
5130
|
noTemplates: 'No templates.',
|
|
4764
5131
|
featured: 'Featured',
|
|
4765
5132
|
allApps: 'All',
|
|
@@ -4905,6 +5272,28 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
4905
5272
|
importN: "Import {n}",
|
|
4906
5273
|
importing: "Importing…",
|
|
4907
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",
|
|
4908
5297
|
importFailed: "Import failed.",
|
|
4909
5298
|
browse: "Browse",
|
|
4910
5299
|
foundSkills: "{n} skills",
|
|
@@ -4924,8 +5313,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
4924
5313
|
letBotWrite: "Let the bot write it",
|
|
4925
5314
|
writeByHand: "Write by hand",
|
|
4926
5315
|
skillsHint2: "Instructions {name} loads when a task needs them.",
|
|
4927
|
-
skillMix: "{dsh} Harness · {import} GitHub · {own} own",
|
|
4928
|
-
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.",
|
|
4929
5318
|
harnessManaged: "Provided by the Harness, kept up to date",
|
|
4930
5319
|
src_dsh: "Harness",
|
|
4931
5320
|
src_import: "GitHub",
|
|
@@ -4946,6 +5335,56 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
4946
5335
|
suggest_b1: "Introduce yourself: what can you do for me, and what do you need from me?",
|
|
4947
5336
|
suggest_b2: "Look at what is on your plate and suggest the first thing to do today.",
|
|
4948
5337
|
suggest_b3: "Show me which of your skills and apps are ready, and which still need setup.",
|
|
5338
|
+
// chat channels
|
|
5339
|
+
chatChannel: 'chat app',
|
|
5340
|
+
createChatBot: 'Create a bot',
|
|
5341
|
+
channelHow: 'Add it to your dispatcher. Once it connects, pair yourself with the one-time code shown here; then message the bot in {app} to hand out work, and the replies come back to the chat.',
|
|
5342
|
+
channelSaveNote: 'It connects as soon as you save.',
|
|
5343
|
+
channelConnected: 'Connected as {handle}',
|
|
5344
|
+
channelConnecting: 'Connecting to {app}…',
|
|
5345
|
+
channelError: 'Not connected',
|
|
5346
|
+
channelOff: 'Off. Turn it on to connect.',
|
|
5347
|
+
channelMissing: 'Paste the bot token to connect to {app}.',
|
|
5348
|
+
channelHint_token: '{app} rejected the bot token. Copy it again and save.',
|
|
5349
|
+
channelHint_intent: 'Turn on Message Content Intent: Developer Portal → your app → Bot → Privileged Gateway Intents. Then reconnect.',
|
|
5350
|
+
channelHint_conflict: 'Another program is using this bot token. Stop it, or create a separate bot for the team.',
|
|
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.',
|
|
5363
|
+
reconnect: 'Reconnect',
|
|
5364
|
+
pairedPeople: 'Paired people ({n})',
|
|
5365
|
+
nobodyPaired: 'Nobody yet. Until someone is paired, the bot answers no one in {app}.',
|
|
5366
|
+
pairedFirst: 'gets scheduled reports',
|
|
5367
|
+
pairedSince: 'since {when}',
|
|
5368
|
+
unpaired: '{name} removed.',
|
|
5369
|
+
pairStepTelegram: 'From your own Telegram account, send this code to {handle}, or open the link and press Start. It works once.',
|
|
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.',
|
|
5373
|
+
pairStep: 'From your own {app} account, send this code to {handle}. It works once.',
|
|
5374
|
+
copy: 'Copy',
|
|
5375
|
+
copied: 'Copied.',
|
|
5376
|
+
openIn: 'Open in {app}',
|
|
5377
|
+
codeExpires: 'expires {when}',
|
|
5378
|
+
newCode: 'New code',
|
|
5379
|
+
pairSomeone: 'Pair yourself',
|
|
5380
|
+
pairAnother: 'Pair another person',
|
|
5381
|
+
pairWhenConnected: 'Pairing starts once it is connected.',
|
|
5382
|
+
inviteDiscord: 'Invite the bot to a server you are in (needed before you can DM it)',
|
|
5383
|
+
channelSchedules: 'Scheduled reports also go to {name} in {app}',
|
|
5384
|
+
channelIgnored: 'Ignored {n} messages from people who are not paired (last: {name}).',
|
|
5385
|
+
channelPrivate: 'Only paired people reach the team. Anyone else is ignored (at most a one-line "this bot is private" a day). In a group the bot only answers when @mentioned or replied to.',
|
|
5386
|
+
viaChannel: '{app} · {who}',
|
|
5387
|
+
sentToChannel: 'Also sent to {app}',
|
|
4949
5388
|
},
|
|
4950
5389
|
zh: {
|
|
4951
5390
|
lang: 'zh',
|
|
@@ -5204,7 +5643,7 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5204
5643
|
installedApps: '已安装的应用({n})',
|
|
5205
5644
|
noApps: '还没有应用。从下方的应用库添加一个。',
|
|
5206
5645
|
appGallery: '应用库',
|
|
5207
|
-
appGalleryHint: '共 {n}
|
|
5646
|
+
appGalleryHint: '共 {n} 个应用。大多是 MCP 服务器,工具只对这个 Bot 可见;聊天应用(飞书、Telegram、Slack、Discord)让你用手机给团队发消息。',
|
|
5208
5647
|
noTemplates: '没有模板。',
|
|
5209
5648
|
featured: '推荐',
|
|
5210
5649
|
allApps: '全部',
|
|
@@ -5349,6 +5788,28 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5349
5788
|
importN: "导入 {n} 个",
|
|
5350
5789
|
importing: "导入中…",
|
|
5351
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: "本地",
|
|
5352
5813
|
importFailed: "导入失败。",
|
|
5353
5814
|
browse: "浏览",
|
|
5354
5815
|
foundSkills: "{n} 个技能",
|
|
@@ -5368,8 +5829,8 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5368
5829
|
letBotWrite: "让 Bot 自己写",
|
|
5369
5830
|
writeByHand: "手写",
|
|
5370
5831
|
skillsHint2: "{name} 在任务需要时加载的说明。",
|
|
5371
|
-
skillMix: "Harness {dsh} · GitHub {import} · 自写 {own}",
|
|
5372
|
-
noSkillsBody2: "添加 Harness 里已安装的技能、从 GitHub
|
|
5832
|
+
skillMix: "Harness {dsh} · GitHub {import} · 本地 {local} · 自写 {own}",
|
|
5833
|
+
noSkillsBody2: "添加 Harness 里已安装的技能、从 GitHub 或本地文件夹导入,或者描述一下让 Bot 自己写。",
|
|
5373
5834
|
harnessManaged: "由 Harness 提供,自动保持最新",
|
|
5374
5835
|
src_dsh: "Harness",
|
|
5375
5836
|
src_import: "GitHub",
|
|
@@ -5390,6 +5851,56 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5390
5851
|
suggest_b1: "介绍一下你自己:你能帮我做什么?需要我提供什么?",
|
|
5391
5852
|
suggest_b2: "看看你手上有什么事,建议今天先做哪一件。",
|
|
5392
5853
|
suggest_b3: "告诉我你的技能和应用哪些已经可用,哪些还需要配置。",
|
|
5854
|
+
// chat channels
|
|
5855
|
+
chatChannel: '聊天应用',
|
|
5856
|
+
createChatBot: '创建 Bot',
|
|
5857
|
+
channelHow: '把它加到调度者身上。连上以后,用这里显示的一次性配对码把你自己配对上;之后在 {app} 里给 Bot 发消息就能派活,回复会回到聊天里。',
|
|
5858
|
+
channelSaveNote: '保存后立即连接。',
|
|
5859
|
+
channelConnected: '已连接:{handle}',
|
|
5860
|
+
channelConnecting: '正在连接 {app}…',
|
|
5861
|
+
channelError: '未连接',
|
|
5862
|
+
channelOff: '已关闭。打开后才会连接。',
|
|
5863
|
+
channelMissing: '粘贴 Bot Token 后即可连接 {app}。',
|
|
5864
|
+
channelHint_token: '{app} 拒绝了这个 Bot Token。请重新复制并保存。',
|
|
5865
|
+
channelHint_intent: '请打开 Message Content Intent:开发者后台 → 你的应用 → Bot → Privileged Gateway Intents,然后重新连接。',
|
|
5866
|
+
channelHint_conflict: '另一个程序正在使用这个 Bot Token。请停掉它,或给团队单独建一个 Bot。',
|
|
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 的程序。',
|
|
5879
|
+
reconnect: '重新连接',
|
|
5880
|
+
pairedPeople: '已配对的人({n})',
|
|
5881
|
+
nobodyPaired: '还没有人。配对之前,Bot 在 {app} 里不回复任何人。',
|
|
5882
|
+
pairedFirst: '接收定时汇报',
|
|
5883
|
+
pairedSince: '配对于 {when}',
|
|
5884
|
+
unpaired: '已移除 {name}。',
|
|
5885
|
+
pairStepTelegram: '用你自己的 Telegram 账号把这个配对码发给 {handle},或打开链接后点 Start。只能用一次。',
|
|
5886
|
+
pairStepDiscord: '用你自己的 Discord 账号私信 {handle},发送这个配对码。只能用一次。',
|
|
5887
|
+
pairStepFeishu: '在飞书里打开和 {handle} 的单聊(搜索应用名,或点「在飞书中打开」),发送这个配对码。只能用一次。',
|
|
5888
|
+
pairStepSlack: '用你自己的 Slack 账号打开这个应用的 Messages 标签页(或点链接),发送这个配对码。只能用一次。',
|
|
5889
|
+
pairStep: '用你自己的 {app} 账号把这个配对码发给 {handle}。只能用一次。',
|
|
5890
|
+
copy: '复制',
|
|
5891
|
+
copied: '已复制。',
|
|
5892
|
+
openIn: '在 {app} 中打开',
|
|
5893
|
+
codeExpires: '{when}过期',
|
|
5894
|
+
newCode: '换一个',
|
|
5895
|
+
pairSomeone: '配对我自己',
|
|
5896
|
+
pairAnother: '再配对一个人',
|
|
5897
|
+
pairWhenConnected: '连接成功后才能配对。',
|
|
5898
|
+
inviteDiscord: '把 Bot 邀请进你所在的服务器(私信它之前必须先这样做)',
|
|
5899
|
+
channelSchedules: '定时汇报也发给 {app} 里的 {name}',
|
|
5900
|
+
channelIgnored: '忽略了 {n} 条未配对的人发来的消息(最近:{name})。',
|
|
5901
|
+
channelPrivate: '只有配对过的人能找到团队,其他人一律忽略(每天最多回一句“这是私人 Bot”)。在群里,只有 @ 它或回复它时才会回答。',
|
|
5902
|
+
viaChannel: '{app} · {who}',
|
|
5903
|
+
sentToChannel: '也已发到 {app}',
|
|
5393
5904
|
},
|
|
5394
5905
|
};
|
|
5395
5906
|
|
|
@@ -5444,7 +5955,17 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5444
5955
|
return false;
|
|
5445
5956
|
}
|
|
5446
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
|
+
};
|
|
5447
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))(),
|
|
5448
5969
|
canOpen: () => typeof service('uiWorkspace')?.openSession === 'function',
|
|
5449
5970
|
canPanel: () => typeof service('layout')?.selectPanel === 'function',
|
|
5450
5971
|
/** Ensure the bot's home conversation, then show it; false on failure. */
|