Skip to content

feat(axclient): add a public client package for reaching ax-server - #640

Merged
YoyinZyc merged 3 commits into
google:mainfrom
YoyinZyc:feat/ax-client
Nov 18, 2026
Merged

YoyinZyc merged 3 commits into
google:mainfrom
YoyinZyc:feat/ax-client

Conversation

@YoyinZyc

@YoyinZyc YoyinZyc commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Follow up of the issue in agentexecutor/studio#3.

Add a small shared client to remove the duplication on ax cli and studio and avoid drift.

Also added add ax local status -o json for format output.

AX Studio carries copies of internal/tunnel because it cannot import it.
pkg/axclient exports the part a client needs: ServerURL, Dial,
CurrentContext and ListContexts. The package is alpha.

To make internal/tunnel usable as a library:

- EnsureServerURL takes a context. Cancelling it stops the wait for a new
  port-forward and kills the one being started.
- kubectl is found through a KubectlResolver. The default only looks on
  PATH and in ~/.ax/bin and returns ErrKubectlNotFound. cmd/ax passes a
  resolver that downloads kubectl, so the CLI behaves as before, and
  internal/tunnel no longer imports internal/install.

The ax CLI dials through axclient.Dial. A test fixes the names and JSON
keys of the files in ~/.ax/tunnels, which binaries of different versions
share.
AX Studio re-implements the local cluster status and the container host
checks of internal/install. With -o json, ax local status prints the
cluster status and a host object: the container runtime, its kernel,
memory and rootless mode, and the error or warning that ax local start
would report for it.

The command exits 0 when no container engine is running; the state is
then NotFound and host.error says why. Tool download progress goes to
stderr so that stdout is only the report.
@YoyinZyc
YoyinZyc requested a review from mayawang November 18, 2026 01:46
@rakyll

rakyll commented Nov 18, 2026

Copy link
Copy Markdown
Member

Studio should use the control plane API as gRPC server. Is there an additional need for this?

Comment thread client/client.go Resolved

@mayawang mayawang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, +1 to Jaana's naming notes. Two non-blocking ones as this becomes a library Studio depends on: (1) env vars win over an explicit Options.Context, and a missing kubeconfig quietly falls back to localhost:8080. Fine for the CLI, but worth making env opt-in and erroring instead for library callers. (2) With Studio as a second long-running process, the CLI and Studio can race on ~/.ax/tunnels (both start kubectl, last save wins, orphaned tunnel). A lock around check-start-save would help before Studio ships it.

- Move pkg/axclient to top-level /client (package client) with no stuttering prefix.
- Replace Options.IgnoreEnv with opt-in FromEnv (explicit Context always wins over AX_SERVER) and return ErrNoContext for library callers instead of falling back to http://localhost:8080 (preserving the localhost:8080 fallback for the ax CLI only).
@YoyinZyc

Copy link
Copy Markdown
Collaborator Author

LGTM, +1 to Jaana's naming notes. Two non-blocking ones as this becomes a library Studio depends on: (1) env vars win over an explicit Options.Context, and a missing kubeconfig quietly falls back to localhost:8080. Fine for the CLI, but worth making env opt-in and erroring instead for library callers. (2) With Studio as a second long-running process, the CLI and Studio can race on ~/.ax/tunnels (both start kubectl, last save wins, orphaned tunnel). A lock around check-start-save would help before Studio ships it.

Renamed the package and resolved the first concern on missing kubeconfig. For the second one, I tried to fix but it may introduce some side effect, will look into it as a follow up. Thanks!

Also even if we switch to electron, some feature of the pr is still valued like Also added add ax local status -o json for format output.. So will merge it then. :)

@YoyinZyc
YoyinZyc merged commit 8e2a187 into google:main Nov 18, 2026
12 checks passed
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.

3 participants