Kaynağa Gözat

执行节点设置去掉 Hermes 地址输入框

Hermes 已内置在服务端,下载的 runner.json 固定写入旧默认值以兼容旧版 Runner。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HvtCVfyjw1NDNZsVHYZJZA
Claude 3 saat önce
ebeveyn
işleme
709152ae06

+ 2 - 2
docs/runner.md

@@ -9,7 +9,7 @@ Runner 在执行电脑上主动连接夭夭服务,负责虚拟机桌面、托
 ## 启用
 
 1. 管理员打开设置 → Hermes 连接 → 执行节点。
-2. 选择接管的 Bot 来源、允许的 Profile,以及能从执行电脑访问的夭夭地址。「Runner 本机 Hermes 地址」是旧字段,保持默认即可。
+2. 选择接管的 Bot 来源、允许的 Profile,以及能从执行电脑访问的夭夭地址。
 3. 注册后下载 `runner.json`。节点凭据只在注册响应中返回;列表和刷新不会返回凭据。
 4. 将配置放到执行电脑,执行 `chmod 600 /完整路径/runner.json`。
 5. 在项目目录执行 `npm run build`,然后执行 `npm run runner -- --config /完整路径/runner.json`。
@@ -35,7 +35,7 @@ macOS 完整版 App 可直接通过菜单栏“执行节点 → 导入节点配
 }
 ```
 
-`hermesURL` 和 `hermesCredentials` 是旧版字段:服务端已不再通过 Runner 托管 Hermes 会话,新配置可以省略(`hermesURL` 缺省为 `http://127.0.0.1:9119`,仅为兼容旧配置而保留,执行电脑上不需要有服务监听)。远程明文 HTTP 必须明确设置 `allowInsecureLan: true`。
+`hermesURL` 和 `hermesCredentials` 是旧版字段:服务端已不再通过 Runner 托管 Hermes 会话,设置页不再提供输入,下载的配置固定写入 `http://127.0.0.1:9119` 以兼容旧版 Runner,执行电脑上不需要有服务监听;手写配置可以省略。远程明文 HTTP 必须明确设置 `allowInsecureLan: true`。
 
 每个来源同时只允许一个启用的 Runner。已有配对 Web 来源应在目的 Web 服务内注册自己的 Runner。停用会立即关闭控制面的工具授权,执行电脑在连接恢复或轮询时收到拒绝。配置丢失时停用并重新注册;旧配置不能恢复已撤销的节点。
 

+ 9 - 9
src/client/components/app/RunnerSettingsPanel.vue

@@ -10,7 +10,9 @@ const bundleAvailable=ref(false),fixedDesktops=ref(false)
 const runners = ref<Runner[]>([]), sources = ref<Array<{id:string;name:string}>>([])
 const busy = ref(false), error = ref(''), notice = ref('')
 const name = ref(''), source = ref('local'), profiles = ref('default')
-const serverURL = ref(window.location.origin), hermesURL = ref('http://127.0.0.1:9119')
+// Hermes is embedded in the server; runner.json keeps the legacy field only for older Runners.
+const LEGACY_RUNNER_HERMES_URL = 'http://127.0.0.1:9119'
+const serverURL = ref(window.location.origin)
 const computerNetwork=ref<'none'|'public-proxy'>('public-proxy')
 const managedBrowser=ref(true)
 const computers=ref(!!props.computerSetup),computerRuntime=ref<'docker'|'podman'>('docker'),computerImage=ref(''),computerPython=ref(''),hermesSource=ref(''),hermesHome=ref('')
@@ -28,16 +30,15 @@ async function action(work:()=>Promise<void>) {
 }
 async function register() {
   await action(async()=>{
-    const web = new URL(serverURL.value), local = new URL(hermesURL.value)
+    const web = new URL(serverURL.value)
     if(!['http:','https:'].includes(web.protocol)||web.username||web.password||web.search||web.hash||web.pathname!=='/')throw new Error('请填写不带路径的夭夭服务地址')
     if(web.protocol==='http:'&&!['localhost','127.0.0.1','[::1]'].includes(web.hostname)&&!insecure.value)throw new Error('远程节点请使用 HTTPS,或勾选可信局域网 HTTP')
-    if(!['127.0.0.1','[::1]'].includes(local.hostname)||!['http:','https:'].includes(local.protocol)||local.username||local.password)throw new Error('Hermes 地址必须指向 Runner 所在电脑的回环地址')
     const allowedProfiles = [...new Set(profiles.value.split(/[\s,,]+/).filter(Boolean))]
     if(computers.value&&((!!computerImage.value&&!/^sha256:[a-f0-9]{64}$/.test(computerImage.value))||[computerPython.value,hermesSource.value,hermesHome.value].some(path=>path&&!path.startsWith('/'))))throw new Error('自定义路径必须为执行电脑上的绝对路径;默认安装可留空。镜像 ID 可留空或填写完整 sha256 ID。')
     const result = await apiRequest<{runner:Runner;token:string}>('/api/app/admin/runners', {method:'POST',body:{name:name.value.trim(),sourceNodeId:source.value,allowedProfiles}})
-    configuration.value = {protocol:1,serverURL:web.origin,runnerId:result.runner.id,token:result.token,hermesURL:local.toString(),allowedProfiles,artifactRoots:artifactRoots.value.split('\n').map(p=>p.trim()).filter(Boolean),...(insecure.value?{allowInsecureLan:true}:{}),...(computers.value?{computers:{...(fixedDesktops.value?{managedBy:'compose' as const}:{}),network:fixedDesktops.value?'none':computerNetwork.value,runtime:computerRuntime.value,imageId:computerImage.value||UNCONFIGURED_COMPUTER_IMAGE,python:computerPython.value,hermesSource:hermesSource.value,hermesHome:hermesHome.value}}:{})}
+    configuration.value = {protocol:1,serverURL:web.origin,runnerId:result.runner.id,token:result.token,hermesURL:LEGACY_RUNNER_HERMES_URL,allowedProfiles,artifactRoots:artifactRoots.value.split('\n').map(p=>p.trim()).filter(Boolean),...(insecure.value?{allowInsecureLan:true}:{}),...(computers.value?{computers:{...(fixedDesktops.value?{managedBy:'compose' as const}:{}),network:fixedDesktops.value?'none':computerNetwork.value,runtime:computerRuntime.value,imageId:computerImage.value||UNCONFIGURED_COMPUTER_IMAGE,python:computerPython.value,hermesSource:hermesSource.value,hermesHome:hermesHome.value}}:{})}
     configuration.value.browser={enabled:managedBrowser.value}
-    notice.value = '节点已注册,请下载配置并在 Hermes 所在电脑启动 Runner。'
+    notice.value = '节点已注册,请下载配置并在执行电脑上启动 Runner。'
     await refresh()
   })
 }
