Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Merge remote-tracking branch 'origin/dev' into fix/185-delegated-result-reaches-caller

Fei2411dadd12c4b547
diff --cc ds-bot/src/client/cells.js
index 6e09df9f,24c00cad..feb42b25
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@@ -351,12 -372,19 +372,19 @@@ export function TriggerCell({ node, ses
// The secret card itself shows what the user did; the note to the Bot stays out.
if (source.role === 'secret' || deferred) return null
if (source.role === 'post') {
- // A member's late failure, its work picked up after a restart, or its work the user
- // stopped shows as an event of the round it opens.
- if (source.failed !== undefined || source.resumed === true || source.stopped === true) return null
+ // A member's late failure, its work picked up after a restart, its work the user
+ // stopped, or the end of its work shows as an event of the round it opens.
+ if (source.failed !== undefined || source.resumed === true || source.stopped === true || source.done === true) return null
const room = roster.roomsById[sessionId]
const poster = roster.byId[source.senderSessionId] ?? { id: source.senderSessionId, name: source.senderName ?? t('a Bot'), color: 'gray' }
- return h(GroupMessage, { bot: poster, text: stripHeader(contentText(data.content)), room, roster, actions, msgKey: `${sessionId}:${data.turn}:post`, useUi })
+ // A post past what a message holds came as a file, with its start only.
+ const file = source.length === undefined ? undefined : (data.content ?? []).find(block => block?.type === 'file')?.attachment
+ const text = stripHeader(contentText(data.content))
+ // A trigger's data carries no turn; its event seq is the one durable name of this post.
+ return h(GroupMessage, {
+ bot: poster, text: file ? stripLongNote(text) : text, room, roster, actions, msgKey: `${sessionId}:post:${data.seq ?? node.key}`, useUi,
+ whole: file ? { length: source.length, load: () => actions.fileText(file) } : undefined,
+ })
}
if (source.role === 'report') {
return h(GroupEvent, { prefix: t('Replies from'), room: roster.roomsById[source.roomId], name: t('a group chat'), roster, actions })
diff --cc ds-bot/src/host/groups.js
index f53069d6,0586153b..e7a407fc
--- a/ds-bot/src/host/groups.js
+++ b/ds-bot/src/host/groups.js
@@@ -58,10 -57,9 +57,10 @@@ const lineText = (line, text = line.tex
if (line.kind === 'resumed') return `[${line.who}'s work here was cut off when DeepSeek Harness restarted; it is picking it back up and posts when done]`
if (line.kind === 'cut') return `[${line.who}'s work here was cut off by a restart again, so it stopped; ask it to go on if it still matters]`
if (line.kind === 'stopped') return `[The user stopped ${line.who}'s work here]`
+ if (line.kind === 'done') return `[${line.who} finished the work it was asked for]`
- return `${line.who}: ${line.text}`
+ return `${line.who}: ${text}`
}
- const transcript = lines => lines.map(lineText).join('\n')
+ const transcript = (lines, textOfLine = line => line.text) => lines.map(line => lineText(line, textOfLine(line))).join('\n')
// Models often echo the transcript format ("Name: …") despite the instruction.
export const stripOwnName = (name, text) => text.replace(new RegExp(`^\\s*\\**${escapeRegExp(name)}\\**\\s*[::]\\s*`), '').trim()
@@@ -413,15 -504,19 +505,19 @@@ export function install(rt)
const posts = queued.length > 0 ? queued : [{ text: '' }]
const startSeq = room.seq + 1
// The opening greeting is a cue for the admin, not a line of the group; a member's
- // late failure, its work picked up after a restart, or its work the user stopped is
- // an event of the round.
- const event = item => item.failed || item.resumed || item.stopped
+ // late failure, its work picked up after a restart, its work the user stopped, or
+ // the end of work whose result it already posted is an event of the round.
+ const event = item => item.failed || item.resumed || item.stopped || item.done
for (const post of posts.filter(item => !item.kickoff && !event(item))) {
// Image readings go into the log only; `@` names are picked from what the user typed.
- const text = post.images === undefined ? post.text : [post.text, ...await rt.imagesForGroup(post.images, room.id)].filter(Boolean).join('\n')
- appendRoom(room, post.botId
- ? { who: rt.botOf(post.botId)?.name ?? post.name ?? 'Bot', botId: post.botId, text }
- : { who: 'User', text })
+ // A file stays with its line and reaches each member the line is shown to.
+ const readings = post.images === undefined ? [] : await rt.imagesForGroup(post.images, room.id)
+ const text = [post.text, ...readings, ...(post.files ?? []).map(fileLine)].filter(Boolean).join('\n')
+ appendRoom(room, {
+ ...(post.botId ? { who: rt.botOf(post.botId)?.name ?? post.name ?? 'Bot', botId: post.botId } : { who: 'User' }),
+ text,
+ ...(post.files === undefined ? {} : { files: post.files }),
+ })
}
if (posts.some(post => !post.botId && !post.kickoff)) {
room.botRounds = 0
diff --cc ds-bot/src/host/turns.js
index 2cb89539,98e71958..64bbfa49
--- a/ds-bot/src/host/turns.js
+++ b/ds-bot/src/host/turns.js
@@@ -521,11 -525,14 +527,14 @@@ export function install(rt)
} else if (!stopped && reason?.kind !== 'aborted') {
// The round moved on without this member; how its turn ends still reaches the group.
if (failure !== undefined) void rt.lateRoomFailure?.(id, info, failure)
- else void rt.lateRoomReply?.(id, info, groupReply())
+ else void rt.lateRoomReply?.(id, info, groupReply(), { shown })
}
} else if (!retry && speaksInGroup(id, info)) {
- if (failure !== undefined) void rt.lateRoomFailure?.(id, info ?? {}, failure)
+ // A turn that failed before it took any input (DSH can turn it down before its
+ // first step) never names its call, so the call waiting on this Session fails.
+ const inRound = failure !== undefined && info === undefined && rt.failRoomTurn?.(id, failure) === true
+ if (failure !== undefined) { if (!inRound) void rt.lateRoomFailure?.(id, info ?? {}, failure) }
- else if (reason?.kind !== 'aborted') void rt.lateRoomReply?.(id, info ?? {}, groupReply())
+ else if (reason?.kind !== 'aborted') void rt.lateRoomReply?.(id, info ?? {}, groupReply(), { shown })
} else if (!retry && info !== undefined) {
answer(info, replyText())
}