Add --proxy flag for routing the browser through a Kernel proxy#56
Merged
Conversation
Accepts a proxy id or name, resolved via proxies.retrieve with a list-by-name fallback; ambiguous names and unknown selectors are errors (proxies are never auto-created, unlike --profile). Applies to one-shot subcommands and session start; named sessions persist the resolved proxy_id in their metadata.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Retrieve success falls through names
resolveProxyIdnow treats a successful retrieve without anidas an error and no longer falls through to name-based list matching, with a regression test added for that path.
Or push these changes by commenting:
@cursor push a003234ee5
Preview (a003234ee5)
diff --git a/packages/cli/src/harness-browser.ts b/packages/cli/src/harness-browser.ts
--- a/packages/cli/src/harness-browser.ts
+++ b/packages/cli/src/harness-browser.ts
@@ -65,7 +65,10 @@
if (!trimmed) throw new Error("proxy selector is empty");
try {
const existing = await client.proxies.retrieve(trimmed);
- if (existing.id) return existing.id;
+ if (!existing.id) {
+ throw new Error(`proxy "${trimmed}" lookup returned no id`);
+ }
+ return existing.id;
} catch (err) {
if (!(err instanceof NotFoundError)) {
throw new Error(`looking up proxy "${trimmed}": ${(err as Error).message}`, { cause: err });
diff --git a/packages/cli/test/harness-browser.test.ts b/packages/cli/test/harness-browser.test.ts
--- a/packages/cli/test/harness-browser.test.ts
+++ b/packages/cli/test/harness-browser.test.ts
@@ -22,6 +22,19 @@
await expect(resolveProxyId(client, "proxy_abc")).resolves.toBe("proxy_abc");
});
+ it("does not fall back to name matching when retrieve succeeds without an id", async () => {
+ let listCalled = false;
+ const client = fakeClient({
+ retrieve: async () => ({}),
+ list: async () => {
+ listCalled = true;
+ return [{ id: "proxy_1", name: "proxy_abc" }];
+ },
+ });
+ await expect(resolveProxyId(client, "proxy_abc")).rejects.toThrow(/looking up proxy/);
+ expect(listCalled).toBe(false);
+ });
+
it("falls back to a unique name match from the proxy list", async () => {
const client = fakeClient({ list: async () => [{ id: "proxy_1", name: "residential-us" }, { id: "proxy_2", name: "other" }] });
await expect(resolveProxyId(client, "residential-us")).resolves.toBe("proxy_1");You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 8d6d83b. Configure here.
| const matches = proxies.filter((proxy) => proxy.name === trimmed && proxy.id); | ||
| if (matches.length === 1) return matches[0]!.id!; | ||
| if (matches.length > 1) throw new Error(`proxy name "${trimmed}" is ambiguous (${matches.length} proxies); pass the proxy id`); | ||
| throw new Error(`proxy "${trimmed}" was not found; create one first (e.g. kernel proxies create)`); |
There was a problem hiding this comment.
Retrieve success falls through names
Medium Severity
In resolveProxyId, when proxies.retrieve succeeds but the response has no truthy id, resolution continues as if the lookup failed and tries a name match via proxies.list(). That can route the browser through the wrong proxy or report not found even though retrieve succeeded.
Reviewed by Cursor Bugbot for commit 8d6d83b. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Adds
--proxy <id-or-name>to the cua CLI, mirroring--profile's selector ergonomics without the auto-create behavior:proxies.retrieve(selector)as an id, fall back to a unique name match fromproxies.list(). Ambiguous names and unknown selectors are errors — proxies require type/location/credential configuration, so a bare name is never enough to create one.cua session start; named sessions persist the resolvedproxy_idin their metadata (visible viacua session show), and later-sattaches inherit the browser's proxy naturally.Testing
resolveProxyId(id hit, unique-name fallback, ambiguous name, not-found, non-404 propagation).browsers.createpassthrough is type-checked (proxy_idis a typed param).GOOGLE_API_KEYis present).Release
Bumps
@onkernel/cua-clito 0.3.1. After merge, tag the merge commit withcua-cli/v0.3.1to publish. No changes tocua-ai/cua-agent, so their versions and pinned deps are untouched.Note
Low Risk
Additive CLI option and browser create parameter with explicit lookup errors; no auth or data-model changes beyond optional named-session metadata.
Overview
Adds
--proxy <name|id>socuacan route new Kernel browsers through an existing proxy, with the same id-or-name ergonomics as--profilebut no auto-create for unknown names.Resolution goes through new
resolveProxyId: tryproxies.retrieve, then a uniqueproxies.listname match; ambiguous or missing selectors fail with a clear error. The resolved id is passed asproxy_idonbrowsers.createfor one-shot runs and forcua session start, andproxy_idis stored in named-session metadata (visible viacua session show). Re-attaching with-sreuses the browser and its proxy.Also bumps
@onkernel/cua-clito 0.3.1, updates help and the cua-cli skill doc, and adds unit tests forresolveProxyId.Reviewed by Cursor Bugbot for commit 8d6d83b. Bugbot is set up for automated code reviews on this repo. Configure here.