@@ -59,7 +60,7 @@ onMounted(()=>{void action(refresh)})
 
 <template>
   <section class="runner-panel" aria-label="执行节点设置">
-    <p>执行节点提供虚拟环境和托管浏览器能力。节点要和 Hermes 装在同一台电脑上。</p>
+    <p>执行节点提供虚拟环境和托管浏览器能力。Hermes 已内置在夭夭服务中,执行电脑无需安装 Hermes。</p>
     <p v-if="bundleAvailable"><a href="/api/app/admin/runners/bundle" download>下载配套执行节点程序</a>(包含桌面资源,需要 Node.js 24 或更高版本)。</p>
     <div class="runner-toolbar"><strong>已注册节点</strong><button type="button" :disabled="busy" @click="action(refresh)">刷新状态</button></div>
     <ul v-if="runners.length" class="runner-list">
@@ -74,7 +75,6 @@ onMounted(()=>{void action(refresh)})
       <label>接管的 Bot 来源<select v-model="source" :disabled="busy"><option v-for="item in sources" :key="item.id" :value="item.id">{{ item.name }}</option></select></label>
       <label>允许的 Profile<input v-model="profiles" required placeholder="default, writer" :disabled="busy"><small>填写 Hermes 的 Profile 名称,以逗号分隔;账号权限仍然生效。</small></label>
       <label>夭夭服务地址<input v-model="serverURL" type="url" required :disabled="busy"><small>必须能从 Runner 所在电脑访问。</small></label>
-      <label>Runner 本机 Hermes 地址<input v-model="hermesURL" type="url" required :disabled="busy"></label>
       <label>允许导出的产物目录<textarea v-model="artifactRoots" rows="2" :disabled="busy" placeholder="每行一个绝对路径,留空时禁止导出文件"></textarea></label>
       <label class="runner-check"><input v-model="insecure" type="checkbox" :disabled="busy">使用可信局域网 HTTP</label>
       <label class="runner-check"><input v-model="managedBrowser" type="checkbox" :disabled="busy">托管浏览器</label>
@@ -96,10 +96,10 @@ onMounted(()=>{void action(refresh)})
     </form>
     <div v-else class="runner-setup">
       <button class="solid-button" type="button" @click="download">下载 Runner 配置</button>
-      <p>配置包含本节点的连接凭据,仅本次可下载。将文件放在 Hermes 所在电脑,设置为仅自己可读:</p>
+      <p>配置包含本节点的连接凭据,仅本次可下载。将文件放在执行电脑上,设置为仅自己可读:</p>
       <code v-if="bundleAvailable">mkdir -p yaoyao-runner<br>tar -xzf yaoyao-runner.tar.gz -C yaoyao-runner<br>chmod 600 runner.json<br>node yaoyao-runner/runner.mjs --config /完整路径/runner.json</code>
       <code v-else>chmod 600 runner.json<br>npm run runner -- --config /完整路径/runner.json</code>
-      <small>{{bundleAvailable?(configuration.computers?'在运行 Hermes 和 Docker/Podman 的电脑上执行,节点连接后返回本地虚拟机设置准备桌面。':'在运行 Hermes 的电脑上启动节点。'):'在 yaoyao 项目中先运行 npm run build。'}}配置丢失后可停用节点并重新注册。</small>
+      <small>{{bundleAvailable?(configuration.computers?'在运行 Docker/Podman 的执行电脑上执行,节点连接后返回本地虚拟机设置准备桌面。':'在执行电脑上启动节点。'):'在 yaoyao 项目中先运行 npm run build。'}}配置丢失后可停用节点并重新注册。</small>
     </div>
     <p v-if="error" class="runner-error" role="alert">{{ error }}</p>
     <p v-if="notice" role="status">{{ notice }}</p>