@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.
Files changed (126) hide show
  1. package/dist/auth/auth.controller.d.ts +3 -3
  2. package/dist/auth/auth.service.d.ts +8 -8
  3. package/dist/core.module.d.ts.map +1 -1
  4. package/dist/core.module.js +3 -0
  5. package/dist/core.module.js.map +1 -1
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +4 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/mcp/guards/mcp-auth.guard.d.ts +6 -1
  11. package/dist/mcp/guards/mcp-auth.guard.d.ts.map +1 -1
  12. package/dist/mcp/guards/mcp-auth.guard.js +29 -2
  13. package/dist/mcp/guards/mcp-auth.guard.js.map +1 -1
  14. package/dist/mcp/mcp-api-key.controller.d.ts +32 -0
  15. package/dist/mcp/mcp-api-key.controller.d.ts.map +1 -0
  16. package/dist/mcp/mcp-api-key.controller.js +64 -0
  17. package/dist/mcp/mcp-api-key.controller.js.map +1 -0
  18. package/dist/mcp/mcp-api-key.service.d.ts +27 -0
  19. package/dist/mcp/mcp-api-key.service.d.ts.map +1 -0
  20. package/dist/mcp/mcp-api-key.service.js +74 -0
  21. package/dist/mcp/mcp-api-key.service.js.map +1 -0
  22. package/dist/mcp/mcp-registry.service.d.ts +1 -2
  23. package/dist/mcp/mcp-registry.service.d.ts.map +1 -1
  24. package/dist/mcp/mcp-registry.service.js +6 -2
  25. package/dist/mcp/mcp-registry.service.js.map +1 -1
  26. package/dist/mcp/mcp.module.d.ts.map +1 -1
  27. package/dist/mcp/mcp.module.js +8 -1
  28. package/dist/mcp/mcp.module.js.map +1 -1
  29. package/dist/mcp-chat/mcp-chat.controller.d.ts +4 -0
  30. package/dist/mcp-chat/mcp-chat.controller.d.ts.map +1 -1
  31. package/dist/mcp-chat/mcp-chat.controller.js +46 -0
  32. package/dist/mcp-chat/mcp-chat.controller.js.map +1 -1
  33. package/dist/mcp-chat/mcp-chat.service.d.ts +6 -1
  34. package/dist/mcp-chat/mcp-chat.service.d.ts.map +1 -1
  35. package/dist/mcp-chat/mcp-chat.service.js +125 -17
  36. package/dist/mcp-chat/mcp-chat.service.js.map +1 -1
  37. package/dist/notification/dto/create-notification.dto.d.ts +26 -0
  38. package/dist/notification/dto/create-notification.dto.d.ts.map +1 -0
  39. package/dist/notification/dto/create-notification.dto.js +86 -0
  40. package/dist/notification/dto/create-notification.dto.js.map +1 -0
  41. package/dist/notification/dto/update-progress.dto.d.ts +6 -0
  42. package/dist/notification/dto/update-progress.dto.d.ts.map +1 -0
  43. package/dist/notification/dto/update-progress.dto.js +33 -0
  44. package/dist/notification/dto/update-progress.dto.js.map +1 -0
  45. package/dist/notification/notification.controller.d.ts +108 -0
  46. package/dist/notification/notification.controller.d.ts.map +1 -0
  47. package/dist/notification/notification.controller.js +118 -0
  48. package/dist/notification/notification.controller.js.map +1 -0
  49. package/dist/notification/notification.module.d.ts +3 -0
  50. package/dist/notification/notification.module.d.ts.map +1 -0
  51. package/dist/notification/notification.module.js +29 -0
  52. package/dist/notification/notification.module.js.map +1 -0
  53. package/dist/notification/notification.service.d.ts +98 -0
  54. package/dist/notification/notification.service.d.ts.map +1 -0
  55. package/dist/notification/notification.service.js +123 -0
  56. package/dist/notification/notification.service.js.map +1 -0
  57. package/dist/profile/profile.controller.d.ts +1 -1
  58. package/dist/profile/profile.service.d.ts +1 -1
  59. package/dist/session/session.controller.d.ts +1 -1
  60. package/dist/session/session.service.d.ts +3 -3
  61. package/dist/setting/dto/update-setting-list.dto.d.ts +9 -0
  62. package/dist/setting/dto/update-setting-list.dto.d.ts.map +1 -0
  63. package/dist/setting/dto/update-setting-list.dto.js +44 -0
  64. package/dist/setting/dto/update-setting-list.dto.js.map +1 -0
  65. package/dist/setting/setting.controller.d.ts +19 -0
  66. package/dist/setting/setting.controller.d.ts.map +1 -1
  67. package/dist/setting/setting.controller.js +12 -0
  68. package/dist/setting/setting.controller.js.map +1 -1
  69. package/dist/setting/setting.service.d.ts +19 -0
  70. package/dist/setting/setting.service.d.ts.map +1 -1
  71. package/dist/setting/setting.service.js +79 -0
  72. package/dist/setting/setting.service.js.map +1 -1
  73. package/dist/task/task.service.d.ts +12 -0
  74. package/dist/task/task.service.d.ts.map +1 -1
  75. package/dist/task/task.service.js +60 -0
  76. package/dist/task/task.service.js.map +1 -1
  77. package/dist/user/user.controller.d.ts +2 -2
  78. package/dist/user/user.service.d.ts +6 -6
  79. package/dist/webhook-integration/webhook-integration.service.d.ts +4 -0
  80. package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
  81. package/dist/webhook-integration/webhook-integration.service.js +184 -34
  82. package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
  83. package/dist/webhook-integration/webhook-utils.d.ts +1 -0
  84. package/dist/webhook-integration/webhook-utils.d.ts.map +1 -1
  85. package/dist/webhook-integration/webhook-utils.js +38 -0
  86. package/dist/webhook-integration/webhook-utils.js.map +1 -1
  87. package/hedhog/data/menu.yaml +48 -4
  88. package/hedhog/data/route.yaml +133 -0
  89. package/hedhog/data/setting_group.yaml +45 -0
  90. package/hedhog/data/setting_subgroup.yaml +16 -0
  91. package/hedhog/frontend/app/account/components/mcp-tokens.tsx.ejs +285 -0
  92. package/hedhog/frontend/app/account/layout.tsx.ejs +32 -55
  93. package/hedhog/frontend/app/account/mcp-tokens/page.tsx.ejs +5 -0
  94. package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +2098 -1835
  95. package/hedhog/frontend/app/mcp_chat/chat-components.tsx.ejs +595 -0
  96. package/hedhog/frontend/app/mcp_chat/chat-types.ts.ejs +16 -0
  97. package/hedhog/frontend/app/mcp_chat/page.tsx.ejs +554 -383
  98. package/hedhog/frontend/app/setting-list/page.tsx.ejs +649 -0
  99. package/hedhog/frontend/app/users/page.tsx.ejs +445 -203
  100. package/hedhog/frontend/app/users/user-sheet.tsx.ejs +16 -37
  101. package/hedhog/frontend/messages/en.json +241 -2
  102. package/hedhog/frontend/messages/pt.json +241 -2
  103. package/hedhog/table/mcp_api_key.yaml +30 -0
  104. package/hedhog/table/notification.yaml +72 -0
  105. package/hedhog/table/webhook_action_log.yaml +49 -0
  106. package/package.json +4 -4
  107. package/src/core.module.ts +3 -0
  108. package/src/index.ts +5 -0
  109. package/src/mcp/guards/mcp-auth.guard.ts +64 -32
  110. package/src/mcp/mcp-api-key.controller.ts +42 -0
  111. package/src/mcp/mcp-api-key.service.ts +66 -0
  112. package/src/mcp/mcp-registry.service.ts +75 -69
  113. package/src/mcp/mcp.module.ts +43 -36
  114. package/src/mcp-chat/mcp-chat.controller.ts +113 -60
  115. package/src/mcp-chat/mcp-chat.service.ts +494 -332
  116. package/src/notification/dto/create-notification.dto.ts +71 -0
  117. package/src/notification/dto/update-progress.dto.ts +16 -0
  118. package/src/notification/notification.controller.ts +71 -0
  119. package/src/notification/notification.module.ts +16 -0
  120. package/src/notification/notification.service.ts +124 -0
  121. package/src/setting/dto/update-setting-list.dto.ts +32 -0
  122. package/src/setting/setting.controller.ts +9 -0
  123. package/src/setting/setting.service.ts +91 -0
  124. package/src/task/task.service.ts +72 -0
  125. package/src/webhook-integration/webhook-integration.service.ts +934 -735
  126. 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
