Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/loopx-chat-actions-smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def open_session(self, **kwargs: object) -> tuple[dict[str, object], bool]:
agent_id=str(kwargs["agent_id"]),
adapter_kind="fake",
upstream_thread_id="thread-goal-create",
upstream_mode="chat" if kwargs["agent_id"] == "codex" else "default",
channel_id=channel,
)
return session, False
Expand Down
18 changes: 17 additions & 1 deletion examples/personal-workspace-browser/goal-workspace-backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,23 @@
registry.write_text(json.dumps(data), encoding="utf-8")
runtime = Path(data["common_runtime_root"])
store, sessions = ChatActionStore(runtime / "chat/actions"), ChatSessionStore(runtime)
controller = fixture["FakeRuntimeController"](sessions)


class WorkspaceRuntimeController(fixture["FakeRuntimeController"]):
def __init__(self, store: ChatSessionStore, registry_path: Path, runtime_root: Path) -> None:
super().__init__(store)
self.store = store
self.registry_path = registry_path
self.coordination_runtime_root = runtime_root

def resume_session_queue(self, *, session_id: str, work_dir: Path, objective: str) -> None:
# Observe the queue target at the synthetic dispatch boundary.
session = self.store.load_session(session_id)
assert session is not None
assert Path(session["managed_workspace_path"]) == Path(work_dir)


controller = WorkspaceRuntimeController(sessions, registry, runtime)
# One Dashboard-configured workspace that no Goal uses yet.
configured = root / "docs-site"
configured.mkdir()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,18 @@ runpy.run_path(sys.argv[0], run_name="__main__")
assert.equal(await page.getByText(backend.second, {exact: false}).count(), 0);
assert.equal(JSON.parse(await readFile(backend.registry, "utf8")).goals.length, 2, "Preview created a Goal");
const confirm = page.getByRole("button", {name: /创建 Goal.*开始首轮/});
const confirmation = page.waitForResponse((response) =>
response.request().method() === "POST" && new URL(response.url()).pathname.endsWith("/apply"));
await confirm.click();
await page.waitForFunction(() => document.body.innerText.includes("进入新 Goal"));
assert.ok((await confirmation).ok(), JSON.stringify(applied[0]));
assert.equal(applied.length, 1);
assert.equal(applied[0].proposal.receipt.projection_verified, true);
const receipt = applied[0].proposal.receipt;
assert.equal(receipt.projection_verified, true);
assert.equal(receipt.original_task_request.todo_id, receipt.resource_ids.todo_ids[0]);
assert.equal(receipt.original_task_request.session_id, receipt.resource_ids.session_id);
assert.equal(receipt.original_task_request.permission, "read_only");
assert.deepEqual(receipt.original_task_request.write_scope, []);
await page.getByRole("button", {name: "进入新 Goal", exact: true}).waitFor();
const goalId = requests.at(-1).normalized_parameters.goal_id;
const registry = JSON.parse(await readFile(backend.registry, "utf8"));
const created = registry.goals.find(goal => goal.id === goalId);
Expand Down
8 changes: 6 additions & 2 deletions examples/personal-workspace-browser/typed-actions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,17 @@ export const typedActionsScenario = {
}
const writesBeforeSelection = api.durableWriteCount;
await drawer.getByRole("button", { name: /Workspace 1/ }).click();
await page.getByRole("button", { name: "创建 Goal 并开始首轮", exact: true }).waitFor({ state: "visible" });
const create = drawer.getByRole("button", { name: "创建 Goal", exact: true });
await create.waitFor({ state: "visible" });
const regenerated = api.actionPreviews.at(-1);
if (regenerated?.normalized_parameters.workspace_ref !== "workspace-fixture") {
throw new Error(`Stored workspace selection did not regenerate the Goal preview: ${JSON.stringify(regenerated)}`);
}
if (regenerated.normalized_parameters.start_execution !== storedWorkspaceGate.normalized_parameters.start_execution) {
throw new Error("Workspace selection changed the saved execution intent");
}
if (api.durableWriteCount !== writesBeforeSelection) throw new Error("Selecting a workspace applied without confirmation");
await page.getByRole("button", { name: "创建 Goal 并开始首轮", exact: true }).click();
await create.click();
await page.getByText("已应用,LoopX 状态将刷新。", { exact: true }).waitFor({ state: "visible" });
if (!api.actionApplies.includes(regenerated.proposalId)) throw new Error("Confirmation did not apply the regenerated preview");
if (api.durableWriteCount !== writesBeforeSelection + 1) throw new Error("Confirmation did not write exactly one Goal");
Expand Down
Loading