A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Let a saved key's purpose be edited on its own
Fei241131df959678df
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 662dd1c1..b6fc1d98 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -1495,7 +1495,7 @@ function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cardssecretSet: (payload) => after(call2("secret-set", payload)),secretAllow: (requestId) => after(call2("secret-allow", { requestId })),secretCancel: (requestId) => after(call2("secret-cancel", { requestId })),- secretUpdate: (name, scope) => after(call2("secret-update", { name, scope })),+ secretUpdate: (name, { scope, purpose } = {}) => after(call2("secret-update", { name, scope, purpose })),secretDelete: (name) => after(call2("secret-delete", { name })),connectorConnect: (id, token) => after(call2("connector-connect", { id, token })),connectorDisconnect: (id) => after(call2("connector-disconnect", { id })),@@ -4648,6 +4648,21 @@ function ScopeEditor({ secret, roster, onSave }) {));}+function PurposeEditor({ secret, onSave }) {+ const [purpose, setPurpose] = (0, import_react7.useState)(secret.purpose ?? "");+ const same = purpose.trim() === (secret.purpose ?? "");+ return (0, import_react7.createElement)(+ "div",+ { className: "bt-secret-edit-block" },+ (0, import_react7.createElement)("div", { className: "bt-secret-edit-label" }, t("What it is for")),+ (0, import_react7.createElement)(+ "div",+ { className: "bt-secret-inline" },+ (0, import_react7.createElement)("input", { className: "bt-input", "aria-label": t("What it is for"), placeholder: t("What it is for"), value: purpose, spellCheck: false, autoComplete: "off", onChange: (event) => setPurpose(event.target.value) }),+ (0, import_react7.createElement)("button", { type: "button", className: "bt-soft bt-soft-sm", disabled: same, onClick: () => onSave(purpose.trim()) }, t("Save"))+ )+ );+}function ValueEditor({ secret, onSave }) {const [value, setValue] = (0, import_react7.useState)("");const [replaced, setReplaced] = (0, import_react7.useState)(false);@@ -4707,7 +4722,8 @@ function SecretRow({ secret, roster, actions, run, open, onToggle }) {open ? (0, import_react7.createElement)("div",{ className: "bt-secret-edit" },- (0, import_react7.createElement)(ScopeEditor, { key: JSON.stringify(secret.scope), secret, roster, onSave: (scope) => run(actions.secretUpdate(secret.name, scope)) }),+ (0, import_react7.createElement)(ScopeEditor, { key: JSON.stringify(secret.scope), secret, roster, onSave: (scope) => run(actions.secretUpdate(secret.name, { scope })) }),+ (0, import_react7.createElement)(PurposeEditor, { key: secret.purpose ?? "", secret, onSave: (purpose) => run(actions.secretUpdate(secret.name, { purpose })) }),(0, import_react7.createElement)(ValueEditor, { secret, onSave: (value) => run(actions.secretSet({ name: secret.name, value })) }),(0, import_react7.createElement)("div",@@ -4830,6 +4846,7 @@ var SECRET_CSS = `.bt-secret-bot[aria-pressed=true]{background:var(--bt-active);color:var(--bt-ink);border-color:var(--bt-line-2)}.bt-secret-bot svg{width:13px;height:13px}.bt-secret-inline{display:flex;gap:8px;align-items:center}+.bt-secret-inline .bt-input{flex:1;height:34px}.bt-secret-row-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}.bt-secret-row-actions .bt-set-hint{flex:1}.bt-secret-danger{color:var(--bt-danger);display:inline-flex;align-items:center;gap:4px}diff --git a/ds-bot/src/client/secret-card.js b/ds-bot/src/client/secret-card.jsindex e1f329f5..17d5df3d 100644--- a/ds-bot/src/client/secret-card.js+++ b/ds-bot/src/client/secret-card.js@@ -199,6 +199,16 @@ function ScopeEditor({ secret, roster, onSave }) {h('button', { type: 'button', className: 'bt-soft bt-soft-sm', disabled: same, onClick: () => onSave(mode === 'all' ? 'all' : picked) }, t('Save access'))))}+function PurposeEditor({ secret, onSave }) {+ const [purpose, setPurpose] = useState(secret.purpose ?? '')+ const same = purpose.trim() === (secret.purpose ?? '')+ return h('div', { className: 'bt-secret-edit-block' },+ h('div', { className: 'bt-secret-edit-label' }, t('What it is for')),+ h('div', { className: 'bt-secret-inline' },+ h('input', { className: 'bt-input', 'aria-label': t('What it is for'), placeholder: t('What it is for'), value: purpose, spellCheck: false, autoComplete: 'off', onChange: event => setPurpose(event.target.value) }),+ h('button', { type: 'button', className: 'bt-soft bt-soft-sm', disabled: same, onClick: () => onSave(purpose.trim()) }, t('Save'))))+}+function ValueEditor({ secret, onSave }) {const [value, setValue] = useState('')const [replaced, setReplaced] = useState(false)@@ -233,7 +243,8 @@ function SecretRow({ secret, roster, actions, run, open, onToggle }) {: allowed.length === 0 ? h('span', { className: 'bt-tag' }, t('No Bot')): h('span', { className: 'bt-secret-faces', title: allowed.map(bot => bot.name).join(', ') }, allowed.slice(0, 5).map(bot => h(BotAvatar, { key: bot.id, bot, size: 20, badge: false, live: false }))))),open ? h('div', { className: 'bt-secret-edit' },- h(ScopeEditor, { key: JSON.stringify(secret.scope), secret, roster, onSave: scope => run(actions.secretUpdate(secret.name, scope)) }),+ h(ScopeEditor, { key: JSON.stringify(secret.scope), secret, roster, onSave: scope => run(actions.secretUpdate(secret.name, { scope })) }),+ h(PurposeEditor, { key: secret.purpose ?? '', secret, onSave: purpose => run(actions.secretUpdate(secret.name, { purpose })) }),h(ValueEditor, { secret, onSave: value => run(actions.secretSet({ name: secret.name, value })) }),h('div', { className: 'bt-secret-row-actions' },confirm@@ -336,6 +347,7 @@ export const SECRET_CSS = `.bt-secret-bot[aria-pressed=true]{background:var(--bt-active);color:var(--bt-ink);border-color:var(--bt-line-2)}.bt-secret-bot svg{width:13px;height:13px}.bt-secret-inline{display:flex;gap:8px;align-items:center}+.bt-secret-inline .bt-input{flex:1;height:34px}.bt-secret-row-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}.bt-secret-row-actions .bt-set-hint{flex:1}.bt-secret-danger{color:var(--bt-danger);display:inline-flex;align-items:center;gap:4px}diff --git a/ds-bot/src/client/team-actions.js b/ds-bot/src/client/team-actions.jsindex dbed528f..a77d38e6 100644--- a/ds-bot/src/client/team-actions.js+++ b/ds-bot/src/client/team-actions.js@@ -77,7 +77,7 @@ export function teamActions({ call, after, partFor, roster, ui, live, cards, helsecretSet: payload => after(call('secret-set', payload)),secretAllow: requestId => after(call('secret-allow', { requestId })),secretCancel: requestId => after(call('secret-cancel', { requestId })),- secretUpdate: (name, scope) => after(call('secret-update', { name, scope })),+ secretUpdate: (name, { scope, purpose } = {}) => after(call('secret-update', { name, scope, purpose })),secretDelete: name => after(call('secret-delete', { name })),connectorConnect: (id, token) => after(call('connector-connect', { id, token })),connectorDisconnect: id => after(call('connector-disconnect', { id })),diff --git a/ds-bot/src/host/secrets.js b/ds-bot/src/host/secrets.jsindex 86c3e3b3..965dc7b5 100644--- a/ds-bot/src/host/secrets.js+++ b/ds-bot/src/host/secrets.js@@ -338,7 +338,8 @@ export function install(rt) {async 'secret-update'(body) {const secret = secrets.get(normalizeName(body.name))if (secret === undefined) throw new Error('No such key')- secret.scope = cleanScope(body.scope)+ if (body.scope !== undefined) secret.scope = cleanScope(body.scope)+ if (typeof body.purpose === 'string') secret.purpose = body.purpose.trim().slice(0, 300)secret.updatedAt = Date.now()const notes = []reconcile(secret.name, notes)diff --git a/ds-bot/test/secrets.test.js b/ds-bot/test/secrets.test.jsindex a4e844e0..80fc2c2d 100644--- a/ds-bot/test/secrets.test.js+++ b/ds-bot/test/secrets.test.js@@ -244,6 +244,27 @@ test('a Bot outside the scope gets an allow card, and allowing resolves it', asyassert.deepEqual(JSON.parse(readFileSync(join(bench.home, 'secrets.json'), 'utf8')).secrets, [])})+test('a key\'s purpose can be changed or cleared on its own', async (t) => {+ const bench = start()+ t.after(bench.stop)+ await bench.call('secret-set', { name: 'DEMO_TOKEN', value: fresh(), purpose: 'first', scope: 'all' })++ const changed = await bench.call('secret-update', { name: 'DEMO_TOKEN', purpose: 'renamed' })+ assert.equal(changed.value.purpose, 'renamed')+ assert.equal(changed.value.scope, 'all')+ const cleared = await bench.call('secret-update', { name: 'DEMO_TOKEN', purpose: '' })+ assert.equal(cleared.value.purpose, '')+ const scoped = await bench.call('secret-update', { name: 'DEMO_TOKEN', scope: ['b2'] })+ assert.deepEqual(scoped.value.scope, ['b2'])+ assert.equal(scoped.value.purpose, '')+ const both = await bench.call('secret-update', { name: 'DEMO_TOKEN', scope: 'all', purpose: 'kept' })+ assert.equal(both.value.scope, 'all')+ assert.equal(both.value.purpose, 'kept')+ const saved = JSON.parse(readFileSync(join(bench.home, 'secrets.json'), 'utf8')).secrets[0]+ assert.equal(saved.purpose, 'kept')+ assert.equal(saved.scope, 'all')+})+test('cards stay in a Bot\'s own chat; canceling tells the Bot', async (t) => {const bench = start()t.after(bench.stop)