UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

20 lines (19 loc) • 839 B
import { isPermissionMode, PERMISSION_MODES } from "../ask-origin.js"; export function streamModeVerb(input) { const { live, ready, orTimeout, steeringError } = input; const setPermissionMode = async (mode) => { const modeIn = mode; if (!isPermissionMode(modeIn)) { const e = new Error(`cannot set the permission mode: it must be one of ${PERMISSION_MODES.join("/")} (got ${JSON.stringify(modeIn)})`); e.code = "steering.invalid_content"; throw e; } if (live.resultValue) throw steeringError("the task has already finished"); const h = live.handle ?? (await orTimeout(ready)); if (!h) throw steeringError("the task is not running"); return h.permissionMode.steer(modeIn); }; return { setPermissionMode }; }