From b892ee3af65f1e97d79d4faca9595aff376b21ad Mon Sep 17 00:00:00 2001 From: jiangchen <1703935164@qq.com> Date: Tue, 1 Sep 2026 19:05:40 +0800 Subject: [PATCH] feat: add harness.cancel convenience (cancel active session) --- lib/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/index.js b/lib/index.js index 1455779..364f4ae 100644 --- a/lib/index.js +++ b/lib/index.js @@ -96,6 +96,7 @@ function apply(ctx, config) { params = params || {}; if (method === 'harness.status') return computeStatus(); if (method === 'harness.prompt') return harnessPrompt(params); + if (method === 'harness.cancel') return harnessCancel(); const dot = method.indexOf('.'); if (dot <= 0) throw new Error('unknown method ' + method); const domain = method.slice(0, dot); @@ -129,6 +130,13 @@ function apply(ctx, config) { }); } + async function harnessCancel() { + const status = await computeStatus(); + const sessionId = status.activeSessionId; + if (!sessionId) throw new Error('no active session to cancel'); + return api.sessions.cancel({ sessionId }); + } + function handleRequest(msg, respond) { invoke(msg.method || '', msg.params || {}).then((result) => { respond({ type: 'response', requestId: msg.requestId, ok: true, result });