dsh-rwkv-plugin 0.0.0-stage → 0.2.0

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.
Files changed (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -2
  3. package/cordis.patch.yml +59 -0
  4. package/lib/client.js +3148 -0
  5. package/lib/client.js.map +7 -0
  6. package/lib/index.js +6294 -0
  7. package/lib/index.js.map +7 -0
  8. package/lib/line-edit.js +1423 -0
  9. package/lib/line-edit.js.map +7 -0
  10. package/lib/todo.js +610 -0
  11. package/lib/todo.js.map +7 -0
  12. package/package.json +72 -4
  13. package/scripts/build.mjs +77 -0
  14. package/scripts/headless.ts +279 -0
  15. package/scripts/link-dsh.sh +31 -0
  16. package/scripts/relay-e2e.mjs +157 -0
  17. package/scripts/smoke.ts +116 -0
  18. package/scripts/state.ts +39 -0
  19. package/scripts/tokenizer-parity.ts +107 -0
  20. package/scripts/trace-stats.ts +33 -0
  21. package/src/adapter.ts +388 -0
  22. package/src/backend/generator.ts +221 -0
  23. package/src/backend/irwkv.ts +117 -0
  24. package/src/backend/lightning.ts +228 -0
  25. package/src/backend/stream.ts +97 -0
  26. package/src/client/AdapterPicker.tsx +264 -0
  27. package/src/client/DeveloperPanel.tsx +403 -0
  28. package/src/client/FoldNode.tsx +82 -0
  29. package/src/client/ModelCard.tsx +230 -0
  30. package/src/client/RwkvSettings.tsx +265 -0
  31. package/src/client/Segment.tsx +15 -0
  32. package/src/client/StatePicker.tsx +248 -0
  33. package/src/client/TraceFrames.tsx +462 -0
  34. package/src/client/TraceView.tsx +77 -0
  35. package/src/client/WirePanel.tsx +566 -0
  36. package/src/client/fields.tsx +362 -0
  37. package/src/client/index.tsx +109 -0
  38. package/src/client/styles.ts +277 -0
  39. package/src/client/traces-api.ts +222 -0
  40. package/src/client/url.ts +20 -0
  41. package/src/core/agent.ts +586 -0
  42. package/src/core/defaults.ts +51 -0
  43. package/src/core/dsh-prompt.ts +32 -0
  44. package/src/core/edit-modes/index.ts +108 -0
  45. package/src/core/edit-modes/line-edit.ts +793 -0
  46. package/src/core/edit-modes/literal.ts +26 -0
  47. package/src/core/edit-modes/shared.ts +213 -0
  48. package/src/core/edit-modes/tolerant.ts +558 -0
  49. package/src/core/fold-pairs.ts +407 -0
  50. package/src/core/fold-window.ts +563 -0
  51. package/src/core/line-edit.ts +33 -0
  52. package/src/core/parse.ts +290 -0
  53. package/src/core/policy.ts +500 -0
  54. package/src/core/prompt.ts +220 -0
  55. package/src/core/relay.ts +400 -0
  56. package/src/core/step-gates.ts +371 -0
  57. package/src/core/time-zone.ts +32 -0
  58. package/src/core/todo-state.ts +227 -0
  59. package/src/core/tolerant-edit.ts +14 -0
  60. package/src/core/tool-mappings.ts +209 -0
  61. package/src/core/tool-repairs.ts +255 -0
  62. package/src/core/tools.ts +162 -0
  63. package/src/core/worklist.ts +606 -0
  64. package/src/dsh-host.ts +48 -0
  65. package/src/edit-modes/folded-read-guard.ts +32 -0
  66. package/src/edit-modes/index.ts +26 -0
  67. package/src/edit-modes/line-edit.ts +154 -0
  68. package/src/edit-modes/literal.ts +9 -0
  69. package/src/edit-modes/observations.ts +234 -0
  70. package/src/edit-modes/syntax-check.ts +226 -0
  71. package/src/edit-modes/tolerant.ts +232 -0
  72. package/src/folded-read-guard.ts +6 -0
  73. package/src/history.ts +163 -0
  74. package/src/index.ts +287 -0
  75. package/src/line-edit.ts +15 -0
  76. package/src/live-wire.ts +133 -0
  77. package/src/paths.ts +91 -0
  78. package/src/relay-store.ts +59 -0
  79. package/src/result-budget.ts +225 -0
  80. package/src/routes.ts +324 -0
  81. package/src/session-setup.ts +150 -0
  82. package/src/syntax-check.ts +2 -0
  83. package/src/todo.ts +328 -0
  84. package/src/tokenizer.ts +48 -0
  85. package/src/tolerant-edit.ts +2 -0
  86. package/src/trace-stats.ts +225 -0
  87. package/src/traces.ts +289 -0
  88. package/vendor/rwkv-tokenizer/NOTICE.md +26 -0
  89. package/vendor/rwkv-tokenizer/package.json +5 -0
  90. package/vendor/rwkv-tokenizer/rwkv_tokenizer.d.ts +11 -0
  91. package/vendor/rwkv-tokenizer/rwkv_tokenizer.js +280 -0
  92. package/vendor/rwkv-tokenizer/rwkv_tokenizer_bg.wasm +0 -0
@@ -0,0 +1,362 @@
1
+ // Reusable form field primitives for the RWKV settings page.
2
+
3
+ import { useEffect, useId, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'
4
+
5
+ export const same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b)
6
+
7
+ function ChevronIcon(props: { open?: boolean }) {
8
+ return (
9
+ <svg
10
+ className={props.open ? 'rwkv-menu-chevron rwkv-menu-chevron-open' : 'rwkv-menu-chevron'}
11
+ width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true"
12
+ >
13
+ <path d="M3 4.5L6 7.5L9 4.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
14
+ </svg>
15
+ )
16
+ }
17
+
18
+ function CheckIcon() {
19
+ return (
20
+ <svg className="rwkv-menu-check" width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
21
+ <path d="M3 7.25L5.75 10L11 4.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
22
+ </svg>
23
+ )
24
+ }
25
+
26
+ function useDismiss(open: boolean, ref: { current: HTMLElement | null }, onClose: () => void) {
27
+ useEffect(() => {
28
+ if (!open) return
29
+ const onPointerDown = (event: PointerEvent) => {
30
+ if (ref.current && !ref.current.contains(event.target as Node)) onClose()
31
+ }
32
+ const onKeyDown = (event: globalThis.KeyboardEvent) => {
33
+ if (event.key === 'Escape') onClose()
34
+ }
35
+ document.addEventListener('pointerdown', onPointerDown)
36
+ document.addEventListener('keydown', onKeyDown)
37
+ return () => {
38
+ document.removeEventListener('pointerdown', onPointerDown)
39
+ document.removeEventListener('keydown', onKeyDown)
40
+ }
41
+ }, [open, ref, onClose])
42
+ }
43
+
44
+ export function Field(props: { label: string; hint?: ReactNode; wide?: boolean; children: ReactNode }) {
45
+ return (
46
+ <label className={props.wide ? 'rwkv-field rwkv-wide' : 'rwkv-field'}>
47
+ <span className="rwkv-label">{props.label}</span>
48
+ {props.children}
49
+ {props.hint ? <p className="rwkv-hint">{props.hint}</p> : null}
50
+ </label>
51
+ )
52
+ }
53
+
54
+ export function TextInput(props: {
55
+ value: string | undefined
56
+ onChange: (value: string) => void
57
+ placeholder?: string
58
+ type?: string
59
+ disabled?: boolean
60
+ list?: string
61
+ }) {
62
+ return (
63
+ <input
64
+ className="rwkv-input" type={props.type ?? 'text'} value={props.value ?? ''} placeholder={props.placeholder} list={props.list}
65
+ disabled={props.disabled} spellCheck={false} autoComplete="off"
66
+ onChange={event => props.onChange(event.target.value)}
67
+ />
68
+ )
69
+ }
70
+
71
+ /** Numbers are edited as text so a half-typed "0." survives; the parsed value is reported when valid. */
72
+ export function NumberInput(props: {
73
+ value: number | undefined
74
+ onChange: (value: number | undefined) => void
75
+ placeholder?: string
76
+ disabled?: boolean
77
+ }) {
78
+ const [text, setText] = useState(props.value === undefined ? '' : String(props.value))
79
+ return (
80
+ <input
81
+ className="rwkv-input" inputMode="decimal" value={text} placeholder={props.placeholder} disabled={props.disabled}
82
+ onChange={event => {
83
+ const next = event.target.value
84
+ setText(next)
85
+ const parsed = Number(next)
86
+ if (next.trim() === '') props.onChange(undefined)
87
+ else if (Number.isFinite(parsed)) props.onChange(parsed)
88
+ }}
89
+ />
90
+ )
91
+ }
92
+
93
+ export function ComboInput(props: {
94
+ value: string | undefined
95
+ options: readonly string[]
96
+ onChange: (value: string) => void
97
+ placeholder?: string
98
+ disabled?: boolean
99
+ align?: 'start' | 'end'
100
+ }) {
101
+ const [open, setOpen] = useState(false)
102
+ const [active, setActive] = useState(-1)
103
+ const rootRef = useRef<HTMLDivElement>(null)
104
+ const listId = useId()
105
+ useDismiss(open, rootRef, () => setOpen(false))
106
+
107
+ const value = props.value ?? ''
108
+ const trimmed = value.trim()
109
+ const exactMatch = props.options.includes(trimmed)
110
+ const filtered = trimmed === '' || exactMatch
111
+ ? props.options
112
+ : props.options.filter(item => item.toLowerCase().includes(trimmed.toLowerCase()))
113
+ const visibleOptions = filtered.length > 0 ? filtered : props.options
114
+ const hasOptions = props.options.length > 0 && !props.disabled
115
+ const showMenu = open && hasOptions
116
+
117
+ const choose = (item: string) => {
118
+ props.onChange(item)
119
+ setOpen(false)
120
+ setActive(-1)
121
+ }
122
+
123
+ const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
124
+ if (!hasOptions) return
125
+ if (event.key === 'ArrowDown') {
126
+ event.preventDefault()
127
+ if (!open) {
128
+ setOpen(true)
129
+ const currentIndex = visibleOptions.indexOf(trimmed)
130
+ setActive(currentIndex >= 0 ? currentIndex : 0)
131
+ } else {
132
+ setActive(index => (index + 1) % visibleOptions.length)
133
+ }
134
+ } else if (event.key === 'ArrowUp') {
135
+ event.preventDefault()
136
+ if (!open) {
137
+ setOpen(true)
138
+ setActive(visibleOptions.length - 1)
139
+ } else {
140
+ setActive(index => (index <= 0 ? visibleOptions.length - 1 : index - 1))
141
+ }
142
+ } else if (event.key === 'Enter' && open && active >= 0 && active < visibleOptions.length) {
143
+ event.preventDefault()
144
+ choose(visibleOptions[active]!)
145
+ } else if (event.key === 'Escape' && open) {
146
+ event.preventDefault()
147
+ setOpen(false)
148
+ }
149
+ }
150
+
151
+ return (
152
+ <div ref={rootRef} className="rwkv-combo">
153
+ <input
154
+ className={hasOptions ? 'rwkv-input rwkv-combo-input' : 'rwkv-input'}
155
+ type="text"
156
+ role="combobox"
157
+ aria-expanded={showMenu}
158
+ aria-controls={showMenu ? listId : undefined}
159
+ aria-autocomplete="list"
160
+ value={value}
161
+ placeholder={props.placeholder}
162
+ disabled={props.disabled}
163
+ spellCheck={false}
164
+ autoComplete="off"
165
+ onFocus={() => { if (hasOptions) setOpen(true) }}
166
+ onClick={() => { if (hasOptions) setOpen(true) }}
167
+ onChange={event => {
168
+ props.onChange(event.target.value)
169
+ if (hasOptions) setOpen(true)
170
+ setActive(-1)
171
+ }}
172
+ onKeyDown={onKeyDown}
173
+ />
174
+ {hasOptions ? (
175
+ <button
176
+ type="button"
177
+ className="rwkv-combo-toggle"
178
+ tabIndex={-1}
179
+ aria-label="展开模型列表"
180
+ onMouseDown={event => event.preventDefault()}
181
+ onClick={() => setOpen(current => !current)}
182
+ >
183
+ <ChevronIcon open={showMenu} />
184
+ </button>
185
+ ) : null}
186
+ {showMenu ? (
187
+ <div
188
+ id={listId}
189
+ role="listbox"
190
+ className={props.align === 'end' ? 'rwkv-menu rwkv-menu-end' : 'rwkv-menu'}
191
+ >
192
+ {visibleOptions.map((option, index) => {
193
+ const selected = option === trimmed
194
+ return (
195
+ <button
196
+ key={option}
197
+ type="button"
198
+ role="option"
199
+ aria-selected={selected}
200
+ data-active={active === index ? 'true' : undefined}
201
+ className="rwkv-menu-item"
202
+ title={option}
203
+ onMouseDown={event => event.preventDefault()}
204
+ onMouseEnter={() => setActive(index)}
205
+ onClick={() => choose(option)}
206
+ >
207
+ <span className="rwkv-menu-label">{option}</span>
208
+ {selected ? <CheckIcon /> : null}
209
+ </button>
210
+ )
211
+ })}
212
+ </div>
213
+ ) : null}
214
+ </div>
215
+ )
216
+ }
217
+
218
+ export function SelectInput<T extends string>(props: {
219
+ value: T | ''
220
+ options: readonly (readonly [T | '', string])[]
221
+ onChange: (value: T | '') => void
222
+ disabled?: boolean
223
+ }) {
224
+ const [open, setOpen] = useState(false)
225
+ const [active, setActive] = useState(-1)
226
+ const rootRef = useRef<HTMLDivElement>(null)
227
+ const listId = useId()
228
+ useDismiss(open, rootRef, () => setOpen(false))
229
+
230
+ const selectedIndex = props.options.findIndex(([value]) => value === props.value)
231
+ const currentLabel = selectedIndex >= 0 ? props.options[selectedIndex]![1] : ''
232
+ const showMenu = open && !props.disabled
233
+
234
+ const choose = (value: T | '') => {
235
+ props.onChange(value)
236
+ setOpen(false)
237
+ setActive(-1)
238
+ }
239
+
240
+ const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {
241
+ if (props.disabled) return
242
+ if (event.key === 'ArrowDown') {
243
+ event.preventDefault()
244
+ if (!open) {
245
+ setOpen(true)
246
+ setActive(selectedIndex >= 0 ? selectedIndex : 0)
247
+ } else {
248
+ setActive(index => (index + 1) % props.options.length)
249
+ }
250
+ } else if (event.key === 'ArrowUp') {
251
+ event.preventDefault()
252
+ if (!open) {
253
+ setOpen(true)
254
+ setActive(selectedIndex >= 0 ? selectedIndex : props.options.length - 1)
255
+ } else {
256
+ setActive(index => (index <= 0 ? props.options.length - 1 : index - 1))
257
+ }
258
+ } else if ((event.key === 'Enter' || event.key === ' ') && open && active >= 0 && active < props.options.length) {
259
+ event.preventDefault()
260
+ choose(props.options[active]![0])
261
+ } else if (event.key === 'Escape' && open) {
262
+ event.preventDefault()
263
+ setOpen(false)
264
+ }
265
+ }
266
+
267
+ return (
268
+ <div ref={rootRef} className="rwkv-combo">
269
+ <button
270
+ type="button"
271
+ role="combobox"
272
+ aria-expanded={showMenu}
273
+ aria-controls={showMenu ? listId : undefined}
274
+ className="rwkv-input rwkv-select-trigger"
275
+ disabled={props.disabled}
276
+ onClick={() => {
277
+ setOpen(current => !current)
278
+ setActive(selectedIndex >= 0 ? selectedIndex : 0)
279
+ }}
280
+ onKeyDown={onKeyDown}
281
+ >
282
+ <span className="rwkv-select-value">{currentLabel}</span>
283
+ <ChevronIcon open={showMenu} />
284
+ </button>
285
+ {showMenu ? (
286
+ <div id={listId} role="listbox" className="rwkv-menu">
287
+ {props.options.map(([value, label], index) => {
288
+ const selected = value === props.value
289
+ return (
290
+ <button
291
+ key={value}
292
+ type="button"
293
+ role="option"
294
+ aria-selected={selected}
295
+ data-active={active === index ? 'true' : undefined}
296
+ className="rwkv-menu-item"
297
+ onMouseDown={event => event.preventDefault()}
298
+ onMouseEnter={() => setActive(index)}
299
+ onClick={() => choose(value)}
300
+ >
301
+ <span className="rwkv-menu-label">{label}</span>
302
+ {selected ? <CheckIcon /> : null}
303
+ </button>
304
+ )
305
+ })}
306
+ </div>
307
+ ) : null}
308
+ </div>
309
+ )
310
+ }
311
+
312
+ export function Check(props: { checked: boolean; onChange: (value: boolean) => void; label: string; disabled?: boolean }) {
313
+ return (
314
+ <label className="rwkv-check">
315
+ <input type="checkbox" checked={props.checked} disabled={props.disabled} onChange={event => props.onChange(event.target.checked)} />
316
+ {props.label}
317
+ </label>
318
+ )
319
+ }
320
+
321
+ export function HeadersInput(props: {
322
+ value: Record<string, string> | undefined
323
+ onChange: (value: Record<string, string> | undefined, error?: string) => void
324
+ disabled?: boolean
325
+ }) {
326
+ const [text, setText] = useState(() => props.value && Object.keys(props.value).length > 0 ? JSON.stringify(props.value, null, 2) : '')
327
+ return (
328
+ <textarea
329
+ className="rwkv-input" value={text} disabled={props.disabled} spellCheck={false}
330
+ placeholder={'{"CF-Access-Client-Id": "…", "CF-Access-Client-Secret": "…"}'}
331
+ onChange={event => {
332
+ setText(event.target.value)
333
+ if (event.target.value.trim() === '') return props.onChange(undefined)
334
+ try {
335
+ const parsed: unknown = JSON.parse(event.target.value)
336
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) throw new Error('需要一个 JSON 对象')
337
+ props.onChange(Object.fromEntries(Object.entries(parsed).map(([key, value]) => [key, String(value)])))
338
+ } catch (cause) {
339
+ props.onChange(undefined, `请求头不是有效的 JSON:${cause instanceof Error ? cause.message : String(cause)}`)
340
+ }
341
+ }}
342
+ />
343
+ )
344
+ }
345
+
346
+ export function EditorActions(props: {
347
+ error?: string | undefined
348
+ busy: boolean
349
+ canSave: boolean
350
+ onCancel: () => void
351
+ onSave: () => void
352
+ }) {
353
+ return (
354
+ <div className="rwkv-editor-actions">
355
+ {props.error ? <p className="rwkv-error">{props.error}</p> : null}
356
+ <button type="button" className="rwkv-btn rwkv-secondary" disabled={props.busy} onClick={props.onCancel}>取消</button>
357
+ <button type="button" className="rwkv-btn rwkv-primary" disabled={props.busy || !props.canSave} onClick={props.onSave}>
358
+ {props.busy ? '保存中…' : '保存'}
359
+ </button>
360
+ </div>
361
+ )
362
+ }
@@ -0,0 +1,109 @@
1
+ // Browser half: a "RWKV" section in Settings that edits the rwkv-llm row's
2
+ // config (endpoints, models, adapters, harness, sampling). It registers while
3
+ // the Host serves that row, so a profile without the plugin shows nothing.
4
+ // Built by scripts/build.mjs into the lazy-CJS factory DSH loads;
5
+ // only `react` is shared from the module table.
6
+
7
+ import type { Context } from '@deepseek-ai/cordis'
8
+ import { CONTEXT_FOLD_NODE_KEY, rwkvFoldDefinition, RwkvFoldNodeView } from './FoldNode.tsx'
9
+ import { RwkvSettings, type ConfigFormLike } from './RwkvSettings.tsx'
10
+ import { RwkvTraceView } from './TraceView.tsx'
11
+ import { RwkvWireIcon, RwkvWirePanel, WIRE_TAB_ID } from './WirePanel.tsx'
12
+ import { mountStyles } from './styles.ts'
13
+
14
+ /** Profile row id of the provider plugin, i.e. the settings namespace it is served under. */
15
+ export const NAMESPACE = 'rwkv-llm'
16
+
17
+ export const inject = ['slots', 'configForms', 'remote']
18
+
19
+ interface ClientServices {
20
+ remote?: {
21
+ settings?: {
22
+ mutate(ns: string, ops: unknown[], revision: number | undefined): Promise<{ ok: boolean; error?: { message?: string; code?: string } }>
23
+ }
24
+ }
25
+ configForms: {
26
+ get(entryId: string): ConfigFormLike
27
+ whileServed(namespaces: readonly string[], register: (served: ReadonlySet<string>) => () => void): () => void
28
+ }
29
+ slots: {
30
+ inject(name: string, register: () => () => void): () => void
31
+ register(options: Record<string, unknown>, component: unknown): () => void
32
+ }
33
+ uiConversation?: {
34
+ events?: {
35
+ register(definition: unknown): (() => void) | void
36
+ }
37
+ }
38
+ sidebarRightTabs?: {
39
+ register(definition: unknown): (() => void) | void
40
+ }
41
+ }
42
+
43
+ export function apply(ctx: Context): void {
44
+ const services = ctx as unknown as ClientServices
45
+ const form = services.configForms.get(NAMESPACE)
46
+ // configForms.set reports only true/false. After a refused write, repeat it
47
+ // through the settings remote to read the Host's reason; a refused write
48
+ // changed nothing, so the repeat is refused the same way.
49
+ const explain = async (field: string, value: unknown): Promise<string> => {
50
+ const mutate = services.remote?.settings?.mutate
51
+ if (mutate === undefined) return ''
52
+ try {
53
+ const result = await mutate.call(services.remote!.settings, NAMESPACE, [{ op: 'set', path: [field], value }], form.getSnapshot().revision)
54
+ return result.ok ? '' : result.error?.message ?? result.error?.code ?? ''
55
+ } catch (error) {
56
+ return error instanceof Error ? error.message : String(error)
57
+ }
58
+ }
59
+ ctx.effect(() => mountStyles(), 'rwkv-llm: settings styles')
60
+ ctx.effect(() => services.configForms.whileServed([NAMESPACE], () => services.slots.inject('settings.section', () => services.slots.register({
61
+ name: 'settings.section',
62
+ id: 'rwkv',
63
+ order: 15,
64
+ label: () => 'RWKV Agent',
65
+ inject: () => ({ form, explain }),
66
+ }, RwkvSettings))), 'rwkv-llm: settings section')
67
+ // The RWKV tab beside Chat / Trajectory: the Host keeps traces in memory
68
+ // whether or not they are written to disk, so it is always there.
69
+ ctx.effect(() => services.configForms.whileServed([NAMESPACE], () => services.slots.inject('conversation.view', () => services.slots.register({
70
+ name: 'conversation.view',
71
+ id: 'rwkv-trace',
72
+ order: 45,
73
+ label: () => 'RWKV',
74
+ inject: (sessionId: string) => ({ session: String(sessionId) }),
75
+ }, RwkvTraceView))), 'rwkv-llm: trace view')
76
+ // Inline context-fold divider in the main Chat stream (`plugin:rwkv-llm/context-fold`).
77
+ const injectFn = (ctx as unknown as { inject?: (deps: readonly string[], fn: (sub: Context) => void) => void }).inject
78
+ injectFn?.call(ctx, ['uiConversation'], subCtx => {
79
+ const uiConv = (subCtx as unknown as ClientServices).uiConversation
80
+ const dispose = uiConv?.events?.register?.(rwkvFoldDefinition)
81
+ if (typeof dispose === 'function') subCtx.effect(() => dispose, 'rwkv-llm: chat fold definition')
82
+ subCtx.effect(() => services.slots.inject('conversation.chat.node', () => services.slots.register({
83
+ name: 'conversation.chat.node',
84
+ key: CONTEXT_FOLD_NODE_KEY,
85
+ }, RwkvFoldNodeView)), 'rwkv-llm: chat fold node')
86
+ })
87
+ // Right-sidebar real-time character-level RWKV wire viewer.
88
+ injectFn?.call(ctx, ['sidebarRightTabs'], subCtx => {
89
+ const tabs = (subCtx as unknown as ClientServices).sidebarRightTabs
90
+ const dispose = tabs?.register?.({
91
+ id: WIRE_TAB_ID,
92
+ kind: WIRE_TAB_ID,
93
+ title: () => 'RWKV 实时上下文',
94
+ guide: [{
95
+ id: WIRE_TAB_ID,
96
+ order: 45,
97
+ title: () => 'RWKV 实时上下文',
98
+ description: () => '查看模型原始上下文',
99
+ icon: RwkvWireIcon,
100
+ }],
101
+ })
102
+ if (typeof dispose === 'function') subCtx.effect(() => dispose, 'rwkv-llm: wire tab type')
103
+ subCtx.effect(() => services.slots.inject('sidebar.right.pane.tab', () => services.slots.register({
104
+ name: 'sidebar.right.pane.tab',
105
+ key: WIRE_TAB_ID,
106
+ inject: (sessionId: string) => ({ session: String(sessionId) }),
107
+ }, RwkvWirePanel)), 'rwkv-llm: wire tab body')
108
+ })
109
+ }