Compare commits
1 Commits
feat/ms22-
...
feat/ms22-
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c7f35f881 |
@@ -99,8 +99,7 @@ export class ChatProxyController {
|
||||
const upstreamResponse = await this.chatProxyService.proxyChat(
|
||||
userId,
|
||||
body.messages,
|
||||
abortController.signal,
|
||||
body.agent
|
||||
abortController.signal
|
||||
);
|
||||
|
||||
const upstreamContentType = upstreamResponse.headers.get("content-type");
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import { Type } from "class-transformer";
|
||||
import {
|
||||
ArrayMinSize,
|
||||
IsArray,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
import { ArrayMinSize, IsArray, IsNotEmpty, IsString, ValidateNested } from "class-validator";
|
||||
|
||||
export interface ChatMessage {
|
||||
role: string;
|
||||
@@ -29,8 +22,4 @@ export class ChatStreamDto {
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => ChatMessageDto)
|
||||
messages!: ChatMessageDto[];
|
||||
|
||||
@IsString({ message: "agent must be a string" })
|
||||
@IsOptional()
|
||||
agent?: string;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import {
|
||||
BadGatewayException,
|
||||
Injectable,
|
||||
Logger,
|
||||
NotFoundException,
|
||||
ServiceUnavailableException,
|
||||
} from "@nestjs/common";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
@@ -19,13 +18,6 @@ interface ContainerConnection {
|
||||
token: string;
|
||||
}
|
||||
|
||||
interface AgentConfig {
|
||||
name: string;
|
||||
displayName: string;
|
||||
personality: string;
|
||||
primaryModel: string | null;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class ChatProxyService {
|
||||
private readonly logger = new Logger(ChatProxyService.name);
|
||||
@@ -46,38 +38,21 @@ export class ChatProxyService {
|
||||
async proxyChat(
|
||||
userId: string,
|
||||
messages: ChatMessage[],
|
||||
signal?: AbortSignal,
|
||||
agentName?: string
|
||||
signal?: AbortSignal
|
||||
): Promise<Response> {
|
||||
const { url: containerUrl, token: gatewayToken } = await this.getContainerConnection(userId);
|
||||
|
||||
// Get agent config if specified
|
||||
let agentConfig: AgentConfig | null = null;
|
||||
if (agentName) {
|
||||
agentConfig = await this.getAgentConfig(userId, agentName);
|
||||
}
|
||||
|
||||
const model = agentConfig?.primaryModel ?? (await this.getPreferredModel(userId));
|
||||
|
||||
const requestBody: Record<string, unknown> = {
|
||||
messages,
|
||||
model,
|
||||
stream: true,
|
||||
};
|
||||
|
||||
// Add agent config if available
|
||||
if (agentConfig) {
|
||||
requestBody.agent = agentConfig.name;
|
||||
requestBody.agent_personality = agentConfig.personality;
|
||||
}
|
||||
|
||||
const model = await this.getPreferredModel(userId);
|
||||
const requestInit: RequestInit = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${gatewayToken}`,
|
||||
},
|
||||
body: JSON.stringify(requestBody),
|
||||
body: JSON.stringify({
|
||||
messages,
|
||||
model,
|
||||
stream: true,
|
||||
}),
|
||||
};
|
||||
|
||||
if (signal) {
|
||||
@@ -195,32 +170,4 @@ export class ChatProxyService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async getAgentConfig(userId: string, agentName: string): Promise<AgentConfig> {
|
||||
const agent = await this.prisma.userAgent.findUnique({
|
||||
where: { userId_name: { userId, name: agentName } },
|
||||
select: {
|
||||
name: true,
|
||||
displayName: true,
|
||||
personality: true,
|
||||
primaryModel: true,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!agent) {
|
||||
throw new NotFoundException(`Agent "${agentName}" not found for user`);
|
||||
}
|
||||
|
||||
if (!agent.isActive) {
|
||||
throw new NotFoundException(`Agent "${agentName}" is not active`);
|
||||
}
|
||||
|
||||
return {
|
||||
name: agent.name,
|
||||
displayName: agent.displayName,
|
||||
personality: agent.personality,
|
||||
primaryModel: agent.primaryModel,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,21 +26,11 @@ export class UserAgentController {
|
||||
return this.userAgentService.findAll(user.id);
|
||||
}
|
||||
|
||||
@Get("status")
|
||||
getAllStatuses(@CurrentUser() user: AuthUser) {
|
||||
return this.userAgentService.getAllStatuses(user.id);
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
findOne(@CurrentUser() user: AuthUser, @Param("id", ParseUUIDPipe) id: string) {
|
||||
return this.userAgentService.findOne(user.id, id);
|
||||
}
|
||||
|
||||
@Get(":id/status")
|
||||
getStatus(@CurrentUser() user: AuthUser, @Param("id", ParseUUIDPipe) id: string) {
|
||||
return this.userAgentService.getStatus(user.id, id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@CurrentUser() user: AuthUser, @Body() dto: CreateUserAgentDto) {
|
||||
return this.userAgentService.create(user.id, dto);
|
||||
|
||||
@@ -8,15 +8,6 @@ import { PrismaService } from "../prisma/prisma.service";
|
||||
import { CreateUserAgentDto } from "./dto/create-user-agent.dto";
|
||||
import { UpdateUserAgentDto } from "./dto/update-user-agent.dto";
|
||||
|
||||
export interface AgentStatusResponse {
|
||||
id: string;
|
||||
name: string;
|
||||
displayName: string;
|
||||
role: string;
|
||||
isActive: boolean;
|
||||
containerStatus?: "running" | "stopped" | "unknown";
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserAgentService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
@@ -128,26 +119,4 @@ export class UserAgentService {
|
||||
await this.findOne(userId, id);
|
||||
return this.prisma.userAgent.delete({ where: { id } });
|
||||
}
|
||||
|
||||
async getStatus(userId: string, id: string): Promise<AgentStatusResponse> {
|
||||
const agent = await this.findOne(userId, id);
|
||||
return {
|
||||
id: agent.id,
|
||||
name: agent.name,
|
||||
displayName: agent.displayName,
|
||||
role: agent.role,
|
||||
isActive: agent.isActive,
|
||||
};
|
||||
}
|
||||
|
||||
async getAllStatuses(userId: string): Promise<AgentStatusResponse[]> {
|
||||
const agents = await this.findAll(userId);
|
||||
return agents.map((agent) => ({
|
||||
id: agent.id,
|
||||
name: agent.name,
|
||||
displayName: agent.displayName,
|
||||
role: agent.role,
|
||||
isActive: agent.isActive,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
|
||||
## Milestones
|
||||
|
||||
| # | ID | Name | Status | Tasks | Notes |
|
||||
| --- | ------------- | ------------- | ---------- | -------------- | --------------------- |
|
||||
| 1 | schema-seed | Schema+Seed | ✅ done | P2-001, P2-002 | PRs #675, #677 merged |
|
||||
| 2 | admin-crud | Admin CRUD | ✅ done | P2-003 | PR #678 merged |
|
||||
| 3 | user-crud | User CRUD | ✅ done | P2-004 | PR #682 merged |
|
||||
| 4 | agent-routing | Agent Routing | ⬜ pending | P2-005, P2-006 | Depends on M3 |
|
||||
| 5 | discord-ui | Discord+UI | ⬜ pending | P2-007, P2-008 | Depends on M4 |
|
||||
| 6 | verification | Verification | ⬜ pending | P2-009, P2-010 | Final gate |
|
||||
| # | ID | Name | Status | Tasks | Notes |
|
||||
| --- | ------------- | ------------- | -------------- | -------------- | --------------------- |
|
||||
| 1 | schema-seed | Schema+Seed | ✅ done | P2-001, P2-002 | PRs #675, #677 merged |
|
||||
| 2 | admin-crud | Admin CRUD | ✅ done | P2-003 | PR #678 merged |
|
||||
| 3 | user-crud | User CRUD | 🔄 in-progress | P2-004 | Depends on M2 |
|
||||
| 4 | agent-routing | Agent Routing | ⬜ pending | P2-005, P2-006 | Depends on M3 |
|
||||
| 5 | discord-ui | Discord+UI | ⬜ pending | P2-007, P2-008 | Depends on M4 |
|
||||
| 6 | verification | Verification | ⬜ pending | P2-009, P2-010 | Final gate |
|
||||
|
||||
## Task Summary
|
||||
|
||||
@@ -42,7 +42,7 @@ See `docs/TASKS.md` — MS22 Phase 2 section for full task details.
|
||||
| P2-001 Schema | ✅ done | #675 | AgentTemplate + UserAgent |
|
||||
| P2-002 Seed | ✅ done | #677 | jarvis/builder/medic templates |
|
||||
| P2-003 Admin CRUD | ✅ done | #678 | /admin/agent-templates |
|
||||
| P2-004 User CRUD | ✅ done | #682 | /api/agents |
|
||||
| P2-004 User CRUD | 🔄 in-progress | — | |
|
||||
| P2-005 Status endpoints | ⬜ not-started | — | |
|
||||
| P2-006 Chat routing | ⬜ not-started | — | |
|
||||
| P2-007 Discord routing | ⬜ not-started | — | |
|
||||
@@ -55,14 +55,14 @@ See `docs/TASKS.md` — MS22 Phase 2 section for full task details.
|
||||
| Phase | Est | Used |
|
||||
| ----------------- | -------- | -------------------- |
|
||||
| Schema+Seed+CRUD | 30K | ~15K (done directly) |
|
||||
| User CRUD+Routing | 40K | ~25K |
|
||||
| User CRUD+Routing | 40K | — |
|
||||
| Discord+UI | 30K | — |
|
||||
| Verification | 10K | — |
|
||||
| **Total** | **110K** | **~40K** |
|
||||
| **Total** | **110K** | **~15K** |
|
||||
|
||||
## Session Log
|
||||
|
||||
| Date | Work Done |
|
||||
| ---------- | --------------------------------------------------------------------------------------------------------- |
|
||||
| 2026-03-04 | Session 2: Fixed CI security audit, merged PRs #681, #678, #682. Milestones 1-3 complete (4/6 remaining). |
|
||||
| 2026-03-04 | P2-001..003 shipped; CI fix; postgres rebuilt; mission initialized |
|
||||
| Date | Work Done |
|
||||
| ---------- | ----------------------------------------------------------------------------------------------- |
|
||||
| 2026-03-04 | Session 2: Fixed CI security audit (multer override), merged PR #678, starting P2-004 User CRUD |
|
||||
| 2026-03-04 | P2-001..003 shipped; CI fix; postgres rebuilt; mission initialized |
|
||||
|
||||
@@ -99,8 +99,8 @@ PRD: `docs/PRD-MS22-P2-AGENT-FLEET.md`
|
||||
| MS22-P2-001 | done | p2-fleet | Prisma schema: AgentTemplate, UserAgent | TASKS:P2 | api | feat/ms22-p2-agent-schema | MS22-P1a | P2-002,P2-003 | orchestrator | 2026-03-04 | 2026-03-04 | 10K | 3K | PR #675 merged |
|
||||
| MS22-P2-002 | done | p2-fleet | Seed default agents (jarvis, builder, medic) | TASKS:P2 | api | feat/ms22-p2-agent-seed | P2-001 | P2-004 | orchestrator | 2026-03-04 | 2026-03-04 | 5K | 2K | PR #677 merged |
|
||||
| MS22-P2-003 | done | p2-fleet | Agent template CRUD endpoints (admin) | TASKS:P2 | api | feat/ms22-p2-agent-crud | P2-001 | P2-005 | orchestrator | 2026-03-04 | 2026-03-04 | 15K | 5K | PR #678 merged |
|
||||
| MS22-P2-004 | done | p2-fleet | User agent CRUD endpoints | TASKS:P2 | api | feat/ms22-p2-user-agents | P2-002,P2-003 | P2-006 | orchestrator | 2026-03-04 | 2026-03-04 | 15K | 8K | PR #682 merged |
|
||||
| MS22-P2-005 | in-progress | p2-fleet | Agent status endpoints | TASKS:P2 | api | feat/ms22-p2-agent-status | P2-003 | P2-008 | orchestrator | 2026-03-04 | — | 10K | — | |
|
||||
| MS22-P2-004 | in-progress | p2-fleet | User agent CRUD endpoints | TASKS:P2 | api | feat/ms22-p2-user-agents | P2-002,P2-003 | P2-006 | orchestrator | 2026-03-04 | — | 15K | — | |
|
||||
| MS22-P2-005 | not-started | p2-fleet | Agent status endpoints | TASKS:P2 | api | feat/ms22-p2-agent-api | P2-003 | P2-008 | — | — | — | 10K | — | |
|
||||
| MS22-P2-006 | not-started | p2-fleet | Agent chat routing (select agent by name) | TASKS:P2 | api | feat/ms22-p2-agent-routing | P2-004 | P2-007 | — | — | — | 15K | — | |
|
||||
| MS22-P2-007 | not-started | p2-fleet | Discord channel → agent routing | TASKS:P2 | api | feat/ms22-p2-discord-router | P2-006 | P2-009 | — | — | — | 15K | — | |
|
||||
| MS22-P2-008 | not-started | p2-fleet | Agent list/selector UI in WebUI | TASKS:P2 | web | feat/ms22-p2-agent-ui | P2-005 | — | — | — | — | 15K | — | |
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
|
||||
## Session Log
|
||||
|
||||
| Session | Date | Milestone | Tasks Done | Outcome |
|
||||
| ------- | ---------- | --------- | ---------------------- | ------------------------------------------------------------------------------ |
|
||||
| 2 | 2026-03-04 | M1+M2+M3 | P2-004 done | Fixed CI security audit, merged PRs #681, #678, #682. Milestones 1-3 complete. |
|
||||
| 1 | 2026-03-04 | M1+M2 | P2-001, P2-002, P2-003 | Schema, seed, and Admin CRUD complete |
|
||||
| Session | Date | Milestone | Tasks Done | Outcome |
|
||||
| ------- | ---------- | ----------- | ---------------------- | ---------------------------------------------------------------------------------------- |
|
||||
| 2 | 2026-03-04 | M3-UserCRUD | P2-004 in-progress | Fixed CI security audit (multer>=2.1.1), merged PR #678 (Admin CRUD), starting User CRUD |
|
||||
| 1 | 2026-03-04 | M1+M2 | P2-001, P2-002, P2-003 | Schema, seed, and Admin CRUD complete |
|
||||
|
||||
## Open Questions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user