Commit e796437
authored
feat: Add invocation history command and per-invocation log streaming (#17)
### Summary
This PR introduces two new features to enhance invocation management and
debugging capabilities in the Kernel CLI:
1. **Invocation History Command** (`kernel invoke history`) - View
historical invocations across all apps or filtered by a specific app
2. **Per-Invocation Log Streaming** (`kernel logs <app> --invocation
<id>`) - Stream logs for a specific invocation run
### Changes
#### New `kernel invoke history` Command
- Lists all invocations across all apps by default
- Supports filtering by app name using `--app` flag
- Configurable result limit with `--limit` flag (default: 100)
- Displays invocation details in a formatted table including:
- Invocation ID
- App Name
- Action Name
- Status (succeeded/failed/running)
- Start time (local timezone)
- Duration (with special handling for running invocations)
- Output (truncated to 50 characters)
**Usage:**
```bash
# Show all invocations
kernel invoke history
# Show invocations for a specific app
kernel invoke history --app my-app
# Limit results
kernel invoke history --limit 20
```
#### Enhanced Log Streaming
- Added `--invocation` flag to `kernel logs` command
- Allows streaming logs for a specific invocation by ID or unambiguous
prefix
- Validates that the invocation belongs to the specified app
- Respects `--follow` flag for continuous streaming
- Implements a 3-second timeout for non-follow mode
**Usage:**
```bash
# Stream logs for a specific invocation
kernel logs my-app --invocation abc123
# Follow logs for a running invocation
kernel logs my-app --invocation abc123 --follow
```
#### Other Improvements
- Added invocation ID logging when creating new invocations for easier
reference
- Updated SDK to v0.11.4
- Fixed SDK API call signatures for `FollowStreaming` method
- Improved error handling for streaming events
### Technical Details
- Simplified invocation history implementation to use a single API call
instead of iterating through apps
- Switched from `ListAutoPaging` to `List` to avoid pagination parsing
issues
- Added proper validation for command arguments in the invoke command
### Testing
- Tested invocation history with and without app filtering
- Verified per-invocation log streaming for both running and completed
invocations
- Confirmed proper error handling and validation
---
<!-- mesa-description-start -->
## TL;DR
Adds `kernel invoke history` to view past invocations and enhances
`kernel logs` with an `--invocation` flag to stream logs for a specific
run.
## Why we made these changes
To improve debugging and observability by allowing users to easily find
and view logs for specific invocation runs, instead of searching through
an entire app's log stream.
## What changed?
- **`cmd/invoke.go`:**
- Introduced the `invoke history` subcommand to list and filter recent
invocations.
- The `invoke` command now prints the invocation ID upon submission for
easier reference.
- **`cmd/logs.go`:**
- Added an `--invocation` (`-i`) flag to stream logs for a specific
invocation ID.
- Enhanced log streaming to parse and display distinct error events.
- **`go.mod` & `go.sum`:**
- Bumped the `kernel-go-sdk` dependency from `v0.11.1` to `v0.11.4`.
## Validation
- [ ] Tested invocation history with and without app filtering.
- [ ] Verified per-invocation log streaming for both running and
completed invocations.
- [ ] Confirmed proper error handling and validation for new command
flags.
<sup>_Description generated by Mesa. [Update
settings](https://app.mesa.dev/onkernel/settings/pull-requests)_</sup>
<!-- mesa-description-end -->1 parent 278a502 commit e796437
4 files changed
+185
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
32 | 43 | | |
33 | 44 | | |
34 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
35 | 49 | | |
36 | 50 | | |
37 | 51 | | |
| |||
70 | 84 | | |
71 | 85 | | |
72 | 86 | | |
| 87 | + | |
| 88 | + | |
73 | 89 | | |
74 | 90 | | |
75 | 91 | | |
| |||
117 | 133 | | |
118 | 134 | | |
119 | 135 | | |
120 | | - | |
| 136 | + | |
121 | 137 | | |
122 | 138 | | |
123 | 139 | | |
| |||
187 | 203 | | |
188 | 204 | | |
189 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
48 | 134 | | |
49 | 135 | | |
50 | 136 | | |
| |||
88 | 174 | | |
89 | 175 | | |
90 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
91 | 180 | | |
92 | 181 | | |
93 | 182 | | |
| |||
122 | 211 | | |
123 | 212 | | |
124 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
125 | 217 | | |
126 | 218 | | |
127 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 94 | + | |
| 95 | + | |
98 | 96 | | |
99 | 97 | | |
100 | 98 | | |
| |||
0 commit comments