Skip to content
Open
2 changes: 1 addition & 1 deletion ds-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Tested with dsh `0.2.2-rc.1` (Web and Desktop).
- **Long-lived Bots**: each Bot is a dsh Session in the "DS Bot" workspace, with its own name, role, instructions and model.
- **Working folders**: a Bot can work in a folder you choose instead of the team workspace, and a group chat can set one folder for all its members there. Pick it in the Bot's settings or details panel or in the group's settings, or ask a Bot (`update_bot`, `update_group`). After a change, the chat goes on in a fresh part that starts in the new folder. When a Bot sets a folder outside the team workspace, or adds a Bot to a group that works in one, it asks for your approval if those Bots can only write in their folder. Folders that hold dsh data (`$DSH_HOME`, the team's data) are refused. The team workspace itself moves in Settings > General > Locations; Bots and groups that work there go on in a fresh part in the new folder, and the old folder keeps its files.
- **Permission presets**: each Bot runs with its own dsh permission preset (Read only, Workspace or Full access), set in its details panel. A group chat can run all its members with one preset there, in place of their own: turn on **Same for every member** under Permissions in the group's settings. Only you set permissions; Bots cannot change them.
- **Bots work together**: `message_bot` sends a message to another Bot, `create_bot` and `update_bot` add and set up Bots (including a profile photo from a local image file or a data URL), and `ask_user` asks you a question without blocking the other Bots. `show_view` draws a card in a Bot's own chat — text, metrics, tables, charts, inputs with local formulas, progress, choices, confirmations, short forms and sandboxed HTML; an interactive card waits for your answer. `/side` (or **Side chat** in the panel's `···` menu) opens a side chat in the right panel that answers from a snapshot of the Bot's chat without running tools or interrupting its work. A Bot can also be marked **Private** in its settings: other Bots cannot read its working folder, memory or chat, and its outbound sharing needs your approval.
- **Bots work together**: `message_bot` sends a message to another Bot, `create_bot` and `update_bot` add and set up Bots (including a profile photo from a local image file or a data URL), and `ask_user` asks you a question without blocking the other Bots. A question card closes when the Bot finishes a later turn you can see that asks nothing, or when a Main Bot withdraws it with `void_question`; a turn that only answers another Bot leaves it open, and a late click on a closed card is refused. `show_view` draws a card in a Bot's own chat: text, metrics, tables, charts, inputs with local formulas, progress, choices, confirmations, short forms and sandboxed HTML; an interactive card waits for your answer. `/side` (or **Side chat** in the panel's `···` menu) opens a side chat in the right panel that answers from a snapshot of the Bot's chat without running tools or interrupting its work. A Bot can also be marked **Private** in its settings: other Bots cannot read its working folder, memory or chat, and its outbound sharing needs your approval.
- **Group chats**: in admin-first mode the admin answers first and calls in other members with `@Name`; in all-members mode members speak in order. Members `@`-mentioned in the same message start work in parallel. Type `@` to pick a member from a list, or use **+ → Reference a chat** to attach another Bot's chat as context. A member with nothing new to add stays quiet (`[PASS]`). For multi-stage work, the admin can align on and run a group **Goal** (`group_goal`), assigning tasks per stage and checking evidence before advancing. Each member has its own hidden Session per group, so a group never reads a Bot's private chat.
- **Roles and permissions**:

Expand Down
2,153 changes: 1,190 additions & 963 deletions ds-bot/client.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion ds-bot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ import * as usage from './src/host/usage.js'
import * as update from './src/host/update.js'
import * as dshUpdate from './src/host/dsh-update.js'
import * as thinking from './src/host/thinking.js'
import * as operatorTasks from './src/host/operator-tasks.js'
import * as channel from './src/host/channel.js'
import * as feed from './src/host/feed.js'
import * as im from './src/host/im/index.js'
import * as officeSkills from './src/host/office-skills.js'
import * as goalSkills from './src/host/goal-skills.js'
import * as localAgents from './src/host/local-agents/index.js'
import * as creditGuard from './src/host/credit-guard.js'

export { COLORS } from './src/host/constants.js'

