dsh-nova-lewis 0.2.3 → 0.2.4

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.
@@ -0,0 +1,52 @@
1
+ /* Only hide the original body after its authenticated, same-row presentation mounts.
2
+ The native turn actions and persisted message keep their original contents. */
3
+ [data-chat-flow-kind="assistant-step"]:has(> [data-nova-replies]) > [data-slot="conversation.chat.node"] {
4
+ /* DSH supplies display:contents inline on the slot anchor. */
5
+ display:none !important;
6
+ }
7
+ /* Wallpaper Engine decorates the host's assistant row when its avatar option is on. */
8
+ [data-chat-flow-kind="assistant-step"][data-we-avatar-row]:has(> [data-nova-replies]) > .we-avatar { display:none; }
9
+ [data-nova-replies] {
10
+ min-width:0;
11
+ color:var(--dsw-alias-label-primary,CanvasText);
12
+ font-size:var(--dsh-content-font-size,14px);
13
+ text-align:start;
14
+ }
15
+ [data-nova-replies] > [role="list"], [data-nova-participant], [data-nova-closing] {
16
+ display:flex;
17
+ flex-direction:column;
18
+ align-items:flex-start;
19
+ min-width:0;
20
+ }
21
+ [data-nova-replies] > [role="list"] { gap:12px; }
22
+ [data-nova-participant], [data-nova-closing] { gap:4px; max-width:100%; }
23
+ [data-nova-closing] { margin-block-start:22px; }
24
+ [data-nova-name] {
25
+ max-width:100%;
26
+ overflow-wrap:anywhere;
27
+ font-size:var(--dsh-content-font-size-secondary,13px);
28
+ font-weight:600;
29
+ color:var(--dsw-alias-label-secondary,CanvasText);
30
+ }
31
+ [data-nova-bubble] {
32
+ min-width:0;
33
+ max-width:100%;
34
+ overflow-wrap:anywhere;
35
+ white-space:pre-wrap;
36
+ user-select:text;
37
+ }
38
+ [data-nova-copy] {
39
+ display:inline-flex;
40
+ align-items:center;
41
+ justify-content:center;
42
+ width:28px;
43
+ height:28px;
44
+ margin-top:8px;
45
+ padding:4px;
46
+ border:0;
47
+ border-radius:var(--dsw-radius-sm,6px);
48
+ color:var(--dsw-alias-label-secondary,CanvasText);
49
+ background:transparent;
50
+ cursor:pointer;
51
+ }
52
+ [data-nova-copy]:hover { background:var(--dsw-alias-interactive-bg-hover); }
@@ -0,0 +1,151 @@
1
+ import React, {useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'
2
+ import {createPortal} from 'react-dom'
3
+ import {IconCheckOutlineRegular, IconCopyOutlineRegular, MarkdownText, UserMessageBubble, useClipboardCopy} from '@deepseek-ai/dsh-client-ui-primitives'
4
+ import {hasRollCallClosing} from '../src/easter-egg.mjs'
5
+ import bubbleCSS from './chat-replies.css'
6
+
7
+ const h = React.createElement
8
+ const labels = {
9
+ code:{copyLabel:'复制', copiedLabel:'已复制', toolbarLabels:{codeLabel:'代码', wrapLabel:'自动换行', unwrapLabel:'取消换行'}},
10
+ footnotes:'脚注',
11
+ }
12
+
13
+ // Historical turns can mount together. Only query nearby visible answers, share in-flight
14
+ // requests between panes, and retain negative identities rather than large answer bodies.
15
+ const pending = new Map(), ordinary = new Set()
16
+ const standaloneKind = 'dsh-nova-standalone-reply'
17
+ const deliveryEvent = 'plugin:collaboration/reply-delivered'
18
+ async function lookup(sessionId, messageId, seq) {
19
+ const key = JSON.stringify([sessionId, messageId, seq])
20
+ if (ordinary.has(key)) return null
21
+ if (pending.has(key)) return pending.get(key)
22
+ const request = (async () => {
23
+ const response = await fetch('/api/collaboration-local/reply', {
24
+ method:'POST', credentials:'same-origin', cache:'no-store', headers:{'Content-Type':'application/json'},
25
+ body:JSON.stringify({sessionId, messageId, seq}),
26
+ })
27
+ if (!response.ok) throw Error('读取协作回复失败')
28
+ const result = await response.json()
29
+ if (!result.ok) throw Error('读取协作回复失败')
30
+ if (result.value === null) {
31
+ ordinary.add(key)
32
+ if (ordinary.size > 512) ordinary.delete(ordinary.values().next().value)
33
+ }
34
+ return result.value
35
+ })().finally(() => pending.delete(key))
36
+ pending.set(key, request)
37
+ return request
38
+ }
39
+
40
+ function Participant({name, text, closing=false}) {
41
+ return h('div', closing ? {'data-nova-closing':''} : {'data-nova-participant':'',role:'listitem'},
42
+ h('div', {'data-nova-name':''}, name),
43
+ h(UserMessageBubble, {'data-message-bubble':'', 'data-nova-bubble':'', 'data-text-interaction-source':''}, text))
44
+ }
45
+
46
+ function Replies({value}) {
47
+ return h('section', {'data-nova-replies':'', 'aria-label':'协作模型回复'},
48
+ h('style', null, bubbleCSS),
49
+ h('div', {role:'list'}, value.participants.map(({name,text}, index) =>
50
+ h(Participant, {key:index, name, text}))),
51
+ h(Participant, {name:'NOVA', text:value.closing.replace(/^NOVA:/u,''), closing:true}))
52
+ }
53
+
54
+ function useReply(target, sessionId, messageId, seq, markdown) {
55
+ const [answer, setAnswer] = useState(null)
56
+ useEffect(() => {
57
+ if (!target || !messageId || markdown === null) return
58
+ let live = true, retry, observer, attempts = 0
59
+ const read = async () => {
60
+ try {
61
+ const value = await lookup(sessionId, messageId, seq)
62
+ if (live && value && (markdown === undefined || value.markdown === markdown))
63
+ setAnswer({target, messageId, value})
64
+ } catch {
65
+ // Keep the normal DSH answer available during a transient host/persistence failure.
66
+ if (live && ++attempts < 3) retry = setTimeout(read, 400 * attempts)
67
+ }
68
+ }
69
+ if (typeof IntersectionObserver === 'function') {
70
+ observer = new IntersectionObserver(entries => {
71
+ if (!entries.some(entry => entry.isIntersecting)) return
72
+ observer.disconnect()
73
+ void read()
74
+ }, {rootMargin:'700px 0px'})
75
+ observer.observe(target)
76
+ } else void read()
77
+ return () => { live = false; observer?.disconnect(); clearTimeout(retry) }
78
+ }, [target, sessionId, messageId, seq, markdown])
79
+ return answer?.target === target && answer?.messageId === messageId &&
80
+ (markdown === undefined || answer?.value.markdown === markdown) ? answer?.value : null
81
+ }
82
+
83
+ // An out-of-turn Workbench delivery has no native chat row or turn tail in rc.5.
84
+ // Only NOVA's own delivery receipt contributes this new node kind to the transcript.
85
+ export function registerStandaloneReplies(ctx) {
86
+ ctx.uiConversation.events.register({
87
+ kind:standaloneKind, target:'chat',
88
+ match:{[deliveryEvent]:event => event.ignorable === true && typeof event.data?.messageId === 'string' &&
89
+ Number.isSafeInteger(event.data.seq) && event.data.seq === event.seq - 1 ? {id:event.data.messageId,role:'start'} : null},
90
+ start:(_context, match) => match.event.data,
91
+ update:context => context.state,
92
+ buildViewNode:context => context.state ? {key:context.key, id:context.id, kind:standaloneKind, target:'chat',
93
+ anchorSeq:context.state.seq, location:{kind:'session'}, visibility:'visible', groupTree:'turn', data:context.state} : null,
94
+ })
95
+ ctx.slots.inject('conversation.chat.node',()=>ctx.slots.register({name:'conversation.chat.node', key:standaloneKind,
96
+ inject:sessionId=>({sessionId, eventSource:ctx.sessions.binding(sessionId)?.eventSource})},StandaloneReply))
97
+ }
98
+
99
+ function savedDeliveryText(entries, {messageId,seq}) {
100
+ // The authorized client's event window can still supply a plain answer while the
101
+ // host is reconnecting. Require the original receipt, answer and completion together.
102
+ const index = entries?.findLastIndex(({event}) => event?.type === deliveryEvent && event.seq === seq + 1 && event.data.messageId === messageId)
103
+ if (!(index >= 2)) return
104
+ const completed = entries[index - 2].event, entry = entries[index - 1].event, message = entry?.data?.message
105
+ if (completed?.type !== 'plugin:collaboration/run' || completed.seq !== seq - 1 || completed.ignorable !== true ||
106
+ completed.data.fields?.status !== 'completed' || entry?.type !== 'assistant/message' || entry.seq !== seq ||
107
+ entry.data.turn !== 0 || entry.data.step !== 0 || message?.id !== messageId || message.role !== 'assistant' ||
108
+ message.source?.kind !== 'model' || !message.content?.length || message.content.some(b=>b.type !== 'text')) return
109
+ return message.content.map(block=>block.text).join('')
110
+ }
111
+
112
+ function StandaloneReply({sessionId, node, eventSource}) {
113
+ const [target, setTarget] = useState(null)
114
+ const original = useMemo(()=>savedDeliveryText(eventSource?.getSnapshot().entries,node.data),[eventSource,node.data])
115
+ const value = useReply(target, sessionId, node.data.messageId, node.data.seq,original)
116
+ const markdown = value?.markdown ?? original
117
+ const {copied, onCopy} = useClipboardCopy(markdown || '')
118
+ return h('div', {ref:setTarget}, h('style',null,bubbleCSS),
119
+ markdown && h(MarkdownText,{text:markdown,labels,streaming:false,textInteractionSource:true}),
120
+ markdown && h('button',{type:'button', 'aria-label':copied ? '已复制' : '复制', 'data-nova-copy':'',onClick:onCopy},
121
+ h(copied ? IconCheckOutlineRegular : IconCopyOutlineRegular, {size:16,'aria-hidden':true})))
122
+ }
123
+
124
+ // rc.5 exposes the durable closing message through its per-turn extension seat. The
125
+ // keyed assistant renderer itself owns DSH chat behaviour for every other plugin.
126
+ export function ChatReplies({sessionId, turn, seq, useChat}) {
127
+ const marker = useRef(null)
128
+ const [target, setTarget] = useState(null)
129
+ const closing = turn.data.get('turn-tail')?.closing
130
+ const blocks = closing?.blocks
131
+ const markdown = blocks?.length === 1 && blocks[0].kind === 'text' && hasRollCallClosing(blocks[0].text) ? blocks[0].text : null
132
+ const messageId = markdown !== null && closing?.finalNode?.seq === seq ? closing.finalNode.messageId : null
133
+ const turnNumber = turn.turn, step = closing?.step
134
+ const selectKey = useCallback(snapshot => {
135
+ if (!messageId) return null
136
+ return snapshot.locations.getStep(turnNumber,step).find(key => {
137
+ const node = snapshot.nodes.get(key)
138
+ return node?.kind === 'assistant-step' && node.data.finalNode?.messageId === messageId
139
+ }) || null
140
+ }, [turnNumber, step, messageId])
141
+ const nodeKey = useChat(selectKey)
142
+ const value = useReply(target, sessionId, messageId, seq, markdown)
143
+
144
+ useLayoutEffect(() => {
145
+ const flow = marker.current?.closest('[data-slot="conversation.chat.flow"]')
146
+ const row = nodeKey && flow?.querySelector(`[data-chat-flow-kind="assistant-step"][data-chat-node-key="${CSS.escape(nodeKey)}"]:not([data-chat-group-part="reasoning"])`)
147
+ setTarget(row || null)
148
+ }, [sessionId, nodeKey])
149
+ return h(React.Fragment, null, h('span',{ref:marker,hidden:true}),
150
+ value?.kind === 'roll-call' && value.participants?.length > 0 && value.closing && createPortal(h(Replies,{value}),target))
151
+ }
package/host/client.mjs CHANGED
@@ -14,6 +14,7 @@ import {isNewVisiblePlan} from './plan-view.mjs'
14
14
  import {mountChoice,POLICY_OPTIONS} from '../ui/choices.mjs'
15
15
  import {composerPlacement} from './composer-layout.mjs'
16
16
  import {preserveExactComposerText} from './exact-composer-text.mjs'
17
+ import {ChatReplies,registerStandaloneReplies} from './chat-replies.mjs'
17
18
  import composerCSS from './composer.css'
18
19
 
19
20
  // Keep DSH's persisted sidebar tabs, series shortcuts and settings target valid across the package rename.
@@ -303,6 +304,9 @@ function Composer({ctx,sessionId}){
303
304
  }},'协作'+(hint?' · '+hint:''))),pop)
