@nine-lab/nine-mu 0.1.213 → 0.1.214

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.213",
3
+ "version": "0.1.214",
4
4
  "description": "AI-Driven Full-Stack Code Fabrication Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-mu.umd.js",
@@ -97,11 +97,33 @@ export class NineChat extends HTMLElement {
97
97
 
98
98
  if (err) {
99
99
  trace.error(err);
100
+ // 에러가 났을 때 기존 로딩 컴포넌트를 지우거나 교체하는 로직이 있다면 연동해 주세요.
100
101
  this.#$nineChatMessage.add("ai", err.message || "알 수 없는 오류가 발생했습니다. 다시 시도해주세요.");
101
102
  } else {
102
103
  trace.log(result);
103
- this.#manager.addChatHistory(result.message);
104
- this.#$nineChatMessage.add("ai", result.message);
104
+
105
+ try {
106
+ // 💡 [핵심] MCP 규격의 content[0].text에서 스트링을 추출합니다.
107
+ const rawText = result?.content?.[0]?.text;
108
+
109
+ // 텍스트를 JSON 객체로 파싱
110
+ const parsedData = JSON.parse(rawText);
111
+
112
+ // 관제탑(system-brain)이나 하위 툴이 준 실제 대화 메시지 추출
113
+ const aiMessage = parsedData.message || "처리가 완료되었습니다.";
114
+
115
+ // 매니저 히스토리 저장 및 UI 반영
116
+ this.#manager.addChatHistory(aiMessage);
117
+ this.#$nineChatMessage.add("ai", aiMessage);
118
+
119
+ // 💡 만약 intent가 EXECUTE_TOOL이거나 NAVIGATE일 때 프론트에서
120
+ // 화면 이동(Routing)이나 추가 액션을 해야 한다면 여기서 parsedData.target_path 등을 활용하면 됩니다!
121
+
122
+ } catch (parseErr) {
123
+ // 만약 AI가 JSON 형식이 아닌 일반 텍스트로 답장했을 경우를 대비한 예외 처리
124
+ const fallbackMessage = result?.content?.[0]?.text || "응답 데이터를 해석하지 못했습니다.";
125
+ this.#$nineChatMessage.add("ai", fallbackMessage);
126
+ }
105
127
  }
106
128
  }
107
129
  });
@@ -72,21 +72,9 @@ export class NineChatManager {
72
72
  (notification) => {
73
73
  //notification.params.message
74
74
  trace.log(notification);
75
- trace.log(this);
75
+
76
76
  this.#owner.addMessage("ai", notification.params.message);
77
77
  this.#owner.addMessage("ing", "");
78
- /**
79
- try {
80
- trace.log("🔔 [MCP 엔진 우회 성공] 알림 도착:", notification);
81
-
82
- const logData = JSON.parse(notification.params.message);
83
- if (logData.type === "BRAIN_DECISION") {
84
- // 드디어 MCP 정식 핸들러를 타고 UI에 안착!
85
- // this.#pushMessage('assistant', logData.message);
86
- }
87
- } catch (e) {
88
- trace.warn("알림 내부 파싱 에러:", e);
89
- }*/
90
78
  }
91
79
  );
92
80
  })