Skip to content

feat(plugin-sdk): expose optional GPU and disk metrics - #172

Open
alvinunreal wants to merge 2 commits into
mainfrom
feat/system-metrics-gpu-disk
Open

feat(plugin-sdk): expose optional GPU and disk metrics#172
alvinunreal wants to merge 2 commits into
mainfrom
feat/system-metrics-gpu-disk

Conversation

@alvinunreal

Copy link
Copy Markdown
Owner

Summary

  • add optional aggregate GPU and system-volume usage fields to ctx.system.metrics()
  • collect from bounded, host-owned probes with five-second caching and no plugin process or file access
  • extend the SDK/test harness contract and document availability semantics

Validation

  • focused system-metrics TypeScript compile and behavior test
  • SDK typecheck

The full desktop test build is currently blocked before compilation by pnpm 11 rejecting the repository’s pre-existing unresolved openclaw and tree-sitter-bash build approvals.

@greptile-apps

greptile-apps Bot commented Aug 29, 2026

Copy link
Copy Markdown

Greptile Summary

The PR extends ctx.system.metrics() with optional host-probed GPU and system-volume usage, adds five-second caching, updates SDK and harness types, and documents availability semantics.

  • Adds platform-specific GPU probes and system-volume statfs collection.
  • Wires extended metrics through the Electron host and public SDK contract.
  • Adds focused collector tests and registers them with the desktop test runner.

Confidence Score: 4/5

The PR should not merge until multi-device GPU values satisfy the advertised aggregate contract; probe latency and missing conformance coverage are additional non-blocking issues.

The new collectors consistently select the busiest GPU or engine rather than aggregate machine utilization, so supported multi-device hosts can return materially misleading SDK data.

Files Needing Attention: apps/desktop/src/system-metrics.ts, packages/sdk/src/index.ts, packages/sdk/src/check-plugin-sdk.ts

Important Files Changed

Filename Overview
apps/desktop/src/system-metrics.ts Adds bounded cross-platform GPU and disk probes, but reports peak device or engine utilization as aggregate usage and can impose multi-second fallback latency.
apps/desktop/src/plugin-host-capabilities.ts Integrates extended metrics with in-flight deduplication and five-second caching while awaiting probes before returning required metrics.
packages/sdk/src/index.ts Extends the public metrics result with optional GPU and disk fields, but the corresponding conformance coverage was not updated.
packages/sdk/src/testing.ts Extends the deterministic harness metrics shape consistently with the public SDK.
apps/desktop/tests/system-metrics.test.ts Covers synthetic collector behavior on Linux and Windows but not multi-device aggregation or SDK and harness propagation.
apps/desktop/scripts/run-tests.mjs Correctly registers the new focused behavior test in the desktop test runner.
apps/desktop/src/plugin-sdk-bridge.ts Keeps the host capability type aligned with the newly exposed optional fields.
docs/sdk.md Documents optional availability and the aggregate, non-identifying nature of the added metrics.

Sequence Diagram

sequenceDiagram
    participant P as Plugin
    participant B as SDK bridge
    participant C as Host metrics cache
    participant M as Platform probes
    P->>B: ctx.system.metrics()
    B->>C: capabilities.system.metrics()
    alt cache valid
        C-->>B: cached GPU/disk fields
    else cache expired
        C->>M: GPU command/sysfs probe + statfs
        M-->>C: optional aggregate fields
        C-->>B: CPU/memory + optional GPU/disk
    end
    B-->>P: OpenPetsSystemMetrics
Loading

Fix all with Greploop Fix All in Claude Code

Reviews (1): Last reviewed commit: "feat(plugin-sdk): expose optional GPU an..." | Re-trigger Greptile

Comment thread apps/desktop/src/system-metrics.ts Outdated
Comment thread apps/desktop/src/system-metrics.ts Outdated
Comment thread packages/sdk/src/index.ts
@alvinunreal

Copy link
Copy Markdown
Owner Author

Addressed all Greptile findings in f204216:

  • GPU samples are averaged rather than reported as peak values.
  • Optional GPU/disk probes run in the background; CPU and memory return immediately.
  • Added SDK conformance coverage for the optional metrics round trip.

Focused system-metrics test and the SDK contract test pass. Greptile re-review reports no findings.

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