Skip to content

The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.

Merge remote-tracking branch 'origin/refactor/skill-entry' into feature/CITRO-3995

Zhuowei Wang8f2dd1e9f7e9
diff --cc package/ego-browser/src/helpers.test.mjs
index 4cb89f6,ce04801..fea81d4
--- a/package/ego-browser/src/helpers.test.mjs
+++ b/package/ego-browser/src/helpers.test.mjs
@@@ -740,81 -740,27 +740,84 @@@ test("useOrCreateTaskSpace reuses exist
assert.deepEqual(calls, [["listTaskSpaces"], ["useTaskSpace", 7]]);
});
-test("useOrCreateTaskSpace selects user-owned spaces without claiming and surfaces the owned user-control guidance", async () => {
+function userOwnedCheckoutEgo(calls, extra = {}) {
+ return {
+ async listTaskSpaces() {
+ calls.push(["listTaskSpaces"]);
+ return {
+ taskSpaces: [
+ {
+ taskId: "checkout-flow",
+ id: 7,
+ name: "checkout-flow",
+ ownership: "user",
+ },
+ ],
+ };
+ },
+ async createTaskSpace(name) {
+ calls.push(["createTaskSpace", name]);
+ return { taskId: name, id: 8, name, ownership: "agent" };
+ },
+ async claimTaskSpace(id, name) {
+ calls.push(["claimTaskSpace", id, name]);
+ return { taskId: name, id, name, ownership: "agent" };
+ },
+ ...extra,
+ };
+}
+
+test("useOrCreateTaskSpace reports a user-owned name as EGO_TASK_SPACE_NAME_IN_USE", async () => {
const calls = [];
await withEgo(
- {
- async listTaskSpaces() {
- calls.push(["listTaskSpaces"]);
- return {
- taskSpaces: [
- {
- taskId: "checkout-flow",
- id: 7,
- name: "checkout-flow",
- ownership: "user",
- },
- ],
- };
- },
- async claimTaskSpace(id, name) {
- calls.push(["claimTaskSpace", id, name]);
- return { taskId: name, id, name, ownership: "agent" };
+ userOwnedCheckoutEgo(calls, {
+ useTaskSpace(taskId) {
+ calls.push(["useTaskSpace", taskId]);
+ return taskId;
},
+ }),
+ async () => {
+ await assert.rejects(
+ () => useOrCreateTaskSpace("checkout-flow"),
+ (error) => {
+ assert.equal(error.error_code, "EGO_TASK_SPACE_NAME_IN_USE");
+ assert.match(
+ error.message,
+ /^useOrCreateTaskSpace: A task space named "checkout-flow" already exists and belongs to the user \(id 7\)/,
+ );
+ assert.match(error.message, /claimTaskSpace\(7\)/);
- assert.doesNotMatch(error.message, /taken control/);
++ assert.doesNotMatch(
++ error.message,
++ /Control of this task space is with the user/,
++ );
+ return true;
+ },
+ );
+ },
+ );
+ // Neither selected, claimed, nor duplicated.
+ assert.deepEqual(calls, [["listTaskSpaces"]]);
+});
+
+test("taskSpace reports a user-owned name as EGO_TASK_SPACE_NAME_IN_USE", async () => {
+ const calls = [];
+ await withEgo(userOwnedCheckoutEgo(calls), async () => {
+ await assert.rejects(
+ () => taskSpace("checkout-flow"),
+ (error) => {
+ assert.equal(error.error_code, "EGO_TASK_SPACE_NAME_IN_USE");
+ assert.match(error.message, /^taskSpace: A task space named/);
+ return true;
+ },
+ );
+ });
+ assert.deepEqual(calls, [["listTaskSpaces"]]);
+});
+
+test("useOrCreateTaskSpace selects a user-owned space targeted by id without claiming and surfaces the owned user-control guidance", async () => {
+ const calls = [];
+ await withEgo(
+ userOwnedCheckoutEgo(calls, {
useTaskSpace(taskId) {
calls.push(["useTaskSpace", taskId]);
// Native attaches the stable code; resolveEgoError overrides the live
@@@ -824,11 -770,11 +827,11 @@@
error_code: "EGO_TASK_SPACE_USER_IN_CONTROL",
};
},
- },
+ }),
async () => {
await assert.rejects(
- () => useOrCreateTaskSpace("checkout-flow"),
+ () => useOrCreateTaskSpace(7),
- /useOrCreateTaskSpace: The user has taken control of this task space/,
+ /useOrCreateTaskSpace: Control of this task space is with the user/,
);
},
);
diff --cc package/ego-browser/src/taskspace-e2e.test.mjs
index 826cf57,5b990a4..bd68438
--- a/package/ego-browser/src/taskspace-e2e.test.mjs
+++ b/package/ego-browser/src/taskspace-e2e.test.mjs
@@@ -234,27 -234,9 +234,27 @@@ test("taskspace e2e useOrCreateTaskSpac
await assert.rejects(
() =>
runTaskspaceScript(ego, `await useOrCreateTaskSpace("checkout-flow")`),
+ /already exists and belongs to the user \(id 7\)/,
+ );
+ assert.deepEqual(ego.calls, [["listTaskSpaces"]]);
+});
+
+test("taskspace e2e useOrCreateTaskSpace selects a user-owned space targeted by id without claiming and surfaces the owned user-control guidance", async () => {
+ const ego = new FakeEgo([
+ {
+ taskId: "checkout-flow",
+ id: 7,
+ name: "checkout-flow",
+ createdBy: "user",
+ ownership: "user",
+ },
+ ]);
+
+ // Native rejects with error_code EGO_TASK_SPACE_USER_IN_CONTROL, so the agent
+ // sees ego-browser's owned guidance block, not the raw native text.
+ await assert.rejects(
+ () => runTaskspaceScript(ego, `await useOrCreateTaskSpace(7)`),
- /has taken control of this task space/,
+ /Control of this task space is with the user/,
);
assert.deepEqual(ego.calls, [["listTaskSpaces"], ["useTaskSpace", 7]]);
});