@nine-lab/nine-mu 0.1.213 → 0.1.215
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/nine-mu.js +20 -8
- package/dist/nine-mu.js.map +1 -1
- package/dist/nine-mu.umd.js +1 -1
- package/dist/nine-mu.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/NineChat.js +29 -2
- package/src/components/NineChatManager.js +1 -13
package/package.json
CHANGED
|
@@ -97,11 +97,38 @@ 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
|
-
|
|
104
|
-
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
// 💡 [핵심] MCP 규격의 content[0].text에서 스트링을 추출합니다.
|
|
107
|
+
const rawText = result?.content?.[0]?.text;
|
|
108
|
+
|
|
109
|
+
trace.log(rawText);
|
|
110
|
+
// 텍스트를 JSON 객체로 파싱
|
|
111
|
+
const parsedData = JSON.parse(rawText);
|
|
112
|
+
|
|
113
|
+
trace.log(parsedData);
|
|
114
|
+
|
|
115
|
+
// 관제탑(system-brain)이나 하위 툴이 준 실제 대화 메시지 추출
|
|
116
|
+
const aiMessage = parsedData.message || "처리가 완료되었습니다.";
|
|
117
|
+
|
|
118
|
+
trace.log(aiMessage);
|
|
119
|
+
// 매니저 히스토리 저장 및 UI 반영
|
|
120
|
+
this.#manager.addChatHistory(aiMessage);
|
|
121
|
+
this.#$nineChatMessage.add("ai", aiMessage);
|
|
122
|
+
|
|
123
|
+
// 💡 만약 intent가 EXECUTE_TOOL이거나 NAVIGATE일 때 프론트에서
|
|
124
|
+
// 화면 이동(Routing)이나 추가 액션을 해야 한다면 여기서 parsedData.target_path 등을 활용하면 됩니다!
|
|
125
|
+
|
|
126
|
+
} catch (err) {
|
|
127
|
+
trace.error(err);
|
|
128
|
+
// 만약 AI가 JSON 형식이 아닌 일반 텍스트로 답장했을 경우를 대비한 예외 처리
|
|
129
|
+
const fallbackMessage = result?.content?.[0]?.text || "응답 데이터를 해석하지 못했습니다.";
|
|
130
|
+
this.#$nineChatMessage.add("ai", fallbackMessage);
|
|
131
|
+
}
|
|
105
132
|
}
|
|
106
133
|
}
|
|
107
134
|
});
|
|
@@ -72,21 +72,9 @@ export class NineChatManager {
|
|
|
72
72
|
(notification) => {
|
|
73
73
|
//notification.params.message
|
|
74
74
|
trace.log(notification);
|
|
75
|
-
|
|
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
|
})
|