dsh-device-fleet 0.1.0-dev.14 → 0.1.0-dev.16
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 +312 -169
- package/docs/notes/dev-release.md +20 -6
- package/package.json +1 -1
- package/src/host/config-web.js +27 -4
- package/src/host/ui-web.js +8 -4
- package/src/plugin/index.js +71 -3
package/client.js
CHANGED
|
@@ -273,6 +273,7 @@ window.__ModuleLoader__.load({
|
|
|
273
273
|
const [rooms, setRooms] = useState([]);
|
|
274
274
|
const [selectedRoom, setSelectedRoom] = useState(null);
|
|
275
275
|
const [roomDetail, setRoomDetail] = useState(null);
|
|
276
|
+
const [roomError, setRoomError] = useState('');
|
|
276
277
|
const [error, setError] = useState('');
|
|
277
278
|
|
|
278
279
|
useEffect(() => {
|
|
@@ -307,12 +308,18 @@ window.__ModuleLoader__.load({
|
|
|
307
308
|
let disposed = false;
|
|
308
309
|
const load = async () => {
|
|
309
310
|
try {
|
|
310
|
-
const response = await fetch('/device-fleet/
|
|
311
|
+
const response = await fetch('/device-fleet/room?id=' + encodeURIComponent(selectedRoom), { headers: { accept: 'application/json' } });
|
|
311
312
|
if (!response.ok) throw new Error('HTTP ' + response.status);
|
|
312
313
|
const data = await response.json();
|
|
313
|
-
if (!disposed)
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
if (!disposed) {
|
|
315
|
+
setRoomDetail(data.room ?? null);
|
|
316
|
+
setRoomError('');
|
|
317
|
+
}
|
|
318
|
+
} catch (problem) {
|
|
319
|
+
if (!disposed) {
|
|
320
|
+
setRoomDetail(null);
|
|
321
|
+
setRoomError(String(problem.message ?? problem));
|
|
322
|
+
}
|
|
316
323
|
}
|
|
317
324
|
};
|
|
318
325
|
load();
|
|
@@ -434,7 +441,7 @@ window.__ModuleLoader__.load({
|
|
|
434
441
|
),
|
|
435
442
|
),
|
|
436
443
|
),
|
|
437
|
-
h('div', { style: { flex: '2 1 420px', minWidth: 320 } }, selectedRoom ? renderRoomDetail(roomDetail) : h('div', { style: { opacity: 0.65, fontSize: 12 } }, '选择一个房间查看成员、时间线与看板。')),
|
|
444
|
+
h('div', { style: { flex: '2 1 420px', minWidth: 320 } }, selectedRoom ? (roomError && !roomDetail ? h('div', { style: { opacity: 0.7, fontSize: 12 } }, '房间加载失败:' + roomError) : renderRoomDetail(roomDetail)) : h('div', { style: { opacity: 0.65, fontSize: 12 } }, '选择一个房间查看成员、时间线与看板。')),
|
|
438
445
|
);
|
|
439
446
|
} else {
|
|
440
447
|
const approvals = overview.approvals ?? [];
|
|
@@ -501,66 +508,147 @@ window.__ModuleLoader__.load({
|
|
|
501
508
|
);
|
|
502
509
|
}
|
|
503
510
|
|
|
504
|
-
|
|
505
|
-
|
|
511
|
+
// ---- DSH-styled configuration page -------------------------------------
|
|
512
|
+
const CONTROL_WIDTH = 260
|
|
513
|
+
const rowStyle = {
|
|
514
|
+
display: 'flex',
|
|
515
|
+
alignItems: 'center',
|
|
516
|
+
gap: 16,
|
|
517
|
+
minHeight: 42,
|
|
518
|
+
padding: '5px 0',
|
|
519
|
+
borderBottom: '1px solid var(--dsw-alias-border-l1, #333)',
|
|
520
|
+
}
|
|
521
|
+
const rowLabelStyle = { flex: 1, fontSize: 13, color: 'var(--dsw-alias-label-primary, #e8e8e8)' }
|
|
522
|
+
const controlStyle = {
|
|
523
|
+
width: CONTROL_WIDTH,
|
|
506
524
|
boxSizing: 'border-box',
|
|
507
|
-
|
|
525
|
+
height: 30,
|
|
526
|
+
padding: '3px 8px',
|
|
508
527
|
borderRadius: 6,
|
|
509
|
-
border: '1px solid var(--dsw-alias-border, #
|
|
510
|
-
background: '
|
|
511
|
-
color: '
|
|
528
|
+
border: '1px solid var(--dsw-alias-border-l1, #333)',
|
|
529
|
+
background: 'var(--dsw-alias-bg-layer-2, #262626)',
|
|
530
|
+
color: 'var(--dsw-alias-label-primary, #e8e8e8)',
|
|
512
531
|
fontSize: 13,
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
const
|
|
532
|
+
outline: 'none',
|
|
533
|
+
}
|
|
534
|
+
const selectStyle = {
|
|
535
|
+
...controlStyle,
|
|
536
|
+
appearance: 'none',
|
|
537
|
+
WebkitAppearance: 'none',
|
|
538
|
+
paddingRight: 24,
|
|
539
|
+
cursor: 'pointer',
|
|
540
|
+
}
|
|
541
|
+
const textareaStyle = {
|
|
542
|
+
...controlStyle,
|
|
543
|
+
width: '100%',
|
|
544
|
+
height: 'auto',
|
|
545
|
+
minHeight: 64,
|
|
546
|
+
resize: 'vertical',
|
|
547
|
+
padding: '6px 8px',
|
|
548
|
+
lineHeight: 1.5,
|
|
549
|
+
fontFamily: 'ui-monospace, monospace',
|
|
550
|
+
}
|
|
551
|
+
const sectionStyle = {
|
|
552
|
+
margin: '22px 0 4px',
|
|
553
|
+
fontSize: 13,
|
|
554
|
+
fontWeight: 600,
|
|
555
|
+
color: 'var(--dsw-alias-label-primary, #e8e8e8)',
|
|
556
|
+
}
|
|
516
557
|
|
|
517
|
-
function
|
|
518
|
-
|
|
558
|
+
function Row({ label, children, wide = false }) {
|
|
559
|
+
if (wide) {
|
|
560
|
+
return h('div', { style: { ...rowStyle, flexDirection: 'column', alignItems: 'stretch', gap: 6, padding: '8px 0' } },
|
|
561
|
+
h('div', { style: rowLabelStyle }, label),
|
|
562
|
+
h('div', { style: { width: '100%' } }, children),
|
|
563
|
+
)
|
|
564
|
+
}
|
|
565
|
+
return h('div', { style: rowStyle },
|
|
566
|
+
h('div', { style: rowLabelStyle }, label),
|
|
567
|
+
h('div', { style: { width: CONTROL_WIDTH } }, children),
|
|
568
|
+
)
|
|
519
569
|
}
|
|
520
570
|
|
|
521
|
-
function
|
|
522
|
-
return h(
|
|
571
|
+
function SelectControl({ value, options, onChange }) {
|
|
572
|
+
return h('select', {
|
|
573
|
+
value: value ?? '',
|
|
574
|
+
onChange: (event) => onChange(event.target.value),
|
|
575
|
+
style: selectStyle,
|
|
576
|
+
},
|
|
577
|
+
...(options ?? []).map((option) => {
|
|
578
|
+
const entry = typeof option === 'string' ? { value: option, label: option } : option
|
|
579
|
+
return h('option', { key: entry.value, value: entry.value }, entry.label)
|
|
580
|
+
}),
|
|
581
|
+
)
|
|
523
582
|
}
|
|
524
583
|
|
|
525
|
-
function
|
|
526
|
-
return h(
|
|
584
|
+
function TextControl({ value, onChange, placeholder }) {
|
|
585
|
+
return h('input', {
|
|
586
|
+
type: 'text',
|
|
587
|
+
value: value ?? '',
|
|
588
|
+
placeholder: placeholder ?? '',
|
|
589
|
+
onChange: (event) => onChange(event.target.value),
|
|
590
|
+
style: controlStyle,
|
|
591
|
+
})
|
|
527
592
|
}
|
|
528
593
|
|
|
529
|
-
function
|
|
530
|
-
return h('
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
594
|
+
function NumberControl({ value, onChange }) {
|
|
595
|
+
return h('input', {
|
|
596
|
+
type: 'number',
|
|
597
|
+
value: value ?? 0,
|
|
598
|
+
onChange: (event) => onChange(Number(event.target.value || 0)),
|
|
599
|
+
style: controlStyle,
|
|
600
|
+
})
|
|
534
601
|
}
|
|
535
602
|
|
|
536
|
-
function
|
|
537
|
-
return h(
|
|
538
|
-
|
|
539
|
-
|
|
603
|
+
function ToggleControl({ value, onChange }) {
|
|
604
|
+
return h(SelectControl, {
|
|
605
|
+
value: value ? 'on' : 'off',
|
|
606
|
+
options: [{ value: 'on', label: '开启' }, { value: 'off', label: '关闭' }],
|
|
607
|
+
onChange: (next) => onChange(next === 'on'),
|
|
608
|
+
})
|
|
540
609
|
}
|
|
541
610
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
611
|
+
const CAPABILITY_ROWS = [
|
|
612
|
+
['capRead', '读取文件'],
|
|
613
|
+
['capList', '列目录'],
|
|
614
|
+
['capGrep', '搜索内容'],
|
|
615
|
+
['capFetch', '获取文件'],
|
|
616
|
+
['capRun', '执行命令'],
|
|
617
|
+
['capTool', '调用原始工具'],
|
|
618
|
+
['capDelegate', '委派任务'],
|
|
619
|
+
]
|
|
620
|
+
|
|
621
|
+
function configToDraft(config = {}, options = {}) {
|
|
622
|
+
const execution = config.execution ?? {}
|
|
623
|
+
const policy = config.policy ?? {}
|
|
624
|
+
const approvals = config.approvals ?? {}
|
|
625
|
+
const direct = config.direct ?? {}
|
|
626
|
+
const relay = config.relay ?? null
|
|
627
|
+
const cwd = execution.cwd ?? ''
|
|
628
|
+
const cwdInfo = options.cwd ?? {}
|
|
629
|
+
let cwdMode = 'custom'
|
|
630
|
+
if (cwd === '') cwdMode = 'default'
|
|
631
|
+
else if (cwdInfo.workspace && cwd === cwdInfo.workspace) cwdMode = 'workspace'
|
|
632
|
+
else if (cwdInfo.dshHome && cwd === cwdInfo.dshHome) cwdMode = 'dshHome'
|
|
633
|
+
else if (cwdInfo.defaultDirectory && cwd === cwdInfo.defaultDirectory) cwdMode = 'default'
|
|
548
634
|
return {
|
|
549
635
|
deviceName: config.deviceName ?? '',
|
|
550
636
|
directHost: direct.host ?? '0.0.0.0',
|
|
551
637
|
directPort: direct.port ?? 0,
|
|
552
638
|
discovery: config.discovery !== false,
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
639
|
+
relayMode: relay && (relay.host || relay.port) ? 'custom' : 'off',
|
|
640
|
+
relayHost: relay?.host ?? '',
|
|
641
|
+
relayPort: relay?.port ?? 0,
|
|
642
|
+
relayDataPort: relay?.dataPort ?? 0,
|
|
643
|
+
cwdMode,
|
|
644
|
+
customCwd: cwdMode === 'custom' ? cwd : '',
|
|
557
645
|
execPreset: execution.agentPreset ?? '',
|
|
558
646
|
execShellTool: execution.shellTool ?? '',
|
|
559
647
|
execApprovalTimeoutMs: execution.approvalTimeoutMs ?? 60000,
|
|
560
648
|
execDelegateTimeoutMs: execution.delegateTimeoutMs ?? 180000,
|
|
561
649
|
execSubagentProvider: execution.subagentProvider ?? 'spawn',
|
|
562
650
|
rootsText: (policy.allowedRoots ?? []).join('\n'),
|
|
563
|
-
|
|
651
|
+
toolsList: Array.isArray(policy.allowedTools) ? [...policy.allowedTools] : [],
|
|
564
652
|
capRead: policy.capabilities?.read ?? 'auto',
|
|
565
653
|
capList: policy.capabilities?.list ?? 'auto',
|
|
566
654
|
capGrep: policy.capabilities?.grep ?? 'auto',
|
|
@@ -574,20 +662,25 @@ window.__ModuleLoader__.load({
|
|
|
574
662
|
autoApproveAsk: config.autoApproveAsk === true,
|
|
575
663
|
promptSection: config.promptSection !== false,
|
|
576
664
|
simulation: approvals.simulation === true,
|
|
577
|
-
|
|
578
|
-
};
|
|
665
|
+
}
|
|
579
666
|
}
|
|
580
667
|
|
|
581
|
-
function draftToPatch(draft) {
|
|
668
|
+
function draftToPatch(draft, options = {}) {
|
|
669
|
+
const cwdInfo = options.cwd ?? {}
|
|
670
|
+
let cwd = ''
|
|
671
|
+
if (draft.cwdMode === 'workspace') cwd = cwdInfo.workspace ?? ''
|
|
672
|
+
else if (draft.cwdMode === 'dshHome') cwd = cwdInfo.dshHome ?? ''
|
|
673
|
+
else if (draft.cwdMode === 'default') cwd = cwdInfo.defaultDirectory || cwdInfo.workspace || ''
|
|
674
|
+
else if (draft.cwdMode === 'custom') cwd = draft.customCwd ?? ''
|
|
582
675
|
return {
|
|
583
676
|
deviceName: draft.deviceName,
|
|
584
677
|
direct: { host: draft.directHost, port: draft.directPort },
|
|
585
678
|
discovery: draft.discovery,
|
|
586
|
-
relay: draft.
|
|
679
|
+
relay: draft.relayMode === 'custom'
|
|
587
680
|
? { host: draft.relayHost, port: draft.relayPort, dataPort: draft.relayDataPort }
|
|
588
681
|
: null,
|
|
589
682
|
execution: {
|
|
590
|
-
cwd
|
|
683
|
+
cwd,
|
|
591
684
|
agentPreset: draft.execPreset,
|
|
592
685
|
shellTool: draft.execShellTool,
|
|
593
686
|
approvalTimeoutMs: draft.execApprovalTimeoutMs,
|
|
@@ -596,7 +689,7 @@ window.__ModuleLoader__.load({
|
|
|
596
689
|
},
|
|
597
690
|
policy: {
|
|
598
691
|
allowedRoots: draft.rootsText.split('\n').map((item) => item.trim()).filter(Boolean),
|
|
599
|
-
allowedTools:
|
|
692
|
+
allowedTools: Array.isArray(draft.toolsList) ? draft.toolsList : [],
|
|
600
693
|
capabilities: {
|
|
601
694
|
read: draft.capRead,
|
|
602
695
|
list: draft.capList,
|
|
@@ -615,158 +708,208 @@ window.__ModuleLoader__.load({
|
|
|
615
708
|
},
|
|
616
709
|
autoApproveAsk: draft.autoApproveAsk,
|
|
617
710
|
promptSection: draft.promptSection,
|
|
618
|
-
}
|
|
711
|
+
}
|
|
619
712
|
}
|
|
620
713
|
|
|
621
714
|
function FleetConfig() {
|
|
622
|
-
const [draft, setDraft] = useState(null)
|
|
623
|
-
const [
|
|
624
|
-
const [
|
|
625
|
-
|
|
626
|
-
const load = async () => {
|
|
627
|
-
try {
|
|
628
|
-
const response = await fetch('/device-fleet/config', { headers: { accept: 'application/json' } });
|
|
629
|
-
if (!response.ok) throw new Error('HTTP ' + response.status);
|
|
630
|
-
const data = await response.json();
|
|
631
|
-
setDraft(configToDraft(data.config));
|
|
632
|
-
} catch (problem) {
|
|
633
|
-
setStatus('加载配置失败:' + String(problem.message ?? problem));
|
|
634
|
-
}
|
|
635
|
-
};
|
|
715
|
+
const [draft, setDraft] = useState(null)
|
|
716
|
+
const [options, setOptions] = useState({})
|
|
717
|
+
const [status, setStatus] = useState('')
|
|
718
|
+
const [busy, setBusy] = useState(false)
|
|
636
719
|
|
|
637
720
|
useEffect(() => {
|
|
638
|
-
|
|
639
|
-
|
|
721
|
+
let disposed = false
|
|
722
|
+
const load = async () => {
|
|
723
|
+
try {
|
|
724
|
+
const [configResponse, optionsResponse] = await Promise.all([
|
|
725
|
+
fetch('/device-fleet/config', { headers: { accept: 'application/json' } }),
|
|
726
|
+
fetch('/device-fleet/options', { headers: { accept: 'application/json' } }),
|
|
727
|
+
])
|
|
728
|
+
const configData = await configResponse.json()
|
|
729
|
+
const optionsData = optionsResponse.ok ? await optionsResponse.json() : {}
|
|
730
|
+
if (disposed) return
|
|
731
|
+
setOptions(optionsData ?? {})
|
|
732
|
+
setDraft(configToDraft(configData.config ?? {}, optionsData ?? {}))
|
|
733
|
+
} catch (problem) {
|
|
734
|
+
if (!disposed) setStatus('加载失败')
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
void load()
|
|
738
|
+
return () => { disposed = true }
|
|
739
|
+
}, [])
|
|
640
740
|
|
|
641
|
-
if (!draft) return h('div', { style: { padding: 8,
|
|
741
|
+
if (!draft) return h('div', { style: { padding: 8, color: 'var(--dsw-alias-label-secondary, #999)' } }, status || '加载中…')
|
|
642
742
|
|
|
643
|
-
const set = (key, value) => setDraft((current) => ({ ...current, [key]: value }))
|
|
743
|
+
const set = (key, value) => setDraft((current) => ({ ...current, [key]: value }))
|
|
644
744
|
const save = async () => {
|
|
645
|
-
setBusy(true)
|
|
646
|
-
setStatus('')
|
|
745
|
+
setBusy(true)
|
|
746
|
+
setStatus('')
|
|
647
747
|
try {
|
|
648
748
|
const response = await fetch('/device-fleet/config', {
|
|
649
749
|
method: 'POST',
|
|
650
750
|
headers: { 'content-type': 'application/json' },
|
|
651
|
-
body: JSON.stringify(draftToPatch(draft)),
|
|
652
|
-
})
|
|
653
|
-
const data = await response.json()
|
|
654
|
-
if (!response.ok) throw new Error(data.error ?? 'HTTP ' + response.status)
|
|
655
|
-
setDraft(configToDraft(data.config))
|
|
656
|
-
setStatus('
|
|
751
|
+
body: JSON.stringify(draftToPatch(draft, options)),
|
|
752
|
+
})
|
|
753
|
+
const data = await response.json()
|
|
754
|
+
if (!response.ok) throw new Error(data.error ?? 'HTTP ' + response.status)
|
|
755
|
+
setDraft(configToDraft(data.config ?? {}, options))
|
|
756
|
+
setStatus('已保存')
|
|
657
757
|
} catch (problem) {
|
|
658
|
-
setStatus('保存失败:' + String(problem.message ?? problem))
|
|
758
|
+
setStatus('保存失败:' + String(problem.message ?? problem))
|
|
659
759
|
} finally {
|
|
660
|
-
setBusy(false)
|
|
760
|
+
setBusy(false)
|
|
661
761
|
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
const sectionCard = (title, children, hint) =>
|
|
665
|
-
h('div', { style: { ...cardStyle, padding: 14 } },
|
|
666
|
-
h('div', { style: sectionTitle }, title),
|
|
667
|
-
hint ? h('div', { style: { fontSize: 11, opacity: 0.55, marginBottom: 8 } }, hint) : null,
|
|
668
|
-
children,
|
|
669
|
-
);
|
|
670
|
-
|
|
671
|
-
const capabilityFields = [
|
|
672
|
-
['capRead', 'read 读取'],
|
|
673
|
-
['capList', 'list 列目录'],
|
|
674
|
-
['capGrep', 'grep 搜索'],
|
|
675
|
-
['capFetch', 'fetch 取文件'],
|
|
676
|
-
['capRun', 'run 执行命令'],
|
|
677
|
-
['capTool', 'tool 原始工具'],
|
|
678
|
-
['capDelegate', 'delegate 委派'],
|
|
679
|
-
];
|
|
680
|
-
const twoCol = (left, right) => h('div', { style: { display: 'flex', gap: 12 } }, h('div', { style: { flex: 1 } }, left), h('div', { style: { flex: 1 } }, right));
|
|
762
|
+
}
|
|
681
763
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
764
|
+
const cwdOptions = [
|
|
765
|
+
{ value: 'workspace', label: 'Device Fleet 工作区' },
|
|
766
|
+
{ value: 'default', label: 'DSH 默认目录' },
|
|
767
|
+
{ value: 'dshHome', label: 'DSH 主目录' },
|
|
768
|
+
{ value: 'custom', label: '自定义路径' },
|
|
769
|
+
]
|
|
770
|
+
const presetOptions = [{ value: '', label: '默认' }, ...((options.presets ?? []).map((preset) => ({ value: preset.id, label: preset.label })))]
|
|
771
|
+
const shellOptions = (options.shells ?? ['pwsh']).map((shell) => ({ value: shell, label: shell }))
|
|
772
|
+
const providerOptions = (options.subagentProviders ?? ['spawn']).map((provider) => ({ value: provider, label: provider }))
|
|
773
|
+
const hostOptions = (options.addresses ?? ['0.0.0.0']).map((address) => ({ value: address, label: address }))
|
|
774
|
+
const modeOptions = [{ value: 'auto', label: '自动' }, { value: 'ask', label: '询问' }, { value: 'deny', label: '拒绝' }]
|
|
775
|
+
|
|
776
|
+
return h('div', { style: { maxWidth: 760, padding: '4px 2px 28px', color: 'var(--dsw-alias-label-primary, #e8e8e8)' } },
|
|
777
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, marginBottom: 4 } },
|
|
778
|
+
h('div', { style: { fontSize: 15, fontWeight: 600 } }, 'Device Fleet'),
|
|
685
779
|
h('span', { style: { flex: 1 } }),
|
|
686
|
-
status ? h('span', { style: { fontSize: 12,
|
|
780
|
+
status ? h('span', { style: { fontSize: 12, color: 'var(--dsw-alias-label-secondary, #999)' } }, status) : null,
|
|
687
781
|
h('button', {
|
|
688
782
|
type: 'button',
|
|
689
783
|
disabled: busy,
|
|
690
784
|
onClick: () => void save(),
|
|
691
785
|
style: {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
786
|
+
height: 30,
|
|
787
|
+
padding: '0 14px',
|
|
788
|
+
borderRadius: 6,
|
|
789
|
+
border: '1px solid var(--dsw-alias-brand-primary, #2f6fed)',
|
|
790
|
+
background: '#2f6fed',
|
|
696
791
|
color: '#fff',
|
|
792
|
+
fontSize: 13,
|
|
697
793
|
cursor: busy ? 'default' : 'pointer',
|
|
698
794
|
opacity: busy ? 0.6 : 1,
|
|
699
795
|
},
|
|
700
|
-
}, busy ? '
|
|
796
|
+
}, busy ? '保存中' : '保存'),
|
|
701
797
|
),
|
|
702
|
-
h('div', { style:
|
|
703
|
-
|
|
704
|
-
h('
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
h('
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
798
|
+
h('div', { style: sectionStyle }, '设备'),
|
|
799
|
+
h(Row, { label: '名称' },
|
|
800
|
+
h(TextControl, { value: draft.deviceName, onChange: (value) => set('deviceName', value) }),
|
|
801
|
+
),
|
|
802
|
+
h('div', { style: sectionStyle }, '网络'),
|
|
803
|
+
h(Row, { label: '直连地址' },
|
|
804
|
+
h(SelectControl, { value: draft.directHost, options: hostOptions, onChange: (value) => set('directHost', value) }),
|
|
805
|
+
),
|
|
806
|
+
h(Row, { label: '直连端口' },
|
|
807
|
+
h(NumberControl, { value: draft.directPort, onChange: (value) => set('directPort', value) }),
|
|
808
|
+
),
|
|
809
|
+
h(Row, { label: '局域网发现' },
|
|
810
|
+
h(ToggleControl, { value: draft.discovery, onChange: (value) => set('discovery', value) }),
|
|
811
|
+
),
|
|
812
|
+
h(Row, { label: 'Relay' },
|
|
813
|
+
h(SelectControl, {
|
|
814
|
+
value: draft.relayMode,
|
|
815
|
+
options: [{ value: 'off', label: '不使用' }, { value: 'custom', label: '自定义' }],
|
|
816
|
+
onChange: (value) => set('relayMode', value),
|
|
817
|
+
}),
|
|
818
|
+
),
|
|
819
|
+
draft.relayMode === 'custom' ? h(Row, { label: 'Relay 地址' },
|
|
820
|
+
h(TextControl, { value: draft.relayHost, onChange: (value) => set('relayHost', value) }),
|
|
821
|
+
) : null,
|
|
822
|
+
draft.relayMode === 'custom' ? h(Row, { label: 'Relay 端口' },
|
|
823
|
+
h(NumberControl, { value: draft.relayPort, onChange: (value) => set('relayPort', value) }),
|
|
824
|
+
) : null,
|
|
825
|
+
draft.relayMode === 'custom' ? h(Row, { label: 'Relay 数据端口' },
|
|
826
|
+
h(NumberControl, { value: draft.relayDataPort, onChange: (value) => set('relayDataPort', value) }),
|
|
827
|
+
) : null,
|
|
828
|
+
h('div', { style: sectionStyle }, '执行上下文'),
|
|
829
|
+
h(Row, { label: '工作目录' },
|
|
830
|
+
h(SelectControl, { value: draft.cwdMode, options: cwdOptions, onChange: (value) => set('cwdMode', value) }),
|
|
831
|
+
),
|
|
832
|
+
draft.cwdMode === 'custom' ? h(Row, { label: '路径' },
|
|
833
|
+
h(TextControl, { value: draft.customCwd, onChange: (value) => set('customCwd', value) }),
|
|
834
|
+
) : null,
|
|
835
|
+
h(Row, { label: 'Agent Preset' },
|
|
836
|
+
h(SelectControl, { value: draft.execPreset, options: presetOptions, onChange: (value) => set('execPreset', value) }),
|
|
837
|
+
),
|
|
838
|
+
h(Row, { label: 'Shell' },
|
|
839
|
+
h(SelectControl, { value: draft.execShellTool, options: shellOptions, onChange: (value) => set('execShellTool', value) }),
|
|
840
|
+
),
|
|
841
|
+
h(Row, { label: '委派 Provider' },
|
|
842
|
+
h(SelectControl, { value: draft.execSubagentProvider, options: providerOptions, onChange: (value) => set('execSubagentProvider', value) }),
|
|
843
|
+
),
|
|
844
|
+
h(Row, { label: '审批超时 (ms)' },
|
|
845
|
+
h(NumberControl, { value: draft.execApprovalTimeoutMs, onChange: (value) => set('execApprovalTimeoutMs', value) }),
|
|
846
|
+
),
|
|
847
|
+
h(Row, { label: '委派超时 (ms)' },
|
|
848
|
+
h(NumberControl, { value: draft.execDelegateTimeoutMs, onChange: (value) => set('execDelegateTimeoutMs', value) }),
|
|
849
|
+
),
|
|
850
|
+
h('div', { style: sectionStyle }, '远端权限'),
|
|
851
|
+
h(Row, { label: '允许的根目录', wide: true },
|
|
852
|
+
h('textarea', {
|
|
853
|
+
value: draft.rootsText,
|
|
854
|
+
onChange: (event) => set('rootsText', event.target.value),
|
|
855
|
+
rows: 3,
|
|
856
|
+
style: textareaStyle,
|
|
857
|
+
}),
|
|
858
|
+
),
|
|
859
|
+
h(Row, { label: '免审批即用的工具', wide: true },
|
|
860
|
+
h('div', {
|
|
861
|
+
style: {
|
|
862
|
+
display: 'flex',
|
|
863
|
+
flexWrap: 'wrap',
|
|
864
|
+
gap: '6px 16px',
|
|
865
|
+
maxHeight: 168,
|
|
866
|
+
overflow: 'auto',
|
|
867
|
+
padding: '6px 8px',
|
|
868
|
+
border: '1px solid var(--dsw-alias-border-l1, #333)',
|
|
869
|
+
borderRadius: 6,
|
|
870
|
+
background: 'var(--dsw-alias-bg-layer-2, #262626)',
|
|
871
|
+
},
|
|
872
|
+
},
|
|
873
|
+
...(options.tools ?? []).map((name) =>
|
|
874
|
+
h('label', { key: name, style: { display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, color: 'var(--dsw-alias-label-primary, #e8e8e8)' } },
|
|
875
|
+
h('input', {
|
|
876
|
+
type: 'checkbox',
|
|
877
|
+
checked: Array.isArray(draft.toolsList) && draft.toolsList.includes(name),
|
|
878
|
+
onChange: (event) => {
|
|
879
|
+
const current = Array.isArray(draft.toolsList) ? draft.toolsList : []
|
|
880
|
+
set('toolsList', event.target.checked ? [...current, name] : current.filter((item) => item !== name))
|
|
881
|
+
},
|
|
882
|
+
}),
|
|
883
|
+
name,
|
|
754
884
|
),
|
|
755
885
|
),
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
h(
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
)),
|
|
769
|
-
|
|
886
|
+
),
|
|
887
|
+
),
|
|
888
|
+
...CAPABILITY_ROWS.map(([key, label]) =>
|
|
889
|
+
h(Row, { key, label },
|
|
890
|
+
h(SelectControl, { value: draft[key], options: modeOptions, onChange: (value) => set(key, value) }),
|
|
891
|
+
),
|
|
892
|
+
),
|
|
893
|
+
h(Row, { label: '授权有效期 (ms)' },
|
|
894
|
+
h(NumberControl, { value: draft.policyApprovalTtlMs, onChange: (value) => set('policyApprovalTtlMs', value) }),
|
|
895
|
+
),
|
|
896
|
+
h('div', { style: sectionStyle }, '审批与提示'),
|
|
897
|
+
h(Row, { label: '审批超时 (ms)' },
|
|
898
|
+
h(NumberControl, { value: draft.approvalsTtlMs, onChange: (value) => set('approvalsTtlMs', value) }),
|
|
899
|
+
),
|
|
900
|
+
h(Row, { label: '最大排队数' },
|
|
901
|
+
h(NumberControl, { value: draft.approvalsMaxPending, onChange: (value) => set('approvalsMaxPending', value) }),
|
|
902
|
+
),
|
|
903
|
+
h(Row, { label: '自动批准(测试)' },
|
|
904
|
+
h(ToggleControl, { value: draft.autoApproveAsk, onChange: (value) => set('autoApproveAsk', value) }),
|
|
905
|
+
),
|
|
906
|
+
h(Row, { label: 'Fleet 系统提示' },
|
|
907
|
+
h(ToggleControl, { value: draft.promptSection, onChange: (value) => set('promptSection', value) }),
|
|
908
|
+
),
|
|
909
|
+
h(Row, { label: '审批模拟(测试)' },
|
|
910
|
+
h(ToggleControl, { value: draft.simulation, onChange: (value) => set('simulation', value) }),
|
|
911
|
+
),
|
|
912
|
+
)
|
|
770
913
|
}
|
|
771
914
|
|
|
772
915
|
return {
|
|
@@ -39,19 +39,19 @@ dsh plugin --profile desktop add dsh-device-fleet@dev
|
|
|
39
39
|
- 邀请里新增 `endpoints`(创建者的局域网/热点 IPv4 + direct 端口),加入方重启后自动向这些地址回连,绕开组播发现失败;
|
|
40
40
|
- 新增 `fleet_status`(deviceId/直连端口/发现/连接/roster/hints)与 `fleet_connect(host, port)`(手动直连,成功后会从握手学到对端 deviceId);
|
|
41
41
|
- `fleet_list` 仍是本地视图;配对成功后双方 roster 会自动固定对端公钥。
|
|
42
|
-
## 0.1.0-dev.
|
|
42
|
+
## 0.1.0-dev.15(稳定化)
|
|
43
43
|
|
|
44
44
|
- 直连端口可固定(profile `direct.port`),插件重载不再换端口;
|
|
45
45
|
- 连接断开后自动重试已知地址(不再只在启动时试一次);
|
|
46
46
|
- `fleet_connect` 手动地址会持久化到 `peer-hints.json`,重启后继续回连;
|
|
47
47
|
- 新增 `fleet_delegate`(dev.5):目标设备用 `SubagentProvider` + `delivery:'caller'` 跑 agent 并返回最终结果。
|
|
48
|
-
## 0.1.0-dev.
|
|
48
|
+
## 0.1.0-dev.15(审批收件箱,逻辑层)
|
|
49
49
|
|
|
50
50
|
- 新增 `ApprovalInbox`:ask 档请求排队、超时 fail-closed、approve(once/ttl)/deny、关闭时全部失败关闭;
|
|
51
51
|
- 直调与委派的 ask 档改为等待本机收件箱结果(不再一律拒绝);
|
|
52
52
|
- 新工具:`fleet_approvals` / `fleet_approve` / `fleet_deny`;`fleet_simulate_request`(仅 `approvals.simulation: true`)用于本机无第二台设备时演练流程;
|
|
53
53
|
- 审批面板(Client UI)与通知尚未实现,当前通过工具/后续 UI 应答。
|
|
54
|
-
## 0.1.0-dev.
|
|
54
|
+
## 0.1.0-dev.15(Room 逻辑层,本机模拟)
|
|
55
55
|
|
|
56
56
|
- `RoomService`:当前会话升级为 Room Host;本地模拟参与者(真实 DSH session/agent);
|
|
57
57
|
- 寻址消息:`room_send` 只唤醒被点名成员,Host 会话写权威 `room/message` 事件;
|
|
@@ -59,15 +59,29 @@ dsh plugin --profile desktop add dsh-device-fleet@dev
|
|
|
59
59
|
- Room Board:`room_task_add/update/list`,`dependsOn` 串行交接(前置完成时唤醒下一个 owner),无依赖任务并行不受影响;
|
|
60
60
|
- 工具:`room_create / room_add_local / room_remove_member / room_send / room_messages / room_status / room_task_* / room_close`;
|
|
61
61
|
- 远程参与者传输与 Client UI 未做(下一步)。
|
|
62
|
-
## 0.1.0-dev.
|
|
62
|
+
## 0.1.0-dev.15(审批面板 UI,第一版)
|
|
63
63
|
|
|
64
64
|
- Host 新增本地 HTTP 数据面:GET `/device-fleet/approvals`、POST `/device-fleet/approvals/decide`(仅本机 web 载体,决策仍走 ApprovalInbox);
|
|
65
65
|
- Client half:`client.js` 闭包工厂,注册 `shell.overlay` 浮动「Fleet 审批」按钮 + 面板,轮询待审批列表,支持允许一次 / 允许 15 分钟 / 拒绝;
|
|
66
66
|
- package.json 增加 `dsh.client` 与 `./client` 导出;`files` 增加 client.js;
|
|
67
67
|
- Client 视觉验证需要刷新页面;当前无浏览器控制,仅验证了 bundle 语法与 Host 路由注册。
|
|
68
|
-
## 0.1.0-dev.
|
|
68
|
+
## 0.1.0-dev.15(审批入口不遮挡)
|
|
69
69
|
|
|
70
70
|
- 触发按钮从右下角浮动改为 `sidebar.footer.action`(设置旁边),不再遮挡任务列表/内容面板;
|
|
71
71
|
- 审批 inbox 改为点击后居中的模态对话框(带遮罩,Esc/点遮罩关闭);
|
|
72
72
|
- 轮询在 Client apply 中启动并由 ctx.effect 清理;待审批数量作为按钮徽标;
|
|
73
|
-
- 已实测:面板点击「允许」后 Host `fleet_approvals` 清空。
|
|
73
|
+
- 已实测:面板点击「允许」后 Host `fleet_approvals` 清空。
|
|
74
|
+
## 0.1.0-dev.15(Phase B:运行时配置 + 配置页)
|
|
75
|
+
|
|
76
|
+
- `RuntimeConfig`:profile patch 为 base,UI 修改写入 `$DSH_HOME/device-fleet/config-overrides.json`,apply 时合并并持久化;
|
|
77
|
+
- 保存即生效:policy/execution/approvals/deviceName/promptSection/autoApproveAsk 直接更新运行时对象;direct/discovery/relay 通过 `FleetNode.reconfigure()` 原地重启网络监听(不重启插件/DSH);`dataDir` 只读;
|
|
78
|
+
- Host:`GET /device-fleet/config`、`POST /device-fleet/config`(校验/清洗后应用);
|
|
79
|
+
- Client:注册 `plugins.row.config`(key `dsh-device-fleet#device-fleet`)与 `plugins.bundle.config`(key `dsh-device-fleet`),配置页含设备/网络、执行上下文、Tool Policy、审批与提示四组表单;
|
|
80
|
+
- 单测 18/18、网络 9/9。
|
|
81
|
+
## 0.1.0-dev.15(配置页 DSH 化改版)
|
|
82
|
+
|
|
83
|
+
- Host 新增 `GET /device-fleet/options`:本机地址、可用 preset 列表、shell 工具、subagent providers、工作目录候选;
|
|
84
|
+
- 配置保存前会 ensure 工作目录存在(Device Fleet 工作区自动创建);
|
|
85
|
+
- 配置页重做:行式布局(label 左/控件右)、DSH token 配色、分组标题、去掉多余说明文字与 dataDir 展示;
|
|
86
|
+
- 下拉化:直连地址、局域网发现、Relay 模式、工作目录(工作区/默认/DSH 主目录/自定义)、Agent Preset、Shell、委派 Provider、7 项能力权限、开关项;
|
|
87
|
+
- 仍保留文本输入:设备名称、端口、超时、根目录/工具列表、自定义工作目录与 Relay 地址。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-device-fleet",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.16",
|
|
4
4
|
"description": "DeepSeek Harness device fleet: enroll devices, direct-call remote tools, shared Rooms with lazy-woken agents, and delegated subagents across devices.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/plugin/index.js",
|
package/src/host/config-web.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Runtime config HTTP surface (dev.
|
|
2
|
-
// patch live. The UI posts here; no plugin or DSH restart is involved.
|
|
1
|
+
// Runtime config HTTP surface (dev.15): read effective config, list UI options,
|
|
2
|
+
// and apply a patch live. The UI posts here; no plugin or DSH restart is involved.
|
|
3
3
|
const MAX_BODY_BYTES = 256 * 1024
|
|
4
4
|
|
|
5
5
|
function json(res, status, value) {
|
|
@@ -25,9 +25,31 @@ async function readJsonBody(req) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @param {object} options
|
|
30
|
+
* @param {object} options.webServer ctx.webServer
|
|
31
|
+
* @param {object} options.runtime RuntimeConfig
|
|
32
|
+
* @param {() => Promise<object>|object} [options.getOptions] UI option catalog (presets, shells, paths)
|
|
33
|
+
* @param {(patch: object) => Promise<object>|object} [options.preparePatch] side effects before applying (e.g. mkdir)
|
|
34
|
+
*/
|
|
35
|
+
export function registerConfigRoutes({ webServer, runtime, getOptions = null, preparePatch = null, logger = null }) {
|
|
29
36
|
if (!webServer?.register || !runtime) return () => {}
|
|
30
37
|
const disposers = []
|
|
38
|
+
disposers.push(
|
|
39
|
+
webServer.register({
|
|
40
|
+
kind: 'exact',
|
|
41
|
+
path: '/device-fleet/options',
|
|
42
|
+
handler: async (req, res) => {
|
|
43
|
+
if (req.method !== 'GET') return json(res, 405, { error: 'method not allowed' })
|
|
44
|
+
try {
|
|
45
|
+
json(res, 200, (await getOptions?.()) ?? {})
|
|
46
|
+
} catch (error) {
|
|
47
|
+
logger?.warn?.(`[device-fleet] options failed: ${String(error?.message ?? error)}`)
|
|
48
|
+
json(res, 500, { error: 'internal error' })
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
)
|
|
31
53
|
disposers.push(
|
|
32
54
|
webServer.register({
|
|
33
55
|
kind: 'exact',
|
|
@@ -45,7 +67,8 @@ export function registerConfigRoutes({ webServer, runtime, logger = null }) {
|
|
|
45
67
|
try {
|
|
46
68
|
const body = await readJsonBody(req)
|
|
47
69
|
const patch = body?.patch ?? body
|
|
48
|
-
const
|
|
70
|
+
const prepared = preparePatch ? await preparePatch(patch) : patch
|
|
71
|
+
const config = await runtime.update(prepared ?? patch)
|
|
49
72
|
json(res, 200, { ok: true, config, appliedAt: Date.now() })
|
|
50
73
|
} catch (error) {
|
|
51
74
|
const status = ['bad-request', 'bad-json', 'body-too-large', 'readonly'].includes(error?.code) ? 400 : 500
|
package/src/host/ui-web.js
CHANGED
|
@@ -57,12 +57,16 @@ export function registerUiRoutes({ webServer, inbox, rooms, getOverview, logger
|
|
|
57
57
|
)
|
|
58
58
|
disposers.push(
|
|
59
59
|
webServer.register({
|
|
60
|
-
kind: '
|
|
61
|
-
path: '/device-fleet/
|
|
60
|
+
kind: 'exact',
|
|
61
|
+
path: '/device-fleet/room',
|
|
62
62
|
handler: async (req, res) => {
|
|
63
63
|
if (req.method !== 'GET') return json(res, 405, { error: 'method not allowed' })
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
let roomId = ''
|
|
65
|
+
try {
|
|
66
|
+
roomId = new URL(req.url ?? '/', 'http://local').searchParams.get('id') ?? ''
|
|
67
|
+
} catch {
|
|
68
|
+
roomId = ''
|
|
69
|
+
}
|
|
66
70
|
if (roomId === '') return json(res, 400, { error: 'room id is required' })
|
|
67
71
|
try {
|
|
68
72
|
json(res, 200, { room: rooms.detail(roomId, { limit: 100 }) })
|
package/src/plugin/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// the six `fleet_*` tools, and the two adoption mechanisms that are cheap to
|
|
5
5
|
// land now (a prompt section and a first-use manual + orchestration nudge).
|
|
6
6
|
// Room, Room Board, delegation and the UI land in later steps.
|
|
7
|
-
import { readFileSync } from 'node:fs'
|
|
7
|
+
import { mkdirSync, readFileSync } from 'node:fs'
|
|
8
8
|
import { networkInterfaces } from 'node:os'
|
|
9
9
|
import { join } from 'node:path'
|
|
10
10
|
import { fileURLToPath } from 'node:url'
|
|
@@ -175,10 +175,12 @@ export function apply(ctx, profileConfig) {
|
|
|
175
175
|
capabilities: CAPABILITIES,
|
|
176
176
|
})
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
const policy = new ToolPolicy(config.policy)
|
|
179
179
|
const sessionController = service('sessionController')
|
|
180
180
|
const fs = service('fs')
|
|
181
181
|
const subagents = service('subagents')
|
|
182
|
+
const agentPresets = service('agentPresets')
|
|
183
|
+
const workingDirectory = service('workingDirectory')
|
|
182
184
|
const inbox = new ApprovalInbox({
|
|
183
185
|
ttlMs: config.approvals?.ttlMs ?? 60_000,
|
|
184
186
|
maxPending: config.approvals?.maxPending ?? 50,
|
|
@@ -218,9 +220,75 @@ export function apply(ctx, profileConfig) {
|
|
|
218
220
|
// Client approval panel data plane (dev.9). Optional service: host-only
|
|
219
221
|
// deployments simply do not expose the panel routes.
|
|
220
222
|
const webServer = service('webServer')
|
|
223
|
+
const workspaceDir = join(state.dataDir, 'workspace')
|
|
224
|
+
const getOptions = async () => {
|
|
225
|
+
const addresses = new Set(['0.0.0.0', '127.0.0.1', runtime.current.direct?.host ?? ''])
|
|
226
|
+
for (const entries of Object.values(networkInterfaces())) {
|
|
227
|
+
for (const entry of entries ?? []) {
|
|
228
|
+
if (entry.family === 'IPv4' && !entry.internal) addresses.add(entry.address)
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
addresses.delete('')
|
|
232
|
+
let toolNames = []
|
|
233
|
+
try {
|
|
234
|
+
toolNames = (ctx.tools.definitions?.() ?? []).map((definition) => definition.name)
|
|
235
|
+
} catch {
|
|
236
|
+
toolNames = []
|
|
237
|
+
}
|
|
238
|
+
const shellCandidates = ['pwsh', 'bash', 'cmd', 'sh']
|
|
239
|
+
let shells = shellCandidates.filter((name) => toolNames.includes(name))
|
|
240
|
+
if (shells.length === 0) shells = [process.platform === 'win32' ? 'pwsh' : 'bash']
|
|
241
|
+
let presets = []
|
|
242
|
+
try {
|
|
243
|
+
presets = (await agentPresets?.list?.()) ?? []
|
|
244
|
+
} catch {
|
|
245
|
+
presets = []
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
platform: process.platform,
|
|
249
|
+
addresses: [...addresses],
|
|
250
|
+
shells,
|
|
251
|
+
subagentProviders: (() => {
|
|
252
|
+
try {
|
|
253
|
+
return subagents?.list?.() ?? ['spawn']
|
|
254
|
+
} catch {
|
|
255
|
+
return ['spawn']
|
|
256
|
+
}
|
|
257
|
+
})(),
|
|
258
|
+
tools: [...toolNames].sort(),
|
|
259
|
+
presets: presets.map((preset) => ({
|
|
260
|
+
id: preset.id ?? preset.name,
|
|
261
|
+
label: preset.name ?? preset.title ?? preset.id,
|
|
262
|
+
})),
|
|
263
|
+
cwd: {
|
|
264
|
+
workspace: workspaceDir,
|
|
265
|
+
dshHome: process.env.DSH_HOME ?? '',
|
|
266
|
+
defaultDirectory: workingDirectory?.defaultDirectory ?? '',
|
|
267
|
+
current: runtime.current.execution?.cwd ?? '',
|
|
268
|
+
},
|
|
269
|
+
}
|
|
270
|
+
}
|
|
221
271
|
if (webServer) {
|
|
222
272
|
ctx.effect(() => registerApprovalRoutes({ webServer, inbox, logger }))
|
|
223
|
-
ctx.effect(() =>
|
|
273
|
+
ctx.effect(() =>
|
|
274
|
+
registerConfigRoutes({
|
|
275
|
+
webServer,
|
|
276
|
+
runtime,
|
|
277
|
+
getOptions,
|
|
278
|
+
preparePatch: async (patch) => {
|
|
279
|
+
const cwd = patch?.execution?.cwd
|
|
280
|
+
if (typeof cwd === 'string' && cwd !== '') {
|
|
281
|
+
try {
|
|
282
|
+
mkdirSync(cwd, { recursive: true })
|
|
283
|
+
} catch (error) {
|
|
284
|
+
logger.warn?.(`[device-fleet] cannot create execution cwd: ${String(error?.message ?? error)}`)
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return patch
|
|
288
|
+
},
|
|
289
|
+
logger,
|
|
290
|
+
}),
|
|
291
|
+
)
|
|
224
292
|
ctx.effect(() =>
|
|
225
293
|
registerUiRoutes({
|
|
226
294
|
webServer,
|