officecli 迁入技能层:skills/office 封装 + executor 预览托管,双盘同步整条退役
- skills/office:SKILL.md + scripts/office 封装层(命令闸门/help 对齐/get-pos 语义糖/create、open 出 ui_card marker);install.sh 按技能双跑约定把二进制拉到技能卷 bin/(不进 git/不进镜像,GitHub→gh-proxy 备源) - executor/preview.js:预览槽位+网关(原 mcp 侧 watch/gateway 移植),工作区=tasks 卷真实文件, /__session-kill 供 core 清槽;Dockerfile 零 officecli 痕迹,入口符号链接进 /usr/local/bin/office - core:preview-proxy 默认上游改 agent-executor:3100;tools/executor.js 通用 drainUiCards(terminal 输出 ::ui_card 标记行 → 剥离 + ctx.onCard,任意命令可产卡);engine 删会话改走 rexec.killPreviewSession - compose:agent-executor expose 3100(只走内网);.gitignore 排除技能二进制
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// 与本地 spawn 的行为对齐:stdout+stderr 按到达顺序合并成一个 out 字符串;超时/取消杀远端进程组;
|
||||
// 通过 run.procs 注册句柄(remoteKill),使 engine 的停止/终止会话能连带取消远端任务。
|
||||
'use strict';
|
||||
const http = require('node:http');
|
||||
|
||||
// 单引号安全包裹(内部单引号按 '\'' 规则转义),供拼 sh -c 命令串用。
|
||||
function shq(s) { return "'" + String(s).replace(/'/g, "'\\''") + "'"; }
|
||||
@@ -97,4 +98,25 @@ async function run(cfg, opts) {
|
||||
return { code: exit.code, killed_by: exit.killed_by || localKill, out, truncated: !!exit.truncated };
|
||||
}
|
||||
|
||||
module.exports = { isRemote, run, shq, shellLine };
|
||||
// 预览槽清理:core 删会话后尽力 kill executor 侧该会话的预览槽(executor/preview.js 的 /__session-kill)。
|
||||
// 与 /exec 同容器异端口:主机名取 cfg.executor.url,端口 env EXECUTOR_PREVIEW_PORT(默认 3100,与 preview.js 对齐)。
|
||||
// fire-and-forget:槽是缓存不是承诺,漏网槽闲置回收自然到期,失败只静默不阻断会话删除。
|
||||
function killPreviewSession(cfg, sessionId, timeoutMs) {
|
||||
if (!isRemote(cfg) || !sessionId) return;
|
||||
let host;
|
||||
try { host = new URL(cfg.executor.url).hostname; } catch (_) { return; }
|
||||
const port = Number(process.env.EXECUTOR_PREVIEW_PORT || 3100);
|
||||
const body = JSON.stringify({ session: String(sessionId) });
|
||||
const headers = { 'content-type': 'application/json', 'content-length': String(Buffer.byteLength(body)) };
|
||||
if (cfg.executor.token) headers.authorization = 'Bearer ' + cfg.executor.token;
|
||||
let req;
|
||||
try {
|
||||
req = http.request({ host, port, path: '/__session-kill', method: 'POST', timeout: Number(timeoutMs) || 5000, headers },
|
||||
(res) => { res.resume(); });
|
||||
} catch (_) { return; }
|
||||
req.on('error', () => {});
|
||||
req.on('timeout', () => { req.destroy(); });
|
||||
req.end(body);
|
||||
}
|
||||
|
||||
module.exports = { isRemote, run, shq, shellLine, killPreviewSession };
|
||||
|
||||
Reference in New Issue
Block a user