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.
184 lines
6.3 KiB
PowerShell
184 lines
6.3 KiB
PowerShell
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[ValidateSet("unread_count","latest","send_clipboard","summarize_inbox")]
|
|
[string]$Action,
|
|
|
|
[string]$Recipient = "",
|
|
[string]$Body = "",
|
|
[int]$Limit = 5
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$OutputEncoding = [System.Text.Encoding]::UTF8
|
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
|
|
# Output protocol (parsed by Lua scripts):
|
|
# First line: "OK" or "ERR:<code>" or "ERR:<code>:<message>"
|
|
# Subsequent lines depend on Action:
|
|
# unread_count -> "<count>"
|
|
# latest -> "FROM\t<name>" / "SUBJECT\t<subj>" / "PREVIEW\t<body200>"
|
|
# send_clipboard -> "TO\t<name>" / "ADDR\t<email>" / "SUBJECT\t<subj>"
|
|
# summarize_inbox -> repeated "FROM\t<name>\tSUBJECT\t<subj>"
|
|
#
|
|
# All multiline strings get newlines collapsed to spaces before printing.
|
|
|
|
function Clean-Line([string]$s) {
|
|
if (-not $s) { return "" }
|
|
$s = $s -replace "`r", " " -replace "`n", " " -replace "`t", " "
|
|
return ($s -replace '\s+', ' ').Trim()
|
|
}
|
|
|
|
function Fail($code, $msg = "") {
|
|
if ($msg) {
|
|
Write-Output ("ERR:{0}:{1}" -f $code, (Clean-Line $msg))
|
|
} else {
|
|
Write-Output ("ERR:{0}" -f $code)
|
|
}
|
|
exit 0
|
|
}
|
|
|
|
function Get-OutlookSession {
|
|
try {
|
|
$ol = New-Object -ComObject Outlook.Application
|
|
$ns = $ol.GetNamespace("MAPI")
|
|
return @{ App = $ol; Ns = $ns }
|
|
} catch {
|
|
Fail "outlook_unavailable" $_.Exception.Message
|
|
}
|
|
}
|
|
|
|
function Strip-Html([string]$s) {
|
|
if (-not $s) { return "" }
|
|
$s = [regex]::Replace($s, '<[^>]+>', ' ')
|
|
$s = $s -replace ' ', ' ' -replace '&', '&' -replace '<', '<' -replace '>', '>' -replace '"', '"' -replace "'", "'"
|
|
return Clean-Line $s
|
|
}
|
|
|
|
function Resolve-Recipient([object]$ns, [string]$query) {
|
|
if ([string]::IsNullOrWhiteSpace($query)) { return $null }
|
|
try {
|
|
$r = $ns.CreateRecipient($query)
|
|
$null = $r.Resolve()
|
|
if ($r.Resolved) {
|
|
$addr = $null
|
|
try { $addr = $r.AddressEntry.GetExchangeUser().PrimarySmtpAddress } catch { }
|
|
if (-not $addr) {
|
|
try { $addr = $r.AddressEntry.Address } catch { }
|
|
}
|
|
if (-not $addr) { $addr = $r.Name }
|
|
return @{ Name = $r.Name; Address = $addr }
|
|
}
|
|
} catch { }
|
|
return $null
|
|
}
|
|
|
|
switch ($Action) {
|
|
"unread_count" {
|
|
$s = Get-OutlookSession
|
|
try {
|
|
$inbox = $s.Ns.GetDefaultFolder(6)
|
|
$count = 0
|
|
try { $count = [int]$inbox.UnReadItemCount } catch { }
|
|
if (-not $count) {
|
|
$count = ($inbox.Items | Where-Object { $_.UnRead -eq $true }).Count
|
|
}
|
|
Write-Output "OK"
|
|
Write-Output ([int]$count).ToString()
|
|
} catch {
|
|
Fail "inbox_failed" $_.Exception.Message
|
|
}
|
|
}
|
|
|
|
"latest" {
|
|
$s = Get-OutlookSession
|
|
try {
|
|
$inbox = $s.Ns.GetDefaultFolder(6)
|
|
$items = $inbox.Items
|
|
$items.Sort("[ReceivedTime]", $true)
|
|
$latest = $null
|
|
foreach ($it in $items) {
|
|
if ($it.Class -eq 43) { $latest = $it; break } # olMail = 43
|
|
}
|
|
if (-not $latest) { Fail "empty_inbox" }
|
|
$fromName = ""
|
|
try { $fromName = $latest.SenderName } catch { }
|
|
if (-not $fromName) { try { $fromName = $latest.SenderEmailAddress } catch { } }
|
|
$subject = ""
|
|
try { $subject = $latest.Subject } catch { }
|
|
$body = ""
|
|
try { $body = $latest.Body } catch { }
|
|
if (-not $body) {
|
|
try { $body = Strip-Html $latest.HTMLBody } catch { }
|
|
} else {
|
|
$body = Clean-Line $body
|
|
}
|
|
if ($body.Length -gt 200) { $body = $body.Substring(0, 200) + "..." }
|
|
Write-Output "OK"
|
|
Write-Output ("FROM`t{0}" -f (Clean-Line $fromName))
|
|
Write-Output ("SUBJECT`t{0}" -f (Clean-Line $subject))
|
|
Write-Output ("PREVIEW`t{0}" -f $body)
|
|
} catch {
|
|
Fail "latest_failed" $_.Exception.Message
|
|
}
|
|
}
|
|
|
|
"send_clipboard" {
|
|
if ([string]::IsNullOrWhiteSpace($Recipient)) { Fail "no_recipient" }
|
|
$s = Get-OutlookSession
|
|
try {
|
|
$resolved = Resolve-Recipient $s.Ns $Recipient
|
|
if (-not $resolved) { Fail "unresolved" $Recipient }
|
|
$bodyText = if ($Body) { $Body } else { "" }
|
|
$subject = ""
|
|
if ($bodyText) {
|
|
$firstLine = ($bodyText -split "`r?`n", 2)[0].Trim()
|
|
if ($firstLine.Length -gt 60) {
|
|
$subject = $firstLine.Substring(0, 60).Trim()
|
|
} else {
|
|
$subject = $firstLine
|
|
}
|
|
}
|
|
if ([string]::IsNullOrWhiteSpace($subject)) { $subject = "From J.A.R.V.I.S." }
|
|
|
|
$mail = $s.App.CreateItem(0)
|
|
$mail.To = $resolved.Address
|
|
$mail.Subject = $subject
|
|
$mail.Body = $bodyText
|
|
$mail.Send()
|
|
Write-Output "OK"
|
|
Write-Output ("TO`t{0}" -f (Clean-Line $resolved.Name))
|
|
Write-Output ("ADDR`t{0}" -f (Clean-Line $resolved.Address))
|
|
Write-Output ("SUBJECT`t{0}" -f (Clean-Line $subject))
|
|
} catch {
|
|
Fail "send_failed" $_.Exception.Message
|
|
}
|
|
}
|
|
|
|
"summarize_inbox" {
|
|
$s = Get-OutlookSession
|
|
try {
|
|
$inbox = $s.Ns.GetDefaultFolder(6)
|
|
$items = $inbox.Items
|
|
$items.Sort("[ReceivedTime]", $true)
|
|
$taken = 0
|
|
$lines = @()
|
|
foreach ($it in $items) {
|
|
if ($taken -ge $Limit) { break }
|
|
if ($it.Class -ne 43) { continue }
|
|
$unread = $false
|
|
try { $unread = [bool]$it.UnRead } catch { }
|
|
if (-not $unread) { continue }
|
|
$fromName = ""
|
|
try { $fromName = $it.SenderName } catch { }
|
|
$subj = ""
|
|
try { $subj = $it.Subject } catch { }
|
|
$lines += ("FROM`t{0}`tSUBJECT`t{1}" -f (Clean-Line $fromName), (Clean-Line $subj))
|
|
$taken += 1
|
|
}
|
|
Write-Output "OK"
|
|
foreach ($l in $lines) { Write-Output $l }
|
|
} catch {
|
|
Fail "summary_failed" $_.Exception.Message
|
|
}
|
|
}
|
|
}
|