A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Let every Bot rename itself again
lulu feizhu2c23db9bcebe
diff --git a/ds-bot/src/host/prompt.js b/ds-bot/src/host/prompt.jsindex 6f89201d..9309a3b3 100644--- a/ds-bot/src/host/prompt.js+++ b/ds-bot/src/host/prompt.js@@ -14,7 +14,7 @@ const TEAM_RULES = ['- Only for a direct user request in your own chat that needs several steps: write one short sentence of normal reply text before your first tool call, and make that tool call in the same response. Never start such a task with tools alone or end it with a promise. On long tasks, give brief factual updates only at meaningful milestones, then keep working.','- For "[Group chat …]", "[Message from …]", or "[Reply from …]" messages, do not write plans or progress updates: use tools silently, then reply with the answer. Simple answers do not need progress messages.','- Offer choices with ask_user (a tap-to-answer card) instead of long option lists in text. Calling it ends your turn at once, so write everything you want to say before the call, in the same reply. The answer arrives as the user\'s next message.',- '- update_bot changes your own settings: role label, color, model, working folder, or instructions. Only a Main Bot can rename a Bot. Leave out bot to change yourself. Use it when the user asks you to change how you are set up, for example to work in a project folder (work_dir, a full path). Only a Main Bot can change other Bots; when another Bot needs changing, ask a Main Bot.',+ '- update_bot changes your own settings: name, role label, color, model, working folder, or instructions. Leave out bot to change yourself. Use it when the user asks you to change how you are set up, for example to work in a project folder (work_dir, a full path). Only a Main Bot can change other Bots; when another Bot needs changing, ask a Main Bot.','- You may be in group chats with the user and other Bots. You speak in each group from a separate conversation of yours, apart from your own chat with the user. There your turn arrives as a "[Group chat …]" message that shows the speaking order, and your reply is posted to the group. When someone there asks you to do something, do the work in that turn: the group goes on without waiting, and your final reply is posted when you finish. Any member can hand work to another with @Name, and the one that asked answers the result. In a group, read_own_chat shows your own chat (the group sees that you looked; share only what the group needs). In your own chat, read_group_chat shows what was said in a group. A group may have an admin, who steers it: the admin can call members with @Name, change the group with update_group, and start a new discussion there with post_to_group.','- When you need a key, token, or password, call request_secret: the user types it into a secure card and you never see it. Never ask the user to paste one into the chat. Use it through its environment variable ($DSH_SECRET_<NAME> in bash, $env:DSH_SECRET_<NAME> in PowerShell) and never print it. list_secrets shows which keys exist.','- web_search results say which search backend answered. If web_search fails, never guess URLs or present pages you remember as search results: use a browser tool if you have one, otherwise tell the user that search is unavailable and the reason it gave.',diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.jsindex 3f797a8e..40bf166b 100644--- a/ds-bot/src/host/tools.js+++ b/ds-bot/src/host/tools.js@@ -201,7 +201,7 @@ export function install(rt) {ctx.tools.register(defineTool({name: 'update_bot',- description: 'Change a Bot\'s name, role, color, model, working folder, or instructions. Every Bot may change itself except its name; only a Main Bot may rename a Bot or change another Bot.',+ description: 'Change a Bot\'s name, role, color, model, working folder, or instructions. Every Bot may change itself; only a Main Bot may change another Bot.',parameters: {bot: { type: 'string', description: 'Current name of the Bot to change; leave out to change yourself' },name: { type: 'string', description: 'New name' },@@ -220,8 +220,6 @@ export function install(rt) {const bot = args.bot ? rt.findBot(args.bot) : callerif (bot === undefined) return `No Bot named ${args.bot}.`if (bot.id !== caller.id && !rt.isMain(self)) return 'Only a Main Bot can change another Bot. Leave out bot to change yourself, or ask a Main Bot with message_bot.'- // A rename would let a Bot pass itself off as a Bot that does not exist.- if (args.name !== undefined && String(args.name).trim() !== bot.name && !rt.isMain(self)) return 'Only a Main Bot can rename a Bot. When the user wants another Bot, ask a Main Bot with message_bot.'try {const { name: newName, role, instructions, color, model } = argsconst moving = typeof args.work_dir === 'string'diff --git a/ds-bot/test/update-bot.test.js b/ds-bot/test/update-bot.test.jsindex efb97391..1cc74699 100644--- a/ds-bot/test/update-bot.test.js+++ b/ds-bot/test/update-bot.test.js@@ -59,22 +59,15 @@ function start() {test('a Bot changes itself by leaving out bot, or by naming itself', async (t) => {const { tool, state, stop } = start()t.after(stop)- assert.equal(await tool('update_bot', { instructions: 'Lead the team' }, 'b2'), 'Updated Writer.')- assert.equal(state().bots.b2.instructions, 'Lead the team')- assert.equal(await tool('update_bot', { bot: 'Writer', role: '掌门', name: 'Writer' }, 'b2'), 'Updated Writer.')+ assert.equal(await tool('update_bot', { name: 'King', instructions: 'Lead the team' }, 'b2'), 'Updated King.')+ const king = state().bots.b2+ assert.equal(king.name, 'King')+ assert.equal(king.instructions, 'Lead the team')+ // Its current name resolves to it again.+ assert.equal(await tool('update_bot', { bot: 'King', role: '掌门' }, 'b2'), 'Updated King.')assert.equal(state().bots.b2.role, '掌门')})-test('only a Main Bot renames a Bot, so a Bot cannot pass itself off as another', async (t) => {- const { tool, state, stop } = start()- t.after(stop)- assert.match(await tool('update_bot', { name: 'Editor', instructions: 'Edit' }, 'b2'), /^Only a Main Bot can rename a Bot/)- assert.equal(state().bots.b2.name, 'Writer')- assert.equal(state().bots.b2.instructions, '')- assert.equal(await tool('update_bot', { bot: 'Writer', name: 'King' }, 'm1'), 'Updated King.')- assert.equal(await tool('update_bot', { name: 'Boss' }, 'm1'), 'Updated Boss.')-})-test('a Bot cannot change another Bot; a Main Bot can', async (t) => {const { tool, state, stop } = start()t.after(stop)