@memo-code/memo 0.8.5 → 0.8.6

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.
Files changed (97) hide show
  1. package/dist/web/server/main.cjs +145360 -0
  2. package/package.json +2 -1
  3. package/dist/web/server/app.controller.d.ts +0 -6
  4. package/dist/web/server/app.controller.js +0 -33
  5. package/dist/web/server/app.module.d.ts +0 -4
  6. package/dist/web/server/app.module.js +0 -61
  7. package/dist/web/server/auth/access-token.guard.d.ts +0 -9
  8. package/dist/web/server/auth/access-token.guard.js +0 -53
  9. package/dist/web/server/auth/auth.controller.d.ts +0 -18
  10. package/dist/web/server/auth/auth.controller.js +0 -75
  11. package/dist/web/server/auth/auth.module.d.ts +0 -2
  12. package/dist/web/server/auth/auth.module.js +0 -24
  13. package/dist/web/server/auth/auth.service.d.ts +0 -15
  14. package/dist/web/server/auth/auth.service.js +0 -146
  15. package/dist/web/server/auth/auth.types.d.ts +0 -26
  16. package/dist/web/server/auth/auth.types.js +0 -2
  17. package/dist/web/server/auth/public.decorator.d.ts +0 -2
  18. package/dist/web/server/auth/public.decorator.js +0 -7
  19. package/dist/web/server/chat/chat.controller.d.ts +0 -30
  20. package/dist/web/server/chat/chat.controller.js +0 -150
  21. package/dist/web/server/chat/chat.module.d.ts +0 -2
  22. package/dist/web/server/chat/chat.module.js +0 -26
  23. package/dist/web/server/chat/chat.service.d.ts +0 -61
  24. package/dist/web/server/chat/chat.service.js +0 -847
  25. package/dist/web/server/chat/chat.types.d.ts +0 -38
  26. package/dist/web/server/chat/chat.types.js +0 -2
  27. package/dist/web/server/common/constants.d.ts +0 -1
  28. package/dist/web/server/common/constants.js +0 -4
  29. package/dist/web/server/common/filters/api-error.filter.d.ts +0 -7
  30. package/dist/web/server/common/filters/api-error.filter.js +0 -95
  31. package/dist/web/server/common/interceptors/api-response.interceptor.d.ts +0 -15
  32. package/dist/web/server/common/interceptors/api-response.interceptor.js +0 -51
  33. package/dist/web/server/common/middleware/request-logging.middleware.d.ts +0 -7
  34. package/dist/web/server/common/middleware/request-logging.middleware.js +0 -42
  35. package/dist/web/server/config/memo-config.service.d.ts +0 -7
  36. package/dist/web/server/config/memo-config.service.js +0 -106
  37. package/dist/web/server/config/memo-config.types.d.ts +0 -6
  38. package/dist/web/server/config/memo-config.types.js +0 -2
  39. package/dist/web/server/config/server-config.module.d.ts +0 -2
  40. package/dist/web/server/config/server-config.module.js +0 -22
  41. package/dist/web/server/config/server-config.service.d.ts +0 -14
  42. package/dist/web/server/config/server-config.service.js +0 -326
  43. package/dist/web/server/config/server-config.service.test.d.ts +0 -1
  44. package/dist/web/server/config/server-config.service.test.js +0 -193
  45. package/dist/web/server/config/server-config.types.d.ts +0 -27
  46. package/dist/web/server/config/server-config.types.js +0 -2
  47. package/dist/web/server/main.d.ts +0 -1
  48. package/dist/web/server/main.js +0 -19
  49. package/dist/web/server/mcp/mcp.controller.d.ts +0 -38
  50. package/dist/web/server/mcp/mcp.controller.js +0 -126
  51. package/dist/web/server/mcp/mcp.module.d.ts +0 -2
  52. package/dist/web/server/mcp/mcp.module.js +0 -22
  53. package/dist/web/server/mcp/mcp.service.d.ts +0 -25
  54. package/dist/web/server/mcp/mcp.service.js +0 -56
  55. package/dist/web/server/server.d.ts +0 -18
  56. package/dist/web/server/server.js +0 -142
  57. package/dist/web/server/sessions/sessions.controller.d.ts +0 -8
  58. package/dist/web/server/sessions/sessions.controller.js +0 -59
  59. package/dist/web/server/sessions/sessions.module.d.ts +0 -2
  60. package/dist/web/server/sessions/sessions.module.js +0 -24
  61. package/dist/web/server/sessions/sessions.service.d.ts +0 -22
  62. package/dist/web/server/sessions/sessions.service.js +0 -217
  63. package/dist/web/server/sessions/sessions.types.d.ts +0 -18
  64. package/dist/web/server/sessions/sessions.types.js +0 -2
  65. package/dist/web/server/skills/skills.controller.d.ts +0 -31
  66. package/dist/web/server/skills/skills.controller.js +0 -86
  67. package/dist/web/server/skills/skills.module.d.ts +0 -2
  68. package/dist/web/server/skills/skills.module.js +0 -24
  69. package/dist/web/server/skills/skills.service.d.ts +0 -38
  70. package/dist/web/server/skills/skills.service.js +0 -97
  71. package/dist/web/server/stream/stream.module.d.ts +0 -2
  72. package/dist/web/server/stream/stream.module.js +0 -20
  73. package/dist/web/server/stream/stream.service.d.ts +0 -26
  74. package/dist/web/server/stream/stream.service.js +0 -166
  75. package/dist/web/server/tsconfig.build.tsbuildinfo +0 -1
  76. package/dist/web/server/workspaces/workspaces.module.d.ts +0 -2
  77. package/dist/web/server/workspaces/workspaces.module.js +0 -20
  78. package/dist/web/server/workspaces/workspaces.service.d.ts +0 -38
  79. package/dist/web/server/workspaces/workspaces.service.js +0 -378
  80. package/dist/web/server/workspaces/workspaces.types.d.ts +0 -1
  81. package/dist/web/server/workspaces/workspaces.types.js +0 -2
  82. package/dist/web/server/workspaces/workspaces.utils.d.ts +0 -1
  83. package/dist/web/server/workspaces/workspaces.utils.js +0 -9
  84. package/dist/web/server/ws/rpc-router.service.d.ts +0 -20
  85. package/dist/web/server/ws/rpc-router.service.js +0 -275
  86. package/dist/web/server/ws/session-runtime-registry.service.d.ts +0 -37
  87. package/dist/web/server/ws/session-runtime-registry.service.js +0 -118
  88. package/dist/web/server/ws/ws-event-bus.service.d.ts +0 -5
  89. package/dist/web/server/ws/ws-event-bus.service.js +0 -27
  90. package/dist/web/server/ws/ws-gateway.module.d.ts +0 -2
  91. package/dist/web/server/ws/ws-gateway.module.js +0 -42
  92. package/dist/web/server/ws/ws-gateway.service.d.ts +0 -42
  93. package/dist/web/server/ws/ws-gateway.service.js +0 -473
  94. package/dist/web/server/ws/ws.errors.d.ts +0 -8
  95. package/dist/web/server/ws/ws.errors.js +0 -16
  96. package/dist/web/server/ws/ws.types.d.ts +0 -34
  97. package/dist/web/server/ws/ws.types.js +0 -2