Expand All @@ -58,7 +60,7 @@ export const inject = ['llm', 'tools', 'systemPrompt', 'sessionController', 'ses
// install. Listeners run and tools are listed in registration order, so this order holds:
// usage meters model requests after every listener that rewrites them. privacy checks a
// call before the hooks of tools do, so a closed call never reaches a card they show.
const MODULES = [diagnostics, store, models, providers, permissions, turns, steer, handoffs, requests, delivery, roster, folders, privacy, agents, prompt, timeContext, tools, chatIndex, groups, groupLog, goals, approvals, resume, memory, parts, images, avatarLibrary, secrets, connectors, capabilities, learning, schedules, browser, browserPlugins, computer, usage, update, dshUpdate, thinking, feed, im, channel, officeSkills, goalSkills, localAgents]
const MODULES = [diagnostics, store, models, providers, permissions, turns, steer, handoffs, requests, delivery, roster, folders, privacy, agents, prompt, timeContext, tools, chatIndex, groups, groupLog, goals, approvals, resume, memory, parts, images, avatarLibrary, secrets, connectors, capabilities, learning, schedules, browser, browserPlugins, computer, usage, update, dshUpdate, thinking, feed, im, operatorTasks, channel, officeSkills, goalSkills, localAgents, creditGuard]

export function apply(ctx, config = {}) {
createRuntime(ctx, config)
Expand Down
12 changes: 12 additions & 0 deletions ds-bot/src/client/brainstorm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// The composer's Brainstorm row. It only types the word at the caret: the word itself
// is what switches a Bot into its show-me-options-first stance (the operator's
// AGENTS.md), so no mode flips and nothing else is sent.
export const BRAINSTORM_TEXT = 'brainstorm '

export const canBrainstorm = inputActions => typeof inputActions?.insertText === 'function'

export function insertBrainstorm(inputActions) {
if (!canBrainstorm(inputActions)) return false
inputActions.insertText(BRAINSTORM_TEXT, inputActions.captureInsertion?.())
return true
}
8 changes: 7 additions & 1 deletion ds-bot/src/client/composer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { createElement as h, Fragment, useEffect, useMemo, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
import { ChatsIcon, ClockIcon, GoalIcon, MicIcon, PaperclipIcon, PeopleIcon, PlusIcon, WaveIcon } from './icons.js'
import { BulbIcon, ChatsIcon, ClockIcon, GoalIcon, MicIcon, PaperclipIcon, PeopleIcon, PlusIcon, WaveIcon } from './icons.js'
import { canSetGoal } from './goal.js'
import { BotMark } from './mark.js'
import { stepMenuFocus, useLinger, useViewport, viewBottom } from './motion.js'
import { t } from './i18n.js'
import { insertComposerNewline, sendsOnEnter } from './enter-key.js'
import { enterSteers, steerable } from './enter-steer.js'
import { canBrainstorm, insertBrainstorm } from './brainstorm.js'

// -------------------------------------------------------------------------
// Composer: dictation mic and the voice-chat button. The shell's send
Expand Down Expand Up @@ -200,6 +201,10 @@ export function ComposerPlus({ sessionId, inputActions, useInput, useRoster, act
actions.referenceChat(sessionId, inputActions?.captureInsertion?.())
}
const canReference = typeof inputActions?.captureInsertion === 'function' && actions.canReferenceChat()
const brainstorm = () => {
setOpen(null)
insertBrainstorm(inputActions)
}
const room = roster.roomsById?.[sessionId]
const goal = () => {
setOpen(null)
Expand All @@ -216,6 +221,7 @@ export function ComposerPlus({ sessionId, inputActions, useInput, useRoster, act
},
shown.files ? h('button', { type: 'button', role: 'menuitem', onClick: attach }, h(PaperclipIcon), h('span', { className: 'bt-menu-label' }, t('Add files'))) : null,
canReference ? h('button', { type: 'button', role: 'menuitem', onMouseDown: keepComposerFocus, onClick: reference }, h(ChatsIcon), h('span', { className: 'bt-menu-label' }, t('Reference a chat'))) : null,
canBrainstorm(inputActions) ? h('button', { type: 'button', role: 'menuitem', onMouseDown: keepComposerFocus, onClick: brainstorm }, h(BulbIcon), h('span', { className: 'bt-menu-label' }, t('Brainstorm'))) : null,
canSetGoal(room, roster) ? h('button', { type: 'button', role: 'menuitem', onClick: goal }, h(GoalIcon), h('span', { className: 'bt-menu-label' }, t('Set a goal'))) : null,
h('button', { type: 'button', role: 'menuitem', onClick: schedule }, h(ClockIcon), h('span', { className: 'bt-menu-label' }, t('Scheduled task')))), document.body) : null)
}
2 changes: 2 additions & 0 deletions ds-bot/src/client/details-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ModelMenu, modelOf } from './model-menu.js'
import { FolderMenu } from './folder-menu.js'
import { MemoryRow } from './memory-panel.js'
import { ScheduleSummary } from './schedules.js'
import { OperatorTasks } from './operator-tasks.js'
import { useGlide, useMorph } from './motion.js'
import { MemberApprovals, MemberState, StopMemberWork, StopRoomWork, useMemberWork, workState } from './member-status.js'
import { canSetGoal, goalView, hasGoalAdmin } from './goal.js'
Expand Down Expand Up @@ -339,6 +340,7 @@ export function DetailsDrawer({ sessionId, startRenaming, startTab, hasStrip, ro
usage ? h('div', { key: 'usage' }, h('div', { className: 'bt-section-title' }, t('Usage')),
h('div', { className: 'bt-kv' }, h('span', null, bot.name), h('span', null, usage))) : null,
h(ScheduleSummary, { key: 'routines', bot, actions }),
h(OperatorTasks, { key: 'operator-tasks', bot, roster }),
] : null,
bot && tab === 'browser' ? h(BrowserCards, { bot, sessionId, roster, actions, useBrowserTabs, useBrowserPages }) : null)]
}
2 changes: 2 additions & 0 deletions ds-bot/src/client/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AgentBadge } from './agent-badge.js'
import { ActivityIndicator } from './activity-row.js'
import { clockLabel, openingTurn, unseenSince } from './cells.js'
import { GoalIsland, goalView } from './goal.js'
import { OperatorBadge, operatorCount, unresolvedCount } from './operator-tasks.js'
import { viewBottom } from './motion.js'
import { t } from './i18n.js'

