@blogic-cz/agent-tools 0.8.1 → 0.8.2

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.8.1",
3
+ "version": "0.8.2",
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",
@@ -456,12 +456,7 @@ export function transformDescribe(textOutput: string): string {
456
456
  return outputLines.join("\n").trim();
457
457
  }
458
458
 
459
- export function transformLogs(textOutput: string): string {
460
- return deduplicateLines(textOutput, {
461
- normalizeTimestamps: true,
462
- normalizeUUIDs: true,
463
- });
464
- }
459
+ export { transformLogOutput as transformLogs } from "#logs/transformers";
465
460
 
466
461
  export function transformGenericKubectl(
467
462
  textOutput: string,
@@ -66,9 +66,28 @@ function toText(value: unknown): string | undefined {
66
66
  return undefined;
67
67
  }
68
68
 
69
- function firstMappedField(obj: unknown, fields: ReadonlyArray<string>): string | undefined {
69
+ function formatTimestamp(value: unknown): string | undefined {
70
+ if (typeof value === "number" && value > 1_000_000_000_000) {
71
+ return new Date(value).toISOString();
72
+ }
73
+ if (typeof value === "number" && value > 1_000_000_000) {
74
+ return new Date(value * 1000).toISOString();
75
+ }
76
+ return undefined;
77
+ }
78
+
79
+ function firstMappedField(
80
+ obj: unknown,
81
+ fields: ReadonlyArray<string>,
82
+ isTimestamp = false,
83
+ ): string | undefined {
70
84
  for (const field of fields) {
71
- const value = toText(getByPath(obj, field));
85
+ const raw = getByPath(obj, field);
86
+ if (isTimestamp) {
87
+ const formatted = formatTimestamp(raw);
88
+ if (formatted) return formatted;
89
+ }
90
+ const value = toText(raw);
72
91
  if (value) {
73
92
  return value;
74
93
  }
@@ -84,6 +103,15 @@ function normalizeLevel(rawLevel: string | undefined): LogLevel {
84
103
  return "INFO";
85
104
  }
86
105
 
106
+ // Pino numeric levels: 10=trace, 20=debug, 30=info, 40=warn, 50=error, 60=fatal
107
+ const numericLevel = Number(normalized);
108
+ if (Number.isFinite(numericLevel)) {
109
+ if (numericLevel >= 50) return "ERROR";
110
+ if (numericLevel >= 40) return "WARN";
111
+ if (numericLevel >= 30) return "INFO";
112
+ return "DEBUG";
113
+ }
114
+
87
115
  if (normalized === "error" || normalized === "err" || normalized === "fatal") {
88
116
  return "ERROR";
89
117
  }
@@ -114,7 +142,7 @@ function formatLine({ level, timestamp, message }: ParsedLogLine): string {
114
142
  function parseJsonLogLine(line: string, originalIndex: number): ParsedLogLine {
115
143
  try {
116
144
  const parsed = JSON.parse(line) as unknown;
117
- const timestamp = firstMappedField(parsed, TIMESTAMP_FIELDS);
145
+ const timestamp = firstMappedField(parsed, TIMESTAMP_FIELDS, true);
118
146
  const level = normalizeLevel(firstMappedField(parsed, LEVEL_FIELDS));
119
147
  const message =
120
148
  firstMappedField(parsed, MESSAGE_FIELDS) ??