UNPKG

@iqai/adk-cli

Version:

CLI tool for creating, running, and testing ADK-TS agents

116 lines 5.46 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SessionsController = void 0; const common_1 = require("@nestjs/common"); const swagger_1 = require("@nestjs/swagger"); const api_dto_1 = require("../dto/api.dto"); const sessions_service_1 = require("./sessions.service"); let SessionsController = class SessionsController { sessions; constructor(sessions) { this.sessions = sessions; } async listSessions(id) { const agentPath = decodeURIComponent(id); return this.sessions.listSessions(agentPath); } async createSession(id, request) { const agentPath = decodeURIComponent(id); return this.sessions.createSession(agentPath, request); } async deleteSession(id, sessionId) { const agentPath = decodeURIComponent(id); return this.sessions.deleteSession(agentPath, sessionId); } async switchSession(id, sessionId) { const agentPath = decodeURIComponent(id); return this.sessions.switchSession(agentPath, sessionId); } }; exports.SessionsController = SessionsController; __decorate([ (0, common_1.Get)(), (0, swagger_1.ApiOperation)({ summary: "List sessions for an agent", description: "Returns all active sessions for the specified agent including metadata.", }), (0, swagger_1.ApiParam)({ name: "id", description: "URL-encoded absolute agent path or identifier", }), (0, swagger_1.ApiOkResponse)({ type: api_dto_1.SessionsResponseDto }), __param(0, (0, common_1.Param)("id")), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], SessionsController.prototype, "listSessions", null); __decorate([ (0, common_1.Post)(), (0, swagger_1.ApiOperation)({ summary: "Create a new session", description: "Creates a session for the agent. Optional state and custom sessionId may be provided.", }), (0, swagger_1.ApiParam)({ name: "id", description: "URL-encoded absolute agent path or identifier", }), (0, swagger_1.ApiBody)({ description: "Initial session creation payload with optional state", schema: { example: { state: { foo: "bar" }, sessionId: "custom-id-123" } }, }), (0, swagger_1.ApiOkResponse)({ type: api_dto_1.SessionResponseDto }), __param(0, (0, common_1.Param)("id")), __param(1, (0, common_1.Body)()), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object]), __metadata("design:returntype", Promise) ], SessionsController.prototype, "createSession", null); __decorate([ (0, common_1.Delete)(":sessionId"), (0, swagger_1.ApiOperation)({ summary: "Delete a session", description: "Stops and removes the session if it exists.", }), (0, swagger_1.ApiParam)({ name: "id", description: "Agent identifier" }), (0, swagger_1.ApiParam)({ name: "sessionId", description: "Session to delete" }), (0, swagger_1.ApiOkResponse)({ type: api_dto_1.SuccessResponseDto }), __param(0, (0, common_1.Param)("id")), __param(1, (0, common_1.Param)("sessionId")), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise) ], SessionsController.prototype, "deleteSession", null); __decorate([ (0, common_1.Post)(":sessionId/switch"), (0, swagger_1.ApiOperation)({ summary: "Switch active session", description: "Marks the specified session as active (implementation specific).", }), (0, swagger_1.ApiParam)({ name: "id", description: "Agent identifier" }), (0, swagger_1.ApiParam)({ name: "sessionId", description: "Session to switch to" }), (0, swagger_1.ApiOkResponse)({ type: api_dto_1.SuccessResponseDto }), __param(0, (0, common_1.Param)("id")), __param(1, (0, common_1.Param)("sessionId")), __metadata("design:type", Function), __metadata("design:paramtypes", [String, String]), __metadata("design:returntype", Promise) ], SessionsController.prototype, "switchSession", null); exports.SessionsController = SessionsController = __decorate([ (0, swagger_1.ApiTags)("sessions"), (0, common_1.Controller)("api/agents/:id/sessions"), __param(0, (0, common_1.Inject)(sessions_service_1.SessionsService)), __metadata("design:paramtypes", [sessions_service_1.SessionsService]) ], SessionsController); //# sourceMappingURL=sessions.controller.js.map