@sshirkit/dsh-orchestrator 1.0.1 → 1.0.3

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
@@ -28,7 +28,8 @@ window.__ModuleLoader__.load({
28
28
  'route.catalogFailed': '无法加载模型目录',
29
29
  'route.readonly': '当前不可写,无法保存',
30
30
  'route.saveFailed': '保存失败',
31
- 'route.note': '主代理的改动对新会话生效;子代理的改动从下一次委派起生效。所有子代理共用同一个模型。',
31
+ 'route.note': '主代理的全局默认模型对新会话生效;子代理从下一次委派起使用新路由,可在任务或阶段中显式覆盖。',
32
+ 'route.sessionNote': '主代理的新路由在当前会话的下一步生效;子代理从下一次委派起使用新路由。',
32
33
  'route.search': '搜索模型…',
33
34
  'route.noMatch': '没有匹配的模型',
34
35
  'route.noMatchHint': '换个关键词,或清空搜索看全部',
@@ -37,14 +38,28 @@ window.__ModuleLoader__.load({
37
38
  'route.enableNote': '开启后主代理只做规划、由子代理执行;已打开的会话也会立即生效。',
38
39
  'route.enableFailed': '切换失败',
39
40
  'worktreeIsolation.label': '默认启用 Git Worktree 隔离',
40
- 'worktreeIsolation.hint': 'Git 仓库中的写任务默认使用独立 Worktree,并用 git diff / git log 审计。delegate 按任务、orchestrate 按条目隔离;非 Git 目录自动使用逻辑快照审计。',
41
+ 'worktreeIsolation.hint': 'Git 仓库中的写任务默认使用独立 Worktree,delegate 按任务隔离,orchestrate 按条目隔离。非 Git 工作区使用写租约协调共享目录中的写入。',
41
42
  'allowed.title': 'Allowed Tools',
42
43
  'allowed.search': '搜索工具…',
43
44
  'allowed.empty': '没有匹配的工具',
44
45
  'allowed.reset': '重置',
46
+ 'allowed.session': '仅当前会话',
47
+ 'allowed.sessionOn': '面板内所有选项仅对当前会话生效。',
48
+ 'allowed.sessionOff': '继承全局默认;编辑将修改全局设置。',
49
+ 'allowed.sessionMissing': '没有可用于保存的会话。',
50
+ 'allowed.sessionLoading': '正在加载会话设置…',
51
+ 'allowed.sessionFailed': '无法加载会话设置',
52
+ 'allowed.sessionStorage': '会话设置存储不可用。',
53
+ 'more.button': '更多',
54
+ 'more.title': '更多调度设置',
55
+ 'more.close': '关闭',
56
+ 'readOnly.label': '启用只读参数',
57
+ 'readOnly.hint': '关闭时隐藏 readOnly 参数,并引导模型用 isolation: "shared" 做只读调研。若开启则推荐配合“子代理平级主动通讯”选项一块开启(对应“允许平级询问”开关)。',
58
+ 'peerReadOnlyConsult.label': '允许平级询问',
59
+ 'peerReadOnlyConsult.hint': '同一会话中的只读子代理可以共享已读索引并互相咨询,主代理不会收到通知。',
45
60
  'allowed.hint': '白名单式驱动:勾选 = 允许主代理使用;未勾选(含新插件工具)= 自动禁用。',
46
61
  'allowed.nativeBlocked': '按 ADR-0004 默认禁用;建议改用 delegate / orchestrate。显式勾选可覆盖。',
47
- 'allowed.teamDisabled': '当前配置已关闭原生 Team 共享任务板(allowAgentTeam: false)。',
62
+ 'allowed.teamDisabled': '调度模式下禁止主代理调用原生 Team 任务板工具(allowAgentTeam: false)。',
48
63
  'supervise.label': '子代理巡检间隔(秒)',
49
64
  'supervise.hint': '默认 600 秒(10 分钟)。主代理会按此间隔检查运行中的子代理,运行中修改立即生效。范围 10–86400。',
50
65
  'supervise.invalid': '请输入 10–86400 之间的整数',
@@ -67,7 +82,8 @@ window.__ModuleLoader__.load({
67
82
  'route.catalogFailed': 'Could not load the model catalog',
68
83
  'route.readonly': 'Not writable right now, cannot save',
69
84
  'route.saveFailed': 'Could not save',
70
- 'route.note': 'A main agent change applies to new sessions; a subagent change applies from the next delegation. All subagents share one model.',
85
+ 'route.note': 'The global main agent default applies to new sessions. Subagents use the new route from the next delegation, unless a task or stage overrides it.',
86
+ 'route.sessionNote': 'The main agent uses the new route on the next step in this session. Subagents use it from the next delegation.',
71
87
  'route.search': 'Search models…',
72
88
  'route.noMatch': 'No matching models',
73
89
  'route.noMatchHint': 'Try another keyword, or clear the search to see everything',
@@ -76,14 +92,28 @@ window.__ModuleLoader__.load({
76
92
  'route.enableNote': 'The main agent only plans and delegates the work; an open conversation follows the switch immediately.',
77
93
  'route.enableFailed': 'Could not switch',
78
94
  'worktreeIsolation.label': 'Enable Git Worktree isolation by default',
79
- 'worktreeIsolation.hint': 'Write tasks in Git repositories use separate worktrees with git diff / git log audits: one per delegate task or orchestrate item. Non-Git directories fall back to snapshot audits.',
95
+ 'worktreeIsolation.hint': 'By default, write tasks in Git repositories use separate worktrees: one per delegate task or orchestrate item. Non-Git workspaces use write leases to coordinate writes in the shared directory.',
80
96
  'allowed.title': 'Allowed Tools',
81
97
  'allowed.search': 'Filter tools…',
82
98
  'allowed.empty': 'No matching tools',
83
99
  'allowed.reset': 'Reset',
100
+ 'allowed.session': 'Only for this session',
101
+ 'allowed.sessionOn': 'All settings in this panel apply only to this session.',
102
+ 'allowed.sessionOff': 'Inherits global defaults; edits change the global settings.',
103
+ 'allowed.sessionMissing': 'No session is available for saving.',
104
+ 'allowed.sessionLoading': 'Loading session settings…',
105
+ 'allowed.sessionFailed': 'Could not load session settings',
106
+ 'allowed.sessionStorage': 'Session settings storage is unavailable.',
107
+ 'more.button': 'More',
108
+ 'more.title': 'More dispatch settings',
109
+ 'more.close': 'Close',
110
+ 'readOnly.label': 'Enable the read-only parameter',
111
+ 'readOnly.hint': 'When off, readOnly is hidden and models are directed to use isolation: "shared" for read-only research. If enabled, we recommend also turning on "Allow peer consultation" for proactive communication between subagents.',
112
+ 'peerReadOnlyConsult.label': 'Allow peer consultation',
113
+ 'peerReadOnlyConsult.hint': 'Read-only subagents in the same session can share indexes of what they have read and consult each other without notifying the main agent.',
84
114
  'allowed.hint': 'Whitelist-driven: checked = allowed for the main agent; unchecked (including new plugin tools) = blocked automatically.',
85
115
  'allowed.nativeBlocked': 'Disabled by default under ADR-0004; prefer delegate / orchestrate. Check explicitly to override.',
86
- 'allowed.teamDisabled': 'The native Team task board is disabled by configuration (allowAgentTeam: false).',
116
+ 'allowed.teamDisabled': 'In dispatch mode, the main agent cannot call native Team task-board tools (allowAgentTeam: false).',
87
117
  'supervise.label': 'Subagent check interval (seconds)',
88
118
  'supervise.hint': 'Default 600 seconds (10 minutes). The main agent checks running subagents at this interval; changes apply immediately. Range 10–86400.',
89
119
  'supervise.invalid': 'Enter an integer between 10 and 86400',
@@ -414,34 +444,370 @@ window.__ModuleLoader__.load({
414
444
  return [{ op: 'unset', path: [ALLOW_KEY] }]
415
445
  }
416
446
 
447
+ // The Web ModuleLoader loads this factory as a script, not as ESM. Mirror the
448
+ // host's descriptor browser-side and check the complete wire contract in tests.
449
+ const SESSION_REMOTE_PACKAGE = '@sshirkit/dsh-orchestrator'
450
+ const SESSION_REMOTE = 'orchestratorSession'
451
+ const SESSION_REMOTE_INJECT = `remote.${SESSION_REMOTE}`
452
+ function createSessionToolsDescriptors() {
453
+ const nonempty = (value, field) => {
454
+ if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${field} must be a non-empty string`)
455
+ return value
456
+ }
457
+ const parseSession = (value) => nonempty(value, 'sessionId')
458
+ const parseNames = (value) => {
459
+ if (!Array.isArray(value)) throw new TypeError('allowedTools must be an array')
460
+ return [...new Set(Array.from(value, (name) => nonempty(name, 'tool name')))]
461
+ }
462
+ const parseRevision = (value) => {
463
+ if (!Number.isSafeInteger(value) || value < 0) throw new TypeError('revision must be a non-negative safe integer')
464
+ return value
465
+ }
466
+ const isObject = (value) => value !== null && typeof value === 'object'
467
+ const objectRecord = (value) => {
468
+ const prototype = isObject(value) ? Object.getPrototypeOf(value) : undefined
469
+ return prototype === Object.prototype || prototype === null
470
+ }
471
+ const fields = (value, names) => {
472
+ if (!isObject(value) || Array.isArray(value) || Object.keys(value).length !== names.length ||
473
+ !names.every((key) => Object.hasOwn(value, key))) {
474
+ throw new TypeError(`expected record with fields ${names.join(', ')}`)
475
+ }
476
+ }
477
+ const boolean = (value, field) => {
478
+ if (typeof value !== 'boolean') throw new TypeError(`${field} must be a boolean`)
479
+ return value
480
+ }
481
+ const integer = (value, { key, min, max }) => {
482
+ if (!Number.isInteger(value) || value < min || value > max) {
483
+ throw new TypeError(`${key} must be an integer in ${min}..${max}`)
484
+ }
485
+ return value
486
+ }
487
+ const parseRoute = (value, field) => {
488
+ if (value === null) return null
489
+ if (!objectRecord(value) || !Object.hasOwn(value, 'provider') || !Object.hasOwn(value, 'model') ||
490
+ Object.keys(value).some((key) => !['provider', 'model', 'reasoningEffort'].includes(key))) {
491
+ throw new TypeError(`${field} must be a route with provider, model and optional reasoningEffort, or null`)
492
+ }
493
+ const provider = nonempty(value.provider, `${field}.provider`).trim()
494
+ const model = nonempty(value.model, `${field}.model`).trim()
495
+ if (Object.hasOwn(value, 'reasoningEffort') && typeof value.reasoningEffort !== 'string') {
496
+ throw new TypeError(`${field}.reasoningEffort must be a string`)
497
+ }
498
+ const reasoningEffort = value.reasoningEffort?.trim()
499
+ return { provider, model, ...(reasoningEffort && { reasoningEffort }) }
500
+ }
501
+ const configParsers = {
502
+ enabled: boolean,
503
+ worktreeIsolationEnabled: boolean,
504
+ readOnlyEnabled: boolean,
505
+ peerReadOnlyConsultEnabled: boolean,
506
+ mainRoute: parseRoute,
507
+ workerRoute: parseRoute,
508
+ superviseIntervalSeconds: (value) => integer(value, INTERVAL),
509
+ superviseMaxNoticesPerChild: (value) => integer(value, PATROL_COUNT),
510
+ superviseUnlimited: boolean,
511
+ allowedTools: parseNames,
512
+ }
513
+ const parseConfigPatch = (value) => {
514
+ if (!objectRecord(value)) throw new TypeError('config must be an object')
515
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => {
516
+ if (!Object.hasOwn(configParsers, key)) throw new TypeError(`unknown config field: ${key}`)
517
+ return [key, configParsers[key](item, key)]
518
+ }))
519
+ }
520
+ const parseResult = (value) => {
521
+ if (value?.ok === false) {
522
+ fields(value, ['ok', 'error'])
523
+ fields(value.error, ['code', 'message'])
524
+ nonempty(value.error.code, 'error code')
525
+ nonempty(value.error.message, 'error message')
526
+ return value
527
+ }
528
+ fields(value, ['sessionId', 'enabled', 'allowedTools', 'config', 'revision', 'storageReady'])
529
+ if (typeof value.enabled !== 'boolean' || typeof value.storageReady !== 'boolean') {
530
+ throw new TypeError('enabled and storageReady must be booleans')
531
+ }
532
+ parseSession(value.sessionId)
533
+ fields(value.config, Object.keys(configParsers))
534
+ const config = parseConfigPatch(value.config)
535
+ const allowedTools = parseNames(value.allowedTools)
536
+ if (allowedTools.length !== value.allowedTools.length || allowedTools.length !== value.config.allowedTools.length ||
537
+ !allowedTools.every((name, index) => config.allowedTools[index] === name)) {
538
+ throw new TypeError('allowedTools must match config.allowedTools exactly')
539
+ }
540
+ parseRevision(value.revision)
541
+ return { ...value, allowedTools, config }
542
+ }
543
+ const codec = (typeSymbol, parse) => ({ mode: 'strict', typeSymbol, create: () => ({ parse }) })
544
+ const parameter = (name, typeSymbol, parse) => ({
545
+ name, wire: name, source: 'json', codec: codec(typeSymbol, parse),
546
+ })
547
+ const session = parameter('sessionId', 'SessionId', parseSession)
548
+ const names = parameter('allowedTools', 'OrchestratorToolNames', parseNames)
549
+ const revision = parameter('expectedRevision', 'OrchestratorToolsRevision', parseRevision)
550
+ const config = parameter('config', 'OrchestratorSessionConfigPatch', parseConfigPatch)
551
+ const result = codec('OrchestratorSessionToolsResult', parseResult)
552
+ return Object.entries({
553
+ get: [session], set: [session, names, revision], setConfig: [session, config, revision], clear: [session, revision],
554
+ })
555
+ .map(([method, parameters]) => ({
556
+ id: `${SESSION_REMOTE_PACKAGE}/${SESSION_REMOTE}/${method}`,
557
+ service: SESSION_REMOTE,
558
+ namespace: SESSION_REMOTE,
559
+ method,
560
+ invocation: { kind: 'direct' },
561
+ parameters,
562
+ result,
563
+ }))
564
+ }
565
+
566
+ function mountSessionRemote(ctx) {
567
+ const unavailable = () => new Error('Session tools Remote is unavailable')
568
+ let stopped = false
569
+ let service
570
+ let unmount
571
+ let injectFiber
572
+ let injectTimeout
573
+ let closing
574
+ let resolveReady, rejectReady
575
+ const ready = new Promise((resolve, reject) => {
576
+ resolveReady = resolve
577
+ rejectReady = reject
578
+ })
579
+ const setup = Promise.resolve().then(async () => {
580
+ if (stopped || typeof ctx.remote?.$mount !== 'function') throw unavailable()
581
+ unmount = await ctx.remote.$mount({
582
+ package: SESSION_REMOTE_PACKAGE,
583
+ descriptors: createSessionToolsDescriptors(),
584
+ })
585
+ if (typeof unmount !== 'function') throw new Error('Session tools Remote registration was not confirmed')
586
+ if (stopped) return
587
+ if (typeof ctx.inject !== 'function') {
588
+ service = typeof ctx.get === 'function' ? ctx.get(SESSION_REMOTE_INJECT) : ctx.remote?.[SESSION_REMOTE]
589
+ if (!service) throw unavailable()
590
+ resolveReady()
591
+ return
592
+ }
593
+
594
+ injectTimeout = setTimeout(() => {
595
+ rejectReady(new Error('Timed out waiting for Session tools Remote injection'))
596
+ }, 5000)
597
+ injectFiber = ctx.inject([SESSION_REMOTE_INJECT], (scopedCtx) => {
598
+ if (stopped) return
599
+ try {
600
+ const injected = scopedCtx.remote[SESSION_REMOTE]
601
+ if (!injected) throw unavailable()
602
+ scopedCtx.on('dispose', () => {
603
+ if (service === injected) service = undefined
604
+ })
605
+ service = injected
606
+ // Cordis fibers are thenable. Wait for activation after the callback binds the service.
607
+ void activation.then(resolveReady, rejectReady)
608
+ } catch (error) {
609
+ rejectReady(error)
610
+ }
611
+ })
612
+ })
613
+ const activation = setup.then(() => injectFiber)
614
+ void activation.catch(rejectReady)
615
+ void ready.then(() => clearTimeout(injectTimeout), () => dispose().catch(() => {}))
616
+
617
+ function dispose() {
618
+ if (closing) return closing
619
+ stopped = true
620
+ service = undefined
621
+ clearTimeout(injectTimeout)
622
+ rejectReady(unavailable())
623
+ // Wait only for setup to acquire the handles. Activation may still be pending.
624
+ closing = setup.catch(() => {}).then(async () => {
625
+ try {
626
+ await injectFiber?.dispose?.()
627
+ } finally {
628
+ if (typeof unmount === 'function') await unmount()
629
+ }
630
+ })
631
+ return closing
632
+ }
633
+
634
+ return {
635
+ async call(method, sessionId, ...args) {
636
+ await ready
637
+ if (typeof service?.[method] !== 'function') throw unavailable()
638
+ const { ok, value, error } = await service[method](sessionId, ...args)
639
+ if (ok !== true) throw error ?? new Error('Session tools Remote call failed')
640
+ if (value?.ok === false) throw value.error
641
+ if (value?.sessionId !== sessionId) throw new Error('Session tools Remote returned a different session')
642
+ return value
643
+ },
644
+ dispose,
645
+ }
646
+ }
647
+
648
+ function toSessionRoute({ provider, model, effort }) {
649
+ if (!provider.trim() || !model.trim()) return null
650
+ return { provider, model, ...(effort.trim() === '' ? {} : { reasoningEffort: effort }) }
651
+ }
652
+
653
+ function fromSessionRoute(route) {
654
+ return { provider: route?.provider ?? '', model: route?.model ?? '', effort: route?.reasoningEffort ?? '' }
655
+ }
656
+
657
+ function createGlobalSnapshot(plugin, main, worker, catalog = catalogOf(plugin)) {
658
+ return {
659
+ enabled: plugin?.enabled ?? true,
660
+ worktreeIsolationEnabled: worktreeIsolationOf(plugin),
661
+ readOnlyEnabled: plugin?.readOnlyEnabled === true,
662
+ peerReadOnlyConsultEnabled: plugin?.peerReadOnlyConsultEnabled === true,
663
+ mainRoute: toSessionRoute(routeOf(MAIN.fields, main)),
664
+ workerRoute: toSessionRoute(routeOf(WORKER.fields, worker)),
665
+ superviseIntervalSeconds: intervalOf(plugin),
666
+ superviseMaxNoticesPerChild: patrolCountOf(plugin),
667
+ superviseUnlimited: unlimitedOf(plugin),
668
+ allowedTools: [...allowedSetOf(plugin, catalog)],
669
+ }
670
+ }
671
+
672
+ function writable(snapshot) {
673
+ return snapshot.status === 'ready' && snapshot.writable === true
674
+ }
675
+
676
+ function useSessionConfig(sessionId, remote, open, t) {
677
+ const active = React.useRef(null)
678
+ const [view, setView] = React.useState(null)
679
+ const scoped = remote !== undefined || sessionId !== undefined
680
+ const validId = typeof sessionId === 'string' && sessionId.trim() !== ''
681
+ const available = validId && Boolean(remote)
682
+ const display = view?.sessionId === sessionId && view?.remote === remote ? view : null
683
+ const state = display?.state
684
+ const loading = available && (!display?.loaded || display.loading)
685
+ const saving = display?.saving === true
686
+
687
+ const render = (request) => {
688
+ if (active.current === request) setView({ ...request })
689
+ }
690
+ React.useEffect(() => {
691
+ const request = { sessionId, remote, loaded: false, loading: false, saving: false }
692
+ active.current = request
693
+ return () => { if (active.current === request) active.current = null }
694
+ }, [sessionId, remote])
695
+ React.useEffect(() => {
696
+ if (!open || !available) return
697
+ const request = active.current
698
+ if (request.loading || request.saving) return
699
+ request.loading = true
700
+ request.problem = null
701
+ render(request)
702
+ Promise.resolve().then(() => remote.call('get', sessionId)).then((next) => {
703
+ request.state = next
704
+ }, (error) => {
705
+ if (request.state) request.state = { ...request.state, storageReady: false }
706
+ request.problem = error?.message || t('allowed.sessionFailed')
707
+ }).finally(() => {
708
+ request.loaded = true
709
+ request.loading = false
710
+ render(request)
711
+ })
712
+ }, [sessionId, remote, open])
713
+
714
+ const write = async (method, config) => {
715
+ const request = active.current
716
+ if (request?.sessionId !== sessionId || request?.remote !== remote ||
717
+ request?.state?.storageReady !== true || request.loading || request.saving) return t('route.readonly')
718
+ request.saving = true
719
+ request.problem = null
720
+ render(request)
721
+ try {
722
+ const { revision } = request.state
723
+ request.state = method === 'clear'
724
+ ? await remote.call('clear', sessionId, revision)
725
+ : await remote.call('setConfig', sessionId, config, revision)
726
+ return null
727
+ } catch (error) {
728
+ if (active.current === request && ['REVISION_CONFLICT', 'STORAGE_UNAVAILABLE', 'STORAGE_WRITE_FAILED'].includes(error?.code)) {
729
+ try {
730
+ request.state = await remote.call('get', sessionId)
731
+ } catch {
732
+ request.state = { ...request.state, storageReady: false }
733
+ }
734
+ }
735
+ request.problem = error?.message || t('route.saveFailed')
736
+ return request.problem
737
+ } finally {
738
+ request.saving = false
739
+ render(request)
740
+ }
741
+ }
742
+ const problem = display?.problem || (scoped && !validId ? t('allowed.sessionMissing')
743
+ : scoped && !remote ? t('allowed.sessionFailed')
744
+ : state?.storageReady === false ? t('allowed.sessionStorage') : null)
745
+ return { state, loading, saving, problem, write }
746
+ }
747
+
417
748
  const h = React.createElement
418
- // The popover is two columns: the original panel keeps its width, padding and
419
- // outline, and its own right border separates it from the allowed-tools column.
420
- const panelStyle = {
421
- position: 'absolute',
422
- // Anchored by its left column: the original panel keeps the exact place it had
423
- // (`right: 0` with width 340), and the allowed-tools column grows to its right
424
- // instead of pushing the left column under the conversation sidebar.
425
- left: 'calc(100% - 340px)',
426
- bottom: 'calc(100% + 8px)',
427
- zIndex: 50,
428
- width: 'auto',
429
- padding: 0,
749
+ const panelBorder = '1px solid var(--dsw-alias-border-l2, color-mix(in srgb, currentColor 22%, transparent))'
750
+ const popoverSurface = {
751
+ boxSizing: 'border-box',
430
752
  borderRadius: '12px',
431
- border: '1px solid var(--dsw-alias-border-l2, color-mix(in srgb, currentColor 22%, transparent))',
753
+ border: panelBorder,
432
754
  background: 'var(--dsw-alias-bg-layer-2, Canvas)',
433
- color: 'inherit',
755
+ color: 'var(--dsw-alias-label-primary, CanvasText)',
434
756
  boxShadow: '0 12px 32px rgba(0, 0, 0, .3)',
435
757
  fontSize: '12px',
758
+ }
759
+ const panelWidth = 574
760
+ // The original left column keeps its width where the viewport allows; the
761
+ // tools sit to its right and neither column can grow outside the viewport.
762
+ const panelStyle = {
763
+ ...popoverSurface,
764
+ position: 'fixed',
765
+ zIndex: 1090,
766
+ width: `min(${panelWidth}px, calc(100vw - 16px))`,
436
767
  display: 'flex',
437
768
  alignItems: 'stretch',
438
769
  overflow: 'hidden',
439
- // Last-resort guard for a short window: the popover may never grow past the viewport.
440
- // The left column scrolls on its own when this bites (see `panelColumnStyle`).
441
- maxHeight: 'calc(100vh - 96px)',
770
+ visibility: 'hidden',
771
+ }
772
+ const topInsetProbeStyle = {
773
+ position: 'absolute',
774
+ visibility: 'hidden',
775
+ pointerEvents: 'none',
776
+ width: 0,
777
+ height: 'var(--dsh-frame-overlay-top, 0px)',
778
+ }
779
+ const headingRowStyle = { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '6px' }
780
+ const sessionSeparatorStyle = { borderTop: panelBorder, marginBlock: '2px' }
781
+ const moreOverlayStyle = {
782
+ position: 'fixed',
783
+ inset: 0,
784
+ zIndex: 1110,
785
+ display: 'grid',
786
+ placeItems: 'center',
787
+ padding: '12px',
788
+ background: 'rgba(0, 0, 0, .25)',
789
+ }
790
+ const morePanelStyle = {
791
+ ...popoverSurface,
792
+ width: 'min(100%, 400px)',
793
+ maxHeight: '100%',
794
+ minHeight: 0,
795
+ display: 'grid',
796
+ gap: '12px',
797
+ padding: '14px',
798
+ overflowY: 'auto',
799
+ }
800
+
801
+ function portalToBody(node) {
802
+ if (node === null || typeof ReactDOM?.createPortal !== 'function' || typeof document === 'undefined' || !document.body) {
803
+ return node
804
+ }
805
+ return ReactDOM.createPortal(node, document.body)
442
806
  }
443
807
  const panelColumnStyle = {
444
- width: '340px',
808
+ flex: '340 1 0px',
809
+ minWidth: 0,
810
+ minHeight: 0,
445
811
  padding: '12px',
446
812
  display: 'grid',
447
813
  // One column pinned to the column's own width: with the implicit `auto` track a vertical
@@ -459,7 +825,9 @@ window.__ModuleLoader__.load({
459
825
  borderRight: '1px solid var(--dsw-alias-border-l2, color-mix(in srgb, currentColor 22%, transparent))',
460
826
  }
461
827
  const allowedColumnStyle = {
462
- width: '232px',
828
+ flex: '232 1 0px',
829
+ minWidth: 0,
830
+ overflow: 'hidden auto',
463
831
  padding: '12px',
464
832
  display: 'flex',
465
833
  flexDirection: 'column',
@@ -492,7 +860,7 @@ window.__ModuleLoader__.load({
492
860
  border: '1px solid var(--dsw-alias-border-l2, color-mix(in srgb, currentColor 22%, transparent))',
493
861
  background: 'var(--dsw-alias-bg-layer-1, transparent)',
494
862
  flex: '1 1 0px',
495
- minHeight: 0,
863
+ minHeight: '84px',
496
864
  boxSizing: 'border-box',
497
865
  contain: 'size',
498
866
  }
@@ -670,26 +1038,90 @@ window.__ModuleLoader__.load({
670
1038
  }
671
1039
  }
672
1040
 
673
- /**
674
- * The popover opens upward from its trigger, so the room it really has is the space above
675
- * that trigger, not the whole window: capping it to `100vh` still let the top of the panel
676
- * hang outside the window when the composer sat low. `null` keeps the static style (a host
677
- * without layout, as in a unit test).
678
- */
679
- function panelStyleOf(room) {
680
- if (room === null || room === undefined) return panelStyle
681
- return Object.assign({}, panelStyle, { maxHeight: room + 'px' })
1041
+ /** Available height above the trigger, within the viewport's safe band. */
1042
+ function panelRoom(triggerTop, viewportHeight, topSafe = 56) {
1043
+ if (![triggerTop, viewportHeight, topSafe].every(Number.isFinite)) return null
1044
+ return Math.max(0, Math.min(triggerTop - 8, viewportHeight - 8) - topSafe)
682
1045
  }
683
1046
 
684
- /**
685
- * The height the popover may use. It is bottom-anchored 8px above its trigger, so the room
686
- * is `trigger.top - 56` (8px gap + 48px of host top chrome): anything larger hangs under
687
- * the session header, which clips the panel's rounded top edge and the first rows of both
688
- * columns — the columns then scrolled to reveal what was already off screen.
689
- */
690
- function panelRoom(triggerTop, viewportHeight) {
691
- if (!Number.isFinite(triggerTop) || !Number.isFinite(viewportHeight)) return null
692
- return Math.max(Math.min(triggerTop - 56, viewportHeight - 96), 240)
1047
+ function panelPlacement(rect, viewportHeight, viewportWidth, topSafe = 56, panelHeight = 0) {
1048
+ if (![rect?.top, rect?.bottom, viewportHeight, topSafe].every(Number.isFinite)) return null
1049
+ const limit = viewportHeight - 8
1050
+ const spaceAbove = panelRoom(rect.top, viewportHeight, topSafe)
1051
+ const downTop = Math.max(topSafe, rect.bottom + 8)
1052
+ const spaceBelow = Math.max(0, limit - downTop)
1053
+ const side = spaceAbove >= 320 || spaceAbove >= spaceBelow ? 'up' : 'down'
1054
+ // The actual room also wins in tiny windows: a visual minimum would cross a safe edge.
1055
+ const maxHeight = side === 'up' ? spaceAbove : spaceBelow
1056
+ const height = panelHeight > 0 ? Math.min(panelHeight, maxHeight) : maxHeight
1057
+ const top = side === 'up' ? Math.max(topSafe, Math.min(rect.top - 8, limit) - height) : downTop
1058
+ const right = Number.isFinite(rect.right) ? rect.right : 348
1059
+ const maxLeft = Number.isFinite(viewportWidth) ? Math.max(8, viewportWidth - panelWidth - 8) : Infinity
1060
+ const left = Math.min(Math.max(8, right - 340), maxLeft)
1061
+ return { side, top, left, maxHeight }
1062
+ }
1063
+
1064
+ function panelStyleOf(placement) {
1065
+ if (placement === null) return panelStyle
1066
+ const { top, left, maxHeight } = placement
1067
+ return { ...panelStyle, top, left, maxHeight, visibility: maxHeight >= 2 ? 'visible' : 'hidden' }
1068
+ }
1069
+
1070
+ function frameTopSafe(rect, probe, viewportHeight) {
1071
+ const styleOf = typeof window.getComputedStyle === 'function' ? window.getComputedStyle.bind(window) : null
1072
+ const inset = styleOf && document.documentElement
1073
+ ? styleOf(document.documentElement).getPropertyValue('--dsh-frame-overlay-top').trim() : ''
1074
+ // The host also publishes this token as calc(...); the browser resolves it on the probe.
1075
+ const token = /^\d+(?:\.\d+)?px$/.test(inset) ? Number.parseFloat(inset) : probe?.getBoundingClientRect?.().height
1076
+ let topSafe = Math.max(56, token || 0)
1077
+ const headers = document.querySelectorAll?.('header, [role="banner"], [data-conversation-header], [data-app-titlebar]') ?? []
1078
+ for (const header of headers) {
1079
+ const box = header.getBoundingClientRect()
1080
+ if (box.width <= 0 || box.height <= 0 || box.bottom <= 0 || box.top > topSafe || box.bottom >= viewportHeight ||
1081
+ box.right <= rect.right - panelWidth || box.left >= rect.right + 232) continue
1082
+ const style = styleOf?.(header)
1083
+ if (style?.visibility === 'hidden' || style?.visibility === 'collapse' || style?.opacity === '0') continue
1084
+ topSafe = Math.max(topSafe, box.bottom)
1085
+ }
1086
+ return topSafe
1087
+ }
1088
+
1089
+ const useLayoutEffect = React.useLayoutEffect ?? React.useEffect
1090
+
1091
+ function usePanelPlacement(open, anchor, panel, probe) {
1092
+ const [placement, setPlacement] = React.useState(null)
1093
+ useLayoutEffect(() => {
1094
+ if (!open) {
1095
+ setPlacement(null)
1096
+ return undefined
1097
+ }
1098
+ const trigger = anchor.current
1099
+ if (!trigger?.getBoundingClientRect || typeof window === 'undefined') return undefined
1100
+ const measure = () => {
1101
+ const rect = trigger.getBoundingClientRect()
1102
+ const viewportHeight = window.innerHeight
1103
+ const topSafe = frameTopSafe(rect, probe.current, viewportHeight)
1104
+ const panelHeight = panel.current?.getBoundingClientRect?.().height
1105
+ const next = panelPlacement(rect, viewportHeight, window.innerWidth, topSafe, panelHeight)
1106
+ if (next === null) return
1107
+ setPlacement((current) => current !== null && Object.keys(next).every((key) => next[key] === current[key]) ? current : next)
1108
+ }
1109
+ measure()
1110
+ window.addEventListener?.('resize', measure)
1111
+ window.addEventListener?.('scroll', measure, true)
1112
+ const observer = typeof window.ResizeObserver === 'function' ? new window.ResizeObserver(measure) : null
1113
+ if (observer) {
1114
+ observer.observe(trigger)
1115
+ if (panel.current) observer.observe(panel.current)
1116
+ if (probe.current) observer.observe(probe.current)
1117
+ }
1118
+ return () => {
1119
+ window.removeEventListener?.('resize', measure)
1120
+ window.removeEventListener?.('scroll', measure, true)
1121
+ observer?.disconnect()
1122
+ }
1123
+ }, [open])
1124
+ return placement
693
1125
  }
694
1126
 
695
1127
  /** The style for a measured placement, or the static fallback when there is none. */
@@ -791,17 +1223,15 @@ window.__ModuleLoader__.load({
791
1223
  /**
792
1224
  * The subagent check interval. Edits stay local until blur or Enter; invalid input is
793
1225
  * rejected without writing and the shown value snaps back to the stored one. The panel's
794
- * scope subscription keeps the field in step with a value changed anywhere else.
1226
+ * effective config keeps the field in step with a value changed anywhere else.
795
1227
  */
796
- function SuperviseIntervalField({ scope, t }) {
797
- const snapshot = useScope(scope)
798
- const current = intervalOf(snapshot.value)
1228
+ function SuperviseIntervalField({ config, editable, saveField, t }) {
1229
+ const current = intervalOf(config)
799
1230
  const [draft, setDraft] = React.useState(String(current))
800
1231
  const [hint, setHint] = React.useState(null)
801
1232
  const [busy, setBusy] = React.useState(false)
802
1233
  const alive = React.useRef(true)
803
1234
  const shown = React.useRef(current)
804
- const editable = snapshot.status === 'ready' && snapshot.writable === true
805
1235
 
806
1236
  React.useEffect(() => {
807
1237
  alive.current = true
@@ -846,16 +1276,12 @@ window.__ModuleLoader__.load({
846
1276
  reject(t('supervise.readonly'))
847
1277
  return
848
1278
  }
849
- const live = scope.getSnapshot()
850
1279
  setBusy(true)
851
1280
  try {
852
- await scope.mutate([{ op: 'set', path: [INTERVAL.key], value: parsed.seconds }], live.revision)
1281
+ const failure = await saveField(INTERVAL.key, parsed.seconds)
853
1282
  if (!alive.current) return
854
- if (intervalOf(scope.getSnapshot().value) === parsed.seconds) setHint(null)
855
- else reject(t('supervise.saveFailed'))
856
- } catch {
857
- // A remote failure may be a plain object; the panel only needs a short line.
858
- if (alive.current) reject(t('supervise.saveFailed'))
1283
+ if (failure === null) setHint(null)
1284
+ else reject(failure)
859
1285
  } finally {
860
1286
  if (alive.current) setBusy(false)
861
1287
  }
@@ -907,16 +1333,14 @@ window.__ModuleLoader__.load({
907
1333
  * and keeps the patrol running until the child stops, delivers, or ends. Edits stay
908
1334
  * local until blur or Enter, and invalid input is rejected without writing.
909
1335
  */
910
- function SuperviseCountField({ scope, t }) {
911
- const snapshot = useScope(scope)
912
- const current = patrolCountOf(snapshot.value)
913
- const unlimited = unlimitedOf(snapshot.value)
1336
+ function SuperviseCountField({ config, editable, saveField, t }) {
1337
+ const current = patrolCountOf(config)
1338
+ const unlimited = unlimitedOf(config)
914
1339
  const [draft, setDraft] = React.useState(String(current))
915
1340
  const [hint, setHint] = React.useState(null)
916
1341
  const [busy, setBusy] = React.useState(false)
917
1342
  const alive = React.useRef(true)
918
1343
  const shown = React.useRef(current)
919
- const editable = snapshot.status === 'ready' && snapshot.writable === true
920
1344
 
921
1345
  React.useEffect(() => {
922
1346
  alive.current = true
@@ -961,16 +1385,12 @@ window.__ModuleLoader__.load({
961
1385
  reject(t('supervise.readonly'))
962
1386
  return
963
1387
  }
964
- const live = scope.getSnapshot()
965
1388
  setBusy(true)
966
1389
  try {
967
- await scope.mutate([{ op: 'set', path: [PATROL_COUNT.key], value: parsed.count }], live.revision)
1390
+ const failure = await saveField(PATROL_COUNT.key, parsed.count)
968
1391
  if (!alive.current) return
969
- if (patrolCountOf(scope.getSnapshot().value) === parsed.count) setHint(null)
970
- else reject(t('supervise.saveFailed'))
971
- } catch {
972
- // A remote failure may be a plain object; the panel only needs a short line.
973
- if (alive.current) reject(t('supervise.saveFailed'))
1392
+ if (failure === null) setHint(null)
1393
+ else reject(failure)
974
1394
  } finally {
975
1395
  if (alive.current) setBusy(false)
976
1396
  }
@@ -982,20 +1402,13 @@ window.__ModuleLoader__.load({
982
1402
  setHint(t('supervise.readonly'))
983
1403
  return
984
1404
  }
985
- const live = scope.getSnapshot()
986
1405
  setBusy(true)
987
1406
  try {
988
- await scope.mutate([{ op: 'set', path: [PATROL_COUNT.unlimitedKey], value: on }], live.revision)
1407
+ const failure = await saveField(PATROL_COUNT.unlimitedKey, on)
989
1408
  if (!alive.current) return
990
- if (unlimitedOf(scope.getSnapshot().value) === on) {
991
- setHint(null)
992
- // Turning unlimited on discards an uncommitted draft: the field is locked now.
993
- if (on) setDraft(String(current))
994
- } else {
995
- setHint(t('supervise.saveFailed'))
996
- }
997
- } catch {
998
- if (alive.current) setHint(t('supervise.saveFailed'))
1409
+ setHint(failure)
1410
+ // Turning unlimited on discards an uncommitted draft: the field is locked now.
1411
+ if (failure === null && on) setDraft(String(current))
999
1412
  } finally {
1000
1413
  if (alive.current) setBusy(false)
1001
1414
  }
@@ -1116,61 +1529,70 @@ window.__ModuleLoader__.load({
1116
1529
  }
1117
1530
 
1118
1531
  function worktreeIsolationOf(config) {
1119
- return config?.worktreeIsolationEnabled ?? true
1532
+ return config?.worktreeIsolationEnabled !== false
1120
1533
  }
1121
1534
 
1122
- /** Toggle the default for future write dispatches without pinning any tool preferences. */
1123
- function WorktreeIsolationField({ scope, t }) {
1124
- const snapshot = useScope(scope)
1125
- const checked = worktreeIsolationOf(snapshot.value)
1126
- const editable = snapshot.status === 'ready' && snapshot.writable === true
1127
- const [busy, setBusy] = React.useState(false)
1128
- const [problem, setProblem] = React.useState(null)
1129
- const alive = React.useRef(true)
1130
- React.useEffect(() => {
1131
- alive.current = true
1132
- return () => {
1133
- alive.current = false
1134
- }
1135
- }, [])
1136
-
1137
- const toggle = async (on) => {
1138
- if (busy) return
1139
- const live = scope.getSnapshot()
1140
- if (live.status !== 'ready' || live.writable !== true) {
1141
- setProblem(t('route.readonly'))
1142
- return
1143
- }
1144
- setBusy(true)
1145
- setProblem(null)
1146
- try {
1147
- await scope.mutate([{ op: 'set', path: ['worktreeIsolationEnabled'], value: on }], live.revision)
1148
- if (alive.current && worktreeIsolationOf(scope.getSnapshot().value) !== on) {
1149
- setProblem(t('route.enableFailed'))
1150
- }
1151
- } catch {
1152
- if (alive.current) setProblem(t('route.enableFailed'))
1153
- } finally {
1154
- if (alive.current) setBusy(false)
1155
- }
1156
- }
1535
+ const hintStyle = { color: 'var(--dsw-alias-label-tertiary, inherit)', lineHeight: 1.3 }
1536
+ const alertStyle = { color: 'var(--dsw-alias-label-error, #ff7b72)' }
1537
+ const moreFields = [
1538
+ ['worktreeIsolationEnabled', 'worktreeIsolation'],
1539
+ ['readOnlyEnabled', 'readOnly'],
1540
+ ['peerReadOnlyConsultEnabled', 'peerReadOnlyConsult'],
1541
+ ]
1157
1542
 
1543
+ function SettingSwitch({ checked, disabled, onChange, label, hint, field }) {
1158
1544
  return h(
1159
1545
  'div',
1160
- { style: { display: 'grid', gap: '4px' } },
1546
+ { 'data-setting': field, style: { display: 'flex', alignItems: 'center', gap: '10px' } },
1161
1547
  h(
1162
1548
  'div',
1163
- { style: { display: 'flex', alignItems: 'center', gap: '10px' } },
1549
+ { style: { display: 'grid', gap: '2px', flex: '1 1 auto', minWidth: 0 } },
1550
+ h('span', { style: { fontWeight: 600 } }, label),
1551
+ h('span', { style: hintStyle }, hint),
1552
+ ),
1553
+ h(EnableSwitch, { checked, disabled, onChange, label }),
1554
+ )
1555
+ }
1556
+
1557
+ function MoreSettingsPanel({ overlayRef, dialogRef, onClose, config, editable, saveField, problem, t }) {
1558
+ const closeButton = React.useRef(null)
1559
+ React.useEffect(() => { closeButton.current?.focus?.({ preventScroll: true }) }, [])
1560
+ return portalToBody(h(
1561
+ 'div',
1562
+ {
1563
+ ref: overlayRef,
1564
+ 'data-overlay': 'more-settings',
1565
+ style: moreOverlayStyle,
1566
+ onClick: (event) => { if (event.target === event.currentTarget) onClose() },
1567
+ },
1568
+ h(
1569
+ 'div',
1570
+ {
1571
+ ref: dialogRef,
1572
+ role: 'dialog',
1573
+ 'aria-modal': true,
1574
+ 'aria-label': t('more.title'),
1575
+ 'data-panel': 'more-settings',
1576
+ style: morePanelStyle,
1577
+ },
1164
1578
  h(
1165
1579
  'div',
1166
- { style: { display: 'grid', gap: '2px', flex: '1 1 auto', minWidth: 0 } },
1167
- h('span', { style: { fontWeight: 600 } }, t('worktreeIsolation.label')),
1168
- h('span', { style: { color: 'var(--dsw-alias-label-tertiary, inherit)', lineHeight: 1.3 } }, t('worktreeIsolation.hint')),
1580
+ { style: headingRowStyle },
1581
+ h('strong', null, t('more.title')),
1582
+ h('button', { ref: closeButton, type: 'button', style: baseStyle, onClick: onClose }, t('more.close')),
1169
1583
  ),
1170
- h(EnableSwitch, { checked, disabled: busy || !editable, onChange: toggle, label: t('worktreeIsolation.label') }),
1584
+ moreFields.map(([field, prefix]) => h(SettingSwitch, {
1585
+ key: field,
1586
+ field,
1587
+ checked: config[field],
1588
+ disabled: !editable,
1589
+ onChange: (checked) => saveField(field, checked),
1590
+ label: t(`${prefix}.label`),
1591
+ hint: t(`${prefix}.hint`),
1592
+ })),
1593
+ problem ? h('div', { role: 'alert', style: alertStyle }, problem) : null,
1171
1594
  ),
1172
- problem === null ? null : h('div', { role: 'alert', style: { color: 'var(--dsw-alias-label-error, #ff7b72)' } }, problem),
1173
- )
1595
+ ))
1174
1596
  }
1175
1597
 
1176
1598
  /**
@@ -1180,56 +1602,27 @@ window.__ModuleLoader__.load({
1180
1602
  * Every change writes the single allow key from the checkbox state, so the stored
1181
1603
  * config always describes exactly what the panel shows.
1182
1604
  */
1183
- function AllowedToolsPanel({ scope, t }) {
1184
- const snapshot = useScope(scope)
1605
+ function AllowedToolsPanel({
1606
+ t, config, pluginValue, catalog, editable, session, canChangeSession, onSessionChange,
1607
+ moreTrigger, moreOpen, onMore, saveTools, resetTools,
1608
+ }) {
1185
1609
  const [query, setQuery] = React.useState('')
1186
- const [saving, setSaving] = React.useState(false)
1187
- const [problem, setProblem] = React.useState(null)
1188
- const alive = React.useRef(true)
1189
- React.useEffect(() => {
1190
- alive.current = true
1191
- return () => {
1192
- alive.current = false
1193
- }
1194
- }, [])
1195
-
1196
1610
  // Shipped order first, then the catalog/config extras alphabetically, so a row
1197
- // keeps its place when the live catalog changes. The remembered copy survives the
1198
- // instant a settings write resets the published field (see catalogFor).
1199
- const remembered = React.useRef([])
1200
- const live = catalogFor(snapshot.value, remembered.current)
1201
- if (live.length > 0) remembered.current = live
1202
- const names = toolListOf(snapshot.value, live)
1203
- const allowed = allowedSetOf(snapshot.value, live)
1204
- const teamEnabled = snapshot.value?.[ALLOW_AGENT_TEAM_KEY] !== false
1611
+ // keeps its place when the live catalog changes.
1612
+ const value = { ...pluginValue, [ALLOW_KEY]: config.allowedTools }
1613
+ const names = toolListOf(value, catalog)
1614
+ const allowed = allowedSetOf(value, catalog)
1615
+ const teamEnabled = pluginValue?.[ALLOW_AGENT_TEAM_KEY] !== false
1205
1616
  const visible = filterTools(names, query)
1206
- const editable = snapshot.status === 'ready' && snapshot.writable === true
1207
-
1208
- const write = async (ops) => {
1209
- if (saving) return
1210
- const live = scope.getSnapshot()
1211
- if (live.status !== 'ready' || live.writable !== true) {
1212
- setProblem(t('route.readonly'))
1213
- return
1214
- }
1215
- setSaving(true)
1216
- setProblem(null)
1217
- try {
1218
- await scope.mutate(ops, live.revision)
1219
- } catch (reason) {
1220
- if (!alive.current) return
1221
- // Not `instanceof Error`: a remote failure can be a plain { code, message } object.
1222
- setProblem(typeof reason?.message === 'string' && reason.message !== '' ? reason.message : t('route.saveFailed'))
1223
- } finally {
1224
- if (alive.current) setSaving(false)
1225
- }
1226
- }
1617
+ const sessionEnabled = session.state?.enabled === true
1227
1618
 
1228
1619
  const toggle = (name, on) => {
1229
- const next = new Set(allowed)
1620
+ // Preserve latent Team settings when ordinary checkboxes are edited; the
1621
+ // hard Team switch still filters what is shown and what the backend permits.
1622
+ const next = new Set(sessionEnabled ? config.allowedTools : allowed)
1230
1623
  if (on) next.add(name)
1231
1624
  else next.delete(name)
1232
- return write(allowOps(next, snapshot.value, live))
1625
+ return saveTools([...next])
1233
1626
  }
1234
1627
 
1235
1628
  return h(
@@ -1237,18 +1630,42 @@ window.__ModuleLoader__.load({
1237
1630
  { style: allowedColumnStyle, 'data-panel': 'allowed-tools' },
1238
1631
  h(
1239
1632
  'div',
1240
- { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '6px' } },
1241
- h('span', { style: { fontWeight: 600 }, title: t('allowed.hint') }, t('allowed.title')),
1633
+ { 'data-scope': 'session-tools', style: { display: 'grid', gap: '4px' } },
1242
1634
  h(
1243
- 'button',
1244
- {
1635
+ 'div',
1636
+ { style: { ...headingRowStyle, flexWrap: 'wrap' } },
1637
+ h('span', { style: { fontWeight: 600 } }, t('allowed.session')),
1638
+ h(EnableSwitch, {
1639
+ checked: sessionEnabled,
1640
+ disabled: !canChangeSession,
1641
+ label: t('allowed.session'),
1642
+ onChange: onSessionChange,
1643
+ }),
1644
+ h('button', {
1645
+ ref: moreTrigger,
1245
1646
  type: 'button',
1246
- style: resetLinkStyle(editable && !saving),
1247
- disabled: saving || !editable,
1248
- onClick: () => write(resetAllowOps()),
1249
- },
1250
- t('allowed.reset'),
1647
+ 'data-action': 'more-settings',
1648
+ 'aria-haspopup': 'dialog',
1649
+ 'aria-expanded': moreOpen,
1650
+ style: { ...baseStyle, marginInlineStart: 'auto', height: '24px' },
1651
+ onClick: onMore,
1652
+ }, t('more.button')),
1251
1653
  ),
1654
+ h('span', { style: hintStyle }, session.loading ? t('allowed.sessionLoading')
1655
+ : t(sessionEnabled ? 'allowed.sessionOn' : 'allowed.sessionOff')),
1656
+ session.problem ? h('div', { role: 'alert', style: alertStyle }, session.problem) : null,
1657
+ ),
1658
+ h('div', { role: 'separator', style: sessionSeparatorStyle }),
1659
+ h(
1660
+ 'div',
1661
+ { style: headingRowStyle },
1662
+ h('span', { style: { fontWeight: 600 }, title: t('allowed.hint') }, t('allowed.title')),
1663
+ h('button', {
1664
+ type: 'button',
1665
+ style: resetLinkStyle(editable),
1666
+ disabled: !editable,
1667
+ onClick: resetTools,
1668
+ }, t('allowed.reset')),
1252
1669
  ),
1253
1670
  h(
1254
1671
  'div',
@@ -1275,7 +1692,7 @@ window.__ModuleLoader__.load({
1275
1692
  )
1276
1693
  : visible.map((name) => {
1277
1694
  const teamDisabled = !teamEnabled && NATIVE_TEAM_TOOLS.includes(name)
1278
- const disabled = saving || !editable || teamDisabled
1695
+ const disabled = !editable || teamDisabled
1279
1696
  const hint = teamDisabled
1280
1697
  ? t('allowed.teamDisabled')
1281
1698
  : DEFAULT_BLOCKED_NATIVE_TOOLS.includes(name) ? t('allowed.nativeBlocked') : undefined
@@ -1295,12 +1712,15 @@ window.__ModuleLoader__.load({
1295
1712
  }),
1296
1713
  ),
1297
1714
  ),
1298
- problem === null ? null : h('div', { role: 'alert', style: { color: 'var(--dsw-alias-label-error, #ff7b72)' } }, problem),
1299
1715
  )
1300
1716
  }
1301
1717
 
1718
+ function contains(ref, target) {
1719
+ return Boolean(ref.current?.contains?.(target))
1720
+ }
1721
+
1302
1722
  /** One row: the current model, and the searchable list that opens in place. */
1303
- function RouteRow({ label, route, groups, disabled, onChange, t }) {
1723
+ function RouteRow({ label, route, groups, disabled, onChange, listRef, t }) {
1304
1724
  const [open, setOpen] = React.useState(false)
1305
1725
  const [active, setActive] = React.useState(0)
1306
1726
  const [query, setQuery] = React.useState('')
@@ -1308,7 +1728,8 @@ window.__ModuleLoader__.load({
1308
1728
  const box = React.useRef(null)
1309
1729
  // Portalled to the body, the list is no longer a DOM descendant of `box`, so it needs a
1310
1730
  // ref of its own for the outside-click test and for scrolling itself.
1311
- const listBox = React.useRef(null)
1731
+ const localListBox = React.useRef(null)
1732
+ const listBox = listRef ?? localListBox
1312
1733
  const searchInput = React.useRef(null)
1313
1734
  const options = React.useRef(new Map())
1314
1735
  const model = findModel(groups, route)
@@ -1351,11 +1772,7 @@ window.__ModuleLoader__.load({
1351
1772
  React.useEffect(() => {
1352
1773
  if (!open) return undefined
1353
1774
  const outside = (event) => {
1354
- if (typeof box.current?.contains === 'function' && box.current.contains(event.target)) return
1355
- // The list is portalled to the body, so a click inside it is outside `box` in the
1356
- // DOM tree. Without this check the `pointerdown` capture would close the list
1357
- // before the option's own `click` ever fired.
1358
- if (typeof listBox.current?.contains === 'function' && listBox.current.contains(event.target)) return
1775
+ if (contains(box, event.target) || contains(listBox, event.target)) return
1359
1776
  dismiss()
1360
1777
  }
1361
1778
  document.addEventListener('pointerdown', outside, true)
@@ -1370,10 +1787,9 @@ window.__ModuleLoader__.load({
1370
1787
  return undefined
1371
1788
  }
1372
1789
  const node = box.current
1373
- const viewport = typeof window === 'undefined' ? undefined : window.innerHeight
1374
- if (node === null || node === undefined || typeof node.getBoundingClientRect !== 'function') return undefined
1790
+ if (!node?.getBoundingClientRect || typeof window === 'undefined') return undefined
1375
1791
  const measure = () => {
1376
- const next = popupPlacement(node.getBoundingClientRect(), viewport)
1792
+ const next = popupPlacement(node.getBoundingClientRect(), window.innerHeight)
1377
1793
  if (next !== null) setPlacement(next)
1378
1794
  }
1379
1795
  measure()
@@ -1461,6 +1877,12 @@ window.__ModuleLoader__.load({
1461
1877
  role: 'listbox',
1462
1878
  'aria-label': label + ' · ' + t('route.search'),
1463
1879
  'data-side': placement?.side,
1880
+ onKeyDown: (event) => {
1881
+ if (event.key !== 'Escape') return
1882
+ event.preventDefault()
1883
+ event.stopPropagation()
1884
+ dismiss()
1885
+ },
1464
1886
  },
1465
1887
  h(
1466
1888
  'div',
@@ -1474,10 +1896,7 @@ window.__ModuleLoader__.load({
1474
1896
  style: searchStyle,
1475
1897
  onChange: (event) => setQuery(event.target.value),
1476
1898
  onKeyDown: (event) => {
1477
- if (event.key === 'Escape') {
1478
- event.stopPropagation()
1479
- dismiss()
1480
- } else if (event.key === 'ArrowDown') {
1899
+ if (event.key === 'ArrowDown') {
1481
1900
  event.preventDefault()
1482
1901
  move(1)
1483
1902
  } else if (event.key === 'ArrowUp') {
@@ -1504,13 +1923,7 @@ window.__ModuleLoader__.load({
1504
1923
  : items.map(renderItem),
1505
1924
  )
1506
1925
  : null
1507
- const canPortal =
1508
- listboxNode !== null &&
1509
- typeof ReactDOM?.createPortal === 'function' &&
1510
- typeof document !== 'undefined' &&
1511
- document.body !== undefined &&
1512
- document.body !== null
1513
- const listbox = canPortal ? ReactDOM.createPortal(listboxNode, document.body) : listboxNode
1926
+ const listbox = portalToBody(listboxNode)
1514
1927
  return h(
1515
1928
  'div',
1516
1929
  { style: { display: 'grid', gap: '4px' } },
@@ -1563,49 +1976,65 @@ window.__ModuleLoader__.load({
1563
1976
  )
1564
1977
  }
1565
1978
  /** Button plus panel: pick the default model and effort for the main agent and for workers. */
1566
- function RoutePicker({ t, scopes, orch, loadCatalog, modelDirectories, sessionId }) {
1979
+ function RoutePicker({ t, scopes, orch, loadCatalog, modelDirectories, sessionId, sessionRemote }) {
1567
1980
  const [open, setOpen] = React.useState(false)
1568
- const [room, setRoom] = React.useState(null)
1981
+ const [moreOpen, setMoreOpen] = React.useState(false)
1569
1982
  const anchor = React.useRef(null)
1570
- const [fallback, setFallback] = React.useState({ groups: undefined, loading: false })
1571
- const [problem, setProblem] = React.useState(null)
1572
- const [saving, setSaving] = React.useState(false)
1573
- const request = React.useRef(0)
1983
+ const panel = React.useRef(null)
1984
+ const probe = React.useRef(null)
1985
+ const mainList = React.useRef(null)
1986
+ const workerList = React.useRef(null)
1987
+ const moreTrigger = React.useRef(null)
1988
+ const moreOverlay = React.useRef(null)
1989
+ const moreDialog = React.useRef(null)
1990
+ const placement = usePanelPlacement(open, anchor, panel, probe)
1991
+ const [fallbackGroups, setFallbackGroups] = React.useState(undefined)
1992
+ const [catalogError, setCatalogError] = React.useState(null)
1993
+ const [saveError, setSaveError] = React.useState(null)
1994
+ const [globalSaving, setGlobalSaving] = React.useState(false)
1995
+ const globalBusy = React.useRef(false)
1574
1996
  const loader = React.useRef(loadCatalog)
1575
1997
  loader.current = loadCatalog
1576
1998
  const main = useScope(scopes.main)
1577
1999
  const worker = useScope(scopes.worker)
1578
2000
  const plugin = useScope(orch)
2001
+ const session = useSessionConfig(sessionId, sessionRemote, open, t)
2002
+ const sessionEnabled = session.state?.enabled === true
2003
+ const rememberedCatalog = React.useRef([])
2004
+ const catalog = catalogFor(plugin.value, rememberedCatalog.current)
2005
+ if (catalog.length > 0) rememberedCatalog.current = catalog
2006
+ const globalConfig = createGlobalSnapshot(plugin.value, main.value, worker.value, catalog)
2007
+ const config = sessionEnabled ? session.state.config : globalConfig
2008
+ const editing = !session.loading && !session.saving && !globalSaving
2009
+ const editable = (snapshot) => editing && (sessionEnabled ? session.state.storageReady : writable(snapshot))
2010
+ const pluginEditable = editable(plugin)
2011
+ const globalConfigReady = [main, worker, plugin].every((snapshot) => snapshot.status === 'ready')
2012
+ const canChangeSession = editing && session.state?.storageReady === true && (sessionEnabled || globalConfigReady)
2013
+ const fieldScope = sessionEnabled ? `session:${sessionId}` : 'global'
1579
2014
  const directory = resolveModelDirectory(modelDirectories, sessionId)
1580
2015
  const directoryState = useModelDirectory(directory)
1581
2016
  const usingDirectory = directory !== undefined
1582
- const groups = usingDirectory ? directoryState.groups : fallback.groups
1583
- const catalogProblem = usingDirectory ? directoryState.error : problem
2017
+ const groups = usingDirectory ? directoryState.groups : fallbackGroups
2018
+ const catalogProblem = usingDirectory ? directoryState.error : catalogError
1584
2019
 
1585
2020
  React.useEffect(() => {
1586
2021
  if (usingDirectory || !open) return undefined
1587
- const current = request.current + 1
1588
- request.current = current
1589
2022
  let live = true
1590
- setProblem(null)
1591
- setFallback((previous) => ({ ...previous, loading: true }))
2023
+ setCatalogError(null)
1592
2024
  Promise.resolve().then(() => {
1593
2025
  if (typeof loader.current !== 'function') throw new Error('model catalog loader unavailable')
1594
2026
  return loader.current()
1595
2027
  }).then(
1596
2028
  (response) => {
1597
- if (!live || request.current !== current) return
2029
+ if (!live) return
1598
2030
  if (response?.ok === true && Array.isArray(response.value?.groups)) {
1599
- setFallback({ groups: response.value.groups, loading: false })
2031
+ setFallbackGroups(response.value.groups)
1600
2032
  return
1601
2033
  }
1602
- setFallback((previous) => ({ ...previous, loading: false }))
1603
- setProblem(t('route.catalogFailed'))
2034
+ setCatalogError(t('route.catalogFailed'))
1604
2035
  },
1605
2036
  () => {
1606
- if (!live || request.current !== current) return
1607
- setFallback((previous) => ({ ...previous, loading: false }))
1608
- setProblem(t('route.catalogFailed'))
2037
+ if (live) setCatalogError(t('route.catalogFailed'))
1609
2038
  },
1610
2039
  )
1611
2040
  return () => {
@@ -1613,132 +2042,194 @@ window.__ModuleLoader__.load({
1613
2042
  }
1614
2043
  }, [open, usingDirectory])
1615
2044
 
1616
- const write = async (which, route) => {
1617
- setSaving(true)
1618
- setProblem(null)
1619
- const failure = await saveRoute(which === 'main' ? scopes.main : scopes.worker, which === 'main' ? MAIN.fields : WORKER.fields, route, t)
1620
- setSaving(false)
1621
- setProblem(failure)
1622
- }
1623
-
1624
- const toggleEnabled = async (on) => {
1625
- const snapshot = orch.getSnapshot()
1626
- if (snapshot.status !== 'ready' || !snapshot.writable) {
1627
- setProblem(t('route.readonly'))
1628
- return
1629
- }
1630
- setSaving(true)
1631
- setProblem(null)
2045
+ const runGlobal = async (operation, fallbackMessage) => {
2046
+ if (!editing || globalBusy.current) return t('route.readonly')
2047
+ globalBusy.current = true
2048
+ setGlobalSaving(true)
2049
+ setSaveError(null)
1632
2050
  try {
1633
- await orch.mutate([{ op: 'set', path: ['enabled'], value: on }], snapshot.revision)
1634
- } catch (reason) {
1635
- setProblem(typeof reason?.message === 'string' && reason.message !== '' ? reason.message : t('route.enableFailed'))
2051
+ const failure = await operation()
2052
+ setSaveError(failure)
2053
+ return failure
2054
+ } catch (error) {
2055
+ const failure = error?.message || fallbackMessage
2056
+ setSaveError(failure)
2057
+ return failure
2058
+ } finally {
2059
+ globalBusy.current = false
2060
+ setGlobalSaving(false)
1636
2061
  }
1637
- setSaving(false)
1638
2062
  }
1639
2063
 
1640
- // The panel is anchored above the trigger and opens upward, so its real ceiling is the
1641
- // space between the trigger and the top of the window (`panelStyle.maxHeight` alone only
1642
- // knows the viewport, which is how a low composer used to push the panel off screen).
1643
- React.useEffect(() => {
1644
- if (!open) {
1645
- setRoom(null)
1646
- return undefined
1647
- }
1648
- const node = anchor.current
1649
- if (node === null || node === undefined || typeof node.getBoundingClientRect !== 'function') return undefined
1650
- const measure = () => {
1651
- const rect = node.getBoundingClientRect()
1652
- const viewport = typeof window === 'undefined' ? undefined : window.innerHeight
1653
- const next = panelRoom(rect?.top, viewport)
1654
- if (next !== null) setRoom(next)
2064
+ const mutatePlugin = (operations, confirm = () => true, failure = t('route.saveFailed')) => runGlobal(async () => {
2065
+ const current = orch.getSnapshot()
2066
+ if (!writable(current)) return t('route.readonly')
2067
+ const result = await orch.mutate(operations(current.value), current.revision)
2068
+ return result !== false && confirm(orch.getSnapshot().value) ? null : failure
2069
+ }, failure)
2070
+
2071
+ const saveField = (key, value) => {
2072
+ if (!pluginEditable || globalBusy.current) return t('route.readonly')
2073
+ if (sessionEnabled) return session.write('setConfig', { [key]: value })
2074
+ return mutatePlugin(() => [{ op: 'set', path: [key], value }], (current) => current?.[key] === value)
2075
+ }
2076
+
2077
+ const readGlobalConfig = () => {
2078
+ const value = orch.getSnapshot().value
2079
+ return createGlobalSnapshot(value, scopes.main.getSnapshot().value, scopes.worker.getSnapshot().value,
2080
+ catalogFor(value, rememberedCatalog.current))
2081
+ }
2082
+ const changeSession = (on) => {
2083
+ if (!canChangeSession || globalBusy.current || on === sessionEnabled) return
2084
+ setSaveError(null)
2085
+ // Clearing resumes the current global route as well as the other global settings.
2086
+ return on ? session.write('setConfig', readGlobalConfig()) : session.write('clear')
2087
+ }
2088
+ const resetTools = () => pluginEditable && (sessionEnabled
2089
+ ? session.write('setConfig', { allowedTools: readGlobalConfig().allowedTools })
2090
+ : mutatePlugin(resetAllowOps))
2091
+ const saveTools = (tools) => pluginEditable && (sessionEnabled
2092
+ ? session.write('setConfig', { allowedTools: tools })
2093
+ : mutatePlugin((value) => allowOps(tools, value, catalogFor(value, rememberedCatalog.current))))
2094
+
2095
+ const write = (which, route) => {
2096
+ if (!editing || globalBusy.current) return
2097
+ if (sessionEnabled) {
2098
+ const key = which === 'main' ? 'mainRoute' : 'workerRoute'
2099
+ return session.write('setConfig', { [key]: toSessionRoute(route) })
1655
2100
  }
1656
- measure()
1657
- if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') return undefined
1658
- window.addEventListener('resize', measure)
1659
- return () => window.removeEventListener('resize', measure)
1660
- }, [open])
2101
+ const fields = which === 'main' ? MAIN.fields : WORKER.fields
2102
+ return runGlobal(() => saveRoute(scopes[which], fields, route, t), t('route.saveFailed'))
2103
+ }
1661
2104
 
1662
- const writable = main.writable === true && worker.writable === true
1663
2105
  const close = () => {
2106
+ setMoreOpen(false)
1664
2107
  setOpen(false)
1665
2108
  }
2109
+ const closeMore = () => {
2110
+ setMoreOpen(false)
2111
+ moreTrigger.current?.focus?.({ preventScroll: true })
2112
+ }
2113
+ React.useEffect(() => {
2114
+ if (!open || typeof document === 'undefined') return undefined
2115
+ const outside = (event) => {
2116
+ const target = event.target
2117
+ if ([anchor, panel, mainList, workerList, moreTrigger, moreDialog, moreOverlay].some((ref) => contains(ref, target))) return
2118
+ if (moreOpen) closeMore()
2119
+ else close()
2120
+ }
2121
+ const escape = (event) => {
2122
+ if (event.key !== 'Escape') return
2123
+ if (!moreOpen && (mainList.current || workerList.current || event.target?.type === 'text')) return
2124
+ event.preventDefault()
2125
+ event.stopPropagation()
2126
+ if (moreOpen) closeMore()
2127
+ else {
2128
+ close()
2129
+ anchor.current?.focus?.({ preventScroll: true })
2130
+ }
2131
+ }
2132
+ document.addEventListener('pointerdown', outside, true)
2133
+ document.addEventListener('keydown', escape, true)
2134
+ return () => {
2135
+ document.removeEventListener('pointerdown', outside, true)
2136
+ document.removeEventListener('keydown', escape, true)
2137
+ }
2138
+ }, [open, moreOpen])
2139
+
1666
2140
  const showLoading = catalogProblem === null && (
1667
2141
  groups === undefined || (usingDirectory && directoryState.loading && groups.length === 0)
1668
2142
  )
2143
+ const modelRows = ['main', 'worker'].map((which) => h(RouteRow, {
2144
+ key: `${which}:${fieldScope}`,
2145
+ label: t(`route.${which}`),
2146
+ route: fromSessionRoute(config[`${which}Route`]),
2147
+ groups: groups ?? [],
2148
+ disabled: !editable(which === 'main' ? main : worker) || groups === undefined || showLoading,
2149
+ listRef: which === 'main' ? mainList : workerList,
2150
+ onChange: (route) => write(which, route),
2151
+ t,
2152
+ }))
1669
2153
  return h(
1670
2154
  'span',
1671
- { ref: anchor, style: { position: 'relative', display: 'inline-flex' } },
2155
+ { style: { display: 'inline-flex' } },
1672
2156
  h(
1673
2157
  'button',
1674
2158
  {
2159
+ ref: anchor,
1675
2160
  type: 'button',
1676
2161
  style: Object.assign({}, baseStyle, open ? onStyle : null),
1677
2162
  onClick: () => (open ? close() : setOpen(true)),
1678
2163
  title: t('route.title'),
1679
2164
  'aria-label': t('route.title'),
2165
+ 'aria-haspopup': 'dialog',
1680
2166
  'aria-expanded': open,
1681
2167
  },
1682
2168
  h('span', null, t('route.button')),
1683
2169
  ),
2170
+ open ? h('span', { ref: probe, style: topInsetProbeStyle, 'aria-hidden': true }) : null,
1684
2171
  open
1685
- ? h(
2172
+ ? portalToBody(h(
1686
2173
  'div',
1687
- { style: panelStyleOf(room), role: 'dialog', 'aria-label': t('route.title') },
2174
+ {
2175
+ ref: panel,
2176
+ style: panelStyleOf(placement),
2177
+ role: 'dialog',
2178
+ 'aria-label': t('route.title'),
2179
+ 'data-panel': 'orchestrator-settings',
2180
+ 'data-side': placement?.side,
2181
+ },
1688
2182
  h(
1689
2183
  'div',
1690
2184
  { style: panelColumnStyle },
1691
- h(
1692
- 'div',
1693
- { style: { display: 'flex', alignItems: 'center', gap: '10px', padding: '0 0 6px' } },
1694
- h(
1695
- 'div',
1696
- { style: { display: 'grid', gap: '2px', flex: '1 1 auto', minWidth: 0 } },
1697
- h('span', { style: { fontWeight: 600 } }, t('route.enable')),
1698
- h('span', { style: { color: 'var(--dsw-alias-label-tertiary, inherit)', lineHeight: 1.3 } }, t('route.enableNote')),
1699
- ),
1700
- h(EnableSwitch, {
1701
- checked: plugin.value?.enabled === true,
1702
- disabled: saving || plugin.writable !== true,
1703
- onChange: toggleEnabled,
1704
- label: t('route.enable'),
1705
- }),
1706
- ),
1707
- h(WorktreeIsolationField, { scope: scopes.orch, t }),
1708
- showLoading
1709
- ? h('div', null, t('route.loading'))
1710
- : groups === undefined
1711
- ? null
1712
- : [
1713
- h(RouteRow, {
1714
- key: 'main',
1715
- label: t('route.main'),
1716
- route: routeOf(MAIN.fields, main.value),
1717
- groups,
1718
- disabled: saving || !writable,
1719
- onChange: (route) => write('main', route),
1720
- t,
1721
- }),
1722
- h(RouteRow, {
1723
- key: 'worker',
1724
- label: t('route.worker'),
1725
- route: routeOf(WORKER.fields, worker.value),
1726
- groups,
1727
- disabled: saving || !writable,
1728
- onChange: (route) => write('worker', route),
1729
- t,
1730
- }),
1731
- ],
1732
- h(SuperviseIntervalField, { scope: scopes.orch, t }),
1733
- h(SuperviseCountField, { scope: scopes.orch, t }),
1734
- catalogProblem === null ? null : h('div', { style: { color: 'var(--dsw-alias-label-error, #ff7b72)' }, role: 'alert' }, catalogProblem),
1735
- !writable && groups !== undefined
1736
- ? h('div', { style: { color: 'var(--dsw-alias-label-tertiary, inherit)' } }, t('route.readonly'))
2185
+ h(SettingSwitch, {
2186
+ field: 'enabled',
2187
+ checked: config.enabled,
2188
+ disabled: !pluginEditable,
2189
+ onChange: (checked) => saveField('enabled', checked),
2190
+ label: t('route.enable'),
2191
+ hint: t('route.enableNote'),
2192
+ }),
2193
+ modelRows,
2194
+ showLoading ? h('div', null, t('route.loading')) : null,
2195
+ h(SuperviseIntervalField, { key: `interval:${fieldScope}`, config, editable: pluginEditable, saveField, t }),
2196
+ h(SuperviseCountField, { key: `count:${fieldScope}`, config, editable: pluginEditable, saveField, t }),
2197
+ catalogProblem ? h('div', { style: alertStyle, role: 'alert' }, catalogProblem) : null,
2198
+ saveError ? h('div', { style: alertStyle, role: 'alert' }, saveError) : null,
2199
+ !sessionEnabled && (!writable(main) || !writable(worker) || !writable(plugin))
2200
+ ? h('div', { style: hintStyle }, t('route.readonly'))
1737
2201
  : null,
1738
- h('div', { style: { color: 'var(--dsw-alias-label-tertiary, inherit)', lineHeight: 1.3 } }, t('route.note')),
2202
+ h('div', { style: hintStyle }, t(sessionEnabled ? 'route.sessionNote' : 'route.note')),
1739
2203
  ),
1740
- h(AllowedToolsPanel, { scope: scopes.orch, t }),
1741
- )
2204
+ h(AllowedToolsPanel, {
2205
+ key: sessionId,
2206
+ t,
2207
+ config,
2208
+ pluginValue: plugin.value,
2209
+ catalog,
2210
+ editable: pluginEditable,
2211
+ session,
2212
+ canChangeSession,
2213
+ onSessionChange: changeSession,
2214
+ moreTrigger,
2215
+ moreOpen,
2216
+ onMore: () => setMoreOpen(true),
2217
+ saveTools,
2218
+ resetTools,
2219
+ }),
2220
+ ))
2221
+ : null,
2222
+ open && moreOpen
2223
+ ? h(MoreSettingsPanel, {
2224
+ overlayRef: moreOverlay,
2225
+ dialogRef: moreDialog,
2226
+ onClose: closeMore,
2227
+ config,
2228
+ editable: pluginEditable,
2229
+ saveField,
2230
+ problem: sessionEnabled ? session.problem : saveError,
2231
+ t,
2232
+ })
1742
2233
  : null,
1743
2234
  )
1744
2235
  }
@@ -1748,6 +2239,8 @@ window.__ModuleLoader__.load({
1748
2239
 
1749
2240
  function apply(ctx) {
1750
2241
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'orchestrator: dictionaries')
2242
+ const sessionRemote = mountSessionRemote(ctx)
2243
+ ctx.effect(() => sessionRemote.dispose, 'orchestrator: session tools Remote')
1751
2244
  const scopes = { main: ctx.configForms.get(MAIN.ns), worker: ctx.configForms.get(WORKER.ns), orch: ctx.configForms.get(NS) }
1752
2245
  ctx.slots.inject('conversation.input.right', () =>
1753
2246
  ctx.slots.register(
@@ -1761,6 +2254,7 @@ window.__ModuleLoader__.load({
1761
2254
  orch: scopes.orch,
1762
2255
  loadCatalog: () => ctx.remote.session.modelCatalog(),
1763
2256
  sessionId,
2257
+ sessionRemote,
1764
2258
  // Cordis property access can throw for undeclared services.
1765
2259
  modelDirectories: typeof ctx.get === 'function' ? ctx.get('modelDirectories') : ctx.modelDirectories,
1766
2260
  }),
@@ -1793,6 +2287,7 @@ window.__ModuleLoader__.load({
1793
2287
  panelStyle,
1794
2288
  panelStyleOf,
1795
2289
  panelRoom,
2290
+ panelPlacement,
1796
2291
  panelColumnStyle,
1797
2292
  allowedColumnStyle,
1798
2293
  allowedListBoxStyle,
@@ -1803,8 +2298,11 @@ window.__ModuleLoader__.load({
1803
2298
  allowOps,
1804
2299
  resetAllowOps,
1805
2300
  EnableSwitch,
1806
- WorktreeIsolationField,
2301
+ MoreSettingsPanel,
1807
2302
  AllowedToolsPanel,
2303
+ createGlobalSnapshot,
2304
+ createSessionToolsDescriptors,
2305
+ mountSessionRemote,
1808
2306
  RoutePicker,
1809
2307
  routeKey,
1810
2308
  parseRouteKey,