pyb-ts
Version:
PYB-CLI - Minimal AI Agent with multi-model support and CLI interface
38 lines (37 loc) • 1.16 kB
JavaScript
import { logError } from "@utils/log";
import { execFileNoThrow } from "@utils/execFileNoThrow";
const isEnabled = process.platform === "darwin" && ["iTerm.app", "Apple_Terminal"].includes(process.env.TERM_PROGRAM || "");
const listen = {
type: "local",
name: "listen",
description: "Activates speech recognition and transcribes speech to text",
isEnabled,
isHidden: isEnabled,
userFacingName() {
return "listen";
},
async call(_, { abortController }) {
const script = `tell application "System Events" to tell \xAC
(the first process whose frontmost is true) to tell \xAC
menu bar 1 to tell \xAC
menu bar item "Edit" to tell \xAC
menu "Edit" to tell \xAC
menu item "Start Dictation" to \xAC
if exists then click it`;
const { stderr, code } = await execFileNoThrow(
"osascript",
["-e", script],
abortController.signal
);
if (code !== 0) {
logError(`Failed to start dictation: ${stderr}`);
return "Failed to start dictation";
}
return "Dictation started. Press esc to stop.";
}
};
var listen_default = listen;
export {
listen_default as default
};
//# sourceMappingURL=listen.js.map