feat: add harness.cancel convenience (cancel active session)
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user