Expand Down Expand Up @@ -131,6 +132,7 @@ export function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus
h('span', { className: 'bt-pill-goal' }, h('span', { className: 'bt-pill-ico', 'aria-hidden': true }, h(GoalIcon)), h('span', { className: 'bt-pill-title' }, view.title)),
h('span', { className: 'bt-pill-name' }, name))
: h('span', { className: 'bt-pill-name' }, away ? t('Back to chat') : bot?.name ?? room?.name ?? (title || t('New chat')), !away && bot?.engine ? h(AgentBadge, { engine: bot.engine }) : null),
bot && !away ? h(OperatorBadge, { operator: operatorCount(roster, bot.id), unresolved: unresolvedCount(roster, bot.id) }) : null,
goalShown && view?.number !== undefined ? h('span', { className: 'bt-pill-count' }, `${view.number}/${view.count}`) : null,
h(MemoryNotice, { shown: memoryNotice }),
h('span', { className: 'bt-pill-go', 'aria-hidden': true }, h(GoArrow)))
Expand Down
35 changes: 35 additions & 0 deletions ds-bot/src/client/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const ZH = {
Working: '进行中',
'Waiting for your answer': '等你回答',
'Waiting for {names}': '等 {names} 交回',
'Waiting for a teammate': '等队友交回工作',
'Unread activity': '有未读',
'Not read yet': '未读',
Search: '搜索',
Expand Down Expand Up @@ -1260,6 +1261,7 @@ const ZH = {
'Add files': '添加文件',
'Reference a chat': '引用对话',
'Chat with {name}': '与 {name} 的对话',
Brainstorm: '头脑风暴',
'Scheduled task': '定时任务',
'Send to': '发给',
'Scheduled task: {text}': '定时任务:{text}',
Expand Down Expand Up @@ -1313,6 +1315,39 @@ const ZH = {
'New task': '新建任务',
'No scheduled tasks yet.': '还没有定时任务。',
'No scheduled tasks yet. Add one': '还没有定时任务,去添加',
'Operator Tasks': '你交给它的任务',
'Active Tasks': '进行中的任务',
'Unresolved Tasks': '待你处理的任务',
'{title} · {count}': '{title} · {count}',
'Your ask': '你的要求',
'The ask is not recorded': '没有记录你的要求',
'Relayed by {name}': '由 {name} 转达',
'Nothing of yours in hand.': '你交给它的任务都完成了。',
'Nothing running right now.': '现在没有在进行的工作。',
'Nothing waiting on you.': '没有等你处理的事。',
'1 task from you': '有 1 件事来自你',
'{count} tasks from you': '有 {count} 件事来自你',
'1 task waits on you': '有 1 件事等你处理',
'{count} tasks wait on you': '有 {count} 件事等你处理',
'{yours} from you, {waiting} waiting on you': '{yours} 件来自你,{waiting} 件等你处理',
'a teammate': '一位队友',
'a group': '一个群聊',
'in group "{name}"': '在群聊「{name}」里',
'Question card': '问题卡片',
'Answer card': '待回答的卡片',
'A card waiting for your answer': '一张等你回答的卡片',
'Key request': '密钥请求',
'Tool approval': '工具审批',
'Decision {id}': '决定 {id}',
'due {date}': '截止 {date}',
'not shown on a card yet': '还没有以卡片形式出现',
'Working now': '正在工作',
'Moving on to a fresh part': '正在换到新的对话段',
'Running {tool} on {target}': '正在对 {target} 运行 {tool}',
'Running {tool}': '正在运行 {tool}',
Order: '委托',
'From {name}': '来自 {name}',
'Waiting on': '在等',
'Automation tasks are off in DSH': 'DSH 的「自动化任务」没有打开',
'No such Bot': '没有这个 Bot',
'No such Bot or group chat': '没有这个 Bot 或群聊',
Expand Down
2 changes: 2 additions & 0 deletions ds-bot/src/client/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export const ConnectorIcon = lineIcon(['M7 10a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5
export const SignOutIcon = lineIcon(['M8.5 17H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h2.5', 'M10 10h6.5', 'M13.5 7l3 3-3 3'])
export const SignInIcon = lineIcon(['M11.5 3H14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-2.5', 'M3.5 10H10', 'M7 7l3 3-3 3'])
export const PaperclipIcon = lineIcon(['M15.5 9.5l-5.6 5.6a3.4 3.4 0 0 1-4.8-4.8l6.1-6.1a2.25 2.25 0 0 1 3.2 3.2l-6 6a1.1 1.1 0 0 1-1.6-1.6l5.5-5.5'])
// A bulb on a short base: an idea, for the composer's brainstorm row.
export const BulbIcon = lineIcon(['M7.5 14.5h5', 'M8.25 17h3.5', 'M7.5 12.5a5 5 0 1 1 5 0v2h-5z'])
export const ClockIcon = lineIcon(['M10 3.5a6.5 6.5 0 1 1 0 13 6.5 6.5 0 0 1 0-13z', 'M10 6.5V10l2.5 1.5'])
// Six broad, shallow teeth around a wide hub: it reads as a gear even at 15px.
export const GearIcon = lineIcon(['M10 7.4a2.6 2.6 0 1 1 0 5.2 2.6 2.6 0 0 1 0-5.2z', 'M7.85 4.4l.29-1.87a7.7 7.7 0 0 1 3.72 0l.29 1.87a6 6 0 0 1 1.63.94l1.76-.69a7.7 7.7 0 0 1 1.86 3.23l-1.47 1.18a6 6 0 0 1 0 1.88l1.47 1.18a7.7 7.7 0 0 1-1.86 3.23l-1.76-.69a6 6 0 0 1-1.63.94l-.29 1.87a7.7 7.7 0 0 1-3.72 0l-.29-1.87a6 6 0 0 1-1.63-.94l-1.76.69a7.7 7.7 0 0 1-1.86-3.23l1.47-1.18a6 6 0 0 1 0-1.88L2.6 7.88a7.7 7.7 0 0 1 1.86-3.23l1.76.69a6 6 0 0 1 1.63-.94z'])
Expand Down
23 changes: 21 additions & 2 deletions ds-bot/src/client/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { call } from './api.js'
import { isHex, inkText, paintCss } from './inks.js'
import { DEFAULT_MASK, SHAPES, markupCache, maskOf } from './characters.js'
import { createSource, EMPTY_ROSTER, indexRoster, isAgentSession } from './sources.js'
import { createSource, EMPTY_ROSTER, indexRoster, isAgentSession, ownedSessionIds, publishOwnedSessions } from './sources.js'
import { teamActions } from './team-actions.js'
import { themeCss, shellTokens, registry, registerShape, registerTheme, allThemes, layoutOf, widthOf, flatWidthOf } from './themes.js'
import { MENTION_ORIGIN, currentPart } from './text.js'
Expand Down Expand Up @@ -40,6 +40,7 @@ import { GROUP_SETTINGS_CSS } from './group-settings.js'
import { FOLDER_CSS } from './folder-menu.js'
import { USAGE_CSS } from './usage-page.js'
import { SCHEDULE_CSS } from './schedules.js'
import { OPERATOR_TASKS_CSS } from './operator-tasks.js'
import { STORAGE, migrateStorage } from './storage.js'
import { noteLeft, setUnread, sharedMap, toggleReaction } from './shared-map.js'
import { freePriority, groupsFor, readMode, surfaceGroups, writeMode } from './surface.js'
Expand Down Expand Up @@ -68,6 +69,18 @@ export function apply(ctx) {
let savedPrefs = {}
try { savedPrefs = JSON.parse(localStorage.getItem(PREFS_KEY) ?? '{}') ?? {} } catch { savedPrefs = {} }
const roster = createSource({ ...EMPTY_ROSTER, prefs: savedPrefs })
// local: sidebar-coexistence. The shell files every Session it lists; the ones this
// plugin owns (Bot chats and parts, group Sessions, Agent Sessions) are published
// here so the shell can keep them out of its own sections.
ctx.effect(() => {
const publish = () => publishOwnedSessions(window, ownedSessionIds(roster.getSnapshot()))
const off = roster.subscribe(publish)
publish()
return () => {
off()
publishOwnedSessions(window, [])
}
}, 'ds-bot: publish owned sessions')
const unreadStore = sharedMap(STORAGE.unread)
const reactionStore = sharedMap(STORAGE.reactions)
// When each conversation was last left; a visit compares new turns against it.
Expand Down Expand Up @@ -198,6 +211,7 @@ export function apply(ctx) {
const live = {}
if (value.connectors !== undefined && JSON.stringify(value.connectors) !== JSON.stringify(current.connectors ?? [])) live.connectors = value.connectors
if (value.capabilityStatuses !== undefined && JSON.stringify(value.capabilityStatuses) !== JSON.stringify(current.capabilityStatuses ?? {})) live.capabilityStatuses = value.capabilityStatuses
if (value.operatorTasks !== undefined && JSON.stringify(value.operatorTasks) !== JSON.stringify(current.operatorTasks ?? {})) live.operatorTasks = value.operatorTasks
if (value.learning !== undefined && JSON.stringify(value.learning) !== JSON.stringify(current.learning ?? {})) live.learning = value.learning
if (value.learningSettled !== undefined && JSON.stringify(value.learningSettled) !== JSON.stringify(current.learningSettled ?? {})) live.learningSettled = value.learningSettled
if (value.btwCards !== undefined && JSON.stringify(value.btwCards) !== JSON.stringify(current.btwCards ?? {})) live.btwCards = value.btwCards
Expand Down Expand Up @@ -1033,6 +1047,7 @@ export function apply(ctx) {
[MODEL_CSS + FOLDER_CSS + BOT_SETTINGS_CSS + AGENT_CARDS_CSS + GROUP_SETTINGS_CSS + AVATAR_LIBRARY_CSS, 'models'],
[USAGE_CSS, 'usage'],
[SCHEDULE_CSS, 'schedules'],
[OPERATOR_TASKS_CSS, 'operator-tasks'],
[FEEDBACK_CSS, 'feedback'],
[ABOUT_CSS, 'about'],
[MEMBER_CSS, 'members'],
Expand Down Expand Up @@ -1150,7 +1165,11 @@ export function apply(ctx) {
const sync = () => {
const list = ctx.sessions.list.getSnapshot()
const main = Object.values(list.byId ?? {}).find(session => (session?.retainedBy?.mainView ?? 0) > 0)?.id
const plain = isAgentSessionId(main)
// local: sidebar-coexistence. A Session the roster does not own was opened from the
// shell's own sections, so it shows as the native dsh page.
const snap = roster.getSnapshot()
const unowned = main !== undefined && !ownedSessionIds(snap).includes(main)
const plain = isAgentSessionId(main) || (snap.ready && unowned)
setPlain(plain)
if (plain) dropPanels()
if (main === previous) return
Expand Down
Loading
Loading