@blogic-cz/agent-tools 0.14.9 → 0.14.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogic-cz/agent-tools",
3
- "version": "0.14.9",
3
+ "version": "0.14.10",
4
4
  "description": "CLI tools for AI coding agent workflows — GitHub, database, Kubernetes, Azure DevOps, logs, sessions, and audit",
5
5
  "keywords": [
6
6
  "agent",
@@ -15,9 +15,18 @@ import {
15
15
  type LogLine = {
16
16
  readonly timestamp: string;
17
17
  readonly line: string;
18
+ readonly body?: string;
19
+ readonly severity?: string;
20
+ readonly attributes?: Record<string, unknown>;
18
21
  readonly labels: Record<string, string>;
19
22
  };
20
23
 
24
+ type StructuredLogLine = {
25
+ readonly body?: string;
26
+ readonly severity?: string;
27
+ readonly attributes?: Record<string, unknown>;
28
+ };
29
+
21
30
  function parseLabel(value: string | Record<string, string>): Record<string, string> {
22
31
  if (typeof value === "object" && value !== null) {
23
32
  return value;
@@ -30,6 +39,27 @@ function parseLabel(value: string | Record<string, string>): Record<string, stri
30
39
  }
31
40
  }
32
41
 
42
+ function parseStructuredLogLine(line: string): StructuredLogLine {
43
+ try {
44
+ const parsed = JSON.parse(line) as unknown;
45
+ if (typeof parsed !== "object" || parsed === null) {
46
+ return {};
47
+ }
48
+
49
+ const record = parsed as Record<string, unknown>;
50
+ return {
51
+ body: typeof record.body === "string" ? record.body : undefined,
52
+ severity: typeof record.severity === "string" ? record.severity : undefined,
53
+ attributes:
54
+ typeof record.attributes === "object" && record.attributes !== null
55
+ ? (record.attributes as Record<string, unknown>)
56
+ : undefined,
57
+ };
58
+ } catch {
59
+ return {};
60
+ }
61
+ }
62
+
33
63
  export function extractLogsFromDsQuery(response: {
34
64
  results: {
35
65
  A: {
@@ -62,9 +92,11 @@ export function extractLogsFromDsQuery(response: {
62
92
  >;
63
93
 
64
94
  for (const [index, line] of lines.entries()) {
95
+ const structured = parseStructuredLogLine(line);
65
96
  logs.push({
66
97
  timestamp: String(timestamps[index] ?? ""),
67
98
  line,
99
+ ...structured,
68
100
  labels: labelValues[index] ? parseLabel(labelValues[index]) : {},
69
101
  });
70
102
  }