Skip to content

Commit c2c8eb2

Browse files
committed
feat(agent): add log scan task and release notes v1.0.6
1 parent c0078da commit c2c8eb2

6 files changed

Lines changed: 1009 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ Formatting rules:
1515

1616
## [Unreleased]
1717

18+
## [1.0.6] - 2026-04-05
19+
20+
### Added
21+
22+
- Added a new `log.scan` task type with payload validation for `mode` and `sourcePresetId`, including optional root execution guarded by `task` scope checks.
23+
- Added `noderax-agent log-scan --request <path>` to execute log scan requests from a JSON file and return structured JSON results for task parsing.
24+
- Added a dedicated log scanning engine that supports preset sources (`syslog`, `auth.log`, `kern.log`, `noderax-agent`) with `preview` and `monitor` modes, source-aware cursor handling, and hard limits for lines, bytes, and backfill.
25+
26+
### Fixed
27+
28+
- Monitor-mode file scans now detect log rotation (inode change) and truncation (offset beyond file size), automatically reset the cursor, replay tail lines, and emit warning metadata for downstream diagnostics.
29+
- Log scan task result parsing now reports explicit system errors when command output is empty or invalid JSON, improving failure visibility in task logs.
30+
1831
## [1.0.5] - 2026-04-05
1932

2033
### Fixed

internal/agentctl/commands.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ func (c CLI) Handle(ctx context.Context, args []string) (bool, error) {
129129
case "config":
130130
brand.PrintLogo(c.stdoutOrDefault())
131131
return true, c.Config(ctx, args[1:])
132+
case "log-scan":
133+
return true, c.LogScan(ctx, args[1:])
132134
case "version", "--version", "-v":
133135
return true, c.VersionInfo(args[1:])
134136
default:

internal/agentctl/logscan.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package agentctl
2+
3+
import (
4+
"context"
5+
"encoding/json"
6+
"flag"
7+
"fmt"
8+
"io"
9+
"os"
10+
11+
"github.com/noderax/noderax-agent/internal/logscan"
12+
)
13+
14+
func (c CLI) LogScan(ctx context.Context, args []string) error {
15+
flagSet := flag.NewFlagSet("log-scan", flag.ContinueOnError)
16+
flagSet.SetOutput(io.Discard)
17+
18+
requestPath := flagSet.String("request", "", "")
19+
if err := flagSet.Parse(args); err != nil {
20+
return err
21+
}
22+
if *requestPath == "" {
23+
return fmt.Errorf("log-scan requires --request")
24+
}
25+
if flagSet.NArg() > 0 {
26+
return fmt.Errorf("unexpected log-scan arguments: %v", flagSet.Args())
27+
}
28+
29+
request, err := logscan.LoadRequest(*requestPath)
30+
if err != nil {
31+
return err
32+
}
33+
_ = os.Remove(*requestPath)
34+
35+
result, err := logscan.Run(ctx, request)
36+
if err != nil {
37+
return err
38+
}
39+
40+
encoder := json.NewEncoder(c.stdoutOrDefault())
41+
encoder.SetEscapeHTML(false)
42+
return encoder.Encode(result)
43+
}

0 commit comments

Comments
 (0)