Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

e2e: create room groups with an admin-owned agent

Petr Bauchf0aa41262f54
diff --git a/console/tooling-e2e/src/clients/switch-client.ts b/console/tooling-e2e/src/clients/switch-client.ts
index 02d57fbb1..ebf530fa9 100644
--- a/console/tooling-e2e/src/clients/switch-client.ts
+++ b/console/tooling-e2e/src/clients/switch-client.ts
@@ -546,7 +546,7 @@ export class SwitchClient {
async registerAgentAsUser(params: {
name: string;
description: string;
- }): Promise<AgentRef> {
+ }): Promise<RegisteredAgent> {
const body = await this.gateway<{ id: string; api_key: string }>(
"POST",
"/agents/register",
@@ -558,7 +558,7 @@ export class SwitchClient {
},
);
this.issued.record(body.api_key);
- return { id: body.id, name: params.name };
+ return { id: body.id, name: params.name, apiKey: body.api_key };
}
/** `GET /gateway/feature-flags` — the flags this deployment has turned on. */
diff --git a/console/tooling-e2e/src/fast/room-groups.ts b/console/tooling-e2e/src/fast/room-groups.ts
index 20d00217a..c5df719f9 100644
--- a/console/tooling-e2e/src/fast/room-groups.ts
+++ b/console/tooling-e2e/src/fast/room-groups.ts
@@ -31,7 +31,8 @@ export const roomGroupPaths: FastScenario = {
requires: [],
},
async run({ fixtures, names, switchClient, log }) {
- const agent = await fixtures.agent('grp');
+ // Only a workspace admin's agent may create room groups.
+ const agent = await fixtures.agent('grp', { ownedByAdmin: true });
const call = <T>(operation: string, args: Record<string, unknown>): Promise<T> =>
switchClient.callOperation<T>(agent, operation, args);
const group = async (name: string, parent: string | null): Promise<RoomGroup> => {
diff --git a/console/tooling-e2e/src/fixtures/fixtures.ts b/console/tooling-e2e/src/fixtures/fixtures.ts
index 872a17310..da086b0a0 100644
--- a/console/tooling-e2e/src/fixtures/fixtures.ts
+++ b/console/tooling-e2e/src/fixtures/fixtures.ts
@@ -50,6 +50,10 @@ export class Fixtures {
* `autoSession` is off unless asked for: with it on, Switch expects a
* connector to spawn a session when the agent is addressed, and an operator's
* Console watching the same server could fight the harness for the room.
+ *
+ * The registration token's agents belong to a non-admin account. With
+ * `ownedByAdmin` the agent is registered by the signed-in gateway admin
+ * instead, for operations only a workspace admin's agent may call.
*/
async agent(
role: string,
@@ -57,18 +61,35 @@ export class Fixtures {
autoSession?: boolean;
agentType?: HarnessAgentType;
repoDir?: string;
+ ownedByAdmin?: boolean;
} = {},
): Promise<RegisteredAgent> {
const name = this.names.name(role);
+ const description = `Switch end-to-end harness agent (run ${this.names.runId}). Safe to delete.`;
+ if (options.ownedByAdmin) {
+ if (options.autoSession || options.agentType || options.repoDir) {
+ throw new Error(
+ "ownedByAdmin registers a plain opencode agent; drop the other options",
+ );
+ }
+ return this.track(
+ await this.switchClient.registerAgentAsUser({ name, description }),
+ );
+ }
const agent = await this.switchClient.registerKnownAgent({
agentType: options.agentType ?? "opencode",
name,
- description: `Switch end-to-end harness agent (run ${this.names.runId}). Safe to delete.`,
+ description,
options: {
auto_session: options.autoSession ?? false,
...(options.repoDir ? { repo_dir: options.repoDir } : {}),
},
});
+ return this.track(agent);
+ }
+
+ private async track(agent: RegisteredAgent): Promise<RegisteredAgent> {
+ const name = agent.name;
const cleanup = {
label: `agent ${name} (${agent.id})`,
run: () => this.switchClient.deleteAgent(agent),