- Body,
5
- Controller,
6
- Delete,
7
- Get,
8
- Param,
9
- ParseIntPipe,
10
- Post,
11
- } from '@nestjs/common';
12
- import { DeleteDTO } from '../dto/delete.dto';
13
- import { CreateConversationDTO } from './dto/create-conversation.dto';
14
- import { SendMessageDTO } from './dto/send-message.dto';
15
- import { McpChatService } from './mcp-chat.service';
16
-
17
- @Role()
18
- @Controller('mcp-chat')
19
- export class McpChatController {
20
- constructor(private readonly service: McpChatService) {}
21
-
22
- @Get()
23
- listConversations(@User() { id }: { id: number }) {
24
- return this.service.listConversations(id);
25
- }
26
-
27
- @Post()
28
- createConversation(
29
- @User() { id }: { id: number },
30
- @Body() dto: CreateConversationDTO,
31
- ) {
32
- return this.service.createConversation(id, dto);
33
- }
34
-
35
- @Delete()
36
- deleteConversations(
37
- @User() { id }: { id: number },
38
- @Body() dto: DeleteDTO,
39
- ) {
40
- return this.service.deleteConversations(id, dto.ids);
41
- }
42
-
43
- @Get(':id/messages')
44
- getMessages(
45
- @User() { id }: { id: number },
46
- @Param('id', ParseIntPipe) conversationId: number,
47
- ) {
48
- return this.service.getMessages(conversationId, id);
49
- }
50
-
51
- @Post(':id/messages')
52
- sendMessage(
53
- @User() { id }: { id: number },
54
- @Param('id', ParseIntPipe) conversationId: number,
55
- @Body() dto: SendMessageDTO,
56
- @Locale() locale: string,
57
- ) {
58
- return this.service.sendMessage(conversationId, id, locale, dto.message);
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
+ }