@nine-lab/nine-mu 0.1.256 โ†’ 0.1.258

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nine-lab/nine-mu",
3
- "version": "0.1.256",
3
+ "version": "0.1.258",
4
4
  "description": "AI-Driven Full-Stack Code Fabrication Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-mu.umd.js",
@@ -3,7 +3,8 @@ import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/webso
3
3
  import { trace } from "@nopeer";
4
4
  import { api } from "@nine-lab/nine-util";
5
5
  import { z } from "zod";
6
- import { LoggingMessageNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
6
+ //import { LoggingMessageNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
7
+ import { NotificationHandler } from "./NotificationHandler.js";
7
8
 
8
9
  export class NineChatManager {
9
10
  #mcpClient;
@@ -13,6 +14,7 @@ export class NineChatManager {
13
14
  #owner;
14
15
  #routeUrl;
15
16
  #chatHistory = []; // ๐Ÿ’ก ์ด์ „ ๋Œ€ํ™”๋“ค์„ ์ €์žฅํ•  ๋ฉ”๋ชจ๋ฆฌ ์ฐฝ๊ณ 
17
+ #notiHandler;
16
18
 
17
19
  constructor(owner, callbacks = {}) {
18
20
  this.#owner = owner;
@@ -23,6 +25,7 @@ export class NineChatManager {
23
25
  this.#onStatus = callbacks.onStatus;
24
26
  this.#onMessage = callbacks.onMessage;
25
27
 
28
+ this.#notiHandler = new NotificationHandler(this.#owner);
26
29
  // ์—ฐ๊ฒฐ ์‹œ์ž‘ (๋น„๋™๊ธฐ)
27
30
  this.#connect();
28
31
  }
@@ -44,7 +47,7 @@ export class NineChatManager {
44
47
 
45
48
  //trace.log(this.#mcpClient);
46
49
 
47
- this.#mcpClient.connect(transport, {timeout: 300000})
50
+ this.#mcpClient.connect(transport, {timeout: 3000000})
48
51
  .then( async () => {
49
52
  this.#updateStatus("โœ… MCP Connected");
50
53
 
@@ -69,6 +72,14 @@ export class NineChatManager {
69
72
  })
70
73
  });
71
74
  //
75
+ this.#mcpClient.setNotificationHandler(
76
+ customNotificationSchema,
77
+ (notification) => {
78
+ // ๋‚ ๊ฒƒ์˜ ์ˆ˜์‹  ๋ฐ์ดํ„ฐ๋ฅผ ๊ทธ๋Œ€๋กœ ๊ฐ€๊ณต ์ „๋‹ด ํŒŒ์ผ๋กœ ๋˜์ง!
79
+ this.#notiHandler.handle(notification);
80
+ }
81
+ );
82
+ /**
72
83
  this.#mcpClient.setNotificationHandler(
73
84
  customNotificationSchema, // ๐Ÿ‘ˆ ๊ป๋ฐ๊ธฐ ํ†ต๊ณผ์šฉ ์ปค์Šคํ…€ ์Šคํ‚ค๋งˆ
74
85
  (notification) => {
@@ -78,7 +89,7 @@ export class NineChatManager {
78
89
  this.#owner.addMessage("ai", notification.params.message);
79
90
  this.#owner.addMessage("ing", "");
80
91
  }
81
- );
92
+ ); */
82
93
  })
83
94
  .catch((err) => {
84
95
  trace.error("โŒ MCP ์—ฐ๊ฒฐ ์‹คํŒจ", err);
@@ -114,7 +125,7 @@ export class NineChatManager {
114
125
  return this.#mcpClient.callTool(
115
126
  { name: toolName, arguments: args },
116
127
  undefined, // ํ•„์š” ์‹œ extra ๋ณ€์ˆ˜ ์ž๋ฆฌ (๊ธฐ๋ณธ๊ฐ’ undefined)
117
- { timeout: 300000 } // ๐Ÿ’ก ๊ฐœ๋ณ„ ์š”์ฒญ ํƒ€์ž„์•„์›ƒ์„ 5๋ถ„์œผ๋กœ ํ™•์žฅ
128
+ { timeout: 3000000 } // ๐Ÿ’ก ๊ฐœ๋ณ„ ์š”์ฒญ ํƒ€์ž„์•„์›ƒ์„ 5๋ถ„์œผ๋กœ ํ™•์žฅ
118
129
  );
119
130
  }
120
131
 
@@ -0,0 +1,66 @@
1
+ import { trace } from "@nopeer";
2
+
3
+ export class NotificationHandler {
4
+ #owner;
5
+
6
+ constructor(owner) {
7
+ this.#owner = owner; // ์›น ์ปดํฌ๋„ŒํŠธ๋‚˜ UI DOM ์ธ์Šคํ„ด์Šค
8
+ }
9
+
10
+ /**
11
+ * MCP๋กœ๋ถ€ํ„ฐ ์ˆ˜์‹ ๋œ ๋‚ ๊ฒƒ์˜ ๋…ธํ‹ฐํŒŒ์ด ๋ฐ์ดํ„ฐ๋ฅผ ์ •์„๋Œ€๋กœ ๋ผ์šฐํŒ…ํ•˜๋Š” ๋ฉ”์ธ ๋ฉ”์„œ๋“œ
12
+ */
13
+ handle(notification) {
14
+ try {
15
+ const { method, params } = notification;
16
+
17
+ // ๋กœ๊น… ๋ฐ ์ง„ํ–‰ ์ƒํ™ฉ ๋ฉ”์‹œ์ง€ ๋…ธํ‹ฐ์ธ ๊ฒฝ์šฐ
18
+ if (method === "notifications/logging/message") {
19
+ this.#handleLoggingMessage(params);
20
+ }
21
+
22
+ // ์ถ”ํ›„ ๋‹ค๋ฅธ ํ”„๋กœํ† ์ฝœ ๋ฉ”์„œ๋“œ๊ฐ€ ์ถ”๊ฐ€๋˜๋ฉด ์—ฌ๊ธฐ์— ๊น”๋”ํ•˜๊ฒŒ ๋ถ„๊ธฐ ํ™•์žฅ ๊ฐ€๋Šฅ
23
+ // else if (method === "notifications/๋‹ค๋ฅธ๊ฑฐ") { ... }
24
+
25
+ } catch (error) {
26
+ trace.error("๐Ÿ”ฅ ๋…ธํ‹ฐํŒŒ์ด ํ•ธ๋“ค๋Ÿฌ ๋‚ด๋ถ€ ์ฒ˜๋ฆฌ ์‹คํŒจ:", error);
27
+ }
28
+ }
29
+
30
+ /**
31
+ * [๋ถ„๋ฆฌ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง 1] ๋กœ๊น… ๋ฐ UI ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ ์ œ์–ด
32
+ */
33
+ #handleLoggingMessage(params) {
34
+ const { message, data, logger } = params;
35
+
36
+ // 1. ๊ธฐ๋ณธ UI ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ (ํ™”๋ฉด์— ์‹ค์‹œ๊ฐ„์œผ๋กœ ๋นŒ๋“œ ์ƒํƒœ ๋ฟŒ๋ ค์ฃผ๊ธฐ)
37
+ if (message) {
38
+ this.#owner.addMessage("ai", message);
39
+ this.#owner.addMessage("ing", "");
40
+ }
41
+
42
+ // 2. ๐Ÿšจ [๋‚˜์ค‘์— 100์‹œ๊ฐ„์งœ๋ฆฌ ์™„๋ฒฝ์„ ์ฑ„์šธ ํ•ต์‹ฌ ๊ธธ๋ชฉ]
43
+ // ๋ฐ์ดํ„ฐ์— ์†Œ์Šค์ฝ”๋“œ ์•Œ๋งน์ด(data.source)๋‚˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๊ฐ€ ์‹ค๋ ค ๋‚ด๋ ค์™”์„ ๋•Œ์˜ ํ–‰์œ„๋ฅผ ์—ฌ๊ธฐ์„œ ๊ฒฉ๋ฆฌ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
44
+ if (data && data.status === "PROGRESS") {
45
+ trace.log(`[์‹œ๊ทธ๋„ ๊ฐ์ง€] ${data.menu} - ${data.layer} ์„ค๊ณ„ ์™„๋ฃŒ`);
46
+
47
+ // ์—ฌ๊ธฐ์„œ ํŒŒ์ผ ์ €์žฅ ์ „ ๋ฒ„ํผ์— ๋ชจ์œผ๊ฑฐ๋‚˜,
48
+ // ๋ฐฉ์–ด์šฉ ํ—ฌํผ ๊ฐ์ฒด๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ์†Œ์Šค ํŒŒ์‹ฑ ๊ฒ€์ฆ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๋“ฑ์˜ ์ •์„ ๋กœ์ง์ด ๋“ค์–ด๊ฐˆ ์ž๋ฆฌ์ž…๋‹ˆ๋‹ค.
49
+ //this.#processSourceData(data);
50
+ }
51
+ }
52
+
53
+ /**
54
+ * [๋ถ„๋ฆฌ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง 2] ์ˆ˜์‹ ๋œ ์†Œ์Šค์ฝ”๋“œ ๋ฐ์ดํ„ฐ ์œ ํšจ์„ฑ ๊ฒ€์ฆ ๋ฐ ์ถ”ํ›„ ํŒŒ์ผ ์ €์žฅ ์—ฐ๋™
55
+ */
56
+ #processSourceData(sourceData) {
57
+ // ์†Œ์Šค์ฝ”๋“œ ๋ฐ์ดํ„ฐ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ํ™•๋ณด๋˜์—ˆ๋Š”์ง€ 1%์˜ ๋ˆ„๋ฝ ๊ฒ€์ฆ
58
+ if (!sourceData.source || !sourceData.file_name) {
59
+ trace.warn("โš ๏ธ ์†Œ์Šค ๋˜๋Š” ํŒŒ์ผ๋ช… ๋ˆ„๋ฝ ๋ฐ์ดํ„ฐ ์ˆ˜์‹ ๋จ", sourceData);
60
+ return;
61
+ }
62
+
63
+ // TODO: ์ถ”ํ›„ ๋‹ค๋ฅธ ๊ฑฐ ๊ฐœ๋ฐœ ์™„๋ฃŒ ์‹œ, ์—ฌ๊ธฐ์— ์‹ค์ œ ๋กœ์ปฌ ๋ฌผ๋ฆฌ ํŒŒ์ผ ๋ผ์ดํ„ฐ ์„œ๋น„์Šค ์—ฐ๊ฒฐ
64
+ // Example: FileWritableService.write(sourceData.path, sourceData.file_name, sourceData.source);
65
+ }
66
+ }