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: run main's agent rename and delete check as a fast-lane scenario

Petr Bauch6747732e57bb
diff --git a/console/tooling-e2e/src/agent-identity.integration.test.ts b/console/tooling-e2e/src/agent-identity.integration.test.ts
deleted file mode 100644
index 90f8648a6..000000000
--- a/console/tooling-e2e/src/agent-identity.integration.test.ts
+++ /dev/null
@@ -1,146 +0,0 @@
-import { afterAll, beforeAll, describe, expect, it } from 'vitest';
-import { describeEnv } from './env.ts';
-import { resolveSkip, setupHarness, teardownHarness, type Harness } from './harness.ts';
-import type { MattermostPost } from './mattermost-client.ts';
-import { eventText, sleep } from './switch-client.ts';
-
-/**
- * Renaming and deleting an agent, end to end against a live Switch and
- * Mattermost, with no Switch Console and no model in the loop (the harness
- * plays the agent, as the loopback check does):
- *
- * 1. a rename from the gateway renames the agent's Mattermost bot in place,
- * and the new name reaches the agent while the old one does not;
- * 2. `!rename-agent` from the chat does the same, for the person who owns the
- * agent or administers the workspace;
- * 3. `!delete-agent`, confirmed, deletes it.
- *
- * The scenarios run in order and each builds on the last.
- */
-
-let harness: Harness | null = null;
-let skip: string | null = null;
-let currentName = '';
-let adminBotId = '';
-
-beforeAll(async () => {
- const resolved = await resolveSkip();
- skip = resolved.skip;
- if (skip || !resolved.env) return;
- harness = await setupHarness(resolved.env, { autoSession: false, prefix: 'e2e-rn' });
- currentName = harness.agent.name;
- console.log(
- `identity: ${describeEnv(resolved.env)} agent=${harness.agent.name} (${harness.agent.id}) ` +
- `channel=${harness.channel.name} room=${harness.room.id}`
- );
- // The chat commands recognise the sender through the Switch user who linked
- // their chat account; the gateway admin the harness signs in as links it.
- await harness.switch.claimIdentity('mattermost', harness.human.id, harness.human.username);
- // A registered agent answers only its owner by default; the harness's human
- // is linked to the admin instead, so the mentions below need it open.
- await harness.switch.openAddressing(harness.agent.id);
-}, 300_000);
-
-afterAll(async () => {
- await teardownHarness(harness);
-});
-
-function renamed(suffix: string): string {
- // Same length as the original, so it stays inside Mattermost's cap, and
- // still `e2e-` prefixed so the cleanup script finds it after a failed run.
- return harness!.agent.name.replace(/^e2e-rn/, `e2e-r${suffix}`);
-}
-
-async function switchReply(sinceMs: number, pattern: RegExp): Promise<MattermostPost> {
- const h = harness!;
- if (!adminBotId) {
- const admin = await h.mattermost.waitForBotUser('switch-admin', 30_000);
- adminBotId = admin.id;
- }
- const found = await h.mattermost.waitForPost({
- channelId: h.channel.id,
- fromUserId: adminBotId,
- predicate: (post) => pattern.test(post.message),
- sinceMs,
- deadlineMs: 60_000,
- });
- if (!found.match) {
- throw new Error(
- `Switch never replied with ${pattern}. Transcript: ` +
- found.transcript.map((p) => `${p.user_id}: ${p.message}`).join(' | ')
- );
- }
- return found.match;
-}
-
-async function reachesAgent(name: string): Promise<boolean> {
- const h = harness!;
- const marker = `SWITCH_E2E_${Math.random().toString(36).slice(2, 10).toUpperCase()}`;
- await h.mattermost.post({ channelId: h.channel.id, message: `@${name} ping ${marker}` });
- const seen = await h.switch.waitForNotification(
- h.agent,
- (event) => eventText(event).includes(marker),
- 20_000
- );
- return seen.match !== null;
-}
-
-describe('renaming and deleting an agent', () => {
- it('a gateway rename renames the same Mattermost bot, and routing follows', async () => {
- if (skip) return void console.log(`SKIPPED: ${skip}`);
- const h = harness!;
- const newName = renamed('a');
-
- const result = await h.switch.renameAgent(h.agent.id, newName, 'Rename Check');
-
- expect(result.name).toBe(newName);
- expect(result.bridgeFailures).toEqual([]);
- const bot = await h.mattermost.waitForBotUser(newName, 30_000);
- expect(bot.id).toBe(h.bot.id);
- expect(await h.mattermost.findBotUser(currentName)).toBeNull();
- expect(await reachesAgent(newName)).toBe(true);
- expect(await reachesAgent(currentName)).toBe(false);
- currentName = newName;
- }, 300_000);
-
- it('!rename-agent from the chat renames it for the linked owner or admin', async () => {
- if (skip) return void console.log(`SKIPPED: ${skip}`);
- const h = harness!;
- const newName = renamed('b');
- const sinceMs = Date.now();
-
- await h.mattermost.post({
- channelId: h.channel.id,
- message: `!rename-agent @${currentName} ${newName}`,
- });
-
- await switchReply(sinceMs, /Renamed/);
- const bot = await h.mattermost.waitForBotUser(newName, 30_000);
- expect(bot.id).toBe(h.bot.id);
- expect(await reachesAgent(newName)).toBe(true);
- currentName = newName;
- }, 300_000);
-
- it('!delete-agent asks first, and deletes once confirmed', async () => {
- if (skip) return void console.log(`SKIPPED: ${skip}`);
- const h = harness!;
- let sinceMs = Date.now();
-
- await h.mattermost.post({ channelId: h.channel.id, message: `!delete-agent @${currentName}` });
- await switchReply(sinceMs, /To go ahead/);
- expect((await h.switch.listAgents()).some((a) => a.id === h.agent.id)).toBe(true);
-
- sinceMs = Date.now();
- await h.mattermost.post({
- channelId: h.channel.id,
- message: `!delete-agent ${currentName} confirm`,
- });
- await switchReply(sinceMs, /Deleted/);
- // The delete reaches the agent list once it has committed.
- for (let attempt = 0; attempt < 10; attempt++) {
- if (!(await h.switch.listAgents()).some((a) => a.id === h.agent.id)) break;
- await sleep(1_000);
- }
- expect((await h.switch.listAgents()).some((a) => a.id === h.agent.id)).toBe(false);
- }, 300_000);
-});
diff --git a/console/tooling-e2e/src/clients/switch-client.ts b/console/tooling-e2e/src/clients/switch-client.ts
index 4292b349c..e796d2b28 100644
--- a/console/tooling-e2e/src/clients/switch-client.ts
+++ b/console/tooling-e2e/src/clients/switch-client.ts
@@ -1,6 +1,6 @@
-import type { Environment, SwitchEnv } from '../core/env.ts';
-import { assertAllowed } from '../core/guard.ts';
-import type { IssuedSecrets } from '../core/secrets.ts';
+import type { Environment, SwitchEnv } from "../core/env.ts";
+import { assertAllowed } from "../core/guard.ts";
+import type { IssuedSecrets } from "../core/secrets.ts";
/**
* Thin client for the two Switch HTTP surfaces the harness talks to, both served
@@ -104,7 +104,7 @@ export interface AgentEvent {
/** The human-readable text of an event, or `''` when it carries none. */
export function eventText(event: AgentEvent): string {
const body = event.payload?.body;
- return typeof body === 'string' ? body : '';
+ return typeof body === "string" ? body : "";
}
/** What a route answered to a probe: its status, and what it said its body was. */
@@ -122,7 +122,7 @@ export class SwitchHttpError extends Error {
readonly path: string;
constructor(method: string, path: string, status: number, body: string) {
super(`${method} ${path} -> ${status}: ${truncate(body, 400)}`);
- this.name = 'SwitchHttpError';
+ this.name = "SwitchHttpError";
this.status = status;
this.body = body;
this.method = method;
@@ -138,7 +138,7 @@ export function managementErrorCode(error: unknown): string | null {
if (!(error instanceof SwitchHttpError)) return null;
try {
const parsed = JSON.parse(error.body) as { error?: { code?: unknown } };
- return typeof parsed.error?.code === 'string' ? parsed.error.code : null;
+ return typeof parsed.error?.code === "string" ? parsed.error.code : null;
} catch {
return null;
}
@@ -166,7 +166,10 @@ export class SwitchClient {
private gatewayCookie: string | null = null;
// Shared with every client `as()` makes, so one scenario's requests carry
// one tag, numbered without repeats, whichever user sent them.
- private tagging: { tag: string | null; count: number } = { tag: null, count: 0 };
+ private tagging: { tag: string | null; count: number } = {
+ tag: null,
+ count: 0,
+ };
constructor(env: SwitchEnv, environment: Environment, issued: IssuedSecrets) {
this.apiUrl = env.apiUrl;
@@ -191,38 +194,50 @@ export class SwitchClient {
private requestId(): Record<string, string> {
if (this.tagging.tag === null) return {};
this.tagging.count += 1;
- return { 'X-Request-Id': `${this.tagging.tag}-${this.tagging.count}` };
+ return { "X-Request-Id": `${this.tagging.tag}-${this.tagging.count}` };
}
- private async request<T>(method: string, path: string, init: SwitchRequest = {}): Promise<T> {
+ private async request<T>(
+ method: string,
+ path: string,
+ init: SwitchRequest = {},
+ ): Promise<T> {
return (await this.rawRequest(method, path, init)).parsed as T;
}
private async rawRequest(
method: string,
path: string,
- init: SwitchRequest
+ init: SwitchRequest,
): Promise<{ parsed: unknown; response: Response }> {
assertAllowed(this.environment, method, path);
- const headers: Record<string, string> = { Accept: 'application/json', ...this.requestId() };
+ const headers: Record<string, string> = {
+ Accept: "application/json",
+ ...this.requestId(),
+ };
if (init.token) headers.Authorization = `Bearer ${init.token}`;
if (init.cookie) headers.Cookie = init.cookie;
- if (init.body !== undefined) headers['Content-Type'] = 'application/json';
+ if (init.body !== undefined) headers["Content-Type"] = "application/json";
const response = await fetch(`${this.apiUrl}${path}`, {
method,
headers,
body: init.body === undefined ? undefined : JSON.stringify(init.body),
- redirect: 'manual',
+ redirect: "manual",
signal: AbortSignal.timeout(init.timeoutMs ?? 30_000),
});
if (!response.ok) {
- throw new SwitchHttpError(method, path, response.status, await response.text());
+ throw new SwitchHttpError(
+ method,
+ path,
+ response.status,
+ await response.text(),
+ );
}
if (response.status === 204) return { parsed: undefined, response };
const text = await response.text();
- return { parsed: text === '' ? undefined : JSON.parse(text), response };
+ return { parsed: text === "" ? undefined : JSON.parse(text), response };
}
/**
@@ -230,7 +245,10 @@ export class SwitchClient {
* key, no body. For the check that every route which takes a session refuses
* a request without one.
*/
- async statusWithoutCredentials(method: string, path: string): Promise<RouteProbe> {
+ async statusWithoutCredentials(
+ method: string,
+ path: string,
+ ): Promise<RouteProbe> {
return this.probe(method, path, null);
}
@@ -243,24 +261,28 @@ export class SwitchClient {
return this.probe(method, path, await this.gatewayLogin());
}
- private async probe(method: string, path: string, cookie: string | null): Promise<RouteProbe> {
+ private async probe(
+ method: string,
+ path: string,
+ cookie: string | null,
+ ): Promise<RouteProbe> {
assertAllowed(this.environment, method, path);
const tag = this.requestId();
const response = await fetch(`${this.apiUrl}${path}`, {
method,
headers: {
- Accept: 'application/json',
+ Accept: "application/json",
...(cookie === null ? {} : { Cookie: cookie }),
...tag,
},
- redirect: 'manual',
+ redirect: "manual",
signal: AbortSignal.timeout(30_000),
});
await response.body?.cancel();
return {
status: response.status,
- contentType: response.headers.get('content-type') ?? '',
- requestId: tag['X-Request-Id'] ?? null,
+ contentType: response.headers.get("content-type") ?? "",
+ requestId: tag["X-Request-Id"] ?? null,
};
}
@@ -279,7 +301,7 @@ export class SwitchClient {
gatewayAdminPassword: password,
},
this.environment,
- this.issued
+ this.issued,
);
other.tagging = this.tagging;
return other;
@@ -290,9 +312,9 @@ export class SwitchClient {
name: string;
email: string;
password: string;
- role: 'user' | 'admin';
+ role: "user" | "admin";
}): Promise<{ id: string }> {
- return this.gateway<{ id: string }>('POST', '/users', params);
+ return this.gateway<{ id: string }>("POST", "/users", params);
}
/**
@@ -301,36 +323,51 @@ export class SwitchClient {
* acts in the new workspace.
*/
async createTenant(name: string): Promise<string> {
- const { parsed, response } = await this.rawRequest('POST', '/gateway/tenants', {
- cookie: await this.gatewayLogin(),
- body: { name },
- });
+ const { parsed, response } = await this.rawRequest(
+ "POST",
+ "/gateway/tenants",
+ {
+ cookie: await this.gatewayLogin(),
+ body: { name },
+ },
+ );
const cookie = sessionCookieFrom(response);
- if (!cookie) throw new Error('Creating a workspace returned no switch_auth cookie for it.');
- this.issued.record(cookie.slice('switch_auth='.length));
+ if (!cookie)
+ throw new Error(
+ "Creating a workspace returned no switch_auth cookie for it.",
+ );
+ this.issued.record(cookie.slice("switch_auth=".length));
this.gatewayCookie = cookie;
return (parsed as { id: string }).id;
}
/** `POST /gateway/agents/register` — an agent owned by the signed-in user, in their current workspace. */
- async registerAgentAsUser(params: { name: string; description: string }): Promise<AgentRef> {
- const body = await this.gateway<{ id: string; api_key: string }>('POST', '/agents/register', {
- agent_type: 'opencode',
- name: params.name,
- description: params.description,
- options: { auto_session: false },
- });
+ async registerAgentAsUser(params: {
+ name: string;
+ description: string;
+ }): Promise<AgentRef> {
+ const body = await this.gateway<{ id: string; api_key: string }>(
+ "POST",
+ "/agents/register",
+ {
+ agent_type: "opencode",
+ name: params.name,
+ description: params.description,
+ options: { auto_session: false },
+ },
+ );
this.issued.record(body.api_key);
return { id: body.id, name: params.name };
}
/** `GET /gateway/feature-flags` — the flags this deployment has turned on. */
async enabledFeatureFlags(): Promise<Set<string>> {
- const body = await this.gateway<{ flags: { key: string; enabled: boolean }[] }>(
- 'GET',
- '/feature-flags'
+ const body = await this.gateway<{
+ flags: { key: string; enabled: boolean }[];
+ }>("GET", "/feature-flags");
+ return new Set(
+ body.flags.filter((flag) => flag.enabled).map((flag) => flag.key),
);
- return new Set(body.flags.filter((flag) => flag.enabled).map((flag) => flag.key));
}
/**
@@ -339,15 +376,15 @@ export class SwitchClient {
* {@link SwitchHttpError} carrying them.
*/
async ready(): Promise<void> {
- await this.request('GET', '/health/ready', { timeoutMs: 10_000 });
+ await this.request("GET", "/health/ready", { timeoutMs: 10_000 });
}
/** `GET /health` — the reachability probe the suite skips on. */
async health(): Promise<void> {
- const body = await this.request<{ status?: string }>('GET', '/health', {
+ const body = await this.request<{ status?: string }>("GET", "/health", {
timeoutMs: 5_000,
});
- if (body?.status !== 'ok') {
+ if (body?.status !== "ok") {
throw new Error(`Switch /health returned ${JSON.stringify(body)}`);
}
}
@@ -365,22 +402,26 @@ export class SwitchClient {
*/
async gatewayLogin(): Promise<string> {
if (this.gatewayCookie) return this.gatewayCookie;
- const { response } = await this.rawRequest('POST', '/gateway/auth/login', {
+ const { response } = await this.rawRequest("POST", "/gateway/auth/login", {
body: { email: this.adminEmail, password: this.adminPassword },
});
const cookie = sessionCookieFrom(response);
if (!cookie) {
throw new Error(
- 'Gateway login succeeded but returned no switch_auth cookie — the gateway ' +
- 'authenticates with a session cookie, not a bearer token.'
+ "Gateway login succeeded but returned no switch_auth cookie — the gateway " +
+ "authenticates with a session cookie, not a bearer token.",
);
}
- this.issued.record(cookie.slice('switch_auth='.length));
+ this.issued.record(cookie.slice("switch_auth=".length));
this.gatewayCookie = cookie;
return cookie;
}
- private async gateway<T>(method: string, path: string, body?: unknown): Promise<T> {
+ private async gateway<T>(
+ method: string,
+ path: string,
+ body?: unknown,
+ ): Promise<T> {
return this.request<T>(method, `/gateway${path}`, {
cookie: await this.gatewayLogin(),
body,
@@ -388,12 +429,12 @@ export class SwitchClient {
}
async listRooms(): Promise<RoomSummary[]> {
- const rows = await this.gateway<RawRoom[]>('GET', '/rooms');
+ const rows = await this.gateway<RawRoom[]>("GET", "/rooms");
return rows.map(toRoomSummary);
}
async getRoom(roomId: string): Promise<RoomDetail> {
- return toRoomDetail(await this.gateway<RawRoom>('GET', `/rooms/${roomId}`));
+ return toRoomDetail(await this.gateway<RawRoom>("GET", `/rooms/${roomId}`));
}
/**
@@ -421,12 +462,16 @@ export class SwitchClient {
agentNames: string[];
userNames: string[];
}): Promise<RoomDetail> {
- const row = await this.gateway<RawRoom>('POST', '/rooms', {
+ const row = await this.gateway<RawRoom>("POST", "/rooms", {
name: params.name,
description: params.description,
...(params.bridgeId === null
? { internal_only: true }
- : { bridge_id: params.bridgeId, internal_only: false, channel_type: 'channel_public' }),
+ : {
+ bridge_id: params.bridgeId,
+ internal_only: false,
+ channel_type: "channel_public",
+ }),
agent_names: params.agentNames,
user_names: params.userNames,
});
@@ -434,7 +479,7 @@ export class SwitchClient {
}
async deleteRoom(roomId: string): Promise<void> {
- await this.gateway('DELETE', `/rooms/${roomId}`);
+ await this.gateway("DELETE", `/rooms/${roomId}`);
}
/**
@@ -443,7 +488,7 @@ export class SwitchClient {
* the cleanup script for agents left behind by an interrupted run.
*/
async deleteAgentByName(name: string): Promise<void> {
- await this.gateway('DELETE', `/agents/by-name/${encodeURIComponent(name)}`);
+ await this.gateway("DELETE", `/agents/by-name/${encodeURIComponent(name)}`);
}
/**
@@ -462,15 +507,15 @@ export class SwitchClient {
definition: ManagedAgentDefinition;
}): Promise<AgentRef> {
const view = await this.gateway<{ agent_id: string; name: string }>(
- 'POST',
- '/management/agents',
+ "POST",
+ "/management/agents",
{
name: params.name,
description: params.description,
controller_id: params.controllerId,
- desired_state: 'running',
+ desired_state: "running",
definition: params.definition,
- }
+ },
);
return { id: view.agent_id, name: view.name };
}
@@ -485,7 +530,9 @@ export class SwitchClient {
* agents and an unclaimed platform user, so its agents are opened explicitly.
*/
async openAddressing(agentId: string): Promise<void> {
- await this.gateway('PUT', `/agents/${agentId}/addressing-policy`, { policy: null });
+ await this.gateway("PUT", `/agents/${agentId}/addressing-policy`, {
+ policy: null,
+ });
}
/**
@@ -493,12 +540,15 @@ export class SwitchClient {
* is attending the room; `dormant` means an auto-session connector is watching
* and would spawn one; `no_session` / `disconnected` mean nothing is there.
*/
- async agentStatusInRoom(roomId: string, agentId: string): Promise<string | null> {
- const row = await this.gateway<RawRoom>('GET', `/rooms/${roomId}`);
+ async agentStatusInRoom(
+ roomId: string,
+ agentId: string,
+ ): Promise<string | null> {
+ const row = await this.gateway<RawRoom>("GET", `/rooms/${roomId}`);
const statuses = row.agent_statuses;
- if (!statuses || typeof statuses !== 'object') return null;
+ if (!statuses || typeof statuses !== "object") return null;
const status = (statuses as Record<string, unknown>)[agentId];
- return typeof status === 'string' ? status : null;
+ return typeof status === "string" ? status : null;
}
/**
@@ -508,12 +558,16 @@ export class SwitchClient {
async renameAgent(
agentId: string,
name: string,
- displayName: string | null
- ): Promise<{ name: string; displayName: string | null; bridgeFailures: string[] }> {
+ displayName: string | null,
+ ): Promise<{
+ name: string;
+ displayName: string | null;
+ bridgeFailures: string[];
+ }> {
const body = await this.gateway<{
agent: { name: string; display_name: string | null };
bridge_failures: string[];
- }>('PUT', `/agents/${agentId}/name`, { name, display_name: displayName });
+ }>("PUT", `/agents/${agentId}/name`, { name, display_name: displayName });
return {
name: body.agent.name,
displayName: body.agent.display_name,
@@ -521,14 +575,6 @@ export class SwitchClient {
};
}
- /**
- * `PUT /gateway/agents/{id}/addressing-policy` with no policy, so anyone in
- * the room may address the agent, not only its owner.
- */
- async openAddressing(agentId: string): Promise<void> {
- await this.gateway('PUT', `/agents/${agentId}/addressing-policy`, { policy: null });
- }
-
/**
* `POST /gateway/collaborations/{bridge}/identities` on the default bridge
* of `bridgeType` — link a chat account to the signed-in Switch user, so
@@ -538,38 +584,48 @@ export class SwitchClient {
async claimIdentity(
bridgeType: string,
externalUserId: string,
- username: string
+ username: string,
): Promise<void> {
const bridges = await this.gateway<
{ bridge_id: string; bridge_type: string; is_default?: boolean }[]
- >('GET', '/collaborations');
+ >("GET", "/collaborations");
const ofType = bridges.filter((row) => row.bridge_type === bridgeType);
const bridge = ofType.find((row) => row.is_default) ?? ofType[0];
- if (!bridge) throw new Error(`No ${bridgeType} collaboration bridge on this Switch server`);
- await this.gateway('POST', `/collaborations/${bridge.bridge_id}/identities`, {
- external_user_id: externalUserId,
- username,
- user_id: null,
- });
+ if (!bridge)
+ throw new Error(
+ `No ${bridgeType} collaboration bridge on this Switch server`,
+ );
+ await this.gateway(
+ "POST",
+ `/collaborations/${bridge.bridge_id}/identities`,
+ {
+ external_user_id: externalUserId,
+ username,
+ user_id: null,
+ },
+ );
}
async listAgents(): Promise<AgentSummary[]> {
- const rows = await this.gateway<{ id: string; name: string; created_at: string }[]>(
- 'GET',
- '/agents'
- );
- return rows.map((row) => ({ id: row.id, name: row.name, createdAt: row.created_at }));
+ const rows = await this.gateway<
+ { id: string; name: string; created_at: string }[]
+ >("GET", "/agents");
+ return rows.map((row) => ({
+ id: row.id,
+ name: row.name,
+ createdAt: row.created_at,
+ }));
}
/** `GET /gateway/auth/session` — the workspace this admin session is bound to. */
async tenantId(): Promise<string> {
- const state = await this.gateway<{ state: string; tenant: { id: string } | null }>(
- 'GET',
- '/auth/session'
- );
+ const state = await this.gateway<{
+ state: string;
+ tenant: { id: string } | null;
+ }>("GET", "/auth/session");
if (state.tenant === null) {
throw new Error(
- `The gateway admin's session is bound to no workspace (state '${state.state}').`
+ `The gateway admin's session is bound to no workspace (state '${state.state}').`,
);
}
return state.tenant.id;
@@ -579,7 +635,11 @@ export class SwitchClient {
* `GET /gateway/tenants/{tenant_id}/usage` — what each client spent, per
* metric and model, over `[since, until)`. Counted in whole UTC hours.
*/
- async usage(tenantId: string, since: Date, until: Date): Promise<UsageTotal[]> {
+ async usage(
+ tenantId: string,
+ since: Date,
+ until: Date,
+ ): Promise<UsageTotal[]> {
const query = `since=${encodeURIComponent(since.toISOString())}&until=${encodeURIComponent(until.toISOString())}`;
const rows = await this.gateway<
{
@@ -589,7 +649,7 @@ export class SwitchClient {
model: string;
amount: number;
}[]
- >('GET', `/tenants/${tenantId}/usage?${query}`);
+ >("GET", `/tenants/${tenantId}/usage?${query}`);
return rows.map((row) => ({
metric: row.metric,
clientId: row.client_id,
@@ -605,13 +665,22 @@ export class SwitchClient {
}
/** The default collaboration bridge of `type`: its id, and the display name a room document names it by. */
- async defaultBridge(type: string): Promise<{ id: string; displayName: string }> {
+ async defaultBridge(
+ type: string,
+ ): Promise<{ id: string; displayName: string }> {
const rows = await this.gateway<
- { id: string; bridge_type: string; display_name: string; is_default?: boolean }[]
- >('GET', '/collaborations');
+ {
+ id: string;
+ bridge_type: string;
+ display_name: string;
+ is_default?: boolean;
+ }[]
+ >("GET", "/collaborations");
const ofType = rows.filter((row) => row.bridge_type === type);
if (ofType.length === 0) {
- throw new Error(`No ${type} collaboration bridge registered on this Switch server`);
+ throw new Error(
+ `No ${type} collaboration bridge registered on this Switch server`,
+ );
}
const row = ofType.find((candidate) => candidate.is_default) ?? ofType[0]!;
return { id: row.id, displayName: row.display_name };
@@ -627,18 +696,23 @@ export class SwitchClient {
const result = await this.gateway<{
room_id?: string;
failed_attachments?: unknown[];
- }>('POST', '/rooms/from-yaml', { yaml });
+ }>("POST", "/rooms/from-yaml", { yaml });
if (result.room_id === undefined) {
- throw new Error(`from-yaml did not make one room: ${JSON.stringify(result)}`);
+ throw new Error(
+ `from-yaml did not make one room: ${JSON.stringify(result)}`,
+ );
}
const roomId = result.room_id;
- if (result.failed_attachments !== undefined && result.failed_attachments.length > 0) {
+ if (
+ result.failed_attachments !== undefined &&
+ result.failed_attachments.length > 0
+ ) {
throw await this.withRoomDeleted(
roomId,
new Error(
`from-yaml made room ${roomId} without part of what it was given: ` +
- JSON.stringify(result.failed_attachments)
- )
+ JSON.stringify(result.failed_attachments),
+ ),
);
}
try {
@@ -649,18 +723,23 @@ export class SwitchClient {
}
/** Delete a room a call made before failing, and return the failure, saying whether the room went too. */
- private async withRoomDeleted(roomId: string, failure: unknown): Promise<Error> {
+ private async withRoomDeleted(
+ roomId: string,
+ failure: unknown,
+ ): Promise<Error> {
const reason = failure instanceof Error ? failure.message : String(failure);
try {
await this.deleteRoom(roomId);
- return new Error(`${reason} (room ${roomId} was deleted)`, { cause: failure });
+ return new Error(`${reason} (room ${roomId} was deleted)`, {
+ cause: failure,
+ });
} catch (cleanup) {
const why = cleanup instanceof Error ? cleanup.message : String(cleanup);
return new Error(
`${reason} (and room ${roomId} could not be deleted, delete it by hand: ${why})`,
{
cause: failure,
- }
+ },
);
}
}
@@ -673,7 +752,7 @@ export class SwitchClient {
*/
async findRoomByExternalChannel(
bridgeId: string,
- externalChannelId: string
+ externalChannelId: string,
): Promise<RoomDetail | null> {
const rooms = await this.listRooms();
for (const room of rooms) {
@@ -688,7 +767,7 @@ export class SwitchClient {
async waitForRoomByExternalChannel(
bridgeId: string,
externalChannelId: string,
- deadlineMs: number
+ deadlineMs: number,
): Promise<RoomDetail> {
const until = Date.now() + deadlineMs;
let last: RoomDetail | null = null;
@@ -699,7 +778,7 @@ export class SwitchClient {
}
throw new Error(
`No Switch room appeared for Mattermost channel ${externalChannelId} within ${deadlineMs}ms. ` +
- `Is the Mattermost bridge running and is the agent's bot a member of the channel?`
+ `Is the Mattermost bridge running and is the agent's bot a member of the channel?`,
);
}
@@ -718,14 +797,14 @@ export class SwitchClient {
* be added to a channel.
*/
async registerKnownAgent(params: {
- agentType: 'opencode' | 'codex' | 'claude-code' | 'antigravity' | 'cursor';
+ agentType: "opencode" | "codex" | "claude-code" | "antigravity" | "cursor";
name: string;
description: string;
options?: Record<string, unknown>;
}): Promise<RegisteredAgent> {
const body = await this.request<{ id: string; api_key: string }>(
- 'POST',
- '/agents/register-known',
+ "POST",
+ "/agents/register-known",
{
token: this.registrationToken,
body: {
@@ -734,7 +813,7 @@ export class SwitchClient {
description: params.description,
options: params.options ?? {},
},
- }
+ },
);
this.issued.record(body.api_key);
return { id: body.id, name: params.name, apiKey: body.api_key };
@@ -746,7 +825,9 @@ export class SwitchClient {
* the path id.
*/
async deleteAgent(agent: RegisteredAgent): Promise<void> {
- await this.request('DELETE', `/agents/${agent.id}`, { token: agent.apiKey });
+ await this.request("DELETE", `/agents/${agent.id}`, {
+ token: agent.apiKey,
+ });
}
// ── agent bridge: acting as an agent ──────────────────────────────────────
@@ -760,11 +841,14 @@ export class SwitchClient {
*
* Returns `[]` on the server's 204 (nothing within the timeout).
*/
- async pollNotifications(agent: RegisteredAgent, timeoutSeconds = 10): Promise<AgentEvent[]> {
+ async pollNotifications(
+ agent: RegisteredAgent,
+ timeoutSeconds = 10,
+ ): Promise<AgentEvent[]> {
const body = await this.request<{ events?: AgentEvent[] } | undefined>(
- 'GET',
+ "GET",
`/agents/${agent.id}/notifications?timeout=${timeoutSeconds}`,
- { token: agent.apiKey, timeoutMs: (timeoutSeconds + 15) * 1000 }
+ { token: agent.apiKey, timeoutMs: (timeoutSeconds + 15) * 1000 },
);
return body?.events ?? [];
}
@@ -773,12 +857,12 @@ export class SwitchClient {
async pollRoomEvents(
agent: RegisteredAgent,
roomId: string,
- timeoutSeconds = 10
+ timeoutSeconds = 10,
): Promise<AgentEvent[]> {
const body = await this.request<{ events?: AgentEvent[] } | undefined>(
- 'GET',
+ "GET",
`/agents/${agent.id}/rooms/${roomId}/events?timeout=${timeoutSeconds}`,
- { token: agent.apiKey, timeoutMs: (timeoutSeconds + 15) * 1000 }
+ { token: agent.apiKey, timeoutMs: (timeoutSeconds + 15) * 1000 },
);
return body?.events ?? [];
}
@@ -791,12 +875,15 @@ export class SwitchClient {
async waitForNotification(
agent: RegisteredAgent,
predicate: (event: AgentEvent) => boolean,
- deadlineMs: number
+ deadlineMs: number,
): Promise<{ match: AgentEvent | null; seen: AgentEvent[] }> {
const until = Date.now() + deadlineMs;
const seen: AgentEvent[] = [];
while (Date.now() < until) {
- const remaining = Math.max(1, Math.min(10, Math.ceil((until - Date.now()) / 1000)));
+ const remaining = Math.max(
+ 1,
+ Math.min(10, Math.ceil((until - Date.now()) / 1000)),
+ );
const events = await this.pollNotifications(agent, remaining);
for (const event of events) {
seen.push(event);
@@ -815,11 +902,23 @@ export class SwitchClient {
async roomHistory(
agent: RegisteredAgent,
roomId: string,
- limit = 20
- ): Promise<{ sender: string; sender_name: string; body: string; timestamp: number | null }[]> {
+ limit = 20,
+ ): Promise<
+ {
+ sender: string;
+ sender_name: string;
+ body: string;
+ timestamp: number | null;
+ }[]
+ > {
const body = await this.request<{
- events: { sender: string; sender_name: string; body: string; timestamp: number | null }[];
- }>('GET', `/agents/${agent.id}/rooms/${roomId}/history?limit=${limit}`, {
+ events: {
+ sender: string;
+ sender_name: string;
+ body: string;
+ timestamp: number | null;
+ }[];
+ }>("GET", `/agents/${agent.id}/rooms/${roomId}/history?limit=${limit}`, {
token: agent.apiKey,
});
return body.events;
@@ -830,11 +929,15 @@ export class SwitchClient {
* the agent. The bridge relays it to Mattermost as the agent's bot. Returns
* the Matrix event id.
*/
- async sendMessage(agent: RegisteredAgent, roomId: string, content: string): Promise<string> {
+ async sendMessage(
+ agent: RegisteredAgent,
+ roomId: string,
+ content: string,
+ ): Promise<string> {
const body = await this.request<{ ok: boolean; event_id: string }>(
- 'POST',
+ "POST",
`/agents/${agent.id}/message`,
- { token: agent.apiKey, body: { room_id: roomId, content } }
+ { token: agent.apiKey, body: { room_id: roomId, content } },
);
return body.event_id;
}
@@ -848,9 +951,9 @@ export class SwitchClient {
*/
async listOperations(agent: RegisteredAgent): Promise<string[]> {
const body = await this.request<{ operations: Record<string, unknown> }>(
- 'GET',
+ "GET",
`/agents/${agent.id}/ops`,
- { token: agent.apiKey }
+ { token: agent.apiKey },
);
return Object.keys(body.operations);
}
@@ -864,12 +967,16 @@ export class SwitchClient {
async callOperation<T>(
agent: RegisteredAgent,
operation: string,
- args: Record<string, unknown>
+ args: Record<string, unknown>,
): Promise<T> {
- const body = await this.request<{ result: T }>('POST', `/agents/${agent.id}/ops/${operation}`, {
- token: agent.apiKey,
- body: args,
- });
+ const body = await this.request<{ result: T }>(
+ "POST",
+ `/agents/${agent.id}/ops/${operation}`,
+ {
+ token: agent.apiKey,
+ body: args,
+ },
+ );
return body.result;
}
@@ -880,7 +987,7 @@ export class SwitchClient {
* rather than DISCONNECTED in rooms with no live session.
*/
async watchHeartbeat(agent: RegisteredAgent): Promise<void> {
- await this.request('POST', `/agents/${agent.id}/watch/heartbeat`, {
+ await this.request("POST", `/agents/${agent.id}/watch/heartbeat`, {
token: agent.apiKey,
body: {},
});
@@ -927,12 +1034,12 @@ function toRoomSummary(row: RawRoom): RoomSummary {
*/
export function sessionCookieFrom(response: Response): string | null {
const raw =
- typeof response.headers.getSetCookie === 'function'
+ typeof response.headers.getSetCookie === "function"
? response.headers.getSetCookie()
- : [response.headers.get('set-cookie') ?? ''];
+ : [response.headers.get("set-cookie") ?? ""];
for (const header of raw) {
- const pair = header.split(';', 1)[0]?.trim();
- if (pair?.startsWith('switch_auth=')) return pair;
+ const pair = header.split(";", 1)[0]?.trim();
+ if (pair?.startsWith("switch_auth=")) return pair;
}
return null;
}
diff --git a/console/tooling-e2e/src/fast/agent-identity.ts b/console/tooling-e2e/src/fast/agent-identity.ts
new file mode 100644
index 000000000..090afcce7
--- /dev/null
+++ b/console/tooling-e2e/src/fast/agent-identity.ts
@@ -0,0 +1,157 @@
+import { expect } from "vitest";
+import type {
+ MattermostClient,
+ MattermostPost,
+} from "../clients/mattermost-client.ts";
+import {
+ eventText,
+ sleep,
+ type RegisteredAgent,
+ type SwitchClient,
+} from "../clients/switch-client.ts";
+import { WRITABLE, type FastScenario } from "./scenario.ts";
+
+/**
+ * Renaming and deleting an agent on the Mattermost bridge, with the harness
+ * playing both the human and the agent:
+ *
+ * 1. a rename from the gateway renames the agent's Mattermost bot in place,
+ * and the new name reaches the agent while the old one does not;
+ * 2. `!rename-agent` from the chat does the same, for the person who owns the
+ * agent or administers the workspace;
+ * 3. `!delete-agent`, confirmed, deletes it.
+ *
+ * Each step builds on the last.
+ */
+export const agentIdentity: FastScenario = {
+ header: {
+ id: "agent-identity",
+ covers: [
+ "PUT /gateway/agents/{agent_id}/name",
+ "POST /gateway/collaborations/{bridge_id}/identities",
+ ],
+ lane: "fast",
+ environments: WRITABLE,
+ owner: "platform",
+ requires: ["mattermost"],
+ },
+ async run({ fixtures, names, switchClient, mattermost, log }) {
+ const mm = mattermost!;
+ const agent = await fixtures.agent("id");
+ const bridged = await fixtures.mattermostRoom("room", [agent]);
+ const bot = bridged.bots.get(agent.id)!;
+ const channelId = bridged.channel.id;
+ // The chat commands recognise the sender through the Switch user who linked
+ // their chat account; the gateway admin the harness signs in as links it.
+ await switchClient.claimIdentity(
+ "mattermost",
+ bridged.human.id,
+ bridged.human.username,
+ );
+ const admin = await mm.waitForBotUser("switch-admin", 30_000);
+ const reaches = (name: string, label: string): Promise<boolean> =>
+ reachesAgent(
+ switchClient,
+ mm,
+ names.marker(label),
+ agent,
+ channelId,
+ name,
+ );
+
+ // ── a rename from the gateway ───────────────────────────────────────────
+ const first = names.name("ida");
+ const result = await switchClient.renameAgent(
+ agent.id,
+ first,
+ "Rename Check",
+ );
+ expect(result.name).toBe(first);
+ expect(result.bridgeFailures).toEqual([]);
+ expect((await mm.waitForBotUser(first, 30_000)).id).toBe(bot.id);
+ expect(await mm.findBotUser(agent.name)).toBeNull();
+ expect(
+ await reaches(first, "new-a"),
+ `@${first} did not reach the renamed agent`,
+ ).toBe(true);
+ expect(
+ await reaches(agent.name, "old-a"),
+ `@${agent.name} still reached the agent`,
+ ).toBe(false);
+ log(`renamed ${agent.name} to ${first} from the gateway`);
+
+ // ── !rename-agent from the chat ─────────────────────────────────────────
+ const second = names.name("idb");
+ let sinceMs = Date.now();
+ await mm.post({ channelId, message: `!rename-agent @${first} ${second}` });
+ await switchReply(mm, channelId, admin.id, sinceMs, /Renamed/);
+ expect((await mm.waitForBotUser(second, 30_000)).id).toBe(bot.id);
+ expect(
+ await reaches(second, "new-b"),
+ `@${second} did not reach the renamed agent`,
+ ).toBe(true);
+ log(`renamed ${first} to ${second} from the chat`);
+
+ // ── !delete-agent, then confirmed ───────────────────────────────────────
+ sinceMs = Date.now();
+ await mm.post({ channelId, message: `!delete-agent @${second}` });
+ await switchReply(mm, channelId, admin.id, sinceMs, /To go ahead/);
+ expect(
+ (await switchClient.listAgents()).some((a) => a.id === agent.id),
+ ).toBe(true);
+
+ sinceMs = Date.now();
+ await mm.post({ channelId, message: `!delete-agent ${second} confirm` });
+ await switchReply(mm, channelId, admin.id, sinceMs, /Deleted/);
+ // The delete reaches the agent list once it has committed.
+ for (let attempt = 0; attempt < 10; attempt++) {
+ if (!(await switchClient.listAgents()).some((a) => a.id === agent.id))
+ break;
+ await sleep(1_000);
+ }
+ expect(
+ (await switchClient.listAgents()).some((a) => a.id === agent.id),
+ ).toBe(false);
+ fixtures.removed(agent);
+ },
+};
+
+async function switchReply(
+ mm: MattermostClient,
+ channelId: string,
+ adminBotId: string,
+ sinceMs: number,
+ pattern: RegExp,
+): Promise<MattermostPost> {
+ const found = await mm.waitForPost({
+ channelId,
+ fromUserId: adminBotId,
+ predicate: (post) => pattern.test(post.message),
+ sinceMs,
+ deadlineMs: 60_000,
+ });
+ if (!found.match) {
+ throw new Error(
+ `Switch never replied with ${pattern}. Transcript: ` +
+ found.transcript.map((p) => `${p.user_id}: ${p.message}`).join(" | "),
+ );
+ }
+ return found.match;
+}
+
+async function reachesAgent(
+ switchClient: SwitchClient,
+ mm: MattermostClient,
+ marker: string,
+ agent: RegisteredAgent,
+ channelId: string,
+ name: string,
+): Promise<boolean> {
+ await mm.post({ channelId, message: `@${name} ping ${marker}` });
+ const seen = await switchClient.waitForNotification(
+ agent,
+ (event) => eventText(event).includes(marker),
+ 20_000,
+ );
+ return seen.match !== null;
+}
diff --git a/console/tooling-e2e/src/fast/index.ts b/console/tooling-e2e/src/fast/index.ts
index c7b7347de..676054e08 100644
--- a/console/tooling-e2e/src/fast/index.ts
+++ b/console/tooling-e2e/src/fast/index.ts
@@ -1,7 +1,8 @@
-import { addressedDelivery, unaddressedHistory } from './agent-messaging.ts';
-import { mattermostRoundtrip } from './mattermost-roundtrip.ts';
-import { operationsFrontDoor } from './operations.ts';
-import type { FastScenario } from './scenario.ts';
+import { agentIdentity } from "./agent-identity.ts";
+import { addressedDelivery, unaddressedHistory } from "./agent-messaging.ts";
+import { mattermostRoundtrip } from "./mattermost-roundtrip.ts";
+import { operationsFrontDoor } from "./operations.ts";
+import type { FastScenario } from "./scenario.ts";
/** Every fast-lane scenario. A scenario not listed here does not run. */
export const FAST_SCENARIOS: readonly FastScenario[] = [
@@ -9,4 +10,5 @@ export const FAST_SCENARIOS: readonly FastScenario[] = [
unaddressedHistory,
operationsFrontDoor,
mattermostRoundtrip,
+ agentIdentity,
];
diff --git a/console/tooling-e2e/src/fixtures/fixtures.ts b/console/tooling-e2e/src/fixtures/fixtures.ts
index 54f9170cf..872a17310 100644
--- a/console/tooling-e2e/src/fixtures/fixtures.ts
+++ b/console/tooling-e2e/src/fixtures/fixtures.ts
@@ -2,15 +2,15 @@ import type {
MattermostChannel,
MattermostClient,
MattermostUser,
-} from '../clients/mattermost-client.ts';
+} from "../clients/mattermost-client.ts";
import {
sleep,
type RegisteredAgent,
type RoomDetail,
type SwitchClient,
-} from '../clients/switch-client.ts';
-import type { HarnessAgentType, HarnessEnv } from '../core/env.ts';
-import type { NameScope } from '../core/run.ts';
+} from "../clients/switch-client.ts";
+import type { HarnessAgentType, HarnessEnv } from "../core/env.ts";
+import type { NameScope } from "../core/run.ts";
/**
* What a scenario stands up, and the teardown that removes it.
@@ -27,12 +27,16 @@ export class Fixtures {
readonly switchClient: SwitchClient;
readonly mattermost: MattermostClient | null;
private readonly cleanups: { label: string; run: () => Promise<void> }[] = [];
+ private readonly agentCleanups = new Map<
+ string,
+ { label: string; run: () => Promise<void> }
+ >();
constructor(
env: HarnessEnv,
names: NameScope,
switchClient: SwitchClient,
- mattermost: MattermostClient | null
+ mattermost: MattermostClient | null,
) {
this.env = env;
this.names = names;
@@ -49,11 +53,15 @@ export class Fixtures {
*/
async agent(
role: string,
- options: { autoSession?: boolean; agentType?: HarnessAgentType; repoDir?: string } = {}
+ options: {
+ autoSession?: boolean;
+ agentType?: HarnessAgentType;
+ repoDir?: string;
+ } = {},
): Promise<RegisteredAgent> {
const name = this.names.name(role);
const agent = await this.switchClient.registerKnownAgent({
- agentType: options.agentType ?? 'opencode',
+ agentType: options.agentType ?? "opencode",
name,
description: `Switch end-to-end harness agent (run ${this.names.runId}). Safe to delete.`,
options: {
@@ -61,13 +69,21 @@ export class Fixtures {
...(options.repoDir ? { repo_dir: options.repoDir } : {}),
},
});
- this.defer(`agent ${name} (${agent.id})`, () => this.switchClient.deleteAgent(agent));
+ const cleanup = {
+ label: `agent ${name} (${agent.id})`,
+ run: () => this.switchClient.deleteAgent(agent),
+ };
+ this.cleanups.push(cleanup);
+ this.agentCleanups.set(agent.id, cleanup);
await this.switchClient.openAddressing(agent.id);
return agent;
}
/** A room with no platform channel: agents only, no bridge involved. */
- async internalRoom(role: string, agents: RegisteredAgent[]): Promise<RoomDetail> {
+ async internalRoom(
+ role: string,
+ agents: RegisteredAgent[],
+ ): Promise<RoomDetail> {
const name = this.names.name(role);
const room = await this.switchClient.createRoom({
name,
@@ -76,9 +92,13 @@ export class Fixtures {
agentNames: agents.map((agent) => agent.name),
userNames: [],
});
- this.defer(`room ${name} (${room.id})`, () => this.switchClient.deleteRoom(room.id));
+ this.defer(`room ${name} (${room.id})`, () =>
+ this.switchClient.deleteRoom(room.id),
+ );
if (room.externalChannelId !== null) {
- throw new Error(`Internal-only room ${room.id} came back with a platform channel.`);
+ throw new Error(
+ `Internal-only room ${room.id} came back with a platform channel.`,
+ );
}
return room;
}
@@ -92,10 +112,13 @@ export class Fixtures {
* the bot is the first in a new channel, because nobody's websocket witnesses
* the join.
*/
- async mattermostRoom(role: string, agents: RegisteredAgent[]): Promise<BridgedRoom> {
+ async mattermostRoom(
+ role: string,
+ agents: RegisteredAgent[],
+ ): Promise<BridgedRoom> {
const mattermost = this.requireMattermost();
const human = await mattermost.me();
- const bridgeId = await this.switchClient.defaultBridgeId('mattermost');
+ const bridgeId = await this.switchClient.defaultBridgeId("mattermost");
// Resolved even though room creation does not need it: it fails fast and
// clearly when MATTERMOST_TEAM names a team that does not exist.
await mattermost.findTeam(this.mattermostTeam());
@@ -118,23 +141,26 @@ export class Fixtures {
const channelId = room.externalChannelId;
// One step, in order: the room first, then its channel only if deleting the
// room did not already archive it.
- this.defer(`room ${name} (${room.id}) and channel ${channelId ?? 'none'}`, async () => {
- await this.switchClient.deleteRoom(room.id);
- if (channelId === null) return;
- const left = await mattermost.getChannel(channelId);
- if (!left.delete_at) await mattermost.archiveChannel(channelId);
- });
+ this.defer(
+ `room ${name} (${room.id}) and channel ${channelId ?? "none"}`,
+ async () => {
+ await this.switchClient.deleteRoom(room.id);
+ if (channelId === null) return;
+ const left = await mattermost.getChannel(channelId);
+ if (!left.delete_at) await mattermost.archiveChannel(channelId);
+ },
+ );
if (channelId === null) {
throw new Error(
`Switch room ${room.id} was created without a Mattermost channel — ` +
- `the collaboration bridge did not provision one.`
+ `the collaboration bridge did not provision one.`,
);
}
const channel = await mattermost.getChannel(channelId);
const bridged: BridgedRoom = { room, channel, human, bots };
const witness = agents[0];
- if (!witness) throw new Error('A bridged room needs at least one agent.');
+ if (!witness) throw new Error("A bridged room needs at least one agent.");
await waitForBridgeReady({
switchClient: this.switchClient,
mattermost,
@@ -146,6 +172,18 @@ export class Fixtures {
return bridged;
}
+ /**
+ * The scenario deleted `agent` itself, and checked that it is gone, so
+ * teardown has nothing left to remove for it.
+ */
+ removed(agent: RegisteredAgent): void {
+ const cleanup = this.agentCleanups.get(agent.id);
+ if (cleanup === undefined)
+ throw new Error(`Agent ${agent.id} was not registered here.`);
+ this.agentCleanups.delete(agent.id);
+ this.cleanups.splice(this.cleanups.indexOf(cleanup), 1);
+ }
+
/** Register a cleanup step for something created outside these helpers. */
defer(label: string, run: () => Promise<void>): void {
this.cleanups.push({ label, run });
@@ -169,7 +207,7 @@ export class Fixtures {
await cleanup.run();
} catch (error) {
failures.push(
- `could not remove ${cleanup.label}: ${error instanceof Error ? error.message : String(error)}`
+ `could not remove ${cleanup.label}: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -179,15 +217,15 @@ export class Fixtures {
private requireMattermost(): MattermostClient {
if (!this.mattermost) {
throw new Error(
- 'This scenario needs Mattermost but none is configured — declare ' +
- "`requires: ['mattermost']` in its header so it is skipped or failed up front."
+ "This scenario needs Mattermost but none is configured — declare " +
+ "`requires: ['mattermost']` in its header so it is skipped or failed up front.",
);
}
return this.mattermost;
}
private mattermostTeam(): string {
- if (!this.env.mattermost) throw new Error('No Mattermost configured.');
+ if (!this.env.mattermost) throw new Error("No Mattermost configured.");
return this.env.mattermost.team;
}
}
@@ -237,8 +275,15 @@ export async function waitForBridgeReady(params: {
// Re-post rather than only re-read: if the socket was down when the last
// one went out, that message is gone for good and no amount of polling
// will produce it.
- await params.mattermost.post({ channelId: params.channel.id, message: probe });
- const history = await params.switchClient.roomHistory(params.agent, params.room.id, 50);
+ await params.mattermost.post({
+ channelId: params.channel.id,
+ message: probe,
+ });
+ const history = await params.switchClient.roomHistory(
+ params.agent,
+ params.room.id,
+ 50,
+ );
if (history.some((event) => event.body.includes(probe))) return;
await sleep(5_000);
}
@@ -246,6 +291,6 @@ export async function waitForBridgeReady(params: {
throw new Error(
`Mattermost -> Switch delivery never came up for room ${params.room.id} ` +
`(channel ${params.channel.id}) within ${deadlineMs}ms: a plain channel message ` +
- `never reached the agent's room history. The agent bot's websocket is probably not connected.`
+ `never reached the agent's room history. The agent bot's websocket is probably not connected.`,
);
}
diff --git a/console/tooling-e2e/surface/exemptions.json b/console/tooling-e2e/surface/exemptions.json
index 68f4b7f7f..ce3f821fb 100644
--- a/console/tooling-e2e/surface/exemptions.json
+++ b/console/tooling-e2e/surface/exemptions.json
@@ -35,12 +35,10 @@
"POST /gateway/auth/signup": "How an account, and its first session, is created."
},
"backlog": [
- "accept_task",
"add_users_to_room",
"archive_room",
"assume_role",
"attach_reference_to_room",
- "cancel_task",
"create_agent",
"create_reference",
"create_room",
@@ -48,12 +46,10 @@
"create_room_from_yaml",
"create_room_group",
"define_role",
- "delegate_task",
"delete_role",
"delete_room_document",
"delete_template",
"edit_role",
- "finalise_task",
"get_advanced_config",
"get_agent_detail",
"get_my_context",
@@ -76,11 +72,12 @@
"list_references",
"list_roles",
"list_room_groups",
- "list_tasks",
"list_templates",
"load_internal_documents",
"release_role",
+ "remove_agent_from_room",
"remove_agent_service",
+ "request_agent_deletion",
"run_template",
"save_template",
"send_targeted_message",
@@ -90,7 +87,6 @@
"update_agent_detail",
"update_room",
"update_room_document",
- "update_task",
"update_template",
"DELETE /gateway/agents/by-name/{agent_name}",
"DELETE /gateway/agents/{agent_id}",
@@ -253,7 +249,6 @@
"POST /gateway/collaborations",
"POST /gateway/collaborations/setup/slack/check",
"POST /gateway/collaborations/{bridge_id}/default",
- "POST /gateway/collaborations/{bridge_id}/identities",
"POST /gateway/collaborations/{bridge_id}/teams/{team_id}",
"POST /gateway/connector-apps/{service}/check",
"POST /gateway/connector-apps/{service}/import",
diff --git a/console/tooling-e2e/surface/server-surface.json b/console/tooling-e2e/surface/server-surface.json
index 67634a36c..07c838125 100644
--- a/console/tooling-e2e/surface/server-surface.json
+++ b/console/tooling-e2e/surface/server-surface.json
@@ -1,12 +1,10 @@
{
"_generated": "by scripts/e2e_surface.py; do not edit. Run `just e2e-surface`.",
"operations": [
- "accept_task",
"add_users_to_room",
"archive_room",
"assume_role",
"attach_reference_to_room",
- "cancel_task",
"connect_to_room",
"create_agent",
"create_reference",
@@ -15,12 +13,10 @@
"create_room_from_yaml",
"create_room_group",
"define_role",
- "delegate_task",
"delete_role",
"delete_room_document",
"delete_template",
"edit_role",
- "finalise_task",
"get_advanced_config",
"get_agent_detail",
"get_my_context",
@@ -44,13 +40,14 @@
"list_roles",
"list_room_groups",
"list_rooms",
- "list_tasks",
"list_templates",
"load_internal_documents",
"post_message",
"read_context",
"release_role",
+ "remove_agent_from_room",
"remove_agent_service",
+ "request_agent_deletion",
"run_template",
"save_template",
"send_targeted_message",
@@ -60,7 +57,6 @@
"update_agent_detail",
"update_room",
"update_room_document",
- "update_task",
"update_template"
],
"gatewayRoutes": [
@@ -1321,6 +1317,11 @@
"auth": "session",
"flags": []
},
+ {
+ "route": "PUT /gateway/agents/{agent_id}/name",
+ "auth": "session",
+ "flags": []
+ },
{
"route": "PUT /gateway/agents/{agent_id}/service-grants/{service}",
"auth": "session",