@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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Agentick Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @agentick/nestjs
2
+
3
+ NestJS integration for Agentick with multiplexed SSE sessions.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @agentick/nestjs
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { Module } from "@nestjs/common";
15
+ import { AgentickModule } from "@agentick/nestjs";
16
+ import { createApp } from "@agentick/core";
17
+
18
+ @Module({
19
+ imports: [
20
+ AgentickModule.forRoot({
21
+ app: createApp(<MyAgent />),
22
+ }),
23
+ ],
24
+ })
25
+ export class AppModule {}
26
+ ```
27
+
28
+ ## Default Endpoints
29
+
30
+ | Method | Path | Description |
31
+ | ------ | ---------------- | ------------------------ |
32
+ | GET | `/events` | SSE stream |
33
+ | POST | `/send` | Send and stream |
34
+ | POST | `/subscribe` | Subscribe to sessions |
35
+ | POST | `/abort` | Abort execution |
36
+ | POST | `/close` | Close session |
37
+ | POST | `/tool-response` | Submit tool confirmation |
38
+ | POST | `/channel` | Publish to channel |
39
+
40
+ ## Custom Controller
41
+
42
+ ```typescript
43
+ @Module({
44
+ imports: [
45
+ AgentickModule.forRoot({
46
+ app,
47
+ registerController: false,
48
+ }),
49
+ ],
50
+ controllers: [ChatController],
51
+ })
52
+ export class AppModule {}
53
+
54
+ @Controller("chat")
55
+ export class ChatController {
56
+ constructor(private agentick: AgentickService) {}
57
+
58
+ @Post("send")
59
+ async send(@Body() body: SendDto, @Res() res: Response) {
60
+ await this.agentick.sendAndStream(body.sessionId, body, res);
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## AgentickService
66
+
67
+ ```typescript
68
+ service.createConnection(res) // SSE connection
69
+ service.subscribe(connId, sessionIds) // Subscribe
70
+ service.unsubscribe(connId, sessionIds) // Unsubscribe
71
+ service.sendAndStream(sessionId, input, res) // Send and stream
72
+ service.abort(sessionId, reason?) // Abort
73
+ service.close(sessionId) // Close
74
+ service.publishToChannel(sessionId, channel, type, payload) // Channel pub
75
+ service.getApp() // Direct App access
76
+ ```
77
+
78
+ ## Inject App Directly
79
+
80
+ ```typescript
81
+ @Injectable()
82
+ export class MyService {
83
+ constructor(@Inject(TENTICKLE_APP) private app: App) {
84
+ const session = this.app.session("conv-123");
85
+ }
86
+ }
87
+ ```
@@ -0,0 +1,112 @@
1
+ /**
2
+ * AgentickModule - NestJS module for Agentick Gateway.
3
+ *
4
+ * This is a thin adapter - all business logic lives in @agentick/gateway.
5
+ *
6
+ * @module @agentick/nestjs/module
7
+ */
8
+ import { type DynamicModule } from "@nestjs/common";
9
+ import type { Request, Response } from "express";
10
+ import { Gateway, type GatewayConfig } from "@agentick/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 AgentickModuleOptions = 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 AgentickService {
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 AgentickController {
33
+ private readonly agentick;
34
+ constructor(agentick: AgentickService);
35
+ handleAll(req: Request, res: Response): Promise<void>;
36
+ }
37
+ /**
38
+ * NestJS module for Agentick.
39
+ *
40
+ * @example Default controller (simplest)
41
+ * ```typescript
42
+ * import { AgentickModule } from '@agentick/nestjs';
43
+ * import { createApp } from '@agentick/core';
44
+ *
45
+ * @Module({
46
+ * imports: [
47
+ * AgentickModule.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 { AgentickModule, method } from '@agentick/nestjs';
60
+ * import { z } from "zod";
61
+ *
62
+ * @Module({
63
+ * imports: [
64
+ * AgentickModule.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 AgentickService
82
+ * ```typescript
83
+ * @Module({
84
+ * imports: [
85
+ * AgentickModule.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 agentick: AgentickService) {}
98
+ *
99
+ * @All('*')
100
+ * async handleAll(@Req() req: Request, @Res() res: Response) {
101
+ * await this.agentick.handleRequest(req, res);
102
+ * }
103
+ * }
104
+ * ```
105
+ */
106
+ export declare class AgentickModule {
107
+ /**
108
+ * Register module with static configuration.
109
+ */
110
+ static forRoot(options: AgentickModuleOptions): DynamicModule;
111
+ }
112
+ //# sourceMappingURL=agentick.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentick.module.d.ts","sourceRoot":"","sources":["../src/agentick.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,mBAAmB,CAAC;AAMhE,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAMrD;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,aAAa,EACb,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAC3C,GAAG;IACF;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAMF,qBACa,eAAe;aAC6B,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,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,eAAe;IAGhD,SAAS,CAAQ,GAAG,EAAE,OAAO,EAAS,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1E;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBACa,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa;CAwB9D"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * AgentickModule - NestJS module for Agentick Gateway.
3
+ *
4
+ * This is a thin adapter - all business logic lives in @agentick/gateway.
5
+ *
6
+ * @module @agentick/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 AgentickModule_1;
21
+ import { Module, Inject, Injectable, Controller, All, Req, Res, } from "@nestjs/common";
22
+ import { Gateway } from "@agentick/gateway";
23
+ // ============================================================================
24
+ // Injection Tokens
25
+ // ============================================================================
26
+ export const TENTICKLE_GATEWAY = "TENTICKLE_GATEWAY";
27
+ // ============================================================================
28
+ // Service (thin wrapper around Gateway)
29
+ // ============================================================================
30
+ let AgentickService = class AgentickService {
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
+ AgentickService = __decorate([
43
+ Injectable(),
44
+ __param(0, Inject(TENTICKLE_GATEWAY)),
45
+ __metadata("design:paramtypes", [Gateway])
46
+ ], AgentickService);
47
+ export { AgentickService };
48
+ // ============================================================================
49
+ // Controller (delegates everything to Gateway)
50
+ // ============================================================================
51
+ let AgentickController = class AgentickController {
52
+ agentick;
53
+ constructor(agentick) {
54
+ this.agentick = agentick;
55
+ }
56
+ async handleAll(req, res) {
57
+ await this.agentick.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
+ ], AgentickController.prototype, "handleAll", null);
68
+ AgentickController = __decorate([
69
+ Controller(),
70
+ __metadata("design:paramtypes", [AgentickService])
71
+ ], AgentickController);
72
+ export { AgentickController };
73
+ // ============================================================================
74
+ // Module
75
+ // ============================================================================
76
+ /**
77
+ * NestJS module for Agentick.
78
+ *
79
+ * @example Default controller (simplest)
80
+ * ```typescript
81
+ * import { AgentickModule } from '@agentick/nestjs';
82
+ * import { createApp } from '@agentick/core';
83
+ *
84
+ * @Module({
85
+ * imports: [
86
+ * AgentickModule.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 { AgentickModule, method } from '@agentick/nestjs';
99
+ * import { z } from "zod";
100
+ *
101
+ * @Module({
102
+ * imports: [
103
+ * AgentickModule.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 AgentickService
121
+ * ```typescript
122
+ * @Module({
123
+ * imports: [
124
+ * AgentickModule.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 agentick: AgentickService) {}
137
+ *
138
+ * @All('*')
139
+ * async handleAll(@Req() req: Request, @Res() res: Response) {
140
+ * await this.agentick.handleRequest(req, res);
141
+ * }
142
+ * }
143
+ * ```
144
+ */
145
+ let AgentickModule = AgentickModule_1 = class AgentickModule {
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
+ AgentickService,
161
+ ];
162
+ const controllers = options.registerController !== false ? [AgentickController] : [];
163
+ return {
164
+ module: AgentickModule_1,
165
+ providers,
166
+ controllers,
167
+ exports: [AgentickService, TENTICKLE_GATEWAY],
168
+ };
169
+ }
170
+ };
171
+ AgentickModule = AgentickModule_1 = __decorate([
172
+ Module({})
173
+ ], AgentickModule);
174
+ export { AgentickModule };
175
+ //# sourceMappingURL=agentick.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ag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9B,UAAU,EAAE;qCAE4B,eAAe;GAD3C,kBAAkB,CAO9B;;AAED,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEI,IAAM,cAAc,sBAApB,MAAM,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,OAA8B;QAC3C,kCAAkC;QAClC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;YAC1B,GAAG,OAAO;YACV,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QAEH,MAAM,SAAS,GAAe;YAC5B;gBACE,OAAO,EAAE,iBAAiB;gBAC1B,QAAQ,EAAE,OAAO;aAClB;YACD,eAAe;SAChB,CAAC;QAEF,MAAM,WAAW,GAAG,OAAO,CAAC,kBAAkB,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAErF,OAAO;YACL,MAAM,EAAE,gBAAc;YACtB,SAAS;YACT,WAAW;YACX,OAAO,EAAE,CAAC,eAAe,EAAE,iBAAiB,CAAC;SAC9C,CAAC;IACJ,CAAC;CACF,CAAA;AA5BY,cAAc;IAD1B,MAAM,CAAC,EAAE,CAAC;GACE,cAAc,CA4B1B"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @agentick/nestjs - NestJS adapter for Agentick Gateway
3
+ *
4
+ * Provides NestJS integration that delegates to Gateway.
5
+ * This is a thin adapter - all business logic lives in @agentick/gateway.
6
+ *
7
+ * @example Default controller
8
+ * ```typescript
9
+ * import { Module } from '@nestjs/common';
10
+ * import { AgentickModule } from '@agentick/nestjs';
11
+ * import { createApp } from '@agentick/core';
12
+ *
13
+ * @Module({
14
+ * imports: [
15
+ * AgentickModule.forRoot({
16
+ * apps: { assistant: createApp(<MyAgent />) },
17
+ * defaultApp: "assistant",
18
+ * }),
19
+ * ],
20
+ * })
21
+ * export class AppModule {}
22
+ * // Endpoints: GET /events, POST /send, POST /invoke, etc.
23
+ * ```
24
+ *
25
+ * @example With custom methods
26
+ * ```typescript
27
+ * import { AgentickModule, method } from '@agentick/nestjs';
28
+ * import { z } from "zod";
29
+ *
30
+ * @Module({
31
+ * imports: [
32
+ * AgentickModule.forRoot({
33
+ * apps: { assistant: myApp },
34
+ * defaultApp: "assistant",
35
+ * methods: {
36
+ * tasks: {
37
+ * list: method({
38
+ * schema: z.object({ sessionId: z.string() }),
39
+ * handler: async (params) => todoService.list(params.sessionId),
40
+ * }),
41
+ * },
42
+ * },
43
+ * }),
44
+ * ],
45
+ * })
46
+ * export class AppModule {}
47
+ * ```
48
+ *
49
+ * ## Default Endpoints
50
+ *
51
+ * | Method | Path | Description |
52
+ * |--------|------|-------------|
53
+ * | GET | `/events` | SSE stream |
54
+ * | POST | `/send` | Send and stream |
55
+ * | POST | `/invoke` | Invoke custom method |
56
+ * | POST | `/subscribe` | Subscribe to sessions |
57
+ * | POST | `/abort` | Abort execution |
58
+ * | POST | `/close` | Close session |
59
+ *
60
+ * @module @agentick/nestjs
61
+ */
62
+ export { AgentickModule, AgentickService, AgentickController, TENTICKLE_GATEWAY, type AgentickModuleOptions, } from "./agentick.module";
63
+ export { method, type GatewayConfig, type MethodDefinition, type AuthConfig, } from "@agentick/gateway";
64
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAGH,OAAO,EACL,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,MAAM,EACN,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @agentick/nestjs - NestJS adapter for Agentick Gateway
3
+ *
4
+ * Provides NestJS integration that delegates to Gateway.
5
+ * This is a thin adapter - all business logic lives in @agentick/gateway.
6
+ *
7
+ * @example Default controller
8
+ * ```typescript
9
+ * import { Module } from '@nestjs/common';
10
+ * import { AgentickModule } from '@agentick/nestjs';
11
+ * import { createApp } from '@agentick/core';
12
+ *
13
+ * @Module({
14
+ * imports: [
15
+ * AgentickModule.forRoot({
16
+ * apps: { assistant: createApp(<MyAgent />) },
17
+ * defaultApp: "assistant",
18
+ * }),
19
+ * ],
20
+ * })
21
+ * export class AppModule {}
22
+ * // Endpoints: GET /events, POST /send, POST /invoke, etc.
23
+ * ```
24
+ *
25
+ * @example With custom methods
26
+ * ```typescript
27
+ * import { AgentickModule, method } from '@agentick/nestjs';
28
+ * import { z } from "zod";
29
+ *
30
+ * @Module({
31
+ * imports: [
32
+ * AgentickModule.forRoot({
33
+ * apps: { assistant: myApp },
34
+ * defaultApp: "assistant",
35
+ * methods: {
36
+ * tasks: {
37
+ * list: method({
38
+ * schema: z.object({ sessionId: z.string() }),
39
+ * handler: async (params) => todoService.list(params.sessionId),
40
+ * }),
41
+ * },
42
+ * },
43
+ * }),
44
+ * ],
45
+ * })
46
+ * export class AppModule {}
47
+ * ```
48
+ *
49
+ * ## Default Endpoints
50
+ *
51
+ * | Method | Path | Description |
52
+ * |--------|------|-------------|
53
+ * | GET | `/events` | SSE stream |
54
+ * | POST | `/send` | Send and stream |
55
+ * | POST | `/invoke` | Invoke custom method |
56
+ * | POST | `/subscribe` | Subscribe to sessions |
57
+ * | POST | `/abort` | Abort execution |
58
+ * | POST | `/close` | Close session |
59
+ *
60
+ * @module @agentick/nestjs
61
+ */
62
+ // Module, Service, Controller
63
+ export { AgentickModule, AgentickService, AgentickController, TENTICKLE_GATEWAY, } from "./agentick.module";
64
+ // Re-export gateway types for convenience
65
+ export { method, } from "@agentick/gateway";
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,8BAA8B;AAC9B,OAAO,EACL,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,iBAAiB,GAElB,MAAM,mBAAmB,CAAC;AAE3B,0CAA0C;AAC1C,OAAO,EACL,MAAM,GAIP,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,120 @@
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
+ import type { Response } from "express";
9
+ import type { Message, ToolConfirmationResponse } from "@tentickle/shared";
10
+ import { TentickleService } from "./tentickle.service";
11
+ interface SubscribeDto {
12
+ connectionId: string;
13
+ add?: string[];
14
+ remove?: string[];
15
+ }
16
+ interface SendDto {
17
+ sessionId?: string;
18
+ message?: Message;
19
+ messages?: Message[];
20
+ props?: Record<string, unknown>;
21
+ metadata?: Record<string, unknown>;
22
+ }
23
+ interface AbortDto {
24
+ sessionId: string;
25
+ reason?: string;
26
+ }
27
+ interface CloseDto {
28
+ sessionId: string;
29
+ }
30
+ interface ToolResponseDto {
31
+ sessionId: string;
32
+ toolUseId: string;
33
+ response: ToolConfirmationResponse;
34
+ }
35
+ interface ChannelPublishDto {
36
+ sessionId: string;
37
+ channel: string;
38
+ type: string;
39
+ payload: unknown;
40
+ }
41
+ /**
42
+ * Default controller for Tentickle endpoints.
43
+ *
44
+ * Provides multiplexed SSE with per-session subscriptions.
45
+ *
46
+ * @example Using the default controller
47
+ * ```typescript
48
+ * @Module({
49
+ * imports: [TentickleModule.forRoot({ app })],
50
+ * })
51
+ * export class AppModule {}
52
+ * ```
53
+ *
54
+ * @example Custom controller
55
+ * ```typescript
56
+ * @Module({
57
+ * imports: [TentickleModule.forRoot({ app, registerController: false })],
58
+ * controllers: [MyController],
59
+ * })
60
+ * export class AppModule {}
61
+ * ```
62
+ */
63
+ export declare class TentickleController {
64
+ private readonly tentickle;
65
+ constructor(tentickle: TentickleService);
66
+ /**
67
+ * SSE endpoint for multiplexed events.
68
+ *
69
+ * GET /events
70
+ */
71
+ events(res: Response): void;
72
+ /**
73
+ * Subscribe to sessions.
74
+ *
75
+ * POST /subscribe
76
+ */
77
+ subscribe(body: SubscribeDto): Promise<{
78
+ success: boolean;
79
+ }>;
80
+ /**
81
+ * Send message and stream events.
82
+ *
83
+ * POST /send
84
+ */
85
+ send(body: SendDto, res: Response): Promise<void>;
86
+ /**
87
+ * Abort execution.
88
+ *
89
+ * POST /abort
90
+ */
91
+ abort(body: AbortDto): Promise<{
92
+ success: boolean;
93
+ }>;
94
+ /**
95
+ * Close session.
96
+ *
97
+ * POST /close
98
+ */
99
+ close(body: CloseDto): Promise<{
100
+ success: boolean;
101
+ }>;
102
+ /**
103
+ * Submit tool confirmation response.
104
+ *
105
+ * POST /tool-response
106
+ */
107
+ toolResponse(body: ToolResponseDto): Promise<{
108
+ success: boolean;
109
+ }>;
110
+ /**
111
+ * Publish to session channel.
112
+ *
113
+ * POST /channel
114
+ */
115
+ channel(body: ChannelPublishDto): Promise<{
116
+ success: boolean;
117
+ }>;
118
+ }
119
+ export {};
120
+ //# sourceMappingURL=tentickle.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tentickle.controller.d.ts","sourceRoot":"","sources":["../src/tentickle.controller.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC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