dsh-baton-host 0.6.5 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -152,11 +152,12 @@ window.__ModuleLoader__.load({
152
152
  }
153
153
  }
154
154
 
155
- function senderOf(node) {
156
- const rpcId = node?.data?.source?.rpcId
155
+ function senderFrom(source) {
156
+ const rpcId = source?.rpcId
157
157
  const m = typeof rpcId === 'string' ? RPC_RE.exec(rpcId) : null
158
158
  return m ? m[1] : null
159
159
  }
160
+ const senderOf = (node) => senderFrom(node?.data?.source)
160
161
  const nameOf = (sender) => NAMES[sender] ?? sender.charAt(0).toUpperCase() + sender.slice(1)
161
162
 
162
163
  // Sender marks, drawn in the label's text colour like ChatGPT's own "sent from another chat" line.
@@ -198,24 +199,44 @@ window.__ModuleLoader__.load({
198
199
  function DshBatonUserMessage(props) {
199
200
  const Inner = shipped(ctx, key, DshBatonUserMessage)
200
201
  if (!Inner) return null
202
+ // Harness 0.2.2 hands each renderer the chain renderer of its own registration; a wrapper
203
+ // has none to pass on, so the shipped renderer gets one that draws nothing.
204
+ const inner = h(Inner, props.renderSlotChain ? props : { ...props, renderSlotChain: () => null })
201
205
  const sender = senderOf(props.node)
202
- if (!sender) return h(Inner, props)
206
+ if (!sender) return inner
203
207
  return h('div', { style: { display: 'flex', flexDirection: 'column' } },
204
208
  h(Label, { sender, text: t('sentFrom', { name: nameOf(sender) }) }),
205
- h(Inner, props))
209
+ inner)
206
210
  }
207
211
  return DshBatonUserMessage
208
212
  }
209
213
 
214
+ // Harness 0.2.2 and later: the chat declares a seat above each user message (BEFORE) and
215
+ // hands it the message's source, so the label sits there and the user renderer is left alone.
216
+ // Steering messages do not get that seat, so they keep the wrapper.
217
+ const BEFORE = 'conversation.chat.user.before'
218
+ const seatsBefore = (e) => e?.options?.key === 'user' && !!(e.children?.[BEFORE] ?? e.options?.children?.[BEFORE])
219
+ function beforeLabel(t) {
220
+ return function DshBatonSender({ matched }) {
221
+ return h(Label, { sender: matched, text: t('sentFrom', { name: nameOf(matched) }) })
222
+ }
223
+ }
224
+
210
225
  module.exports.name = 'dsh-baton-host'
211
226
  module.exports.inject = ['slots', 'locale']
212
227
  module.exports.apply = function apply(ctx) {
213
228
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-baton: dictionaries')
214
229
  const t = ctx.locale.bind(NS)
215
230
  ctx.slots.inject(SLOT, function* () {
231
+ const seated = ctx.slots.entries(SLOT).some(seatsBefore)
216
232
  // locale 'chat': the shipped renderer reads its strings through the `t` it is handed.
217
- for (const key of KEYS) yield ctx.slots.register({ name: SLOT, key, priority: PRIORITY, locale: 'chat' }, wrapperFor(ctx, key, t))
233
+ for (const key of KEYS) {
234
+ if (key === 'user' && seated) continue
235
+ yield ctx.slots.register({ name: SLOT, key, priority: PRIORITY, locale: 'chat' }, wrapperFor(ctx, key, t))
236
+ }
218
237
  })
238
+ // Runs only in a Harness that declares the seat; older ones never declare it.
239
+ ctx.slots.inject(BEFORE, () => ctx.slots.register({ name: BEFORE, select: ({ source }) => senderFrom(source) }, beforeLabel(t)))
219
240
  ctx.slots.inject('plugins.bundle.activation', () => ctx.slots.register({ name: 'plugins.bundle.activation', key: PACKAGE, locale: NS }, wrapActivation(t)))
220
241
  ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({ name: 'plugins.bundle.config', key: PACKAGE, locale: NS }, wrapDetails(t)))
221
242
  }
