mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 11:07:10 +00:00
* refactor: rename Go module path uatu -> sanderling
Module path github.com/priyanshujain/uatu -> github.com/priyanshujain/sanderling,
including all imports and the proto go_package option. Generated .pb.go files
rewritten in-place; safe to regenerate with protoc later.
* chore(proto): regenerate driverpb after module path rename
The previous sed-based module rename corrupted the embedded descriptor
byte lengths. buf generate rewrites them cleanly.
* refactor: rename CLI binary uatu -> sanderling
Updates Makefile target + UATU_BIN var, .goreleaser project/build IDs,
.gitignore comment, and all user-facing strings in the CLI help text,
error messages, and tests. Binary is now bin/sanderling.
* refactor(sdk): rename Kotlin package dev.uatu.sdk -> dev.sanderling.sdk
Moves sdk/android/src/{main,test}/kotlin/dev/uatu -> dev/sanderling and
rewrites package declarations, imports, and the Gradle namespace. Class
names (Uatu, UatuRuntime) are renamed in a follow-up commit.
* refactor(sidecar): rename Kotlin package dev.uatu.sidecar -> dev.sanderling.sidecar
Moves sidecar/src/{main,test}/kotlin/dev/uatu -> dev/sanderling and
rewrites package declarations, imports, and the application mainClass.
* refactor: rename Uatu API surface -> Sanderling
- Kotlin: Uatu -> Sanderling, UatuRuntime -> SanderlingRuntime (+ files).
- JS host binding: globalThis.__uatu__ -> __sanderling__ (Go verifier,
spec-api, tests).
- TS interface: UatuRuntime -> SanderlingRuntime; internal tags
__uatuFormula / __uatuActionGenerator -> __sanderling* variants.
- Go trace: UatuVersion field + uatu_version JSON tag renamed.
- Socket naming: uatu-agent / uatu-agent-reader -> sanderling-agent*.
- Sample app, docs, inline-JS test strings updated to match.
* refactor(examples): rename examples/folio/uatu -> examples/folio/sanderling
Renames the example spec directory; updates justfile paths + gitignore
entries accordingly. Package.json name/description and @uatu/spec
dependency are renamed in the npm + docs commits.
* chore(build): rename gradle property + rootProject.name uatu -> sanderling
- Renames the uatu.version gradle property and all its -P references in
Makefile, build.gradle.kts files, and .github/workflows/release.yml.
- settings.gradle.kts rootProject.name = "sanderling".
- Renames .env.local.example header + release-cli workflow job name.
* refactor(proto): rename proto package uatu.driver.v1 -> sanderling.driver.v1
Updates the proto package and java_package, regenerates driver.pb.go +
driver_grpc.pb.go, rewrites Kotlin imports and the gRPC ServiceName
assertion in driver_test.go.
* refactor: rename npm package @uatu/spec -> @sanderling/spec
Renames package name in pkg/spec-api/package.json + lockfile, all
consumer imports (examples/folio spec, testdata, verifier tests), the
esbuild alias in cmd/sanderling/test_run.go, and related doc references.
* docs: rename uatu -> sanderling in README, docs, and URLs
- README + docs/{manual,development}/*: narrative + GitHub + Pages URLs.
- POM + npm package.json repo/homepage/bugs URLs.
- .gitignore + embed_stub + Makefile-comment references updated to
'make sanderling'.
- Minor narrative comments in cmd/sanderling/test_run.go and
internal/inspect/server.go.
* refactor: rename remaining internal uatu strings -> sanderling
- SANDERLING_TEST_PHONE/OTP env vars (cmd + bundler tests).
- sanderling-sidecar runtime tmp dir + extracted JAR filename.
- Inspect web UI: @sanderling/inspect-web package, title, theme
localStorage key, RunList empty-state copy, uatu_version TS field.
- Sample app storage key sanderling.ledger.v1.
- Test data: sanderling_test AVD name + com.example.sanderling_test.
- Release docs tarball name template.
169 lines
4.7 KiB
Go
169 lines
4.7 KiB
Go
package maestro
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/credentials/insecure"
|
|
|
|
"github.com/priyanshujain/sanderling/internal/driver"
|
|
driverpb "github.com/priyanshujain/sanderling/proto/driverpb"
|
|
)
|
|
|
|
type Client struct {
|
|
connection *grpc.ClientConn
|
|
stub driverpb.DriverClient
|
|
}
|
|
|
|
// Dial connects to the sidecar gRPC server at the given address.
|
|
// Address must be a host:port pair, typically "127.0.0.1:<sidecar-port>".
|
|
func Dial(address string) (*Client, error) {
|
|
connection, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
|
if err != nil {
|
|
return nil, fmt.Errorf("dial sidecar: %w", err)
|
|
}
|
|
return &Client{connection: connection, stub: driverpb.NewDriverClient(connection)}, nil
|
|
}
|
|
|
|
func (c *Client) Close() error { return c.connection.Close() }
|
|
|
|
// WaitForHealth polls the sidecar's Health RPC until it returns Ready=true
|
|
// or the context is canceled.
|
|
func (c *Client) WaitForHealth(ctx context.Context, pollInterval time.Duration) error {
|
|
if pollInterval <= 0 {
|
|
pollInterval = 100 * time.Millisecond
|
|
}
|
|
for {
|
|
response, err := c.stub.Health(ctx, &driverpb.Empty{})
|
|
if err == nil && response.GetReady() {
|
|
return nil
|
|
}
|
|
select {
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
case <-time.After(pollInterval):
|
|
}
|
|
}
|
|
}
|
|
|
|
func (c *Client) Launch(ctx context.Context, bundleID, launcherActivity string, clearState bool) error {
|
|
_, err := c.stub.Launch(ctx, &driverpb.LaunchRequest{
|
|
BundleId: bundleID,
|
|
ClearState: clearState,
|
|
LauncherActivity: launcherActivity,
|
|
})
|
|
return err
|
|
}
|
|
|
|
func (c *Client) Terminate(ctx context.Context) error {
|
|
_, err := c.stub.Terminate(ctx, &driverpb.Empty{})
|
|
return err
|
|
}
|
|
|
|
func (c *Client) Tap(ctx context.Context, x, y int) error {
|
|
_, err := c.stub.Tap(ctx, &driverpb.Point{X: int32(x), Y: int32(y)})
|
|
return err
|
|
}
|
|
|
|
func (c *Client) TapSelector(ctx context.Context, selector string) error {
|
|
_, err := c.stub.TapSelector(ctx, &driverpb.Selector{Value: selector})
|
|
return err
|
|
}
|
|
|
|
func (c *Client) InputText(ctx context.Context, text string) error {
|
|
_, err := c.stub.InputText(ctx, &driverpb.Text{Value: text})
|
|
return err
|
|
}
|
|
|
|
func (c *Client) Swipe(ctx context.Context, fromX, fromY, toX, toY int, duration time.Duration) error {
|
|
_, err := c.stub.Swipe(ctx, &driverpb.SwipeRequest{
|
|
From: &driverpb.Point{X: int32(fromX), Y: int32(fromY)},
|
|
To: &driverpb.Point{X: int32(toX), Y: int32(toY)},
|
|
DurationMillis: duration.Milliseconds(),
|
|
})
|
|
return err
|
|
}
|
|
|
|
func (c *Client) PressKey(ctx context.Context, key string) error {
|
|
_, err := c.stub.PressKey(ctx, &driverpb.PressKeyRequest{Key: key})
|
|
return err
|
|
}
|
|
|
|
func (c *Client) RecentLogs(ctx context.Context, since time.Time, minLevel string) ([]driver.LogEntry, error) {
|
|
sinceMillis := int64(0)
|
|
if !since.IsZero() {
|
|
sinceMillis = since.UnixMilli()
|
|
}
|
|
response, err := c.stub.RecentLogs(ctx, &driverpb.RecentLogsRequest{
|
|
SinceUnixMillis: sinceMillis,
|
|
LevelAtLeast: minLevel,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
entries := response.GetEntries()
|
|
result := make([]driver.LogEntry, 0, len(entries))
|
|
for _, entry := range entries {
|
|
result = append(result, driver.LogEntry{
|
|
UnixMillis: entry.GetUnixMillis(),
|
|
Level: entry.GetLevel(),
|
|
Tag: entry.GetTag(),
|
|
Message: entry.GetMessage(),
|
|
})
|
|
}
|
|
return result, nil
|
|
}
|
|
|
|
func (c *Client) Hierarchy(ctx context.Context) (string, error) {
|
|
response, err := c.stub.Hierarchy(ctx, &driverpb.Empty{})
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return response.GetJson(), nil
|
|
}
|
|
|
|
func (c *Client) Screenshot(ctx context.Context) (driver.Image, error) {
|
|
response, err := c.stub.Screenshot(ctx, &driverpb.Empty{})
|
|
if err != nil {
|
|
return driver.Image{}, err
|
|
}
|
|
return driver.Image{
|
|
PNG: response.GetPng(),
|
|
Width: int(response.GetWidth()),
|
|
Height: int(response.GetHeight()),
|
|
}, nil
|
|
}
|
|
|
|
func (c *Client) WaitForIdle(ctx context.Context, duration time.Duration) error {
|
|
_, err := c.stub.WaitForIdle(ctx, &driverpb.Duration{Millis: duration.Milliseconds()})
|
|
return err
|
|
}
|
|
|
|
func (c *Client) Health(ctx context.Context) (driver.Health, error) {
|
|
response, err := c.stub.Health(ctx, &driverpb.Empty{})
|
|
if err != nil {
|
|
return driver.Health{}, err
|
|
}
|
|
return driver.Health{
|
|
Ready: response.GetReady(),
|
|
Version: response.GetVersion(),
|
|
Platform: response.GetPlatform(),
|
|
}, nil
|
|
}
|
|
|
|
func (c *Client) Metrics(ctx context.Context, bundleID string) (driver.Metrics, error) {
|
|
response, err := c.stub.Metrics(ctx, &driverpb.MetricsRequest{BundleId: bundleID})
|
|
if err != nil {
|
|
return driver.Metrics{}, err
|
|
}
|
|
return driver.Metrics{
|
|
CPUPercent: response.GetCpuPercent(),
|
|
HeapBytes: response.GetHeapBytes(),
|
|
TotalMemoryBytes: response.GetTotalMemoryBytes(),
|
|
}, nil
|
|
}
|
|
|
|
var _ driver.Driver = (*Client)(nil)
|