Add terminal_open / terminal_exec / terminal_close so an AI can hold one shell session per Windows host and run a sequence of commands with cwd and environment preserved, instead of the one-shot exec_command. The persistent terminal is a separate full-command write capability gated by McpTerminal (default off) plus McpReadonly=0, with no whitelist and full audit. One device maps to one terminal session via the shared m_TermSessions map; idle sessions are swept after 300s. terminal_exec rejects commands that contain & or | (they corrupt the sentinel control-operator chain) as well as control characters. Also harden exec_command and terminal_exec against newline/CR injection, fix a dangling subCtx after an abrupt shell disconnect, and refresh lastActiveAt on command completion. Add en/zh-TW translations for the new UI strings and a design document covering both exec_command and the persistent terminal. Co-Authored-By: deepseek-v4-pro
47 lines
1.5 KiB
C++
47 lines
1.5 KiB
C++
#pragma once
|
||
|
||
#include <afxwin.h>
|
||
#include <afxcmn.h>
|
||
#include <vector>
|
||
|
||
// 「MCP设置」配置对话框:启用 MCP / 端口 / 绑定地址 / Token。
|
||
// 因 2015Remote.rc 为 UTF-16 编码、不宜手工编辑,参照 ZstaPickerDlg 用
|
||
// InitModalIndirect + 内存 DLGTEMPLATE 程序化创建(见 docs/Mcp_Design.md §3.8)。
|
||
class CMcpSettingsDlg : public CDialog
|
||
{
|
||
public:
|
||
explicit CMcpSettingsDlg(CWnd* parent = nullptr);
|
||
|
||
virtual INT_PTR DoModal();
|
||
|
||
protected:
|
||
virtual BOOL OnInitDialog();
|
||
virtual void OnOK();
|
||
|
||
DECLARE_MESSAGE_MAP()
|
||
|
||
private:
|
||
enum CtrlId {
|
||
IDC_MCP_ENABLE = 1001, // 「启用 MCP」复选框
|
||
IDC_MCP_PORT = 1002, // 端口编辑框
|
||
IDC_MCP_BIND = 1003, // 绑定地址编辑框
|
||
IDC_MCP_TOKEN = 1004, // Token 编辑框
|
||
IDC_MCP_READONLY = 1005, // 「只读模式」复选框(默认勾选,禁 exec_command)
|
||
IDC_MCP_WHITELIST = 1006, // 命令白名单编辑框(多行,逗号/换行分隔,空 = 内置只读前缀)
|
||
IDC_MCP_TERMINAL = 1007, // 「启用持久终端」复选框(全命令,无白名单,要求只读关)
|
||
};
|
||
|
||
CButton m_btnEnable;
|
||
CStatic m_lblPort, m_lblBind, m_lblToken;
|
||
CEdit m_editPort, m_editBind, m_editToken;
|
||
CButton m_btnReadonly;
|
||
CButton m_btnTerminal;
|
||
CStatic m_lblWhitelist;
|
||
CEdit m_editWhitelist;
|
||
CButton m_btnOK, m_btnCancel;
|
||
|
||
std::vector<BYTE> m_Template; // 内存 DLGTEMPLATE 字节
|
||
|
||
void LayoutControls(int cx, int cy);
|
||
};
|