feat(session): add session list + export commands for AI SRE#30
Merged
Conversation
Add `flashduty session list` and `flashduty session export <id>`, the CLI surface for the AI SRE session APIs (consumed by the /insight skill). - session list: curated command over Sessions.List. --app (default ai-sre), --limit (default 200), --scope, --status, --team-id, and a client-side --since window (the API has no time filter, so rows are filtered by updated_at after fetching). Output --format jsonl (default, one SessionItem per line for jq) / json / toon. - session export: streams the NDJSON transcript straight to stdout via the SDK's hand-written streaming method, line-by-line, so a large transcript never buffers in memory — redirect to a file. session/export is a streaming op (200 is application/x-ndjson), which the generated typed-response template cannot model. cligen now skips streaming ops (mirroring go-flashduty's own generator) and the curated `safari session-export` leaf keeps it reachable at its path-name alongside the generated safari session-get / session-list. The coverage tests account for streaming ops being curated-only. Pins go-flashduty to the commit that adds the Sessions service.
The /safari/session/list handler binds limit with "lte=100": a single request with limit>100 is a hard 400 bind failure, not a clamp. Honor --limit above 100 by paginating server-side (fetchSessionsPaged) — each page requests min(remaining, 100) and advances p until the limit is met or the server is exhausted (short page / accumulated >= total). Adds two regression guards: paginate-beyond-100 and stop-when-exhausted. Also bumps the go-flashduty pin to the squash-merged main commit (7583ebae, go-flashduty#8) so the dependency is reachable from main rather than the soon-stale PR-branch pseudo-version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the CLI surface for the AI SRE session APIs — the commands the
/insightskill shells out to:flashduty session list— curated command overSessions.List. Flags:--app(defaultai-sre),--limit(default 200),--scope,--status,--team-id(setsteam_ids), and a client-side--sincewindow (the API has no time filter, so rows are filtered byupdated_atafter fetching). Output--format jsonl(default — oneSessionItemper line forjq) /json(full envelope) /toon.flashduty session export <session_id>— streams the session's full NDJSON transcript straight to stdout via the SDK's hand-written streaming method, line-by-line so a large transcript never buffers in memory. Redirect to a file:flashduty session export <id> > session.ndjson.--include-subagentsinlines each child session's stream.Streaming op handling (generator + coverage)
session/export's 200 response isapplication/x-ndjson, which the generated typed-response command template cannot model (the SDK exposes it as(io.ReadCloser, *Response, error), not the usual(out, *Response, error)). So:application/json), mirroringgo-flashduty's own generator. Generated tree getssafari session-get/safari session-list; export is excluded.safari session-exportleaf keeps the operation reachable at its path-is-king name, alongside the friendlysession export.TestEveryOperationHasPathCommand,TestGeneratorTargetsFullSpec) account for streaming ops being curated-only: still reachable at their path-name, but not required in the generated manifest.Dependency
Pins
go-flashdutyto the commit that adds the Sessions service (Sessions.Listtyped +Sessions.Exportstreaming).Verification
go build ./...clean;go test ./...green (incl. the 6 new session tests + the two coverage invariants:path-is-king: all 251 operations reachable,generator targets 250/250 non-streaming spec operations (1 streaming, curated)).golangci-lint run→ 0 issues;gofmt/gciclean.session list --app ai-sre --format jsonlreturned real ai-sre sessions (total 988) as one JSON object per line;session export <id>streamed valid NDJSON with line 1 =session_meta(jq-parseable), includingtool_call/final_answerevents (51-line / 53KB transcript, every line valid JSON).