feat(telemetry): add local agent efficiency metrics
This commit is contained in:
1 parent
4fa8708ba7
commit
bdf98d5b71
5 files changed
+86
-14
No files matched your search
@@ -2,7 +2,11 @@
|
||||
param()
|
||||
$root = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent
|
||||
$stateDir = Join-Path $root '.ai-session'
|
||||
New-Item $stateDir -ItemType Directory -Force | Out-Null
|
||||
('{"event":"compact","timestamp":"' + (Get-Date).ToUniversalTime().ToString('o') + '"}') | Add-Content (Join-Path $stateDir 'telemetry.jsonl')
|
||||
if ($env:AI_CONFIG_TELEMETRY -ne '0') {
|
||||
New-Item $stateDir -ItemType Directory -Force | Out-Null
|
||||
$path = Join-Path $stateDir 'telemetry.jsonl'
|
||||
('{"event":"compact","timestamp":"' + (Get-Date).ToUniversalTime().ToString('o') + '"}') | Add-Content $path
|
||||
if ((Get-Item $path).Length -gt 1048576) { Move-Item $path ($path + '.1') -Force }
|
||||
}
|
||||
& python (Join-Path $PSScriptRoot 'session-state.py') --hook
|
||||
exit $LASTEXITCODE
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)
|
||||
mkdir -p "$root/.ai-session"
|
||||
printf '{"event":"compact","timestamp":"%s"}\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$root/.ai-session/telemetry.jsonl"
|
||||
[ "${AI_CONFIG_TELEMETRY:-1}" = 0 ] || { mkdir -p "$root/.ai-session" && printf '{"event":"compact","timestamp":"%s"}\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$root/.ai-session/telemetry.jsonl"; [ "$(wc -c < "$root/.ai-session/telemetry.jsonl")" -le 1048576 ] || mv -f "$root/.ai-session/telemetry.jsonl" "$root/.ai-session/telemetry.jsonl.1"; }
|
||||
python3 "$root/hooks/scripts/session-state.py" --hook
|
||||
Reference in new issue
Block a user