forked from aws/agentcore-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommand.tsx
More file actions
70 lines (63 loc) · 2.71 KB
/
Copy pathcommand.tsx
File metadata and controls
70 lines (63 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { getErrorMessage } from '../../errors';
import { handleLogsEval } from '../../operations/eval';
import type { LogsEvalOptions } from '../../operations/eval';
import { COMMAND_DESCRIPTIONS } from '../../tui/copy';
import { requireProject } from '../../tui/guards';
import { handleLogs } from './action';
import type { LogsOptions } from './types';
import type { Command } from '@commander-js/extra-typings';
import { Text, render } from 'ink';
import React from 'react';
export const registerLogs = (program: Command) => {
// enablePositionalOptions + passThroughOptions ensure options like --since and --runtime
// are passed to the 'evals' subcommand rather than being consumed by the parent 'logs' command.
program.enablePositionalOptions();
const logsCmd = program
.command('logs')
.alias('l')
.enablePositionalOptions()
.passThroughOptions()
.description(COMMAND_DESCRIPTIONS.logs)
.option('--runtime <name>', 'Select specific runtime')
.option('--since <time>', 'Start time — defaults to 1h ago in search mode (e.g. "1h", "30m", "2d", ISO 8601)')
.option('--until <time>', 'End time — defaults to now in search mode (e.g. "now", ISO 8601)')
.option('--level <level>', 'Filter by log level (error, warn, info, debug)')
.option('-n, --limit <count>', 'Maximum number of log lines to return')
.option('--query <text>', 'Server-side text filter')
.option('--json', 'Output as JSON Lines')
.action(async (cliOptions: LogsOptions) => {
requireProject();
try {
const result = await handleLogs(cliOptions);
if (!result.success) {
render(<Text color="red">{result.error}</Text>);
process.exit(1);
}
} catch (error) {
render(<Text color="red">Error: {getErrorMessage(error)}</Text>);
process.exit(1);
}
});
logsCmd
.command('evals')
.description('Stream or search online eval logs')
.option('-r, --runtime <name>', 'Select specific runtime')
.option('--since <time>', 'Start time (e.g. "1h", "30m", "2d", ISO 8601)')
.option('--until <time>', 'End time (e.g. "now", ISO 8601)')
.option('-n, --limit <count>', 'Maximum number of log lines')
.option('-f, --follow', 'Stream logs in real-time (default when no --since/--until)')
.option('--json', 'Output as JSON Lines')
.action(async (cliOptions: LogsEvalOptions) => {
requireProject();
try {
const result = await handleLogsEval(cliOptions);
if (!result.success) {
render(<Text color="red">{result.error}</Text>);
process.exit(1);
}
} catch (error) {
render(<Text color="red">Error: {getErrorMessage(error)}</Text>);
process.exit(1);
}
});
};