@@ -1,275 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.RpcRouterService = void 0;
13
- const common_1 = require("@nestjs/common");
14
- const chat_service_1 = require("../chat/chat.service");
15
- const mcp_service_1 = require("../mcp/mcp.service");
16
- const sessions_service_1 = require("../sessions/sessions.service");
17
- const skills_service_1 = require("../skills/skills.service");
18
- const workspaces_service_1 = require("../workspaces/workspaces.service");
19
- const session_runtime_registry_service_1 = require("./session-runtime-registry.service");
20
- const ws_errors_1 = require("./ws.errors");
21
- function asObject(input) {
22
- if (!input || typeof input !== 'object' || Array.isArray(input)) {
23
- return {};
24
- }
25
- return input;
26
- }
27
- function requireString(input, key, code = 'BAD_REQUEST') {
28
- const value = input[key];
29
- if (typeof value !== 'string' || !value.trim()) {
30
- throw new ws_errors_1.WsRpcError(code, `${key} is required`);
31
- }
32
- return value.trim();
33
- }
34
- function asString(value) {
35
- if (typeof value !== 'string')
36
- return undefined;
37
- const trimmed = value.trim();
38
- return trimmed.length > 0 ? trimmed : undefined;
39
- }
40
- let RpcRouterService = class RpcRouterService {
41
- sessionsService;
42
- chatService;
43
- mcpService;
44
- skillsService;
45
- workspacesService;
46
- sessionRegistry;
47
- constructor(sessionsService, chatService, mcpService, skillsService, workspacesService, sessionRegistry) {
48
- this.sessionsService = sessionsService;
49
- this.chatService = chatService;
50
- this.mcpService = mcpService;
51
- this.skillsService = skillsService;
52
- this.workspacesService = workspacesService;
53
- this.sessionRegistry = sessionRegistry;
54
- }
55
- async dispatch(context, method, params) {
56
- const input = asObject(params);
57
- if (method === 'sessions.list') {
58
- return this.sessionsService.list(input);
59
- }
60
- if (method === 'sessions.detail') {
61
- const sessionId = requireString(input, 'sessionId');
62
- return this.sessionsService.getSessionDetail(sessionId);
63
- }
64
- if (method === 'sessions.events') {
65
- const sessionId = requireString(input, 'sessionId');
66
- return this.sessionsService.getSessionEvents(sessionId, input);
67
- }
68
- if (method === 'sessions.remove') {
69
- const sessionId = requireString(input, 'sessionId');
70
- return this.chatService.deleteSession(sessionId);
71
- }
72
- if (method === 'chat.session.create') {
73
- const mode = input.toolPermissionMode;
74
- return this.chatService.createSession({
75
- providerName: asString(input.providerName),
76
- workspaceId: asString(input.workspaceId),
77
- cwd: asString(input.cwd),
78
- toolPermissionMode: mode === 'none' || mode === 'once' || mode === 'full'
79
- ? mode
80
- : undefined,
81
- activeMcpServers: Array.isArray(input.activeMcpServers)
82
- ? input.activeMcpServers.filter((item) => typeof item === 'string')
83
- : undefined,
84
- });
85
- }
86
- if (method === 'chat.providers.list') {
87
- return this.chatService.listProviders();
88
- }
89
- if (method === 'chat.runtimes.list') {
90
- return this.chatService.listRuntimeBadges({
91
- workspaceId: asString(input.workspaceId),
92
- });
93
- }
94
- if (method === 'chat.session.state') {
95
- const sessionId = requireString(input, 'sessionId');
96
- this.sessionRegistry.requireOwner(sessionId, context.connectionId);
97
- return this.chatService.getSessionState(sessionId);
98
- }
99
- if (method === 'chat.session.attach') {
100
- const sessionId = requireString(input, 'sessionId');
101
- this.sessionRegistry.claim(sessionId, context.connectionId);
102
- try {
103
- return await this.chatService.attachSession(sessionId);
104
- }
105
- catch (error) {
106
- this.sessionRegistry.release(sessionId, context.connectionId);
107
- throw error;
108
- }
109
- }
110
- if (method === 'chat.session.close') {
111
- const sessionId = requireString(input, 'sessionId');
112
- this.sessionRegistry.requireOwner(sessionId, context.connectionId);
113
- const result = this.chatService.closeSession(sessionId);
114
- this.sessionRegistry.release(sessionId, context.connectionId);
115
- return result;
116
- }
117
- if (method === 'chat.files.suggest') {
118
- const sessionId = asString(input.sessionId);
119
- if (sessionId) {
120
- this.sessionRegistry.requireOwner(sessionId, context.connectionId);
121
- }
122
- const query = typeof input.query === 'string' ? input.query : '';
123
- const limit = typeof input.limit === 'number' && Number.isFinite(input.limit)
124
- ? input.limit
125
- : undefined;
126
- return this.chatService.suggestFiles({
127
- query,
128
- limit,
129
- sessionId,
130
- workspaceId: asString(input.workspaceId),
131
- });
132
- }
133
- if (method === 'chat.input.submit') {
134
- const sessionId = requireString(input, 'sessionId');
135
- const text = requireString(input, 'input');
136
- this.sessionRegistry.requireOwner(sessionId, context.connectionId);
137
- return this.chatService.submitInput(sessionId, text);
138
- }
139
- if (method === 'chat.turn.cancel') {
140
- const sessionId = requireString(input, 'sessionId');
141
- this.sessionRegistry.requireOwner(sessionId, context.connectionId);
142
- return this.chatService.cancelCurrentTurn(sessionId);
143
- }
144
- if (method === 'chat.session.compact') {
145
- const sessionId = requireString(input, 'sessionId');
146
- this.sessionRegistry.requireOwner(sessionId, context.connectionId);
147
- return this.chatService.compactSession(sessionId);
148
- }
149
- if (method === 'chat.approval.respond') {
150
- const sessionId = requireString(input, 'sessionId');
151
- const fingerprint = requireString(input, 'fingerprint');
152
- const decision = input.decision;
153
- if (decision !== 'once' &&
154
- decision !== 'session' &&
155
- decision !== 'deny') {
156
- throw new ws_errors_1.WsRpcError('BAD_REQUEST', 'decision must be once | session | deny');
157
- }
158
- this.sessionRegistry.requireOwner(sessionId, context.connectionId);
159
- return this.chatService.applyApprovalDecision(sessionId, fingerprint, decision);
160
- }
161
- if (method === 'mcp.servers.list') {
162
- return this.mcpService.list();
163
- }
164
- if (method === 'mcp.servers.get') {
165
- return this.mcpService.get(requireString(input, 'name'));
166
- }
167
- if (method === 'mcp.servers.create') {
168
- const name = requireString(input, 'name');
169
- return this.mcpService.create(name, input.config);
170
- }
171
- if (method === 'mcp.servers.update') {
172
- const name = requireString(input, 'name');
173
- return this.mcpService.update(name, input.config);
174
- }
175
- if (method === 'mcp.servers.remove') {
176
- return this.mcpService.remove(requireString(input, 'name'));
177
- }
178
- if (method === 'mcp.servers.login') {
179
- const name = requireString(input, 'name');
180
- const scopes = Array.isArray(input.scopes)
181
- ? input.scopes.filter((item) => typeof item === 'string')
182
- : undefined;
183
- return this.mcpService.login(name, scopes);
184
- }
185
- if (method === 'mcp.servers.logout') {
186
- return this.mcpService.logout(requireString(input, 'name'));
187
- }
188
- if (method === 'mcp.active.set') {
189
- if (!Array.isArray(input.names)) {
190
- throw new ws_errors_1.WsRpcError('BAD_REQUEST', 'names must be string[]');
191
- }
192
- const names = input.names
193
- .filter((item) => typeof item === 'string')
194
- .map((item) => item.trim())
195
- .filter(Boolean);
196
- return this.mcpService.setActive(names);
197
- }
198
- if (method === 'skills.list') {
199
- return this.skillsService.list({
200
- scope: input.scope,
201
- q: input.q,
202
- workspaceId: input.workspaceId,
203
- });
204
- }
205
- if (method === 'skills.get') {
206
- return this.skillsService.get(requireString(input, 'id'));
207
- }
208
- if (method === 'skills.create') {
209
- return this.skillsService.create({
210
- scope: input.scope,
211
- name: input.name,
212
- description: input.description,
213
- content: input.content,
214
- workspaceId: input.workspaceId,
215
- });
216
- }
217
- if (method === 'skills.update') {
218
- return this.skillsService.update(requireString(input, 'id'), {
219
- description: input.description,
220
- content: input.content,
221
- });
222
- }
223
- if (method === 'skills.remove') {
224
- return this.skillsService.remove(requireString(input, 'id'));
225
- }
226
- if (method === 'skills.active.set') {
227
- if (!Array.isArray(input.ids)) {
228
- throw new ws_errors_1.WsRpcError('BAD_REQUEST', 'ids must be string[]');
229
- }
230
- const ids = input.ids
231
- .filter((item) => typeof item === 'string')
232
- .map((item) => item.trim())
233
- .filter(Boolean);
234
- return this.skillsService.setActive(ids);
235
- }
236
- if (method === 'workspace.list') {
237
- return this.workspacesService.list();
238
- }
239
- if (method === 'workspace.add') {
240
- return this.workspacesService.add({
241
- cwd: input.cwd,
242
- name: input.name,
243
- });
244
- }
245
- if (method === 'workspace.update') {
246
- return this.workspacesService.update(requireString(input, 'workspaceId'), {
247
- name: input.name,
248
- });
249
- }
250
- if (method === 'workspace.remove') {
251
- const workspaceId = requireString(input, 'workspaceId');
252
- const sessionsResult = await this.sessionsService.removeSessionsByWorkspace(workspaceId);
253
- const workspaceResult = await this.workspacesService.remove(workspaceId);
254
- return {
255
- ...workspaceResult,
256
- deletedSessions: sessionsResult.deletedSessions,
257
- };
258
- }
259
- if (method === 'workspace.fs.list') {
260
- const path = asString(input.path);
261
- return this.workspacesService.listDirectories(path);
262
- }
263
- throw new ws_errors_1.WsRpcError('METHOD_NOT_FOUND', `Unknown method: ${method}`);
264
- }
265
- };
266
- exports.RpcRouterService = RpcRouterService;
267
- exports.RpcRouterService = RpcRouterService = __decorate([
268
- (0, common_1.Injectable)(),
269
- __metadata("design:paramtypes", [sessions_service_1.SessionsService,
270
- chat_service_1.ChatService,
271
- mcp_service_1.McpService,
272
- skills_service_1.SkillsService,
273
- workspaces_service_1.WorkspacesService,
274
- session_runtime_registry_service_1.SessionRuntimeRegistry])
275
- ], RpcRouterService);
@@ -1,37 +0,0 @@
1
- type RuntimeRecord = {
2
- ownerConnectionId: string;
3
- runtimeHandle?: unknown;
4
- historyFilePath?: string;
5
- workspaceId?: string;
6
- status?: 'idle' | 'running' | 'closed';
7
- updatedAt?: string;
8
- };
9
- export declare class SessionRuntimeRegistry {
10
- private readonly sessionMap;
11
- private readonly connectionSessions;
12
- claim(sessionId: string, connectionId: string): void;
13
- release(sessionId: string, connectionId: string): void;
14
- releaseAll(connectionId: string): string[];
15
- isOwner(sessionId: string, connectionId: string): boolean;
16
- requireOwner(sessionId: string, connectionId: string): void;
17
- setRuntime(sessionId: string, runtimeHandle: unknown): void;
18
- setHistoryFilePath(sessionId: string, historyFilePath: string): void;
19
- setWorkspaceId(sessionId: string, workspaceId: string): void;
20
- setStatus(sessionId: string, status: 'idle' | 'running' | 'closed'): void;
21
- listAll(): Array<{
22
- sessionId: string;
23
- ownerConnectionId: string;
24
- workspaceId?: string;
25
- status?: 'idle' | 'running' | 'closed';
26
- updatedAt?: string;
27
- }>;
28
- listByWorkspace(workspaceId: string): Array<{
29
- sessionId: string;
30
- ownerConnectionId: string;
31
- workspaceId?: string;
32
- status?: 'idle' | 'running' | 'closed';
33
- updatedAt?: string;
34
- }>;
35
- get(sessionId: string): RuntimeRecord | null;
36
- }
37
- export {};
@@ -1,118 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.SessionRuntimeRegistry = void 0;
10
- const common_1 = require("@nestjs/common");
11
- const ws_errors_1 = require("./ws.errors");
12
- let SessionRuntimeRegistry = class SessionRuntimeRegistry {
13
- sessionMap = new Map();
14
- connectionSessions = new Map();
15
- claim(sessionId, connectionId) {
16
- const existing = this.sessionMap.get(sessionId);
17
- if (existing && existing.ownerConnectionId !== connectionId) {
18
- throw new ws_errors_1.WsRpcError('SESSION_OCCUPIED', `Session ${sessionId} is already attached by another connection.`);
19
- }
20
- this.sessionMap.set(sessionId, {
21
- ownerConnectionId: connectionId,
22
- runtimeHandle: existing?.runtimeHandle,
23
- historyFilePath: existing?.historyFilePath,
24
- workspaceId: existing?.workspaceId,
25
- status: existing?.status,
26
- updatedAt: new Date().toISOString(),
27
- });
28
- let set = this.connectionSessions.get(connectionId);
29
- if (!set) {
30
- set = new Set();
31
- this.connectionSessions.set(connectionId, set);
32
- }
33
- set.add(sessionId);
34
- }
35
- release(sessionId, connectionId) {
36
- const record = this.sessionMap.get(sessionId);
37
- if (!record)
38
- return;
39
- if (record.ownerConnectionId !== connectionId)
40
- return;
41
- this.sessionMap.delete(sessionId);
42
- const set = this.connectionSessions.get(connectionId);
43
- if (!set)
44
- return;
45
- set.delete(sessionId);
46
- if (set.size === 0) {
47
- this.connectionSessions.delete(connectionId);
48
- }
49
- }
50
- releaseAll(connectionId) {
51
- const set = this.connectionSessions.get(connectionId);
52
- if (!set || set.size === 0)
53
- return [];
54
- const released = Array.from(set.values());
55
- for (const sessionId of released) {
56
- const record = this.sessionMap.get(sessionId);
57
- if (record && record.ownerConnectionId === connectionId) {
58
- this.sessionMap.delete(sessionId);
59
- }
60
- }
61
- this.connectionSessions.delete(connectionId);
62
- return released;
63
- }
64
- isOwner(sessionId, connectionId) {
65
- const record = this.sessionMap.get(sessionId);
66
- return record?.ownerConnectionId === connectionId;
67
- }
68
- requireOwner(sessionId, connectionId) {
69
- if (!this.isOwner(sessionId, connectionId)) {
70
- throw new ws_errors_1.WsRpcError('SESSION_NOT_ATTACHED', `Session ${sessionId} is not attached.`);
71
- }
72
- }
73
- setRuntime(sessionId, runtimeHandle) {
74
- const record = this.sessionMap.get(sessionId);
75
- if (!record)
76
- return;
77
- record.runtimeHandle = runtimeHandle;
78
- }
79
- setHistoryFilePath(sessionId, historyFilePath) {
80
- const record = this.sessionMap.get(sessionId);
81
- if (!record)
82
- return;
83
- record.historyFilePath = historyFilePath;
84
- }
85
- setWorkspaceId(sessionId, workspaceId) {
86
- const record = this.sessionMap.get(sessionId);
87
- if (!record)
88
- return;
89
- record.workspaceId = workspaceId;
90
- record.updatedAt = new Date().toISOString();
91
- }
92
- setStatus(sessionId, status) {
93
- const record = this.sessionMap.get(sessionId);
94
- if (!record)
95
- return;
96
- record.status = status;
97
- record.updatedAt = new Date().toISOString();
98
- }
99
- listAll() {
100
- return Array.from(this.sessionMap.entries()).map(([sessionId, value]) => ({
101
- sessionId,
102
- ownerConnectionId: value.ownerConnectionId,
103
- workspaceId: value.workspaceId,
104
- status: value.status,
105
- updatedAt: value.updatedAt,
106
- }));
107
- }
108
- listByWorkspace(workspaceId) {
109
- return this.listAll().filter((item) => item.workspaceId === workspaceId);
110
- }
111
- get(sessionId) {
112
- return this.sessionMap.get(sessionId) ?? null;
113
- }
114
- };
115
- exports.SessionRuntimeRegistry = SessionRuntimeRegistry;
116
- exports.SessionRuntimeRegistry = SessionRuntimeRegistry = __decorate([
117
- (0, common_1.Injectable)()
118
- ], SessionRuntimeRegistry);
@@ -1,5 +0,0 @@
1
- import type { RpcEventFrame } from './ws.types';
2
- export declare class WsEventBus {
3
- private seq;
4
- create(topic: string, data: unknown): RpcEventFrame;
5
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.WsEventBus = void 0;
10
- const common_1 = require("@nestjs/common");
11
- let WsEventBus = class WsEventBus {
12
- seq = 0;
13
- create(topic, data) {
14
- this.seq += 1;
15
- return {
16
- type: 'event',
17
- topic,
18
- data,
19
- seq: this.seq,
20
- ts: new Date().toISOString(),
21
- };
22
- }
23
- };
24
- exports.WsEventBus = WsEventBus;
25
- exports.WsEventBus = WsEventBus = __decorate([
26
- (0, common_1.Injectable)()
27
- ], WsEventBus);
@@ -1,2 +0,0 @@
1
- export declare class WsGatewayModule {
2
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.WsGatewayModule = void 0;
10
- const common_1 = require("@nestjs/common");
11
- const chat_module_1 = require("../chat/chat.module");
12
- const mcp_module_1 = require("../mcp/mcp.module");
13
- const sessions_module_1 = require("../sessions/sessions.module");
14
- const skills_module_1 = require("../skills/skills.module");
15
- const stream_module_1 = require("../stream/stream.module");
16
- const workspaces_module_1 = require("../workspaces/workspaces.module");
17
- const rpc_router_service_1 = require("./rpc-router.service");
18
- const session_runtime_registry_service_1 = require("./session-runtime-registry.service");
19
- const ws_event_bus_service_1 = require("./ws-event-bus.service");
20
- const ws_gateway_service_1 = require("./ws-gateway.service");
21
- let WsGatewayModule = class WsGatewayModule {
22
- };
23
- exports.WsGatewayModule = WsGatewayModule;
24
- exports.WsGatewayModule = WsGatewayModule = __decorate([
25
- (0, common_1.Module)({
26
- imports: [
27
- sessions_module_1.SessionsModule,
28
- chat_module_1.ChatModule,
29
- mcp_module_1.McpModule,
30
- skills_module_1.SkillsModule,
31
- stream_module_1.StreamModule,
32
- workspaces_module_1.WorkspacesModule,
33
- ],
34
- providers: [
35
- ws_gateway_service_1.WsGatewayService,
36
- rpc_router_service_1.RpcRouterService,
37
- session_runtime_registry_service_1.SessionRuntimeRegistry,
38
- ws_event_bus_service_1.WsEventBus,
39
- ],
40
- exports: [ws_gateway_service_1.WsGatewayService, session_runtime_registry_service_1.SessionRuntimeRegistry],
41
- })
42
- ], WsGatewayModule);
@@ -1,42 +0,0 @@
1
- import type { IncomingMessage } from 'node:http';
2
- import { OnModuleDestroy } from '@nestjs/common';
3
- import type { AccessTokenPayload } from '../auth/auth.types';
4
- import { StreamService } from '../stream/stream.service';
5
- import { RpcRouterService } from './rpc-router.service';
6
- import { SessionRuntimeRegistry } from './session-runtime-registry.service';
7
- import { WsEventBus } from './ws-event-bus.service';
8
- type AccessTokenVerifier = (token: string) => Promise<AccessTokenPayload>;
9
- type AttachOptions = {
10
- httpServer: {
11
- on: (event: 'upgrade', listener: (request: IncomingMessage, socket: import('node:net').Socket, head: Buffer) => void) => void;
12
- };
13
- verifyAccessToken: AccessTokenVerifier;
14
- };
15
- export declare class WsGatewayService implements OnModuleDestroy {
16
- private readonly rpcRouter;
17
- private readonly streamService;
18
- private readonly sessionRegistry;
19
- private readonly eventBus;
20
- private readonly logger;
21
- private readonly connections;
22
- private wsServer;
23
- private attached;
24
- private globalStreamUnsubscribe;
25
- constructor(rpcRouter: RpcRouterService, streamService: StreamService, sessionRegistry: SessionRuntimeRegistry, eventBus: WsEventBus);
26
- attach(options: AttachOptions): void;
27
- onModuleDestroy(): Promise<void>;
28
- private handleConnection;
29
- private handleMessage;
30
- private bindSession;
31
- private unbindSession;
32
- private cleanupConnection;
33
- private mapStreamPayload;
34
- private mapRuntimeStatusPayload;
35
- private sendRpcSuccess;
36
- private sendRpcError;
37
- private sendEvent;
38
- private broadcastEventToAll;
39
- private sendSerialized;
40
- private toWsRpcError;
41
- }
42
- export {};