@hed-hog/core 0.0.349 → 0.0.350
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/dist/auth/auth.controller.d.ts +3 -3
- package/dist/auth/auth.service.d.ts +8 -8
- package/dist/core.module.d.ts.map +1 -1
- package/dist/core.module.js +3 -0
- package/dist/core.module.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/guards/mcp-auth.guard.d.ts +6 -1
- package/dist/mcp/guards/mcp-auth.guard.d.ts.map +1 -1
- package/dist/mcp/guards/mcp-auth.guard.js +29 -2
- package/dist/mcp/guards/mcp-auth.guard.js.map +1 -1
- package/dist/mcp/mcp-api-key.controller.d.ts +32 -0
- package/dist/mcp/mcp-api-key.controller.d.ts.map +1 -0
- package/dist/mcp/mcp-api-key.controller.js +64 -0
- package/dist/mcp/mcp-api-key.controller.js.map +1 -0
- package/dist/mcp/mcp-api-key.service.d.ts +27 -0
- package/dist/mcp/mcp-api-key.service.d.ts.map +1 -0
- package/dist/mcp/mcp-api-key.service.js +74 -0
- package/dist/mcp/mcp-api-key.service.js.map +1 -0
- package/dist/mcp/mcp-registry.service.d.ts +1 -2
- package/dist/mcp/mcp-registry.service.d.ts.map +1 -1
- package/dist/mcp/mcp-registry.service.js +6 -2
- package/dist/mcp/mcp-registry.service.js.map +1 -1
- package/dist/mcp/mcp.module.d.ts.map +1 -1
- package/dist/mcp/mcp.module.js +8 -1
- package/dist/mcp/mcp.module.js.map +1 -1
- package/dist/mcp-chat/mcp-chat.controller.d.ts +4 -0
- package/dist/mcp-chat/mcp-chat.controller.d.ts.map +1 -1
- package/dist/mcp-chat/mcp-chat.controller.js +46 -0
- package/dist/mcp-chat/mcp-chat.controller.js.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.d.ts +6 -1
- package/dist/mcp-chat/mcp-chat.service.d.ts.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.js +125 -17
- package/dist/mcp-chat/mcp-chat.service.js.map +1 -1
- package/dist/notification/dto/create-notification.dto.d.ts +26 -0
- package/dist/notification/dto/create-notification.dto.d.ts.map +1 -0
- package/dist/notification/dto/create-notification.dto.js +86 -0
- package/dist/notification/dto/create-notification.dto.js.map +1 -0
- package/dist/notification/dto/update-progress.dto.d.ts +6 -0
- package/dist/notification/dto/update-progress.dto.d.ts.map +1 -0
- package/dist/notification/dto/update-progress.dto.js +33 -0
- package/dist/notification/dto/update-progress.dto.js.map +1 -0
- package/dist/notification/notification.controller.d.ts +108 -0
- package/dist/notification/notification.controller.d.ts.map +1 -0
- package/dist/notification/notification.controller.js +118 -0
- package/dist/notification/notification.controller.js.map +1 -0
- package/dist/notification/notification.module.d.ts +3 -0
- package/dist/notification/notification.module.d.ts.map +1 -0
- package/dist/notification/notification.module.js +29 -0
- package/dist/notification/notification.module.js.map +1 -0
- package/dist/notification/notification.service.d.ts +98 -0
- package/dist/notification/notification.service.d.ts.map +1 -0
- package/dist/notification/notification.service.js +123 -0
- package/dist/notification/notification.service.js.map +1 -0
- package/dist/profile/profile.controller.d.ts +1 -1
- package/dist/profile/profile.service.d.ts +1 -1
- package/dist/session/session.controller.d.ts +1 -1
- package/dist/session/session.service.d.ts +3 -3
- package/dist/setting/dto/update-setting-list.dto.d.ts +9 -0
- package/dist/setting/dto/update-setting-list.dto.d.ts.map +1 -0
- package/dist/setting/dto/update-setting-list.dto.js +44 -0
- package/dist/setting/dto/update-setting-list.dto.js.map +1 -0
- package/dist/setting/setting.controller.d.ts +19 -0
- package/dist/setting/setting.controller.d.ts.map +1 -1
- package/dist/setting/setting.controller.js +12 -0
- package/dist/setting/setting.controller.js.map +1 -1
- package/dist/setting/setting.service.d.ts +19 -0
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +79 -0
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/task/task.service.d.ts +12 -0
- package/dist/task/task.service.d.ts.map +1 -1
- package/dist/task/task.service.js +60 -0
- package/dist/task/task.service.js.map +1 -1
- package/dist/user/user.controller.d.ts +2 -2
- package/dist/user/user.service.d.ts +6 -6
- package/dist/webhook-integration/webhook-integration.service.d.ts +4 -0
- package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.js +184 -34
- package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
- package/dist/webhook-integration/webhook-utils.d.ts +1 -0
- package/dist/webhook-integration/webhook-utils.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-utils.js +38 -0
- package/dist/webhook-integration/webhook-utils.js.map +1 -1
- package/hedhog/data/menu.yaml +48 -4
- package/hedhog/data/route.yaml +133 -0
- package/hedhog/data/setting_group.yaml +45 -0
- package/hedhog/data/setting_subgroup.yaml +16 -0
- package/hedhog/frontend/app/account/components/mcp-tokens.tsx.ejs +285 -0
- package/hedhog/frontend/app/account/layout.tsx.ejs +32 -55
- package/hedhog/frontend/app/account/mcp-tokens/page.tsx.ejs +5 -0
- package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +2098 -1835
- package/hedhog/frontend/app/mcp_chat/chat-components.tsx.ejs +595 -0
- package/hedhog/frontend/app/mcp_chat/chat-types.ts.ejs +16 -0
- package/hedhog/frontend/app/mcp_chat/page.tsx.ejs +554 -383
- package/hedhog/frontend/app/setting-list/page.tsx.ejs +649 -0
- package/hedhog/frontend/app/users/page.tsx.ejs +445 -203
- package/hedhog/frontend/app/users/user-sheet.tsx.ejs +16 -37
- package/hedhog/frontend/messages/en.json +241 -2
- package/hedhog/frontend/messages/pt.json +241 -2
- package/hedhog/table/mcp_api_key.yaml +30 -0
- package/hedhog/table/notification.yaml +72 -0
- package/hedhog/table/webhook_action_log.yaml +49 -0
- package/package.json +4 -4
- package/src/core.module.ts +3 -0
- package/src/index.ts +5 -0
- package/src/mcp/guards/mcp-auth.guard.ts +64 -32
- package/src/mcp/mcp-api-key.controller.ts +42 -0
- package/src/mcp/mcp-api-key.service.ts +66 -0
- package/src/mcp/mcp-registry.service.ts +75 -69
- package/src/mcp/mcp.module.ts +43 -36
- package/src/mcp-chat/mcp-chat.controller.ts +113 -60
- package/src/mcp-chat/mcp-chat.service.ts +494 -332
- package/src/notification/dto/create-notification.dto.ts +71 -0
- package/src/notification/dto/update-progress.dto.ts +16 -0
- package/src/notification/notification.controller.ts +71 -0
- package/src/notification/notification.module.ts +16 -0
- package/src/notification/notification.service.ts +124 -0
- package/src/setting/dto/update-setting-list.dto.ts +32 -0
- package/src/setting/setting.controller.ts +9 -0
- package/src/setting/setting.service.ts +91 -0
- package/src/task/task.service.ts +72 -0
- package/src/webhook-integration/webhook-integration.service.ts +934 -735
- package/src/webhook-integration/webhook-utils.ts +136 -79
|
@@ -1,60 +1,113 @@
|
|
|
1
|
-
import { Role, User } from '@hed-hog/api';
|
|
2
|
-
import { Locale } from '@hed-hog/api-locale';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
@
|
|
56
|
-
@
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
import { Role, User } from '@hed-hog/api';
|
|
2
|
+
import { Locale } from '@hed-hog/api-locale';
|
|
3
|
+
import {
|
|
4
|
+
Body,
|
|
5
|
+
Controller,
|
|
6
|
+
Delete,
|
|
7
|
+
Get,
|
|
8
|
+
Param,
|
|
9
|
+
ParseIntPipe,
|
|
10
|
+
Post,
|
|
11
|
+
Res,
|
|
12
|
+
} from '@nestjs/common';
|
|
13
|
+
import { Response } from 'express';
|
|
14
|
+
import { DeleteDTO } from '../dto/delete.dto';
|
|
15
|
+
import { CreateConversationDTO } from './dto/create-conversation.dto';
|
|
16
|
+
import { SendMessageDTO } from './dto/send-message.dto';
|
|
17
|
+
import { McpChatService } from './mcp-chat.service';
|
|
18
|
+
|
|
19
|
+
@Role()
|
|
20
|
+
@Controller('mcp-chat')
|
|
21
|
+
export class McpChatController {
|
|
22
|
+
constructor(private readonly service: McpChatService) {}
|
|
23
|
+
|
|
24
|
+
@Get()
|
|
25
|
+
listConversations(@User() { id }: { id: number }) {
|
|
26
|
+
return this.service.listConversations(id);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Post()
|
|
30
|
+
createConversation(
|
|
31
|
+
@User() { id }: { id: number },
|
|
32
|
+
@Body() dto: CreateConversationDTO,
|
|
33
|
+
) {
|
|
34
|
+
return this.service.createConversation(id, dto);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Delete()
|
|
38
|
+
deleteConversations(
|
|
39
|
+
@User() { id }: { id: number },
|
|
40
|
+
@Body() dto: DeleteDTO,
|
|
41
|
+
) {
|
|
42
|
+
return this.service.deleteConversations(id, dto.ids);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Get(':id/messages')
|
|
46
|
+
getMessages(
|
|
47
|
+
@User() { id }: { id: number },
|
|
48
|
+
@Param('id', ParseIntPipe) conversationId: number,
|
|
49
|
+
) {
|
|
50
|
+
return this.service.getMessages(conversationId, id);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Post(':id/messages')
|
|
54
|
+
sendMessage(
|
|
55
|
+
@User() { id }: { id: number },
|
|
56
|
+
@Param('id', ParseIntPipe) conversationId: number,
|
|
57
|
+
@Body() dto: SendMessageDTO,
|
|
58
|
+
@Locale() locale: string,
|
|
59
|
+
) {
|
|
60
|
+
return this.service.sendMessage(conversationId, id, locale, dto.message);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Post(':id/messages/stream')
|
|
64
|
+
async sendMessageStream(
|
|
65
|
+
@User() { id }: { id: number },
|
|
66
|
+
@Param('id', ParseIntPipe) conversationId: number,
|
|
67
|
+
@Body() dto: SendMessageDTO,
|
|
68
|
+
@Locale() locale: string,
|
|
69
|
+
@Res() res: Response,
|
|
70
|
+
) {
|
|
71
|
+
res.setHeader('Content-Type', 'text/event-stream; charset=utf-8');
|
|
72
|
+
res.setHeader('Cache-Control', 'no-cache, no-transform');
|
|
73
|
+
res.setHeader('Connection', 'keep-alive');
|
|
74
|
+
res.setHeader('X-Accel-Buffering', 'no');
|
|
75
|
+
res.flushHeaders();
|
|
76
|
+
|
|
77
|
+
const writeEvent = (payload: unknown) => {
|
|
78
|
+
res.write(`data: ${JSON.stringify(payload)}\n\n`);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const messages = await this.service.sendMessage(
|
|
83
|
+
conversationId,
|
|
84
|
+
id,
|
|
85
|
+
locale,
|
|
86
|
+
dto.message,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const lastAssistant = [...messages]
|
|
90
|
+
.reverse()
|
|
91
|
+
.find((msg) => msg.role === 'assistant');
|
|
92
|
+
const content = lastAssistant?.content ?? '';
|
|
93
|
+
|
|
94
|
+
if (content.length > 0) {
|
|
95
|
+
const chunkSize = Math.max(8, Math.min(32, Math.ceil(content.length / 80)));
|
|
96
|
+
for (let cursor = 0; cursor < content.length; cursor += chunkSize) {
|
|
97
|
+
writeEvent({
|
|
98
|
+
type: 'chunk',
|
|
99
|
+
content: content.slice(cursor, cursor + chunkSize),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
writeEvent({ type: 'done', messages });
|
|
105
|
+
} catch (error) {
|
|
106
|
+
const message =
|
|
107
|
+
error instanceof Error ? error.message : 'Failed to stream message';
|
|
108
|
+
writeEvent({ type: 'error', message });
|
|
109
|
+
} finally {
|
|
110
|
+
res.end();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|