Skip to content

feat(sdk): add MonitQuery and MonitAgent methods#13

Merged
ysyneu merged 2 commits into
mainfrom
feat/sdk-monit-types
May 28, 2026
Merged

feat(sdk): add MonitQuery and MonitAgent methods#13
ysyneu merged 2 commits into
mainfrom
feat/sdk-monit-types

Conversation

@ysyneu
Copy link
Copy Markdown
Contributor

@ysyneu ysyneu commented May 27, 2026

Summary

Adds the SDK surface for Flashduty's monit endpoints so downstream consumers (flashduty-cli, monit-query / monit-agent skills) can call them with strongly-typed inputs instead of raw JSON.

  • MonitQueryDiagnose(ctx, in)POST /monit/query/diagnose (pre-clustered RCA: log_patterns / metric_trends)
  • MonitQueryRows(ctx, in)POST /monit/query/rows (raw datasource passthrough)
  • MonitAgentCatalog(ctx, in)POST /monit/tools/catalog (per-target tool discovery)
  • MonitAgentInvoke(ctx, in)POST /monit/tools/invoke (batch tool invocation, up to 8 concurrent)

Field-name conventions follow the Phase 2 plan (fc-safari/docs/superpowers/plans/2026-05-27-flashduty-cli-phase2-auth.md) so cli + safari call-sites compile straight against these symbols.

Design notes

  • time_range marshal shape: input has flat TimeStart int64 + TimeEnd int64 (unix sec); request body assembles {"time_range":{"start":...,"end":...}} inline at MonitQueryDiagnose time. Mirrors how incidents.go:286 builds nested assigned_to. No public MonitQueryTimeRange struct — nothing else shares the shape.
  • Variable response payloads kept as json.RawMessage for: diagnose Results (varies by operation), rows Data (varies by datasource), monit-agent per-tool Data and per-tool Params. Strongly typing these would force a discriminated union the SDK doesn't need.
  • Three-layer error contract (outer / data-level / per-result) is documented on MonitAgentInvokeOutput and exercised by tests.

Why now

Unblocks Phase 2 of the flashduty-cli adoption — cli subcommands monit-query diagnose|rows and monit-agent catalog|invoke depend on these methods.

Test plan

  • 13 new tests (6 monit_query, 7 monit_agent), full suite green
  • go build ./... && go vet ./... && gofmt -l . clean
  • CI green
  • Downstream cli PR (linked once it goes up) compiles against this branch

ysyneu added 2 commits May 27, 2026 23:57
Adds MonitQueryDiagnoseInput/Output and MonitQueryRowsInput/Output along
with the Client methods that POST to /monit/query/diagnose and
/monit/query/rows. TimeStart/TimeEnd marshal into the nested
time_range:{start,end} object the server expects. Variable inner result
payloads (per-operation for diagnose, per-datasource for rows) stay as
json.RawMessage so callers can decode against their datasource shape
without paying for a fragile strongly-typed union.

Also ignores .worktrees/ and .claude/ so this feature-branch worktree
doesn't get committed back.
Adds MonitAgentCatalogInput/Output and MonitAgentInvokeInput/Output along
with the Client methods that POST to /monit/tools/catalog and
/monit/tools/invoke. Tool input_schema, per-tool params, and per-tool
data payloads stay as json.RawMessage so the agent layer can pass
schemas straight to an LLM and decode per-tool outputs on demand.

MonitAgentInvokeOutput's doc comment spells out the three error layers
real callers must distinguish (HTTP, request-level via dataEnvelope,
per-tool via Results[i].Error) so partial-success isn't accidentally
treated as total failure.
@ysyneu ysyneu merged commit c51f6f0 into main May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant