summaryrefslogtreecommitdiff
path: root/scripts/Read-AgentLog.ps1
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-08-11 21:44:53 +0900
committertanaka takashi <isazaka@gmail.com>2026-08-11 21:44:53 +0900
commit6c3458a5ec37a5b69957ad17c84de58984698f25 (patch)
treebe5c5716e7488fcf1bc1a58de0ded0b9238f34cb /scripts/Read-AgentLog.ps1
parentb5ccecca01007f2a2459265df6d749fbfd31aa84 (diff)
Audit and align v1 runtime design
Diffstat (limited to 'scripts/Read-AgentLog.ps1')
-rw-r--r--scripts/Read-AgentLog.ps138
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/Read-AgentLog.ps1 b/scripts/Read-AgentLog.ps1
new file mode 100644
index 0000000..f842e45
--- /dev/null
+++ b/scripts/Read-AgentLog.ps1
@@ -0,0 +1,38 @@
+param(
+ [Parameter(Mandatory = $true)]
+ [string]$Path,
+ [string]$TaskId,
+ [string]$SessionId,
+ [string]$Event,
+ [string]$CallId,
+ [ValidateRange(1, 100000)]
+ [int]$Tail = 200
+)
+
+$ErrorActionPreference = 'Stop'
+$resolvedLog = (Resolve-Path -LiteralPath $Path).Path
+Get-Content -LiteralPath $resolvedLog -Tail $Tail | ForEach-Object {
+ try { $entry = $_ | ConvertFrom-Json -ErrorAction Stop }
+ catch { return }
+
+ $entryTaskId = $entry.task_id ?? $entry.taskId
+ $entrySessionId = $entry.session_id ?? $entry.sessionId
+ if ($TaskId -and [string]$entryTaskId -ne $TaskId) { return }
+ if ($SessionId -and [string]$entrySessionId -ne $SessionId) { return }
+ if ($Event -and [string]$entry.event_name -ne $Event -and [string]$entry.event -ne $Event) { return }
+ if ($CallId -and [string]$entry.call_id -ne $CallId) { return }
+
+ [pscustomobject]@{
+ timestamp = $entry.timestamp ?? $entry.ts
+ event = $entry.event_name ?? $entry.event
+ task_id = $entryTaskId
+ session_id = $entrySessionId
+ call_id = $entry.call_id
+ phase = $entry.phase
+ iteration = $entry.iteration
+ replan = $entry.replan
+ tool = $entry.tool_name
+ success = $entry.success
+ output = $entry.output
+ }
+} | Format-Table -AutoSize -Wrap