Add Hub Console with agent management and message routing
Implement Hub that auto-connects to Gateway, manages agents via REST API, and routes WebSocket messages to agents by payload.agentId with echo responses sent back to the original sender. - Add Hub with GatewayClient auto-connect, agent CRUD, and message routing - Add Console (NestJS) with REST API and static pages (management + demo client) - Switch Gateway registration from explicit event to query-based on connect - Remove deprecated types (RegisterPayload, metadata, SendMessagePayload) - Add @nestjs/serve-static for serving console UI Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4b3592b5e4
commit
dcca9333ab
18 changed files with 773 additions and 79 deletions
45
src/console/app.controller.ts
Normal file
45
src/console/app.controller.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Delete,
|
||||
Param,
|
||||
Body,
|
||||
Inject,
|
||||
} from "@nestjs/common";
|
||||
import { Hub } from "../hub/hub.js";
|
||||
|
||||
@Controller("api")
|
||||
export class AppController {
|
||||
constructor(@Inject("HUB") private readonly hub: Hub) {}
|
||||
|
||||
@Get("hub")
|
||||
getHub() {
|
||||
return {
|
||||
deviceId: this.hub.deviceId,
|
||||
url: this.hub.url,
|
||||
connectionState: this.hub.connectionState,
|
||||
agentCount: this.hub.listAgents().length,
|
||||
};
|
||||
}
|
||||
|
||||
@Get("agents")
|
||||
listAgents() {
|
||||
return this.hub.listAgents().map((id) => {
|
||||
const agent = this.hub.getAgent(id);
|
||||
return { id, closed: agent?.closed ?? true };
|
||||
});
|
||||
}
|
||||
|
||||
@Post("agents")
|
||||
createAgent(@Body() body?: { id?: string }) {
|
||||
const agent = this.hub.createAgent(body?.id);
|
||||
return { id: agent.id };
|
||||
}
|
||||
|
||||
@Delete("agents/:id")
|
||||
deleteAgent(@Param("id") id: string) {
|
||||
const ok = this.hub.closeAgent(id);
|
||||
return { ok };
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue