Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions runtime/flybot-image/native-ds-bot-overlay.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ import { fileURLToPath, pathToFileURL } from 'node:url'
const sourceDir = fileURLToPath(new URL('../ds-bot-upstream/ds-bot/', import.meta.url))
const patch = fileURLToPath(new URL('./native-ds-bot.patch', import.meta.url))
const files = {
'src/host/tools.js': [
'a5c743b7c75c96498775808f029a5f15c7e08dbe6eaf33089d29b3c2a9ffb382',
'852dafff886dd8625d98152afe85432b8a22648d3627df5b61eddba4cea8c510',
],
'src/host/roster.js': [
'20461d2d4aeae6ca373e3431a5802317d1130468e1940d22032189134429f984',
'31c4ec4f68067b79ef2d4fc967e254e15b5854cbc1928eed831c725030dd77aa',
],
'src/host/prompt.js': [
'b15fd1dd8b046589533540b45388e6573e84fdf51bb09aa48a97e694c1e83c21',
'ebf5a93da2ef5941e0417f4018635350cb251212c9eb9384671f2ef9a7bbc2b8',
],
'client.js': [
'98713d86c6cbf85adab1d0a2d303140778d9ed85fb2220abdadfab377a5f539f',
'8e97d8e25cc1e04ec36f8b7449dc644e1d2d31ec5d6a8fe4071df35701806308',
Expand Down
107 changes: 107 additions & 0 deletions runtime/flybot-image/native-ds-bot.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2049,3 +2049,110 @@ diff --git a/src/host/groups.js b/src/host/groups.js
&& (noticeOnly ? !round.starting : round.nudge !== undefined && !round.closed && !round.abort?.signal.aborted))
if (running !== undefined) {
if (extra.failed !== undefined) {
diff --git a/src/host/tools.js b/src/host/tools.js
--- a/src/host/tools.js
+++ b/src/host/tools.js
@@ -477,7 +477,13 @@
const served = new Set((await rt.catalog()).filter(entry => entry.needsKey !== true && rt.isLocalAgentRef?.(entry.ref) !== true).map(entry => entry.ref))
const fallback = [state.prefs.defaultBotModel, creator?.model].find(ref => ref && served.has(ref))
const model = args.model || fallback
- const bot = await rt.createBot({ ...args, avatar: avatar === undefined ? undefined : { image: avatar }, model, workDir, effort: args.effort, section: args.section, createdBy: creator?.id })
+ const create = flybotWorkspace => rt.createBot({ ...args, avatar: avatar === undefined ? undefined : { image: avatar }, model, workDir, effort: args.effort, section: args.section, createdBy: creator?.id, flybotWorkspace })
+ const workspace = rt.flybotWorkspaceTeam?.scope(exec.agent?.session?.id ?? exec.agent?.id)
+ if (workspace) {
+ const bot = await workspace.createBot({ name: name.slice(0, 40), role: String(args.role ?? '').trim().slice(0, 24), instructions: String(args.instructions ?? '').trim() }, create)
+ return `Created and added ${bot.name} to the user's FlyBot agent directory. Chat: ${bot.url}`
+ }
+ const bot = await create()
return `Created ${bot.name}${workDir ? `, working in ${workDir}` : ''}. It is greeting the user now.`
} catch (error) {
return `Could not create the Bot: ${error.message}`
@@ -631,9 +637,9 @@

rt.teamTools.push(defineTool({
name: 'create_group',
- description: 'Main Bot only. Create a group chat with the user and some Bots. You join it as its admin unless you name another member.',
+ description: 'Main Bot only. Create a group with the user and the specified Bots. A FlyBot workspace group adds only the specified Bots. In DS Bot local groups you join as admin unless another is named.',
parameters: {
- members: { type: 'array', required: true, items: { type: 'string' }, description: 'Exact names of the other Bots to add; you are added automatically' },
+ members: { type: 'array', required: true, items: { type: 'string' }, description: 'Exact names of the Bots to add' },
name: { type: 'string', description: 'Group name; defaults to the member names' },
notice: { type: 'string', description: 'Shared instructions every member reads before speaking in this group; at most 2000 characters' },
admin: { type: 'string', description: 'Member who leads the group; defaults to you' },
@@ -647,6 +653,15 @@
if (!rt.isMain(self)) return 'Only a Main Bot can create group chats. Ask a Main Bot instead.'
const { bots, unknown } = resolveBots(args.members)
if (unknown.length > 0) return `No Bot named ${unknown.join(', ')}. Team: ${teamNames()}`
+ const workspace = rt.flybotWorkspaceTeam?.scope(exec.agent?.session?.id ?? exec.agent?.id)
+ if (workspace) {
+ try {
+ const group = await workspace.createGroup({ ...args, members: bots })
+ return `Created group "${group.title}" with ${bots.map(bot => bot.name).join(', ')}. Open it in the FlyBot sidebar: ${group.url}${group.noticeSaved ? '' : ' (the notice could not be saved)'}`
+ } catch (error) {
+ return `Could not create the group: ${error.message}`
+ }
+ }
const admin = args.admin ? rt.findBot(args.admin) : rt.botOf(self)
if (admin === undefined) return `No Bot named ${args.admin}. Team: ${teamNames()}`
const members = [...new Set([self, ...bots.map(bot => bot.id), admin.id])]
@@ -1189,12 +1204,16 @@
const filterBotAssembly = (agent, held) => {
if (held.filtered === true || typeof agent.ctx?.on !== 'function') return
const filterTools = agent.ctx.on('llm/stream', function filterBuiltinTools(options, next) {
+ // The LLM service waterfall is shared. A specialist's restrictions must
+ // never drop tools from the Chief's concurrent or following model call.
+ if (options.sessionId !== agent.session?.id) return next()
const hidden = rt.hiddenBuiltinTools(agent.session?.id)
if (!options.tools?.some(tool => hidden.has(tool.name))) return next()
return agent.ctx.llm.stream({ ...options, tools: options.tools.filter(tool => !hidden.has(tool.name)) })
})
if (typeof filterTools === 'function') held.disposers.push(filterTools)
- const dispose = agent.ctx.on('system-prompt/assemble', async (_assembly, _context, next) => {
+ const dispose = agent.ctx.on('system-prompt/assemble', async (_assembly, context, next) => {
+ if (context?.agent?.session?.id !== agent.session?.id) return next()
const assembled = await next()
const hidden = new Set([...HIDDEN_TOOLS, ...rt.hiddenBuiltinTools(agent.session?.id)])
// DSH 0.2.2 adds the tool list after this waterfall (#814), so only an
diff --git a/src/host/roster.js b/src/host/roster.js
--- a/src/host/roster.js
+++ b/src/host/roster.js
@@ -190,7 +190,7 @@
return holdName('bot', cleanName, () => buildBot(cleanName, options))
}

- async function buildBot(cleanName, { role = '', instructions = '', color, brief = '', createdBy, main = false, avatar, model, effort, workDir, copyOf, pickModel = false, section, sectionId }) {
+ async function buildBot(cleanName, { role = '', instructions = '', color, brief = '', createdBy, main = false, avatar, model, effort, workDir, copyOf, pickModel = false, section, sectionId, flybotWorkspace }) {
const cleanAvatarValue = cleanAvatar(avatar)
// The model is fixed at creation, so a later change of the DSH default leaves it alone.
const modelRef = model ? await rt.resolveModel(model) : pickModel ? undefined : await rt.defaultBotModel()
@@ -225,6 +225,7 @@
createdBy: createdBy ?? null,
capabilities: [],
packs: [],
+ ...(flybotWorkspace ? { flybotWorkspace } : {}),
}
if (main) state.mainBotIds.push(id)
const creator = rt.botOf(createdBy)
diff --git a/src/host/prompt.js b/src/host/prompt.js
--- a/src/host/prompt.js
+++ b/src/host/prompt.js
@@ -51,12 +51,19 @@
const bot = rt.botOf(self)
if (bot !== undefined) {
const main = rt.isMainForTurn?.(id) ?? rt.isMain(self)
+ const workspace = main && rt.flybotWorkspaceTeam?.scope(id)
return [
'# Your identity',
`You are ${bot.name}, a Bot on the user's team in DS Bot.${bot.role ? ` Your role: ${bot.role}.` : ''}`,
bot.instructions ? `\n${bot.instructions}` : '',
'',
main ? `${MAIN_RULES}\n\n${TEAM_RULES}` : TEAM_RULES,
+ ...(workspace ? [
+ '',
+ '## FlyBot personal workspace',
+ 'When the user asks you to create or assemble a team, use list_bots to reuse existing specialists, call create_bot for missing roles, and call create_group with their exact names. Use DS Bot tool discovery if these tools are not listed directly. You can do this from the current conversation.',
+ 'FlyBot shared groups include only the Bots you list. Include yourself only if the user asks. Supply the name and members, plus a notice if requested. Leave admin, reply mode, and section to group settings. After the tools confirm creation, name the actual Bots and link to the group using the returned link.',
+ ] : []),
].join('\n')
}
const room = rt.roomOf(id)
5 changes: 4 additions & 1 deletion runtime/flybot-image/plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ export function apply(ctx, config = {}) {
}
if (stored.length) options.onStaged?.(stored)
bridge.requireModel(botId)
return runTurn(rt, ctx, botId, text, requestId, undefined, parts, {
const turn = () => runTurn(rt, ctx, botId, text, requestId, undefined, parts, {
sessionId, onProgress: options.onProgress, onPhase: options.onPhase, signal: options.signal,
managedGroup: options.managedGroup,
})
return options.personalTeamScope && rt.flybotWorkspaceTeam
? rt.flybotWorkspaceTeam.run({botId,sessionId,requestId,scope:options.personalTeamScope}, turn)
: turn()
}, botId)
const readNativeAttachment = async file => {
const store = attachmentStore()
Expand Down
Loading
Loading