@agentick/nestjs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,217 @@
1
+ /**
2
+ * TentickleController - Default NestJS controller for Tentickle endpoints.
3
+ *
4
+ * Provides multiplexed SSE endpoints matching Express adapter API.
5
+ *
6
+ * @module @tentickle/nestjs/controller
7
+ */
8
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
9
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11
+ 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;
12
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
13
+ };
14
+ var __metadata = (this && this.__metadata) || function (k, v) {
15
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
16
+ };
17
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
18
+ return function (target, key) { decorator(target, key, paramIndex); }
19
+ };
20
+ import { Controller, Post, Get, Body, Res, HttpException, HttpStatus } from "@nestjs/common";
21
+ import { TentickleService } from "./tentickle.service";
22
+ // ============================================================================
23
+ // Controller
24
+ // ============================================================================
25
+ /**
26
+ * Default controller for Tentickle endpoints.
27
+ *
28
+ * Provides multiplexed SSE with per-session subscriptions.
29
+ *
30
+ * @example Using the default controller
31
+ * ```typescript
32
+ * @Module({
33
+ * imports: [TentickleModule.forRoot({ app })],
34
+ * })
35
+ * export class AppModule {}
36
+ * ```
37
+ *
38
+ * @example Custom controller
39
+ * ```typescript
40
+ * @Module({
41
+ * imports: [TentickleModule.forRoot({ app, registerController: false })],
42
+ * controllers: [MyController],
43
+ * })
44
+ * export class AppModule {}
45
+ * ```
46
+ */
47
+ let TentickleController = class TentickleController {
48
+ tentickle;
49
+ constructor(tentickle) {
50
+ this.tentickle = tentickle;
51
+ }
52
+ /**
53
+ * SSE endpoint for multiplexed events.
54
+ *
55
+ * GET /events
56
+ */
57
+ events(res) {
58
+ this.tentickle.createConnection(res);
59
+ }
60
+ /**
61
+ * Subscribe to sessions.
62
+ *
63
+ * POST /subscribe
64
+ */
65
+ async subscribe(body) {
66
+ if (!body.connectionId) {
67
+ throw new HttpException("connectionId is required", HttpStatus.BAD_REQUEST);
68
+ }
69
+ const { connectionId, add = [], remove = [] } = body;
70
+ if (add.length > 0) {
71
+ await this.tentickle.subscribe(connectionId, add);
72
+ }
73
+ if (remove.length > 0) {
74
+ await this.tentickle.unsubscribe(connectionId, remove);
75
+ }
76
+ return { success: true };
77
+ }
78
+ /**
79
+ * Send message and stream events.
80
+ *
81
+ * POST /send
82
+ */
83
+ async send(body, res) {
84
+ const { sessionId, message, messages, props, metadata } = body;
85
+ // Build valid SendInput - must have message OR messages (not neither)
86
+ let input;
87
+ if (message) {
88
+ input = { message };
89
+ }
90
+ else if (messages && messages.length > 0) {
91
+ input = { messages };
92
+ }
93
+ else {
94
+ throw new HttpException("Either message or messages is required", HttpStatus.BAD_REQUEST);
95
+ }
96
+ // Add optional fields
97
+ const sendInput = {
98
+ ...input,
99
+ ...(props && { props }),
100
+ ...(metadata && { metadata }),
101
+ };
102
+ await this.tentickle.sendAndStream(sessionId, sendInput, res);
103
+ }
104
+ /**
105
+ * Abort execution.
106
+ *
107
+ * POST /abort
108
+ */
109
+ async abort(body) {
110
+ if (!body.sessionId) {
111
+ throw new HttpException("sessionId is required", HttpStatus.BAD_REQUEST);
112
+ }
113
+ await this.tentickle.abort(body.sessionId, body.reason);
114
+ return { success: true };
115
+ }
116
+ /**
117
+ * Close session.
118
+ *
119
+ * POST /close
120
+ */
121
+ async close(body) {
122
+ if (!body.sessionId) {
123
+ throw new HttpException("sessionId is required", HttpStatus.BAD_REQUEST);
124
+ }
125
+ await this.tentickle.close(body.sessionId);
126
+ return { success: true };
127
+ }
128
+ /**
129
+ * Submit tool confirmation response.
130
+ *
131
+ * POST /tool-response
132
+ */
133
+ async toolResponse(body) {
134
+ if (!body.sessionId) {
135
+ throw new HttpException("sessionId is required", HttpStatus.BAD_REQUEST);
136
+ }
137
+ if (!body.toolUseId) {
138
+ throw new HttpException("toolUseId is required", HttpStatus.BAD_REQUEST);
139
+ }
140
+ await this.tentickle.submitToolResult(body.sessionId, body.toolUseId, body.response);
141
+ return { success: true };
142
+ }
143
+ /**
144
+ * Publish to session channel.
145
+ *
146
+ * POST /channel
147
+ */
148
+ async channel(body) {
149
+ if (!body.sessionId) {
150
+ throw new HttpException("sessionId is required", HttpStatus.BAD_REQUEST);
151
+ }
152
+ if (!body.channel) {
153
+ throw new HttpException("channel is required", HttpStatus.BAD_REQUEST);
154
+ }
155
+ if (!body.type) {
156
+ throw new HttpException("type is required", HttpStatus.BAD_REQUEST);
157
+ }
158
+ await this.tentickle.publishToChannel(body.sessionId, body.channel, body.type, body.payload);
159
+ return { success: true };
160
+ }
161
+ };
162
+ __decorate([
163
+ Get("events"),
164
+ __param(0, Res()),
165
+ __metadata("design:type", Function),
166
+ __metadata("design:paramtypes", [Object]),
167
+ __metadata("design:returntype", void 0)
168
+ ], TentickleController.prototype, "events", null);
169
+ __decorate([
170
+ Post("subscribe"),
171
+ __param(0, Body()),
172
+ __metadata("design:type", Function),
173
+ __metadata("design:paramtypes", [Object]),
174
+ __metadata("design:returntype", Promise)
175
+ ], TentickleController.prototype, "subscribe", null);
176
+ __decorate([
177
+ Post("send"),
178
+ __param(0, Body()),
179
+ __param(1, Res()),
180
+ __metadata("design:type", Function),
181
+ __metadata("design:paramtypes", [Object, Object]),
182
+ __metadata("design:returntype", Promise)
183
+ ], TentickleController.prototype, "send", null);
184
+ __decorate([
185
+ Post("abort"),
186
+ __param(0, Body()),
187
+ __metadata("design:type", Function),
188
+ __metadata("design:paramtypes", [Object]),
189
+ __metadata("design:returntype", Promise)
190
+ ], TentickleController.prototype, "abort", null);
191
+ __decorate([
192
+ Post("close"),
193
+ __param(0, Body()),
194
+ __metadata("design:type", Function),
195
+ __metadata("design:paramtypes", [Object]),
196
+ __metadata("design:returntype", Promise)
197
+ ], TentickleController.prototype, "close", null);
198
+ __decorate([
199
+ Post("tool-response"),
200
+ __param(0, Body()),
201
+ __metadata("design:type", Function),
202
+ __metadata("design:paramtypes", [Object]),
203
+ __metadata("design:returntype", Promise)
204
+ ], TentickleController.prototype, "toolResponse", null);
205
+ __decorate([
206
+ Post("channel"),
207
+ __param(0, Body()),
208
+ __metadata("design:type", Function),
209
+ __metadata("design:paramtypes", [Object]),
210
+ __metadata("design:returntype", Promise)
211
+ ], TentickleController.prototype, "channel", null);
212
+ TentickleController = __decorate([
213
+ Controller(),
214
+ __metadata("design:paramtypes", [TentickleService])
215
+ ], TentickleController);
216
+ export { TentickleController };
217
+ //# sourceMappingURL=tentickle.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tentickle.controller.js","sourceRoot":"","sources":["../src/tentickle.controller.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA0CvD,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACD;IAA7B,YAA6B,SAA2B;QAA3B,cAAS,GAAT,SAAS,CAAkB;IAAG,CAAC;IAE5D;;;;OAIG;IAEH,MAAM,CAAQ,GAAa;QACzB,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAED;;;;OAIG;IAEG,AAAN,KAAK,CAAC,SAAS,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AQK;IADL,IAAI,CAAC,eAAe,CAAC;IACF,WAAA,IAAI,EAAE,CAAA;;;;uDAUzB;AAQK;IADL,IAAI,CAAC,SAAS,CAAC;IACD,WAAA,IAAI,EAAE,CAAA;;;;kDAapB;AApIU,mBAAmB;IAD/B,UAAU,EAAE;qCAE6B,gBAAgB;GAD7C,mBAAmB,CAqI/B"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Exception filter for Tentickle errors.
3
+ *
4
+ * Converts domain errors into appropriate HTTP exceptions.
5
+ *
6
+ * @module @tentickle/nestjs/filter
7
+ */
8
+ import { type ExceptionFilter, type ArgumentsHost } from "@nestjs/common";
9
+ import { SessionNotFoundError } from "@tentickle/server";
10
+ /**
11
+ * Exception filter that handles SessionNotFoundError.
12
+ *
13
+ * Converts SessionNotFoundError to HTTP 404 Not Found.
14
+ *
15
+ * @example Controller usage (scoped)
16
+ * ```typescript
17
+ * @Controller()
18
+ * @UseFilters(TentickleExceptionFilter)
19
+ * export class MyController { ... }
20
+ * ```
21
+ *
22
+ * @example Global registration
23
+ * ```typescript
24
+ * app.useGlobalFilters(new TentickleExceptionFilter());
25
+ * ```
26
+ */
27
+ export declare class TentickleExceptionFilter implements ExceptionFilter {
28
+ catch(exception: SessionNotFoundError, host: ArgumentsHost): void;
29
+ }
30
+ //# sourceMappingURL=tentickle.filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tentickle.filter.d.ts","sourceRoot":"","sources":["../src/tentickle.filter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAqB,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,wBAAyB,YAAW,eAAe;IAC9D,KAAK,CAAC,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;CAUlE"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Exception filter for Tentickle errors.
3
+ *
4
+ * Converts domain errors into appropriate HTTP exceptions.
5
+ *
6
+ * @module @tentickle/nestjs/filter
7
+ */
8
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
9
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11
+ 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;
12
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
13
+ };
14
+ import { Catch, HttpStatus } from "@nestjs/common";
15
+ import { SessionNotFoundError } from "@tentickle/server";
16
+ /**
17
+ * Exception filter that handles SessionNotFoundError.
18
+ *
19
+ * Converts SessionNotFoundError to HTTP 404 Not Found.
20
+ *
21
+ * @example Controller usage (scoped)
22
+ * ```typescript
23
+ * @Controller()
24
+ * @UseFilters(TentickleExceptionFilter)
25
+ * export class MyController { ... }
26
+ * ```
27
+ *
28
+ * @example Global registration
29
+ * ```typescript
30
+ * app.useGlobalFilters(new TentickleExceptionFilter());
31
+ * ```
32
+ */
33
+ let TentickleExceptionFilter = class TentickleExceptionFilter {
34
+ catch(exception, host) {
35
+ const ctx = host.switchToHttp();
36
+ const response = ctx.getResponse();
37
+ response.status(HttpStatus.NOT_FOUND).json({
38
+ statusCode: HttpStatus.NOT_FOUND,
39
+ message: "Session not found",
40
+ error: "Not Found",
41
+ });
42
+ }
43
+ };
44
+ TentickleExceptionFilter = __decorate([
45
+ Catch(SessionNotFoundError)
46
+ ], TentickleExceptionFilter);
47
+ export { TentickleExceptionFilter };
48
+ //# sourceMappingURL=tentickle.filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tentickle.filter.js","sourceRoot":"","sources":["../src/tentickle.filter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;AAEH,OAAO,EAAE,KAAK,EAAE,UAAU,EAA4C,MAAM,gBAAgB,CAAC;AAE7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACnC,KAAK,CAAC,SAA+B,EAAE,IAAmB;QACxD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAE7C,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;YACzC,UAAU,EAAE,UAAU,CAAC,SAAS;YAChC,OAAO,EAAE,mBAAmB;YAC5B,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAXY,wBAAwB;IADpC,KAAK,CAAC,oBAAoB,CAAC;GACf,wBAAwB,CAWpC"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * TentickleModule - NestJS module for Tentickle Gateway.
3
+ *
4
+ * This is a thin adapter - all business logic lives in @tentickle/gateway.
5
+ *
6
+ * @module @tentickle/nestjs/module
7
+ */
8
+ import { type DynamicModule } from "@nestjs/common";
9
+ import type { Request, Response } from "express";
10
+ import { Gateway, type GatewayConfig } from "@tentickle/gateway";
11
+ export declare const TENTICKLE_GATEWAY = "TENTICKLE_GATEWAY";
12
+ /**
13
+ * Gateway config type for NestJS module.
14
+ * Excludes standalone-mode-only options.
15
+ */
16
+ export type TentickleModuleOptions = Omit<GatewayConfig, "port" | "host" | "transport" | "httpPort"> & {
17
+ /**
18
+ * Whether to register the default controller.
19
+ * Set to false if you want to define your own routes.
20
+ * @default true
21
+ */
22
+ registerController?: boolean;
23
+ };
24
+ export declare class TentickleService {
25
+ readonly gateway: Gateway;
26
+ constructor(gateway: Gateway);
27
+ /**
28
+ * Handle an HTTP request by delegating to Gateway.
29
+ */
30
+ handleRequest(req: Request, res: Response): Promise<void>;
31
+ }
32
+ export declare class TentickleController {
33
+ private readonly tentickle;
34
+ constructor(tentickle: TentickleService);
35
+ handleAll(req: Request, res: Response): Promise<void>;
36
+ }
37
+ /**
38
+ * NestJS module for Tentickle.
39
+ *
40
+ * @example Default controller (simplest)
41
+ * ```typescript
42
+ * import { TentickleModule } from '@tentickle/nestjs';
43
+ * import { createApp } from '@tentickle/core';
44
+ *
45
+ * @Module({
46
+ * imports: [
47
+ * TentickleModule.forRoot({
48
+ * apps: { assistant: createApp(<MyAgent />) },
49
+ * defaultApp: "assistant",
50
+ * }),
51
+ * ],
52
+ * })
53
+ * export class AppModule {}
54
+ * // Endpoints: GET /events, POST /send, POST /invoke, etc.
55
+ * ```
56
+ *
57
+ * @example With custom methods
58
+ * ```typescript
59
+ * import { TentickleModule, method } from '@tentickle/nestjs';
60
+ * import { z } from "zod";
61
+ *
62
+ * @Module({
63
+ * imports: [
64
+ * TentickleModule.forRoot({
65
+ * apps: { assistant: myApp },
66
+ * defaultApp: "assistant",
67
+ * methods: {
68
+ * tasks: {
69
+ * list: method({
70
+ * schema: z.object({ sessionId: z.string() }),
71
+ * handler: async (params) => todoService.list(params.sessionId),
72
+ * }),
73
+ * },
74
+ * },
75
+ * }),
76
+ * ],
77
+ * })
78
+ * export class AppModule {}
79
+ * ```
80
+ *
81
+ * @example Custom controller with TentickleService
82
+ * ```typescript
83
+ * @Module({
84
+ * imports: [
85
+ * TentickleModule.forRoot({
86
+ * apps: { assistant: myApp },
87
+ * defaultApp: "assistant",
88
+ * registerController: false,
89
+ * }),
90
+ * ],
91
+ * controllers: [ChatController],
92
+ * })
93
+ * export class AppModule {}
94
+ *
95
+ * @Controller('chat')
96
+ * export class ChatController {
97
+ * constructor(private tentickle: TentickleService) {}
98
+ *
99
+ * @All('*')
100
+ * async handleAll(@Req() req: Request, @Res() res: Response) {
101
+ * await this.tentickle.handleRequest(req, res);
102
+ * }
103
+ * }
104
+ * ```
105
+ */
106
+ export declare class TentickleModule {
107
+ /**
108
+ * Register module with static configuration.
109
+ */
110
+ static forRoot(options: TentickleModuleOptions): DynamicModule;
111
+ }
112
+ //# sourceMappingURL=tentickle.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tentickle.module.d.ts","sourceRoot":"","sources":["../src/tentickle.module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,KAAK,aAAa,EAQnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMjE,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAMrD;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,aAAa,EACb,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAC3C,GAAG;IACF;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAMF,qBACa,gBAAgB;aAC4B,OAAO,EAAE,OAAO;gBAAhB,OAAO,EAAE,OAAO;IAEvE;;OAEG;IACG,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAGhE;AAMD,qBACa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,gBAAgB;IAGlD,SAAS,CAAQ,GAAG,EAAE,OAAO,EAAS,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1E;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBACa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,sBAAsB,GAAG,aAAa;CAwB/D"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * TentickleModule - NestJS module for Tentickle Gateway.
3
+ *
4
+ * This is a thin adapter - all business logic lives in @tentickle/gateway.
5
+ *
6
+ * @module @tentickle/nestjs/module
7
+ */
8
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
9
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11
+ 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;
12
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
13
+ };
14
+ var __metadata = (this && this.__metadata) || function (k, v) {
15
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
16
+ };
17
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
18
+ return function (target, key) { decorator(target, key, paramIndex); }
19
+ };
20
+ var TentickleModule_1;
21
+ import { Module, Inject, Injectable, Controller, All, Req, Res, } from "@nestjs/common";
22
+ import { Gateway } from "@tentickle/gateway";
23
+ // ============================================================================
24
+ // Injection Tokens
25
+ // ============================================================================
26
+ export const TENTICKLE_GATEWAY = "TENTICKLE_GATEWAY";
27
+ // ============================================================================
28
+ // Service (thin wrapper around Gateway)
29
+ // ============================================================================
30
+ let TentickleService = class TentickleService {
31
+ gateway;
32
+ constructor(gateway) {
33
+ this.gateway = gateway;
34
+ }
35
+ /**
36
+ * Handle an HTTP request by delegating to Gateway.
37
+ */
38
+ async handleRequest(req, res) {
39
+ return this.gateway.handleRequest(req, res);
40
+ }
41
+ };
42
+ TentickleService = __decorate([
43
+ Injectable(),
44
+ __param(0, Inject(TENTICKLE_GATEWAY)),
45
+ __metadata("design:paramtypes", [Gateway])
46
+ ], TentickleService);
47
+ export { TentickleService };
48
+ // ============================================================================
49
+ // Controller (delegates everything to Gateway)
50
+ // ============================================================================
51
+ let TentickleController = class TentickleController {
52
+ tentickle;
53
+ constructor(tentickle) {
54
+ this.tentickle = tentickle;
55
+ }
56
+ async handleAll(req, res) {
57
+ await this.tentickle.handleRequest(req, res);
58
+ }
59
+ };
60
+ __decorate([
61
+ All("*"),
62
+ __param(0, Req()),
63
+ __param(1, Res()),
64
+ __metadata("design:type", Function),
65
+ __metadata("design:paramtypes", [Object, Object]),
66
+ __metadata("design:returntype", Promise)
67
+ ], TentickleController.prototype, "handleAll", null);
68
+ TentickleController = __decorate([
69
+ Controller(),
70
+ __metadata("design:paramtypes", [TentickleService])
71
+ ], TentickleController);
72
+ export { TentickleController };
73
+ // ============================================================================
74
+ // Module
75
+ // ============================================================================
76
+ /**
77
+ * NestJS module for Tentickle.
78
+ *
79
+ * @example Default controller (simplest)
80
+ * ```typescript
81
+ * import { TentickleModule } from '@tentickle/nestjs';
82
+ * import { createApp } from '@tentickle/core';
83
+ *
84
+ * @Module({
85
+ * imports: [
86
+ * TentickleModule.forRoot({
87
+ * apps: { assistant: createApp(<MyAgent />) },
88
+ * defaultApp: "assistant",
89
+ * }),
90
+ * ],
91
+ * })
92
+ * export class AppModule {}
93
+ * // Endpoints: GET /events, POST /send, POST /invoke, etc.
94
+ * ```
95
+ *
96
+ * @example With custom methods
97
+ * ```typescript
98
+ * import { TentickleModule, method } from '@tentickle/nestjs';
99
+ * import { z } from "zod";
100
+ *
101
+ * @Module({
102
+ * imports: [
103
+ * TentickleModule.forRoot({
104
+ * apps: { assistant: myApp },
105
+ * defaultApp: "assistant",
106
+ * methods: {
107
+ * tasks: {
108
+ * list: method({
109
+ * schema: z.object({ sessionId: z.string() }),
110
+ * handler: async (params) => todoService.list(params.sessionId),
111
+ * }),
112
+ * },
113
+ * },
114
+ * }),
115
+ * ],
116
+ * })
117
+ * export class AppModule {}
118
+ * ```
119
+ *
120
+ * @example Custom controller with TentickleService
121
+ * ```typescript
122
+ * @Module({
123
+ * imports: [
124
+ * TentickleModule.forRoot({
125
+ * apps: { assistant: myApp },
126
+ * defaultApp: "assistant",
127
+ * registerController: false,
128
+ * }),
129
+ * ],
130
+ * controllers: [ChatController],
131
+ * })
132
+ * export class AppModule {}
133
+ *
134
+ * @Controller('chat')
135
+ * export class ChatController {
136
+ * constructor(private tentickle: TentickleService) {}
137
+ *
138
+ * @All('*')
139
+ * async handleAll(@Req() req: Request, @Res() res: Response) {
140
+ * await this.tentickle.handleRequest(req, res);
141
+ * }
142
+ * }
143
+ * ```
144
+ */
145
+ let TentickleModule = TentickleModule_1 = class TentickleModule {
146
+ /**
147
+ * Register module with static configuration.
148
+ */
149
+ static forRoot(options) {
150
+ // Create gateway in embedded mode
151
+ const gateway = new Gateway({
152
+ ...options,
153
+ embedded: true,
154
+ });
155
+ const providers = [
156
+ {
157
+ provide: TENTICKLE_GATEWAY,
158
+ useValue: gateway,
159
+ },
160
+ TentickleService,
161
+ ];
162
+ const controllers = options.registerController !== false ? [TentickleController] : [];
163
+ return {
164
+ module: TentickleModule_1,
165
+ providers,
166
+ controllers,
167
+ exports: [TentickleService, TENTICKLE_GATEWAY],
168
+ };
169
+ }
170
+ };
171
+ TentickleModule = TentickleModule_1 = __decorate([
172
+ Module({})
173
+ ], TentickleModule);
174
+ export { TentickleModule };
175
+ //# sourceMappingURL=tentickle.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tentickle.module.js","sourceRoot":"","sources":["../src/tentickle.module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;;;;;AAEH,OAAO,EACL,MAAM,EAGN,MAAM,EACN,UAAU,EACV,UAAU,EACV,GAAG,EACH,GAAG,EACH,GAAG,GACJ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,OAAO,EAAsB,MAAM,oBAAoB,CAAC;AAEjE,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,iBAAiB,G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