304
305
  }
305
306
  export function apply(ctx){
307
+ ctx.inject?.(['uiConversation','sessions'],registerStandaloneReplies)
308
+ ctx.slots.inject('conversation.chat.turnTail',()=>ctx.slots.register({name:'conversation.chat.turnTail',id:id+'-replies',
309
+ inject:sessionId=>({sessionId})},ChatReplies))
306
310
  ctx.inject?.(['conversation','sessions'],ready=>ready.effect(()=>preserveExactComposerText(ready.conversation,ready.sessions,async sessionId=>{
307
311
  const bridge=hostBridge(ctx,sessionId,true)
308
312
  try{return (await bridge.getState()).composer?.enabled===true}
package/host/index.mjs CHANGED
@@ -12,12 +12,12 @@ import { discoverRoutes, executorFor, plannerFor } from './models.mjs'
12
12
  import {choosePlanner} from '../src/role-routing.mjs'
13
13
  import { createChildren } from './children.mjs'
14
14
  import {sessionSelection} from './selection.mjs'
15
- import {isRollCall,prepareRollCall,executeRollCall,renderRollCall} from './roll-call.mjs'
15
+ import {isRollCall,prepareRollCall,executeRollCall} from './roll-call.mjs'
16
+ import {RUN_RECORD as RECORD, completedText, delivered, transcriptReply} from './reply-view.mjs'
16
17
 
17
18
  export const name = 'dsh-nova-lewis'
18
19
  export const inject = ['commands','llm','agents','sessions','sessionProjections','connection','storageDomain','webServer']
19
20
  export const CHANNEL = '/api/collaboration-local'
20
- const RECORD = 'plugin:collaboration/run'
21
21
  const MATERIAL = 'plugin:collaboration/material'
22
22
  const MATERIAL_SELECTION = 'plugin:collaboration/material-selection'
23
23
  const COMPOSER = 'plugin:collaboration/composer'
@@ -63,15 +63,6 @@ function delta(previous, snapshot) {
63
63
  }
64
64
  return {runId:snapshot.runId,fields,rows,order}
65
65
  }
66
- function delivered(snapshot) {
67
- const finals = snapshot.nodes.filter(n=>n.final && n.artifactId)
68
- const outputs = finals.length ? finals : snapshot.nodes.filter(n=>n.artifactId && !snapshot.nodes.some(next=>next.deps.includes(n.id)))
69
- return outputs.map(n=>snapshot.artifacts.find(a=>a.id===n.artifactId)).filter(Boolean)
70
- }
71
- function answerText(outputs) {
72
- return outputs.map(a=>a.text+(a.unresolved?.length ? '\n未决项:'+a.unresolved.join('、') : '')).join('\n\n') || '本次协作没有可交付的答复。'
73
- }
74
- const completedText = snapshot => snapshot.settings?.easterEgg ? renderRollCall(snapshot) : answerText(delivered(snapshot))
75
66
  const settled = run=>['completed','cancelled','blocked'].includes(run.status)
76
67
  function waitForRun(engine,ready,signal) {
77
68
  return new Promise((resolve,reject)=>{
@@ -154,9 +145,15 @@ export async function installHost(ctx,config,api) {
154
145
  const text = completedText(data)
155
146
  const final = outputs.at(-1), route = [...(data.operations || []),...data.attempts].find(a=>a.id===final?.attemptId)?.route ||
156
147
  data.routes.find(r=>r.id===(final?.routeId || data.plannerRouteId))
157
- if (route) session.append('assistant/message',{turn:0,step:0,stream:[],message:{
158
- role:'assistant',id:randomUUID(),content:[{type:'text',text}],source:{kind:'model',provider:route.providerId,model:route.modelId}
159
- }},{surfaceOp:'append'})
148
+ if (route) {
149
+ const messageId=randomUUID()
150
+ const delivery=session.append('assistant/message',{turn:0,step:0,stream:[],message:{
151
+ role:'assistant',id:messageId,content:[{type:'text',text}],source:{kind:'model',provider:route.providerId,model:route.modelId}
152
+ }},{surfaceOp:'append'})
153
+ // Background deliveries have no native turn/end slot. Refer to the same
154
+ // persisted answer so the chat view can show it without a second message.
155
+ api.appendPluginRecord(session,'plugin:collaboration/reply-delivered',{messageId,...(delivery && {seq:delivery.seq})})
156
+ }
160
157
  }
161
158
  await ctx.sessions.flush(session)
162
159
  last = data
@@ -183,7 +180,7 @@ export async function installHost(ctx,config,api) {
183
180
  if (compact) {
184
181
  const snapshot=room.runs[selectedId]
185
182
  const run=snapshot && snapshot.sessionId===sessionId?{runId:snapshot.runId,status:snapshot.status,planVersion:snapshot.planVersion,
186
- createdAt:snapshot.createdAt,native:!!snapshot.settings?.nativePromptId && !snapshot.settings.easterEgg,
183
+ createdAt:snapshot.createdAt,native:!!snapshot.settings?.nativePromptId,
187
184
  assignmentsHash:snapshot.assignmentsHash,total:snapshot.nodes.length,done:snapshot.nodes.filter(n=>n.status==='done').length}:null
188
185
  const {routes,connections,warnings}=await catalog()
189
186
  return {mode:'host',sessionId,composer:composerSettings(room,sessionId),run,revision:epoch,
@@ -381,12 +378,17 @@ export async function installHost(ctx,config,api) {
381
378
  })
382
379
  }
383
380
  if (endpoint==='wait') return {ok:true,value:{revision:epoch}}
381
+ if (endpoint==='reply') {
382
+ const session=ctx.sessions.get(p.sessionId)
383
+ if (!session) throw Error('当前会话尚未激活。')
384
+ return {ok:true,value:transcriptReply(session,p,runId=>view.stateOf(session).runs[runId])}
385
+ }
384
386
  if (endpoint==='state') return {ok:true,value:await state(p.sessionId,p.runId,p.compact===true)}
385
387
  if (endpoint==='action') return {ok:true,value:await action(p.sessionId,p.type,p.payload) ?? null}
386
388
  throw Error('未知协作接口。')
387
389
  } catch(error){return {ok:false,error:{code:'collaboration/error',message:error.message,details:{}}}}
388
390
  }
389
- for (const endpoint of ['state','wait','action']) {
391
+ for (const endpoint of ['state','wait','action','reply']) {
390
392
  ctx.connection.fetch.register({path:CHANNEL+'/'+endpoint,methods:['POST'],requestBody:'buffered',async fetch(req){
391
393
  try{
392
394
  const result=await listener(endpoint,await req.json(),req.signal,{principal:{kind:'owner'}})
@@ -0,0 +1,82 @@
1
+ import {formatEggMessage, formatEggReply} from '../src/easter-egg.mjs'
2
+ import {isRollCall, renderRollCall, rollCallReplies} from './roll-call.mjs'
3
+
4
+ export const RUN_RECORD = 'plugin:collaboration/run'
5
+
6
+ export function delivered(run) {
7
+ const finals = run.nodes.filter(node => node.final && node.artifactId)
8
+ const used = new Set(run.nodes.flatMap(node => node.deps || []))
9
+ const outputs = finals.length ? finals : run.nodes.filter(node => node.artifactId && !used.has(node.id))
10
+ const artifacts = new Map(run.artifacts.map(artifact => [artifact.id, artifact]))
11
+ return outputs.map(node => artifacts.get(node.artifactId)).filter(Boolean)
12
+ }
13
+
14
+ function artifactText(artifact) {
15
+ return artifact.text + (artifact.unresolved?.length ? '\n未决项:' + artifact.unresolved.join('、') : '')
16
+ }
17
+
18
+ export function completedText(run) {
19
+ if (run.settings?.easterEgg) return renderRollCall(run)
20
+ return delivered(run).map(artifactText).join('\n\n') || '本次协作没有可交付的答复。'
21
+ }
22
+
23
+ function matchingRollCall(run, markdown) {
24
+ const replies = rollCallReplies(run)
25
+ const closing = run.settings.easterEgg.closing
26
+ if (renderRollCall(run, replies) !== markdown) {
27
+ // 0.2.2 and 0.2.3 included the account name in saved lines.
28
+ const older = replies.map(({route, text}) => {
29
+ const provider = route.providerId || route.apiId
30
+ const name = route.modelId || route.label || route.id
31
+ return formatEggReply({modelId:provider ? provider + ' / ' + name : name}, text)
32
+ })
33
+ if (formatEggMessage(older, closing) !== markdown) return null
34
+ }
35
+ return {kind:'roll-call', markdown, participants:replies.map(({route, text}) => ({name:route.modelId || route.label || route.id, text})),
36
+ closing:closing.slice(2, -2)}
37
+ }
38
+
39
+ // The transcript slot identifies a persisted assistant event. Only a completed
40
+ // Nova run in that exact DSH step can supply its attribution and deliverables.
41
+ export function transcriptReply(session, {messageId, seq}, getRun) {
42
+ if (!session || typeof messageId !== 'string' || !messageId) return null
43
+ let at
44
+ if (typeof session.eventAt === 'function' && Number.isSafeInteger(seq) && seq >= 0) {
45
+ if (seq >= session.seq) throw Error('消息尚未保存。')
46
+ at = index => session.eventAt(index)
47
+ } else {
48
+ const events = session.ownEvents()
49
+ seq = events.findIndex(event => event.type === 'assistant/message' && event.data.message?.id === messageId)
50
+ at = index => events[index]
51
+ }
52
+ const entry = at(seq)
53
+ const message = entry?.data?.message
54
+ if (entry?.type !== 'assistant/message' || message?.id !== messageId || message.role !== 'assistant' ||
55
+ message.source?.kind !== 'model' || !message.content?.length || message.content.some(b => b.type !== 'text')) return null
56
+ const markdown = message.content.map(block => block.text).join('')
57
+ // Command/workbench delivery appends its own assistant event immediately after
58
+ // persisting completion, outside the agent loop (turn 0, step 0).
59
+ const standalone = entry.data.turn === 0 && entry.data.step === 0
60
+ const candidates = [], inputs = []
61
+ for (let pos = seq - 1; pos >= 0; pos--) {
62
+ const event = at(pos)
63
+ if (!event || event.type === 'step/start' || event.type === 'turn/start') break
64
+ if (event.type === RUN_RECORD && event.ignorable === true && event.data.fields?.status === 'completed')
65
+ candidates.push(event.data.runId)
66
+ if (standalone) break
67
+ if (event.type === 'assistant/message' && event.data.turn !== 0) break
68
+ if (event.type === 'user/message' && event.data.source?.kind === 'user') inputs.push(event.data)
69
+ }
70
+ if (!standalone && !isRollCall(inputs)) return null
71
+ for (const runId of candidates) {
72
+ const run = getRun(runId)
73
+ if (!run) continue
74
+ if (standalone) {
75
+ if (completedText(run) === markdown) return {kind:'answer', markdown}
76
+ } else if (run.settings?.easterEgg && run.settings.nativePromptId === inputs[0].id) {
77
+ const reply = matchingRollCall(run, markdown)
78
+ if (reply) return reply
79
+ }
80
+ }
81
+ return null
82
+ }
@@ -101,18 +101,21 @@ export async function executeRollCall(ctx, args) {
101
101
  return {...result, text:chosen}
102
102
  }
103
103
 
104
- export function renderRollCall(snapshot) {
105
- const {replies, closing} = snapshot.settings.easterEgg
104
+ export function rollCallReplies(snapshot) {
105
+ const {replies} = snapshot.settings.easterEgg
106
106
  const directory = new Map(snapshot.routes.map(route => [route.id, route]))
107
107
  const nodes = new Map(snapshot.nodes.map(node => [node.routeId, node]))
108
108
  const artifacts = new Map(snapshot.artifacts.map(artifact => [artifact.id, artifact]))
109
- const lines = replies.map(({routeId, choices}) => {
109
+ return replies.map(({routeId, choices}) => {
110
110
  const route = directory.get(routeId) || unavailableRoute(routeId)
111
111
  const node = nodes.get(routeId)
112
112
  const artifact = artifacts.get(node?.artifactId)
113
113
  const text = artifact?.routeId === routeId && choices.includes(artifact.text) ? artifact.text :
114
114
  route.enabled === false ? '(型号当前不可用)' : '(本次未回应)'
115
- return formatEggReply(route, text)
115
+ return {route, text}
116
116
  })
117
- return formatEggMessage(lines, closing)
117
+ }
118
+
119
+ export function renderRollCall(snapshot, replies = rollCallReplies(snapshot)) {
120
+ return formatEggMessage(replies.map(({route, text}) => formatEggReply(route, text)), snapshot.settings.easterEgg.closing)
118
121
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "dsh-nova-lewis",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "lewisEnchantRelease": {
5
- "version": "0.2.3",
5
+ "version": "0.2.4",
6
6
  "notes": ""
7
7
  },
8
8
  "lewisEnchantReleaseEn": {
9
- "version": "0.2.3",
9
+ "version": "0.2.4",
10
10
  "notes": ""
11
11
  },
12
12
  "type": "module",
@@ -15,6 +15,10 @@ const closings = [
15
15
  '**NOVA:Present and shining! ✧**',
16
16
  ]
17
17
 
18
+ export function hasRollCallClosing(markdown) {
19
+ return typeof markdown === 'string' && closings.some(line => markdown === line || markdown.endsWith('\n\n' + line))
20
+ }
21
+
18
22
  // Draw every item once before refilling. At a cycle boundary avoid repeating the last draw.
19
23
  function drawFrom(items, random) {
20
24
  let pool = [], previous
@@ -71,9 +75,7 @@ function markdownText(value) {
71
75
  }
72
76
 
73
77
  export function formatEggReply(route, text) {
74
- const provider = route.providerId || route.apiId
75
- const name = provider ? provider+' / '+modelName(route) : modelName(route)
76
- return '**'+markdownText(name)+'**:'+markdownText(text)
78
+ return '**'+markdownText(modelName(route))+'**:'+markdownText(text)
77
79
  }
78
80
 
79
81
  export function chooseNovaClosing(random = Math.random) {