dsh-quay-bot 1.0.4 → 1.0.6

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/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  window.__ModuleLoader__.load({
2
- id: '@local/dsh-botmode',
2
+ id: 'dsh-quay-bot',
3
3
  factory(require) {
4
4
  const React = require('react')
5
5
  const ReactDOM = require('react-dom')
@@ -1753,9 +1753,11 @@ window.__ModuleLoader__.load({
1753
1753
  .bm-foot-toggle:not([data-wide='true']) span { display: none; }
1754
1754
  .bm-foot-toggle { appearance: none; border: 0; background: transparent; color: var(--dsw-alias-label-secondary);
1755
1755
  font: inherit; font-size: 12px; line-height: 16px; display: inline-flex; align-items: center; gap: 6px;
1756
- padding: 5px 8px; border-radius: var(--dsw-radius-md); cursor: pointer; width: 100%; text-align: left; }
1756
+ padding: 5px 8px; border-radius: var(--dsw-radius-md); cursor: pointer; flex: 1 1 auto; min-width: 0;
1757
+ white-space: nowrap; text-align: left; }
1757
1758
  .bm-foot-toggle:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
1758
1759
  .bm-foot-toggle[data-active='true'] { color: var(--dsw-alias-brand-primary); }
1760
+ .bm-remote-trigger { flex: 0 0 auto; }
1759
1761
 
1760
1762
  /* ---- 3-column workspace + Right Rail (Screen Card + Scheduled Tasks) ---- */
1761
1763
  .bm-workspace { flex: 1; min-height: 0; display: flex; overflow: hidden; }
@@ -1967,10 +1969,19 @@ window.__ModuleLoader__.load({
1967
1969
  return ''
1968
1970
  }
1969
1971
  }
1972
+ ctx.effect(() => {
1973
+ if (typeof document === 'undefined' || !document.head) return undefined
1974
+ const styleEl = document.createElement('style')
1975
+ styleEl.setAttribute('data-botmode-css', '1')
1976
+ styleEl.textContent = CSS
1977
+ document.head.appendChild(styleEl)
1978
+ return () => { styleEl.remove() }
1979
+ }, 'botmode: global styles')
1980
+
1970
1981
  const useAvatarEngine = () => {
1971
1982
  const snap = useSyncExternalStore(
1972
- listener => avatarEngineStore.subscribe(listener),
1973
- () => avatarEngineStore.getSnapshot(),
1983
+ avatarEngineStore.subscribe,
1984
+ avatarEngineStore.getSnapshot,
1974
1985
  )
1975
1986
  useEffect(() => {
1976
1987
  if (snap.status === 'idle') void ensureAvatarEngine()
@@ -2123,14 +2134,17 @@ window.__ModuleLoader__.load({
2123
2134
  const markGroupSeen = () => {}
2124
2135
  ctx.effect(() => {
2125
2136
  void refreshHost()
2137
+ const isBotPanelActive = () => {
2138
+ const panel = ctx.layout.panelInfo.getSnapshot()
2139
+ const id = panel && (panel.activePanelId ?? panel.activeId)
2140
+ return id === PANEL_ID
2141
+ }
2126
2142
  const timer = window.setInterval(() => {
2127
2143
  if (document.visibilityState === 'hidden') return
2128
- const panel = ctx.layout.panelInfo.getSnapshot()
2129
- if (panel && panel.activeId === PANEL_ID) void refreshHost()
2144
+ if (isBotPanelActive()) void refreshHost()
2130
2145
  }, 3000)
2131
2146
  const unsubPanel = ctx.layout.panelInfo.subscribe(() => {
2132
- const panel = ctx.layout.panelInfo.getSnapshot()
2133
- if (panel && panel.activeId === PANEL_ID) void refreshHost()
2147
+ if (isBotPanelActive()) void refreshHost()
2134
2148
  })
2135
2149
  return () => {
2136
2150
  window.clearInterval(timer)
@@ -2309,10 +2323,16 @@ window.__ModuleLoader__.load({
2309
2323
  }
2310
2324
  ctx.effect(registerLocales, 'botmode: dictionaries')
2311
2325
 
2312
- const useLang = () => useSyncExternalStore(
2313
- listener => locale.subscribe(listener),
2314
- () => locale.getLocale(),
2315
- )
2326
+ const subscribeLocale = (listener) => locale.subscribe(listener)
2327
+ let cachedLocaleSnap = { active: 'en' }
2328
+ const getLocaleSnapshot = () => {
2329
+ const raw = locale.getLocale()
2330
+ const active = (raw && raw.active) || 'en'
2331
+ if (cachedLocaleSnap && cachedLocaleSnap.active === active) return cachedLocaleSnap
2332
+ cachedLocaleSnap = raw && typeof raw === 'object' ? raw : { active }
2333
+ return cachedLocaleSnap
2334
+ }
2335
+ const useLang = () => useSyncExternalStore(subscribeLocale, getLocaleSnapshot)
2316
2336
 
2317
2337
  const useT = () => {
2318
2338
  const snapshot = useLang()
@@ -2320,10 +2340,16 @@ window.__ModuleLoader__.load({
2320
2340
  return useMemo(() => (key, vars) => interpolate(dict[key] ?? DICT.en[key] ?? key, vars), [dict])
2321
2341
  }
2322
2342
 
2323
- const useMainPanel = () => useSyncExternalStore(
2324
- listener => ctx.layout.panelInfo.subscribe(listener),
2325
- () => ctx.layout.panelInfo.getSnapshot(),
2326
- )
2343
+ const subscribeMainPanel = (listener) => ctx.layout.panelInfo.subscribe(listener)
2344
+ let cachedPanelSnap = { activePanelId: null }
2345
+ const getMainPanelSnapshot = () => {
2346
+ const raw = ctx.layout.panelInfo.getSnapshot()
2347
+ const id = (raw && (raw.activePanelId ?? raw.activeId)) || null
2348
+ if (cachedPanelSnap && cachedPanelSnap.activePanelId === id) return cachedPanelSnap
2349
+ cachedPanelSnap = { activePanelId: id }
2350
+ return cachedPanelSnap
2351
+ }
2352
+ const useMainPanel = () => useSyncExternalStore(subscribeMainPanel, getMainPanelSnapshot)
2327
2353
 
2328
2354
  const openBot = (bot) => {
2329
2355
  if (!bot.sessionId) return
@@ -4195,14 +4221,24 @@ window.__ModuleLoader__.load({
4195
4221
  useEffect(() => () => { if (reference) reference.release() }, [reference])
4196
4222
  const binding = reference ? reference.binding : null
4197
4223
  const session = binding ? binding.session : null
4198
- const snapshot = useSyncExternalStore(
4199
- listener => (session ? session.subscribe(listener) : () => {}),
4200
- () => (session ? session.getSnapshot() : ERROR_SESSION_SNAP),
4224
+ const subscribeSession = useMemo(
4225
+ () => (session ? (listener => session.subscribe(listener)) : NOOP_SUBSCRIBE),
4226
+ [session],
4227
+ )
4228
+ const getSessionSnap = useMemo(
4229
+ () => (session ? (() => session.getSnapshot()) : GET_ERROR_SESSION_SNAP),
4230
+ [session],
4231
+ )
4232
+ const subscribeEvents = useMemo(
4233
+ () => (binding ? (listener => binding.eventSource.subscribe(listener)) : NOOP_SUBSCRIBE),
4234
+ [binding],
4201
4235
  )
4202
- const events = useSyncExternalStore(
4203
- listener => (binding ? binding.eventSource.subscribe(listener) : () => {}),
4204
- () => (binding ? binding.eventSource.getSnapshot() : EMPTY_EVENT_SNAP),
4236
+ const getEventsSnap = useMemo(
4237
+ () => (binding ? (() => binding.eventSource.getSnapshot()) : GET_EMPTY_EVENT_SNAP),
4238
+ [binding],
4205
4239
  )
4240
+ const snapshot = useSyncExternalStore(subscribeSession, getSessionSnap)
4241
+ const events = useSyncExternalStore(subscribeEvents, getEventsSnap)
4206
4242
  const turns = useMemo(() => buildTranscript(events.entries), [events])
4207
4243
  const stickRef = useRef(true)
4208
4244
  useEffect(() => {
@@ -4353,9 +4389,13 @@ window.__ModuleLoader__.load({
4353
4389
  : h('button', { type: 'submit', className: 'bm-btn primary', disabled: busy || (text.trim() === '' && images.length === 0) }, busy ? t('form.busy') : t('chat.send')))))
4354
4390
  }
4355
4391
 
4392
+ const NOOP_SUBSCRIBE = () => () => {}
4356
4393
  const IDLE_SESSION_SNAP = Object.freeze({ running: false, openState: 'idle', hasMore: false })
4357
4394
  const ERROR_SESSION_SNAP = Object.freeze({ running: false, openState: 'error', hasMore: false })
4358
4395
  const EMPTY_EVENT_SNAP = Object.freeze({ entries: Object.freeze([]), hasMore: false, revision: 0 })
4396
+ const GET_IDLE_SESSION_SNAP = () => IDLE_SESSION_SNAP
4397
+ const GET_ERROR_SESSION_SNAP = () => ERROR_SESSION_SNAP
4398
+ const GET_EMPTY_EVENT_SNAP = () => EMPTY_EVENT_SNAP
4359
4399
 
4360
4400
  function isClientPassToken(raw) {
4361
4401
  let v = String(raw || '').trim()
@@ -4594,14 +4634,24 @@ window.__ModuleLoader__.load({
4594
4634
  useEffect(() => () => { if (reference) reference.release() }, [reference])
4595
4635
  const binding = reference ? reference.binding : null
4596
4636
  const session = binding ? binding.session : null
4597
- const snapshot = useSyncExternalStore(
4598
- listener => (session ? session.subscribe(listener) : () => {}),
4599
- () => (session ? session.getSnapshot() : IDLE_SESSION_SNAP),
4637
+ const subscribeSession = useMemo(
4638
+ () => (session ? (listener => session.subscribe(listener)) : NOOP_SUBSCRIBE),
4639
+ [session],
4600
4640
  )
4601
- const events = useSyncExternalStore(
4602
- listener => (binding ? binding.eventSource.subscribe(listener) : () => {}),
4603
- () => (binding ? binding.eventSource.getSnapshot() : EMPTY_EVENT_SNAP),
4641
+ const getSessionSnap = useMemo(
4642
+ () => (session ? (() => session.getSnapshot()) : GET_IDLE_SESSION_SNAP),
4643
+ [session],
4604
4644
  )
4645
+ const subscribeEvents = useMemo(
4646
+ () => (binding ? (listener => binding.eventSource.subscribe(listener)) : NOOP_SUBSCRIBE),
4647
+ [binding],
4648
+ )
4649
+ const getEventsSnap = useMemo(
4650
+ () => (binding ? (() => binding.eventSource.getSnapshot()) : GET_EMPTY_EVENT_SNAP),
4651
+ [binding],
4652
+ )
4653
+ const snapshot = useSyncExternalStore(subscribeSession, getSessionSnap)
4654
+ const events = useSyncExternalStore(subscribeEvents, getEventsSnap)
4605
4655
 
4606
4656
  const wasRunningRef = useRef(false)
4607
4657
  useEffect(() => {
@@ -7776,14 +7826,14 @@ window.__ModuleLoader__.load({
7776
7826
  }, t('rich.download')))))))
7777
7827
  }
7778
7828
 
7829
+ const EMPTY_SESSION_LIST = Object.freeze({ ids: Object.freeze([]), byId: Object.freeze({}) })
7830
+ const getRawSessionListSafe = () => rawSessionSnapshot() || EMPTY_SESSION_LIST
7831
+
7779
7832
  function BotsPage() {
7780
7833
  const t = useT()
7781
7834
  const stored = useSyncExternalStore(roster.subscribe, roster.getSnapshot)
7782
7835
  const groups = useSyncExternalStore(groupStore.subscribe, groupStore.getSnapshot)
7783
- const list = useSyncExternalStore(
7784
- listener => sessions.list.subscribe(listener),
7785
- rawSessionSnapshot,
7786
- )
7836
+ const list = useSyncExternalStore(rawSessionSubscribe, getRawSessionListSafe)
7787
7837
  const hostSnapshot = useSyncExternalStore(hostStore.subscribe, hostStore.getSnapshot)
7788
7838
  const models = useSyncExternalStore(modelStore.subscribe, modelStore.getSnapshot)
7789
7839
  useEffect(() => {
@@ -7840,6 +7890,7 @@ window.__ModuleLoader__.load({
7840
7890
  const [query, setQuery] = useState('')
7841
7891
  const [railOpen, setRailOpen] = useState(true)
7842
7892
  const [takeoverModal, setTakeoverModal] = useState(null)
7893
+ const [remoteOpen, setRemoteOpen] = useState(false)
7843
7894
 
7844
7895
  const openScreenTakeover = async (targetBot, helpEntry = null) => {
7845
7896
  const botId = (targetBot && targetBot.id) || (helpEntry && helpEntry.botId)
@@ -8047,6 +8098,13 @@ window.__ModuleLoader__.load({
8047
8098
  style: { display: 'inline-flex', alignItems: 'center', gap: '5px', flex: 1, justifyContent: 'center' },
8048
8099
  onClick: () => openSettingsView('soul'),
8049
8100
  }, h(SettingsIcon, { kind: 'gear' }), t('pane.settings')),
8101
+ h('button', {
8102
+ type: 'button',
8103
+ className: 'bm-btn small',
8104
+ style: { display: 'inline-flex', alignItems: 'center', gap: '4px', justifyContent: 'center' },
8105
+ title: t('remote.title'),
8106
+ onClick: () => setRemoteOpen(true),
8107
+ }, h(RemoteIcon, { size: 13 }), t('remote.button')),
8050
8108
  h('button', { type: 'button', className: 'bm-btn small', onClick: toHarness }, t('foot.back'))))
8051
8109
 
8052
8110
  const detailBody = activeBot
@@ -8198,7 +8256,8 @@ window.__ModuleLoader__.load({
8198
8256
  onCommand: hostCommand,
8199
8257
  onScreenInput: sendScreenInput,
8200
8258
  onClose: () => setTakeoverModal(null),
8201
- }))
8259
+ }),
8260
+ remoteOpen ? h(RemoteDialog, { onClose: () => setRemoteOpen(false) }) : null)
8202
8261
  }
8203
8262
 
8204
8263
  function PanelIcon(props) {
@@ -8419,25 +8478,26 @@ window.__ModuleLoader__.load({
8419
8478
  open ? h(RemoteDialog, { onClose: () => setOpen(false) }) : null)
8420
8479
  }
8421
8480
 
8422
- ctx.slots.inject('sidebar.footer.action', () => ctx.slots.register({
8423
- name: 'sidebar.footer.action',
8424
- id: 'botmode.remote',
8425
- order: 11,
8426
- label: () => (typeof locale.getLocale === 'function'
8427
- ? (String((locale.getLocale() || {}).active || '').startsWith('zh') ? '远程访问' : 'Remote')
8428
- : 'Remote'),
8429
- locale: NS,
8430
- }, RemoteFooterButton))
8431
-
8432
- ctx.slots.inject('sidebar.footer.action', () => ctx.slots.register({
8433
- name: 'sidebar.footer.action',
8434
- id: 'botmode.mode-switch',
8435
- order: 10,
8436
- label: () => (typeof locale.getLocale === 'function'
8437
- ? (String((locale.getLocale() || {}).active || '').startsWith('zh') ? 'Bot 模式' : 'Bot mode')
8438
- : 'Bot mode'),
8439
- locale: NS,
8440
- }, FooterToggle))
8481
+ ctx.slots.inject('sidebar.footer.action', function* () {
8482
+ yield ctx.slots.register({
8483
+ name: 'sidebar.footer.action',
8484
+ id: 'botmode.mode-switch',
8485
+ order: 10,
8486
+ label: () => (typeof locale.getLocale === 'function'
8487
+ ? (String((locale.getLocale() || {}).active || '').startsWith('zh') ? 'Bot 模式' : 'Bot mode')
8488
+ : 'Bot mode'),
8489
+ locale: NS,
8490
+ }, FooterToggle)
8491
+ yield ctx.slots.register({
8492
+ name: 'sidebar.footer.action',
8493
+ id: 'botmode.remote',
8494
+ order: 11,
8495
+ label: () => (typeof locale.getLocale === 'function'
8496
+ ? (String((locale.getLocale() || {}).active || '').startsWith('zh') ? '远程访问' : 'Remote')
8497
+ : 'Remote'),
8498
+ locale: NS,
8499
+ }, RemoteFooterButton)
8500
+ })
8441
8501
 
8442
8502
  const panelLabel = () => {
8443
8503
  const active = String((locale.getLocale() && locale.getLocale().active) || '').toLowerCase()
@@ -8463,17 +8523,26 @@ window.__ModuleLoader__.load({
8463
8523
  if (this.state.error) {
8464
8524
  return h('div', { className: 'bm-page', style: { padding: '32px', overflow: 'auto' } },
8465
8525
  h('h2', null, 'Bot 模式渲染失败 / Bot mode failed to render'),
8526
+ h('div', { style: { display: 'flex', gap: '8px', margin: '12px 0' } },
8527
+ h('button', {
8528
+ type: 'button',
8529
+ className: 'bm-btn small primary',
8530
+ onClick: () => this.setState({ error: null }),
8531
+ }, '重试 / Retry')),
8466
8532
  h('pre', { style: { whiteSpace: 'pre-wrap', fontSize: '12px', opacity: 0.8 } },
8467
8533
  String((this.state.error && this.state.error.stack) || this.state.error)))
8468
8534
  }
8469
8535
  return this.props.children
8470
8536
  }
8471
8537
  }
8538
+ function BotsMainSlot() {
8539
+ return h(PageBoundary, null, h(BotsPage))
8540
+ }
8472
8541
  ctx.slots.inject('main', () => ctx.slots.register({
8473
8542
  name: 'main',
8474
8543
  key: PANEL_ID,
8475
8544
  locale: NS,
8476
- }, () => h(PageBoundary, null, h(BotsPage))))
8545
+ }, BotsMainSlot))
8477
8546
  },
8478
8547
  }
8479
8548
  },
package/cordis.patch.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  - insert:
2
2
  - id: botmode
3
- name: '@local/dsh-botmode'
3
+ name: 'dsh-quay-bot'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-quay-bot",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22.5.0"
@@ -29,7 +29,6 @@
29
29
  "remote/bin/**/*",
30
30
  "remote/src/**/*",
31
31
  "remote/package.json",
32
- "vendor/**/*",
33
32
  "host/**/*.js",
34
33
  "host/**/*.mjs",
35
34
  "host/**/*.json",