Repository navigation
feat(axclient): add a public client package for reaching ax-server - #640
Conversation
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.
|
Studio should use the control plane API as gRPC server. Is there an additional need for this? |
mayawang
left a comment
There was a problem hiding this comment.
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).
84e5b32 to
5f05cff
Compare
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 |
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 jsonfor format output.