@kadaliao/dsh-bots 0.6.0 → 0.6.1
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 +2 -0
- package/README.zh-CN.md +1 -0
- package/client.js +64 -7
- package/index.js +17 -5
- package/lib/skills.mjs +15 -5
- package/lib/store.mjs +19 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,6 +72,8 @@ A bot is an ordinary Harness conversation, so everything Harness can do, a bot c
|
|
|
72
72
|
`~/.claude/skills`); linked, not copied, so editing the folder is enough;
|
|
73
73
|
- a skill name is used once per bot: adding one that is already there is skipped, and importing again
|
|
74
74
|
from the same GitHub folder updates it in place;
|
|
75
|
+
- up to 50 skills can be on at once (each one on is in the bot's prompt every turn); a bot keeps up to
|
|
76
|
+
200 in all, so past 50 new ones come in switched off;
|
|
75
77
|
- **Let the bot write it**: describe what you need in a sentence; the bot writes it with skill-creator
|
|
76
78
|
and saves it to itself;
|
|
77
79
|
- writing one by hand is still possible, as the last resort.
|
package/README.zh-CN.md
CHANGED
|
@@ -61,6 +61,7 @@ Bot 就是一个普通的 Harness 会话,所以 Harness 能做的它都能做
|
|
|
61
61
|
- **从 GitHub 导入**:一键浏览 Anthropic 官方技能,或粘贴任意 `owner/repo/path`,整个技能文件夹连脚本一起导入;
|
|
62
62
|
- **从本地文件夹添加**:选本机的一个技能文件夹(或装着多个技能的文件夹,如 `~/.claude/skills`),只引用不复制,改了原文件夹就生效;
|
|
63
63
|
- 同一个 bot 里技能不重名:已有的同名技能会跳过;从同一个 GitHub 文件夹再导入一次则原地更新;
|
|
64
|
+
- 最多同时开 50 个技能(开着的每轮都在 bot 的提示里),总共最多放 200 个;超过 50 个时,新加的先关着;
|
|
64
65
|
- **让 Bot 自己写**:一句话描述需求,bot 用 skill-creator 写好并保存到自己身上;
|
|
65
66
|
- 手写仍然可以,但它是最后的选项;
|
|
66
67
|
- **应用**:只补 Harness 本身没有的外部系统;
|
package/client.js
CHANGED
|
@@ -2311,6 +2311,9 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2311
2311
|
}
|
|
2312
2312
|
|
|
2313
2313
|
const skillSource = (s) => (s?.source === 'dsh' || s?.source === 'import' ? s.source : 'own');
|
|
2314
|
+
/** How many skills a bot keeps, and how many of them may be on at once (from the host; lib/store.mjs). */
|
|
2315
|
+
const skillLimits = () => ({ max: Number(store.state?.limits?.skills) || 200, on: Number(store.state?.limits?.skillsOn) || 50 });
|
|
2316
|
+
const onCount = (skills) => skills.filter((s) => s.enabled !== false).length;
|
|
2314
2317
|
/** A skill linked to a folder on this machine (its origin is a path, not a URL): read live, never copied. */
|
|
2315
2318
|
const isLocalSkill = (s) => s?.source === 'import' && typeof s.origin === 'string' && s.origin !== '' && !/^https?:\/\//i.test(s.origin);
|
|
2316
2319
|
const SOURCE_COLOR = { dsh: '#2563eb', import: '#475569', own: '#16a34a' };
|
|
@@ -2332,7 +2335,18 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2332
2335
|
/** One line for what an import did: added, updated, skipped. */
|
|
2333
2336
|
function importSummary(t, r) {
|
|
2334
2337
|
const n = (k) => (Array.isArray(r?.[k]) ? r[k].length : 0);
|
|
2335
|
-
|
|
2338
|
+
const skipped = Array.isArray(r?.skipped) ? r.skipped : [];
|
|
2339
|
+
const full = skipped.filter((x) => x?.reason === 'full').length;
|
|
2340
|
+
const lim = skillLimits();
|
|
2341
|
+
return [
|
|
2342
|
+
n('added') ? t('importedN', { n: n('added') }) : '',
|
|
2343
|
+
n('off') ? t('offN', { n: n('off'), max: lim.on }) : '',
|
|
2344
|
+
n('updated') ? t('updatedN', { n: n('updated') }) : '',
|
|
2345
|
+
skipped.length - full ? t('skippedN', { n: skipped.length - full }) : '',
|
|
2346
|
+
full ? t('fullN', { n: full, max: lim.max }) : '',
|
|
2347
|
+
]
|
|
2348
|
+
.filter(Boolean)
|
|
2349
|
+
.join(' ');
|
|
2336
2350
|
}
|
|
2337
2351
|
/** Run an import and report it; resolves to the rows that failed, or null when nothing came back. */
|
|
2338
2352
|
function runImport(t, toast, botId, items) {
|
|
@@ -2790,14 +2804,30 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2790
2804
|
toast(t('skillNameTaken', { name: s.name.trim() }), 'error');
|
|
2791
2805
|
return;
|
|
2792
2806
|
}
|
|
2793
|
-
const
|
|
2807
|
+
const lim = skillLimits();
|
|
2808
|
+
if (!prev && skills.length >= lim.max) {
|
|
2809
|
+
toast(t('skillsFull', { max: lim.max }), 'error');
|
|
2810
|
+
return;
|
|
2811
|
+
}
|
|
2812
|
+
// A new skill past the limit of skills on is kept, switched off.
|
|
2813
|
+
const off = !prev && s.enabled !== false && onCount(skills) >= lim.on;
|
|
2814
|
+
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 && !off };
|
|
2794
2815
|
const next = s.id ? skills.map((x) => (x.id === s.id ? item : x)) : [...skills, item];
|
|
2795
|
-
void commit(next, t('skillSaved')).then((ok) => ok && setEditing(null));
|
|
2816
|
+
void commit(next, off ? `${t('skillSaved')} ${t('offN', { n: 1, max: lim.on })}` : t('skillSaved')).then((ok) => ok && setEditing(null));
|
|
2796
2817
|
};
|
|
2797
2818
|
const addHarness = (list) => {
|
|
2798
2819
|
const have = new Set(skills.map((x) => str(x.name).toLowerCase()));
|
|
2799
|
-
const
|
|
2800
|
-
|
|
2820
|
+
const lim = skillLimits();
|
|
2821
|
+
const fresh = list.filter((x) => !have.has(str(x.name).toLowerCase()));
|
|
2822
|
+
if (skills.length + fresh.length > lim.max) {
|
|
2823
|
+
toast(t('skillsRoom', { max: lim.max, n: Math.max(0, lim.max - skills.length) }), 'error');
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2826
|
+
// Past the limit of skills on, the rest come in switched off.
|
|
2827
|
+
const room = Math.max(0, lim.on - onCount(skills));
|
|
2828
|
+
const add = fresh.map((x, i) => ({ name: x.name, source: 'dsh', enabled: i < room, description: str(x.description) }));
|
|
2829
|
+
const off = add.length - Math.min(room, add.length);
|
|
2830
|
+
void commit([...skills, ...add], off ? `${t('addedN', { n: add.length })} ${t('offN', { n: off, max: lim.on })}` : t('addedN', { n: add.length })).then((ok) => ok && setPicker(null));
|
|
2801
2831
|
};
|
|
2802
2832
|
const counts = { dsh: 0, import: 0, local: 0, own: 0 };
|
|
2803
2833
|
for (const s of skills) counts[isLocalSkill(s) ? 'local' : skillSource(s)] += 1;
|
|
@@ -2822,7 +2852,14 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2822
2852
|
{
|
|
2823
2853
|
title: t('botSkills', { n: skills.length }),
|
|
2824
2854
|
hint: t('skillsHint2', { name: bot.name }),
|
|
2825
|
-
right: skills.length
|
|
2855
|
+
right: skills.length
|
|
2856
|
+
? h(
|
|
2857
|
+
'span',
|
|
2858
|
+
{ style: { fontSize: TINY, color: C.faint } },
|
|
2859
|
+
`${t('skillMix', counts)} · `,
|
|
2860
|
+
h('span', { 'data-dsh-bots-skills-on': onCount(skills), style: onCount(skills) >= skillLimits().on ? { color: C.warn, fontWeight: 600 } : null }, t('skillsOnOf', { n: onCount(skills), max: skillLimits().on })),
|
|
2861
|
+
)
|
|
2862
|
+
: null,
|
|
2826
2863
|
},
|
|
2827
2864
|
editing ? h(SkillEditor, { t, skill: editing, onChange: setEditing, onCancel: () => setEditing(null), onSave: saveSkill, busy }) : null,
|
|
2828
2865
|
skills.length === 0 && !editing
|
|
@@ -2840,7 +2877,15 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
2840
2877
|
{ style: { display: 'flex', alignItems: 'center', gap: 8 } },
|
|
2841
2878
|
h('span', { className: 'dshb-mono', style: { fontWeight: 650, flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: s.name }, s.name),
|
|
2842
2879
|
h(SourceBadge, { t, source: src, local: isLocalSkill(s) }),
|
|
2843
|
-
h(Switch, {
|
|
2880
|
+
h(Switch, {
|
|
2881
|
+
on: s.enabled !== false,
|
|
2882
|
+
disabled: busy,
|
|
2883
|
+
title: s.enabled !== false ? t('disable') : t('enable'),
|
|
2884
|
+
onChange: (on) => {
|
|
2885
|
+
if (on && onCount(skills) >= skillLimits().on) return void toast(t('tooManyOn', { max: skillLimits().on }), 'error');
|
|
2886
|
+
void commit(skills.map((x) => (x === s ? { ...x, enabled: on } : x)));
|
|
2887
|
+
},
|
|
2888
|
+
}),
|
|
2844
2889
|
),
|
|
2845
2890
|
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'))),
|
|
2846
2891
|
h(
|
|
@@ -5274,6 +5319,12 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5274
5319
|
importedN: "Imported {n} skills.",
|
|
5275
5320
|
updatedN: "Updated {n}.",
|
|
5276
5321
|
skippedN: "Skipped {n}: a skill of that name is already here.",
|
|
5322
|
+
fullN: "Skipped {n}: a bot keeps at most {max} skills.",
|
|
5323
|
+
offN: "{n} came in switched off: at most {max} skills can be on at once.",
|
|
5324
|
+
tooManyOn: "At most {max} skills can be on at once. Switch one off first.",
|
|
5325
|
+
skillsFull: "A bot keeps at most {max} skills. Remove one first.",
|
|
5326
|
+
skillsRoom: "A bot keeps at most {max} skills; there is room for {n} more.",
|
|
5327
|
+
skillsOnOf: "{n}/{max} on",
|
|
5277
5328
|
nameTaken: "Name already used",
|
|
5278
5329
|
reimport: "Imported · import again to update",
|
|
5279
5330
|
skillNameTaken: "This bot already has a skill named “{name}”.",
|
|
@@ -5790,6 +5841,12 @@ a.dshb-lc:hover{border-color:${C.border};background:${C.layer2}}
|
|
|
5790
5841
|
importedN: "已导入 {n} 个技能。",
|
|
5791
5842
|
updatedN: "已更新 {n} 个。",
|
|
5792
5843
|
skippedN: "跳过 {n} 个:已有同名技能。",
|
|
5844
|
+
fullN: "跳过 {n} 个:一个 Bot 最多放 {max} 个技能。",
|
|
5845
|
+
offN: "其中 {n} 个先关着:最多同时开 {max} 个技能。",
|
|
5846
|
+
tooManyOn: "最多同时开 {max} 个技能,先关掉一个。",
|
|
5847
|
+
skillsFull: "一个 Bot 最多放 {max} 个技能,先删掉一个。",
|
|
5848
|
+
skillsRoom: "一个 Bot 最多放 {max} 个技能,还能加 {n} 个。",
|
|
5849
|
+
skillsOnOf: "开着 {n}/{max}",
|
|
5793
5850
|
nameTaken: "已有同名技能",
|
|
5794
5851
|
reimport: "已导入 · 再次导入可更新",
|
|
5795
5852
|
skillNameTaken: "这个 Bot 已经有名为“{name}”的技能。",
|
package/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import { join, sep } from 'node:path';
|
|
|
26
26
|
import { fileURLToPath } from 'node:url';
|
|
27
27
|
import { randomUUID } from 'node:crypto';
|
|
28
28
|
|
|
29
|
-
import { createStore, initialsOf, slugify, SKILL_RE, PALETTE } from './lib/store.mjs';
|
|
29
|
+
import { createStore, initialsOf, slugify, SKILL_RE, PALETTE, MAX_SKILLS, MAX_SKILLS_ON } from './lib/store.mjs';
|
|
30
30
|
import { catalog as appCatalog, CATEGORIES, mcpConfigFor } from './lib/apps.mjs';
|
|
31
31
|
import { ABILITIES } from './lib/abilities.mjs';
|
|
32
32
|
import { SKILL_SOURCES, importGithubSkill, importUrlSkill, linkLocalSkill, listGithubSkills, listLocalSkills, mergeImported, parseGithub, readLinkedSkill, resolveLocalPath } from './lib/skills.mjs';
|
|
@@ -695,6 +695,15 @@ export function apply(ctx, config, deps = {}) {
|
|
|
695
695
|
items: { type: 'object', additionalProperties: false, properties: { name: { type: 'string', required: true }, description: { type: 'string' }, content: { type: 'string', description: 'Markdown instructions the bot loads when the skill applies.' } } },
|
|
696
696
|
};
|
|
697
697
|
const card = (bot) => `@${bot.handle} — ${bot.name}${bot.role === 'primary' ? ' (dispatcher)' : ''}`;
|
|
698
|
+
const tooManySkills = (n) => {
|
|
699
|
+
if (n > MAX_SKILLS) throw new Error(`a bot keeps at most ${MAX_SKILLS} skills (this would make ${n}); remove some first`);
|
|
700
|
+
};
|
|
701
|
+
/** The tool-result sentence for skills asked on that the store had to leave off (past MAX_SKILLS_ON). */
|
|
702
|
+
const offNote = (asked, saved) => {
|
|
703
|
+
const names = new Set((asked ?? []).map((s) => String(s?.name ?? '').trim().toLowerCase()));
|
|
704
|
+
const off = saved.skills.filter((s) => !s.enabled && names.has(s.name.toLowerCase())).map((s) => s.name);
|
|
705
|
+
return off.length ? ` Added switched off, since at most ${MAX_SKILLS_ON} skills can be on at once: ${off.join(', ')}. To use them, remove skills it no longer needs (remove_skills) or ask the user to switch some off in Bots.` : '';
|
|
706
|
+
};
|
|
698
707
|
|
|
699
708
|
const tools = [
|
|
700
709
|
defineTool({
|
|
@@ -735,6 +744,7 @@ export function apply(ctx, config, deps = {}) {
|
|
|
735
744
|
output: { schema: anyValue, render: (_a, v) => text(v.text), presentationMeta: (_a, v) => ({ bot: v.bot }) },
|
|
736
745
|
execute: async (args, exec) => {
|
|
737
746
|
const by = callerBot(exec);
|
|
747
|
+
tooManySkills((args.skills ?? []).length);
|
|
738
748
|
const bot = store.save(
|
|
739
749
|
{
|
|
740
750
|
name: args.name,
|
|
@@ -746,7 +756,7 @@ export function apply(ctx, config, deps = {}) {
|
|
|
746
756
|
},
|
|
747
757
|
{ createdBy: by?.id ?? 'user' },
|
|
748
758
|
);
|
|
749
|
-
return { ok: true, text: `Created ${card(bot)}. Message it with bot_send_message to @${bot.handle}
|
|
759
|
+
return { ok: true, text: `Created ${card(bot)}. Message it with bot_send_message to @${bot.handle}.${offNote(args.skills, bot)}`, bot: face(bot) };
|
|
750
760
|
},
|
|
751
761
|
}),
|
|
752
762
|
defineTool({
|
|
@@ -759,7 +769,7 @@ export function apply(ctx, config, deps = {}) {
|
|
|
759
769
|
persona: { type: 'string', description: 'Replaces the whole persona.' },
|
|
760
770
|
initials: { type: 'string', description: 'Avatar letters, at most two.' },
|
|
761
771
|
color: { type: 'string', description: 'Avatar background colour, CSS hex.' },
|
|
762
|
-
add_skills: { ...skillInput, description:
|
|
772
|
+
add_skills: { ...skillInput, description: `Skills to add (a skill with the same name is replaced). At most ${MAX_SKILLS_ON} can be on at once; past that they are added switched off.` },
|
|
763
773
|
remove_skills: { type: 'array', items: { type: 'string' }, description: 'Names of skills to remove.' },
|
|
764
774
|
make_dispatcher: { type: 'boolean', description: 'true to make this bot the dispatcher.' },
|
|
765
775
|
},
|
|
@@ -772,10 +782,11 @@ export function apply(ctx, config, deps = {}) {
|
|
|
772
782
|
if (args.add_skills || args.remove_skills) {
|
|
773
783
|
const drop = new Set([...(args.remove_skills ?? []), ...(args.add_skills ?? []).map((s) => s.name)].map((s) => String(s).toLowerCase()));
|
|
774
784
|
next.skills = [...bot.skills.filter((s) => !drop.has(s.name.toLowerCase())), ...(args.add_skills ?? []).map((s) => ({ ...s, enabled: true }))];
|
|
785
|
+
tooManySkills(next.skills.length);
|
|
775
786
|
}
|
|
776
787
|
if (args.make_dispatcher === true) next.role = 'primary';
|
|
777
788
|
const saved = store.save(next);
|
|
778
|
-
return { ok: true, text: `Updated ${card(saved)}
|
|
789
|
+
return { ok: true, text: `Updated ${card(saved)}.${offNote(args.add_skills, saved)}`, bot: face(saved) };
|
|
779
790
|
},
|
|
780
791
|
}),
|
|
781
792
|
defineTool({
|
|
@@ -985,7 +996,7 @@ export function apply(ctx, config, deps = {}) {
|
|
|
985
996
|
});
|
|
986
997
|
const sessionMap = {};
|
|
987
998
|
for (const b of bots) if (b.sessionId) sessionMap[b.sessionId] = b.id;
|
|
988
|
-
return { bots, primaryId: store.primary()?.id ?? null, sessionMap, messageCount: store.messageCount(), version: store.version() };
|
|
999
|
+
return { bots, primaryId: store.primary()?.id ?? null, sessionMap, messageCount: store.messageCount(), version: store.version(), limits: { skills: MAX_SKILLS, skillsOn: MAX_SKILLS_ON } };
|
|
989
1000
|
}
|
|
990
1001
|
|
|
991
1002
|
let ocuInstalling = false;
|
|
@@ -1150,6 +1161,7 @@ export function apply(ctx, config, deps = {}) {
|
|
|
1150
1161
|
bot: publicBot(saved),
|
|
1151
1162
|
added: merged.added,
|
|
1152
1163
|
updated: merged.updated,
|
|
1164
|
+
off: merged.off,
|
|
1153
1165
|
skipped: merged.skipped,
|
|
1154
1166
|
failed,
|
|
1155
1167
|
...(failed.length && !changed ? { reason: failed[0].reason } : {}),
|
package/lib/skills.mjs
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
15
15
|
import { homedir } from 'node:os';
|
|
16
16
|
import { basename, dirname, join, normalize, resolve } from 'node:path';
|
|
17
|
+
import { MAX_SKILLS, MAX_SKILLS_ON } from './store.mjs';
|
|
17
18
|
|
|
18
19
|
/** Skill collections worth browsing, shown as one-click sources. */
|
|
19
20
|
export const SKILL_SOURCES = [
|
|
@@ -300,18 +301,21 @@ export const isLocalOrigin = (origin) => typeof origin === 'string' && origin !=
|
|
|
300
301
|
* Merge freshly imported skills into a bot's list without doubling any:
|
|
301
302
|
* - a new name is added;
|
|
302
303
|
* - the same name from the same origin replaces the old entry in place (an update: id and on/off kept);
|
|
303
|
-
* - the same name from anywhere else is left alone and reported (`exists`), as is one past
|
|
304
|
+
* - the same name from anywhere else is left alone and reported (`exists`), as is one past `limit` skills (`full`);
|
|
305
|
+
* - a new one past `maxOn` skills on is added switched off and reported (`off`).
|
|
304
306
|
* Names compare case-insensitively.
|
|
305
|
-
* @returns {{skills: object[], added: string[], updated: string[], skipped: {name, reason}[], dropped: object[]}}
|
|
307
|
+
* @returns {{skills: object[], added: string[], updated: string[], off: string[], skipped: {name, reason}[], dropped: object[]}}
|
|
306
308
|
* `dropped` are skill objects whose copied folder is no longer used.
|
|
307
309
|
*/
|
|
308
|
-
export function mergeImported(current, incoming, { limit =
|
|
310
|
+
export function mergeImported(current, incoming, { limit = MAX_SKILLS, maxOn = MAX_SKILLS_ON } = {}) {
|
|
309
311
|
const skills = [...current];
|
|
310
312
|
const added = [];
|
|
311
313
|
const updated = [];
|
|
314
|
+
const off = [];
|
|
312
315
|
const skipped = [];
|
|
313
316
|
const dropped = [];
|
|
314
317
|
const key = (s) => String(s.name).trim().toLowerCase();
|
|
318
|
+
let on = skills.filter((s) => s.enabled !== false).length;
|
|
315
319
|
for (const item of incoming) {
|
|
316
320
|
const at = skills.findIndex((s) => key(s) === key(item));
|
|
317
321
|
if (at < 0) {
|
|
@@ -320,7 +324,13 @@ export function mergeImported(current, incoming, { limit = 50 } = {}) {
|
|
|
320
324
|
dropped.push(item);
|
|
321
325
|
continue;
|
|
322
326
|
}
|
|
323
|
-
|
|
327
|
+
if (item.enabled !== false && on >= maxOn) {
|
|
328
|
+
skills.push({ ...item, enabled: false });
|
|
329
|
+
off.push(item.name);
|
|
330
|
+
} else {
|
|
331
|
+
skills.push(item);
|
|
332
|
+
if (item.enabled !== false) on += 1;
|
|
333
|
+
}
|
|
324
334
|
added.push(item.name);
|
|
325
335
|
continue;
|
|
326
336
|
}
|
|
@@ -335,5 +345,5 @@ export function mergeImported(current, incoming, { limit = 50 } = {}) {
|
|
|
335
345
|
dropped.push(item);
|
|
336
346
|
}
|
|
337
347
|
}
|
|
338
|
-
return { skills, added, updated, skipped, dropped };
|
|
348
|
+
return { skills, added, updated, off, skipped, dropped };
|
|
339
349
|
}
|
package/lib/store.mjs
CHANGED
|
@@ -20,7 +20,12 @@ export const HANDLE_RE = /^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/;
|
|
|
20
20
|
export const SERVER_RE = /^[A-Za-z0-9_-]{1,32}$/;
|
|
21
21
|
export const SKILL_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/** Skills one bot may have on at once: each one on is in its prompt and its skill catalog every turn. */
|
|
24
|
+
export const MAX_SKILLS_ON = 50;
|
|
25
|
+
/** Skills one bot may keep, on or off: a bound on what bots.json holds. */
|
|
26
|
+
export const MAX_SKILLS = 200;
|
|
27
|
+
|
|
28
|
+
export const PALETTE =['#7c5cff', '#2f80ed', '#00a3a3', '#27ae60', '#f2994a', '#eb5757', '#d6409f', '#9b51e0', '#56ccf2', '#828282'];
|
|
24
29
|
|
|
25
30
|
/** A short, sortable, unique id. */
|
|
26
31
|
export function newId(prefix, now = Date.now()) {
|
|
@@ -138,6 +143,18 @@ function dedupeSkills(list) {
|
|
|
138
143
|
});
|
|
139
144
|
}
|
|
140
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Keep at most `max` skills on. The ones that were on in `prev` stay on first, then the
|
|
148
|
+
* rest in list order; past that they are switched off, never dropped.
|
|
149
|
+
*/
|
|
150
|
+
export function capSkillsOn(list, prev = [], max = MAX_SKILLS_ON) {
|
|
151
|
+
const on = list.filter((s) => s.enabled);
|
|
152
|
+
if (on.length <= max) return list;
|
|
153
|
+
const wasOn = new Set(prev.filter((s) => s.enabled).map((s) => s.id));
|
|
154
|
+
const keep = new Set([...on.filter((s) => wasOn.has(s.id)), ...on.filter((s) => !wasOn.has(s.id))].slice(0, max));
|
|
155
|
+
return list.map((s) => (s.enabled && !keep.has(s) ? { ...s, enabled: false } : s));
|
|
156
|
+
}
|
|
157
|
+
|
|
141
158
|
const kv = (o) => {
|
|
142
159
|
const out = {};
|
|
143
160
|
if (o && typeof o === 'object' && !Array.isArray(o)) {
|
|
@@ -176,7 +193,7 @@ export function normalizeBot(input, prev, seed = 0) {
|
|
|
176
193
|
const b = { ...(prev ?? {}), ...(input ?? {}) };
|
|
177
194
|
const now = Date.now();
|
|
178
195
|
const name = str(b.name, 60).trim() || prev?.name || 'New bot';
|
|
179
|
-
const skills = dedupeSkills((Array.isArray(b.skills) ? b.skills : []).map(normalizeSkill).filter(Boolean)).slice(0,
|
|
196
|
+
const skills = capSkillsOn(dedupeSkills((Array.isArray(b.skills) ? b.skills : []).map(normalizeSkill).filter(Boolean)).slice(0, MAX_SKILLS), prev?.skills);
|
|
180
197
|
const apps = (Array.isArray(b.apps) ? b.apps : []).map(normalizeApp).filter(Boolean).slice(0, 20);
|
|
181
198
|
const deny = Array.isArray(b.tools?.deny) ? [...new Set(b.tools.deny.map(String).filter(Boolean))].slice(0, 200) : [];
|
|
182
199
|
const model = b.model && typeof b.model === 'object' && str(b.model.provider) && str(b.model.model) ? { provider: str(b.model.provider, 200), model: str(b.model.model, 200) } : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kadaliao/dsh-bots",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Grok-style bots for DeepSeek Harness: create bots with their own avatar, persona, skills, apps and scheduled tasks; they message each other and a dispatcher bot hands out the work.",
|
|
6
6
|
"exports": {
|