package/lib/index.js CHANGED
@@ -523,7 +523,7 @@ export function apply(ctx) {
523
523
  const ids = new Set(pending.map((m) => m?.source?.rpcId))
524
524
  const gone = waiting.filter((r) => !ids.has(r.requestId))
525
525
  if (!gone.length) return []
526
- const log = await controller.inspect(sessionId, signal()).catch(() => null)
526
+ const log = await sessionLog(sessionId).catch(() => null)
527
527
  if (!Array.isArray(log?.events)) return []
528
528
  const delivered = new Set(log.events.filter((e) => e.type === 'user/message').map((e) => e.data?.source?.rpcId))
529
529
  return gone.filter((r) => !delivered.has(r.requestId) && !r.sawPrompt)
@@ -739,8 +739,32 @@ export function apply(ctx) {
739
739
  return out
740
740
  }
741
741
 
742
+ // A session's whole event log and its folder. Harness up to 0.2.1 has sessionController.inspect;
743
+ // 0.2.2 replaced it with paged history (events): the newest page first, beforeSeq walks back,
744
+ // throughSeq pins every page to the same cut. The folder then comes from the session list.
745
+ async function sessionLog(sessionId) {
746
+ if (typeof controller.inspect === 'function') return controller.inspect(sessionId, signal())
747
+ if (typeof controller.events !== 'function') throw new Error('This DeepSeek Harness version cannot read a session log.')
748
+ const address = { kind: 'session', sessionId }
749
+ const pages = []
750
+ let throughSeq
751
+ let beforeSeq
752
+ for (;;) {
753
+ const page = await controller.events({ address, maxMessages: 500, ...(throughSeq === undefined ? {} : { throughSeq }), ...(beforeSeq === undefined ? {} : { beforeSeq }) }, signal())
754
+ throughSeq ??= page.cursor
755
+ const events = (page.records ?? []).filter((r) => r?.type === 'event' && r.event).map((r) => r.event)
756
+ pages.unshift(events)
757
+ if (!page.hasMore || !events.length || events[0].seq === beforeSeq) break
758
+ beforeSeq = events[0].seq
759
+ }
760
+ const seen = new Set()
761
+ const events = pages.flat().filter((e) => (seen.has(e.seq) ? false : (seen.add(e.seq), true)))
762
+ const { items } = await controller.list({}, signal())
763
+ return { meta: { cwd: items.find((it) => it.sessionId === sessionId)?.cwd ?? null }, events }
764
+ }
765
+
742
766
  async function readSession({ session_id, last = 10 }) {
743
- const { meta, events } = await controller.inspect(session_id, signal())
767
+ const { meta, events } = await sessionLog(session_id)
744
768
  const messages = []
745
769
  let title = null
746
770
  for (const e of events) {
@@ -900,7 +924,7 @@ export function apply(ctx) {
900
924
  // the events so far, to tell whether one came during the read.
901
925
  followedUntil.set(session_id, Date.now() + 60_000)
902
926
  const gen = eventGen.get(session_id) ?? 0
903
- const [goal, log] = await Promise.all([goalOf(session_id), controller.inspect(session_id, signal())])
927
+ const [goal, log] = await Promise.all([goalOf(session_id), sessionLog(session_id)])
904
928
  const { ended, running, runningSince } = turnsOf(log?.events)
905
929
  // A first call counts from the start of the round under way, so what it already wrote is
906
930
  // reported; one that comes after the goal stopped, from the start of the last round.
@@ -989,7 +1013,7 @@ export function apply(ctx) {
989
1013
  // A session at a glance, for a client that holds only its id: what it is doing, its goal
990
1014
  // and the reply of its last turn.
991
1015
  async function sessionStatus({ session_id }) {
992
- const [act, goal, log] = await Promise.all([activity({ session_id }), goalOf(session_id), controller.inspect(session_id, signal()).catch(() => null)])
1016
+ const [act, goal, log] = await Promise.all([activity({ session_id }), goalOf(session_id), sessionLog(session_id).catch(() => null)])
993
1017
  const { ended, running } = turnsOf(log?.events)
994
1018
  const question = questions.get(session_id)
995
1019
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-baton-host",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "DeepSeek Harness plugin for dsh-baton: hand coding tasks from Claude Code or Codex to DeepSeek Harness on your machine. Adding it is the whole install: it registers the dsh-baton MCP server for Claude Code and Codex, runs each task live in the Harness window, wakes the main agent when the run ends and hands back the changed files, the project's own test results and a requirement-by-requirement checklist.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -20,7 +20,7 @@
20
20
  "LICENSE"
21
21
  ],
22
22
  "dependencies": {
23
- "dsh-baton-mcp": "0.6.5"
23
+ "dsh-baton-mcp": "0.6.7"
24
24
  },
25
25
  "license": "MIT",
26
26
  "dsh": {