J.A.R.V.I.S-rust/resources/commands/sysinfo/battery.lua

12 lines
555 B
Lua
Raw Permalink Normal View History

feat(commands): add media controls + system info packs media/ — play_pause, next, prev, stop via user32!keybd_event (VK_MEDIA_* 0xB0..0xB3). Helper _media_helper.ps1 mirrors the volume/ pack pattern, so the same C# P/Invoke style works for the four standard media keys without needing any external tooling. Catches Spotify, foobar, browsers, Yandex Music PWA — anything that responds to system media keys. sysinfo/ — battery / time / cpu / ram / disk and an "all" combo. _sysinfo.ps1 uses CIM queries (Win32_Battery, Win32_OperatingSystem, Win32_LogicalDisk, Win32_Processor + Win32_PerfFormattedData_PerfOS_ Processor) — no external deps. Time is rendered in ru-RU culture ("01:17, 15 мая, пятница"). Battery falls back to a friendly "no battery, looks like a desktop" when Win32_Battery is empty. SystemDrive env var resolves the right disk on non-C:/ installs. Each sysinfo command notifies the line as a Windows toast and logs it. Triggered locally: sysinfo_all currently reports: Сейчас: 01:17, 15 мая, пятница Батарея не обнаружена (видимо, десктоп) CPU: AMD Ryzen 7 5700X3D 8-Core Processor, загрузка 4% RAM: 23.4 из 47.9 ГБ (49% занято) Диск C:: свободно 118.2 из 1906.8 ГБ Total command packs is now 9 (verified via jarvis-gui startup log). Portability: all PowerShell helpers use $env:SystemDrive and CIM classes that ship with every Windows install; Lua wrappers resolve the helper path via jarvis.context.command_path (no hardcoded user profile paths or absolute C:\ refs).
2026-05-15 01:19:30 +03:00
local helper = jarvis.context.command_path .. "\\_sysinfo.ps1"
local cmd = string.format('powershell -NoProfile -ExecutionPolicy Bypass -File "%s" -Topic battery', helper)
local res = jarvis.system.exec(cmd)
local text = (res.stdout or ""):gsub("[\r\n]+$", "")
feat: Wave 5 — sysinfo speaks, smart reminders, outlook COM, time tracker, WOL, conversation tools Voice sysinfo overhaul (6 scripts: battery/cpu/ram/disk/time/all): - Now SPEAK the result via jarvis.cmd.ok instead of notify-only. Toast still fires for visual reference, but real Jarvis tells you out loud. - `all` joins lines with commas so TTS doesn't over-pause on linebreaks. Smart reminders (`reminders/set.lua` rewrite): - Was: detached `Start-Sleep` PowerShell subprocesses that died on jarvis-app restart and spawned a hidden process per timer. - Now: routes through `jarvis.scheduler.add(... type=speak ...)`. Persists to schedule.json, survives restart, no zombie processes. Trade-off: sub-minute timers round up to 1 min (rare in voice UX). - Drops UA triggers from earlier UA-removal sweep. Translation polish (`translate/translate.lua` + `clipboard.lua`): - Drops UA target language; adds Italian, Polish, Turkish, French ru triggers + English target detectors. - `language_iso()` helper picks the SAPI voice locale for the TARGET language (German translation → German SAPI voice if installed). LLM system prompt (config.rs): - New LLM_SYSTEM_PROMPT_EN counterpart. Both languages now mention the assistant's tooling (memory / scheduler / profiles / macros / vision / clipboard) so the LLM knows it can DO things, not suggest the user install something. - `get_llm_system_prompt(lang)` picks EN/RU. Conversation pack (NEW `conversation/`): - 2 commands. `conversation.summary` ("о чём мы говорили") pulls the last 12 turns from persisted history, asks LLM for a 1-3 sentence recap in Jarvis tone. Falls back gracefully when offline. - `conversation.repeat` ("повтори") re-speaks the last assistant message. - New Lua API `jarvis.llm_history()` returns array of {role, content} tables, excluding the system prompt. WOL pack (NEW `wol/`): - Voice "разбуди сервер" / "wake server" fires a magic packet at a MAC stored in long-term memory under `wol_<alias>` (default alias "server"). - Setup via voice: "запомни wol_server AA:BB:CC:DD:EE:FF". Falls back to `JARVIS_WOL_TARGET` env if memory empty. Handles every standard MAC format (colons / dashes / dots / bare). Broadcast on UDP 9 via PowerShell System.Net.Sockets.UdpClient. Outlook COM pack (NEW `outlook/`, via subagent): - 4 commands: unread_count, latest, send_clipboard, summarize_inbox. - PowerShell COM bridge `_outlook.ps1` with tab-delimited line protocol. - summarize_inbox calls LLM for a one-paragraph summary. Graceful failure when Outlook isn't running. Time tracker pack (NEW `time_tracker/`, via subagent): - 5 commands: start, stop, today, week, reset. - Persists via `jarvis.state` (structured object: current_session_start + sessions array of {start, end}). - Local-calendar "today" boundary, full Russian pluralisation (час/часа/часов, минута/минуты/минут, сессия/сессии/сессий). Tests: 139 rust (no regression), 81 python (60 → 81, +14 time_tracker +7 outlook). Release build green for jarvis-app and jarvis-cli. Pack count: 88 → 92 rust packs.
2026-05-16 14:34:29 +03:00
if not res.success or text == "" then
feat(commands): add media controls + system info packs media/ — play_pause, next, prev, stop via user32!keybd_event (VK_MEDIA_* 0xB0..0xB3). Helper _media_helper.ps1 mirrors the volume/ pack pattern, so the same C# P/Invoke style works for the four standard media keys without needing any external tooling. Catches Spotify, foobar, browsers, Yandex Music PWA — anything that responds to system media keys. sysinfo/ — battery / time / cpu / ram / disk and an "all" combo. _sysinfo.ps1 uses CIM queries (Win32_Battery, Win32_OperatingSystem, Win32_LogicalDisk, Win32_Processor + Win32_PerfFormattedData_PerfOS_ Processor) — no external deps. Time is rendered in ru-RU culture ("01:17, 15 мая, пятница"). Battery falls back to a friendly "no battery, looks like a desktop" when Win32_Battery is empty. SystemDrive env var resolves the right disk on non-C:/ installs. Each sysinfo command notifies the line as a Windows toast and logs it. Triggered locally: sysinfo_all currently reports: Сейчас: 01:17, 15 мая, пятница Батарея не обнаружена (видимо, десктоп) CPU: AMD Ryzen 7 5700X3D 8-Core Processor, загрузка 4% RAM: 23.4 из 47.9 ГБ (49% занято) Диск C:: свободно 118.2 из 1906.8 ГБ Total command packs is now 9 (verified via jarvis-gui startup log). Portability: all PowerShell helpers use $env:SystemDrive and CIM classes that ship with every Windows install; Lua wrappers resolve the helper path via jarvis.context.command_path (no hardcoded user profile paths or absolute C:\ refs).
2026-05-15 01:19:30 +03:00
jarvis.log("error", "battery info failed: " .. tostring(res.stderr))
feat: Wave 5 — sysinfo speaks, smart reminders, outlook COM, time tracker, WOL, conversation tools Voice sysinfo overhaul (6 scripts: battery/cpu/ram/disk/time/all): - Now SPEAK the result via jarvis.cmd.ok instead of notify-only. Toast still fires for visual reference, but real Jarvis tells you out loud. - `all` joins lines with commas so TTS doesn't over-pause on linebreaks. Smart reminders (`reminders/set.lua` rewrite): - Was: detached `Start-Sleep` PowerShell subprocesses that died on jarvis-app restart and spawned a hidden process per timer. - Now: routes through `jarvis.scheduler.add(... type=speak ...)`. Persists to schedule.json, survives restart, no zombie processes. Trade-off: sub-minute timers round up to 1 min (rare in voice UX). - Drops UA triggers from earlier UA-removal sweep. Translation polish (`translate/translate.lua` + `clipboard.lua`): - Drops UA target language; adds Italian, Polish, Turkish, French ru triggers + English target detectors. - `language_iso()` helper picks the SAPI voice locale for the TARGET language (German translation → German SAPI voice if installed). LLM system prompt (config.rs): - New LLM_SYSTEM_PROMPT_EN counterpart. Both languages now mention the assistant's tooling (memory / scheduler / profiles / macros / vision / clipboard) so the LLM knows it can DO things, not suggest the user install something. - `get_llm_system_prompt(lang)` picks EN/RU. Conversation pack (NEW `conversation/`): - 2 commands. `conversation.summary` ("о чём мы говорили") pulls the last 12 turns from persisted history, asks LLM for a 1-3 sentence recap in Jarvis tone. Falls back gracefully when offline. - `conversation.repeat` ("повтори") re-speaks the last assistant message. - New Lua API `jarvis.llm_history()` returns array of {role, content} tables, excluding the system prompt. WOL pack (NEW `wol/`): - Voice "разбуди сервер" / "wake server" fires a magic packet at a MAC stored in long-term memory under `wol_<alias>` (default alias "server"). - Setup via voice: "запомни wol_server AA:BB:CC:DD:EE:FF". Falls back to `JARVIS_WOL_TARGET` env if memory empty. Handles every standard MAC format (colons / dashes / dots / bare). Broadcast on UDP 9 via PowerShell System.Net.Sockets.UdpClient. Outlook COM pack (NEW `outlook/`, via subagent): - 4 commands: unread_count, latest, send_clipboard, summarize_inbox. - PowerShell COM bridge `_outlook.ps1` with tab-delimited line protocol. - summarize_inbox calls LLM for a one-paragraph summary. Graceful failure when Outlook isn't running. Time tracker pack (NEW `time_tracker/`, via subagent): - 5 commands: start, stop, today, week, reset. - Persists via `jarvis.state` (structured object: current_session_start + sessions array of {start, end}). - Local-calendar "today" boundary, full Russian pluralisation (час/часа/часов, минута/минуты/минут, сессия/сессии/сессий). Tests: 139 rust (no regression), 81 python (60 → 81, +14 time_tracker +7 outlook). Release build green for jarvis-app and jarvis-cli. Pack count: 88 → 92 rust packs.
2026-05-16 14:34:29 +03:00
return jarvis.cmd.error("Не получилось узнать заряд.")
feat(commands): add media controls + system info packs media/ — play_pause, next, prev, stop via user32!keybd_event (VK_MEDIA_* 0xB0..0xB3). Helper _media_helper.ps1 mirrors the volume/ pack pattern, so the same C# P/Invoke style works for the four standard media keys without needing any external tooling. Catches Spotify, foobar, browsers, Yandex Music PWA — anything that responds to system media keys. sysinfo/ — battery / time / cpu / ram / disk and an "all" combo. _sysinfo.ps1 uses CIM queries (Win32_Battery, Win32_OperatingSystem, Win32_LogicalDisk, Win32_Processor + Win32_PerfFormattedData_PerfOS_ Processor) — no external deps. Time is rendered in ru-RU culture ("01:17, 15 мая, пятница"). Battery falls back to a friendly "no battery, looks like a desktop" when Win32_Battery is empty. SystemDrive env var resolves the right disk on non-C:/ installs. Each sysinfo command notifies the line as a Windows toast and logs it. Triggered locally: sysinfo_all currently reports: Сейчас: 01:17, 15 мая, пятница Батарея не обнаружена (видимо, десктоп) CPU: AMD Ryzen 7 5700X3D 8-Core Processor, загрузка 4% RAM: 23.4 из 47.9 ГБ (49% занято) Диск C:: свободно 118.2 из 1906.8 ГБ Total command packs is now 9 (verified via jarvis-gui startup log). Portability: all PowerShell helpers use $env:SystemDrive and CIM classes that ship with every Windows install; Lua wrappers resolve the helper path via jarvis.context.command_path (no hardcoded user profile paths or absolute C:\ refs).
2026-05-15 01:19:30 +03:00
end
feat: Wave 5 — sysinfo speaks, smart reminders, outlook COM, time tracker, WOL, conversation tools Voice sysinfo overhaul (6 scripts: battery/cpu/ram/disk/time/all): - Now SPEAK the result via jarvis.cmd.ok instead of notify-only. Toast still fires for visual reference, but real Jarvis tells you out loud. - `all` joins lines with commas so TTS doesn't over-pause on linebreaks. Smart reminders (`reminders/set.lua` rewrite): - Was: detached `Start-Sleep` PowerShell subprocesses that died on jarvis-app restart and spawned a hidden process per timer. - Now: routes through `jarvis.scheduler.add(... type=speak ...)`. Persists to schedule.json, survives restart, no zombie processes. Trade-off: sub-minute timers round up to 1 min (rare in voice UX). - Drops UA triggers from earlier UA-removal sweep. Translation polish (`translate/translate.lua` + `clipboard.lua`): - Drops UA target language; adds Italian, Polish, Turkish, French ru triggers + English target detectors. - `language_iso()` helper picks the SAPI voice locale for the TARGET language (German translation → German SAPI voice if installed). LLM system prompt (config.rs): - New LLM_SYSTEM_PROMPT_EN counterpart. Both languages now mention the assistant's tooling (memory / scheduler / profiles / macros / vision / clipboard) so the LLM knows it can DO things, not suggest the user install something. - `get_llm_system_prompt(lang)` picks EN/RU. Conversation pack (NEW `conversation/`): - 2 commands. `conversation.summary` ("о чём мы говорили") pulls the last 12 turns from persisted history, asks LLM for a 1-3 sentence recap in Jarvis tone. Falls back gracefully when offline. - `conversation.repeat` ("повтори") re-speaks the last assistant message. - New Lua API `jarvis.llm_history()` returns array of {role, content} tables, excluding the system prompt. WOL pack (NEW `wol/`): - Voice "разбуди сервер" / "wake server" fires a magic packet at a MAC stored in long-term memory under `wol_<alias>` (default alias "server"). - Setup via voice: "запомни wol_server AA:BB:CC:DD:EE:FF". Falls back to `JARVIS_WOL_TARGET` env if memory empty. Handles every standard MAC format (colons / dashes / dots / bare). Broadcast on UDP 9 via PowerShell System.Net.Sockets.UdpClient. Outlook COM pack (NEW `outlook/`, via subagent): - 4 commands: unread_count, latest, send_clipboard, summarize_inbox. - PowerShell COM bridge `_outlook.ps1` with tab-delimited line protocol. - summarize_inbox calls LLM for a one-paragraph summary. Graceful failure when Outlook isn't running. Time tracker pack (NEW `time_tracker/`, via subagent): - 5 commands: start, stop, today, week, reset. - Persists via `jarvis.state` (structured object: current_session_start + sessions array of {start, end}). - Local-calendar "today" boundary, full Russian pluralisation (час/часа/часов, минута/минуты/минут, сессия/сессии/сессий). Tests: 139 rust (no regression), 81 python (60 → 81, +14 time_tracker +7 outlook). Release build green for jarvis-app and jarvis-cli. Pack count: 88 → 92 rust packs.
2026-05-16 14:34:29 +03:00
jarvis.system.notify("Батарея", text)
jarvis.log("info", text)
return jarvis.cmd.ok(text)