openxgen 1.8.0 → 2.1.0

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/index.js CHANGED
@@ -891,72 +891,124 @@ var init_provider = __esm({
891
891
  }
892
892
  });
893
893
 
894
- // src/agent/llm.ts
895
- var llm_exports = {};
896
- __export(llm_exports, {
897
- createLLMClient: () => createLLMClient,
898
- streamChat: () => streamChat
894
+ // src/api/xgen-extra.ts
895
+ var xgen_extra_exports = {};
896
+ __export(xgen_extra_exports, {
897
+ createPrompt: () => createPrompt,
898
+ generateWorkflow: () => generateWorkflow,
899
+ getNodeCategories: () => getNodeCategories,
900
+ getNodeDetail: () => getNodeDetail,
901
+ getSchedulerStatus: () => getSchedulerStatus,
902
+ getTraceDetail: () => getTraceDetail,
903
+ getWorkflowPerformance: () => getWorkflowPerformance,
904
+ listInteractions: () => listInteractions,
905
+ listMcpSessions: () => listMcpSessions,
906
+ listNodes: () => listNodes,
907
+ listPrompts: () => listPrompts,
908
+ listSchedules: () => listSchedules,
909
+ listToolStore: () => listToolStore,
910
+ listTraces: () => listTraces,
911
+ listUserTools: () => listUserTools,
912
+ listWorkflowStore: () => listWorkflowStore,
913
+ searchNodes: () => searchNodes
899
914
  });
900
- import OpenAI2 from "openai";
901
- function createLLMClient(provider) {
902
- const opts = {
903
- apiKey: provider.apiKey || "ollama"
904
- };
905
- if (provider.baseUrl) {
906
- opts.baseURL = provider.baseUrl;
907
- }
908
- return new OpenAI2(opts);
915
+ async function listNodes() {
916
+ const client2 = getClient();
917
+ const res = await client2.get("/api/node/get");
918
+ return res.data.nodes ?? res.data ?? [];
909
919
  }
910
- async function streamChat(client2, model, messages, tools2, onDelta) {
911
- const params = {
912
- model,
913
- messages,
914
- stream: true,
915
- stream_options: { include_usage: true }
916
- };
917
- if (tools2 && tools2.length > 0) {
918
- params.tools = tools2;
919
- }
920
- const stream = await client2.chat.completions.create(params);
921
- let content = "";
922
- let usage = null;
923
- const toolCallMap = /* @__PURE__ */ new Map();
924
- for await (const chunk of stream) {
925
- if (chunk.usage) {
926
- usage = {
927
- promptTokens: chunk.usage.prompt_tokens ?? 0,
928
- completionTokens: chunk.usage.completion_tokens ?? 0,
929
- totalTokens: chunk.usage.total_tokens ?? 0
930
- };
931
- }
932
- const delta = chunk.choices[0]?.delta;
933
- if (!delta) continue;
934
- if (delta.content) {
935
- content += delta.content;
936
- onDelta?.(delta.content);
937
- }
938
- if (delta.tool_calls) {
939
- for (const tc of delta.tool_calls) {
940
- const idx = tc.index;
941
- if (!toolCallMap.has(idx)) {
942
- toolCallMap.set(idx, { id: tc.id ?? "", name: tc.function?.name ?? "", arguments: "" });
943
- }
944
- const entry = toolCallMap.get(idx);
945
- if (tc.id) entry.id = tc.id;
946
- if (tc.function?.name) entry.name = tc.function.name;
947
- if (tc.function?.arguments) entry.arguments += tc.function.arguments;
948
- }
949
- }
950
- }
951
- return {
952
- content,
953
- toolCalls: [...toolCallMap.values()],
954
- usage
955
- };
920
+ async function searchNodes(query) {
921
+ const client2 = getClient();
922
+ const res = await client2.get("/api/node/search", { params: { query } });
923
+ return res.data.nodes ?? res.data ?? [];
924
+ }
925
+ async function getNodeDetail(nodeId) {
926
+ const client2 = getClient();
927
+ const res = await client2.get("/api/node/detail", { params: { node_id: nodeId } });
928
+ return res.data;
929
+ }
930
+ async function getNodeCategories() {
931
+ const client2 = getClient();
932
+ const res = await client2.get("/api/node/categories");
933
+ return res.data.categories ?? res.data ?? [];
934
+ }
935
+ async function listPrompts(opts) {
936
+ const client2 = getClient();
937
+ const params = { limit: opts?.limit ?? 100 };
938
+ if (opts?.language) params.language = opts.language;
939
+ const res = await client2.get("/api/prompt/list", { params });
940
+ return res.data.prompts ?? res.data ?? [];
941
+ }
942
+ async function createPrompt(data) {
943
+ const client2 = getClient();
944
+ const res = await client2.post("/api/prompt/create", data);
945
+ return res.data;
946
+ }
947
+ async function listToolStore() {
948
+ const client2 = getClient();
949
+ const res = await client2.get("/api/tools/store/list");
950
+ return res.data.tools ?? res.data ?? [];
951
+ }
952
+ async function listUserTools() {
953
+ const client2 = getClient();
954
+ const res = await client2.get("/api/tools/storage/list");
955
+ return res.data.tools ?? res.data ?? [];
956
+ }
957
+ async function listSchedules() {
958
+ const client2 = getClient();
959
+ const res = await client2.get("/api/workflow/schedule/sessions");
960
+ return res.data.sessions ?? res.data ?? [];
961
+ }
962
+ async function getSchedulerStatus() {
963
+ const client2 = getClient();
964
+ const res = await client2.get("/api/workflow/schedule/status");
965
+ return res.data;
956
966
  }
957
- var init_llm = __esm({
958
- "src/agent/llm.ts"() {
967
+ async function listInteractions(workflowId, limit = 20) {
968
+ const client2 = getClient();
969
+ const params = { limit };
970
+ if (workflowId) params.workflow_id = workflowId;
971
+ const res = await client2.get("/api/interaction/list", { params });
972
+ return res.data.interactions ?? res.data ?? [];
973
+ }
974
+ async function listTraces(workflowId, page = 1) {
975
+ const client2 = getClient();
976
+ const params = { page, page_size: 20 };
977
+ if (workflowId) params.workflow_id = workflowId;
978
+ const res = await client2.get("/api/workflow/trace/list", { params });
979
+ return res.data;
980
+ }
981
+ async function getTraceDetail(traceId) {
982
+ const client2 = getClient();
983
+ const res = await client2.get(`/api/workflow/trace/detail/${traceId}`);
984
+ return res.data;
985
+ }
986
+ async function listWorkflowStore() {
987
+ const client2 = getClient();
988
+ const res = await client2.get("/api/workflow/store/list");
989
+ return res.data.workflows ?? res.data ?? [];
990
+ }
991
+ async function generateWorkflow(requirements) {
992
+ const client2 = getClient();
993
+ const res = await client2.post("/api/workflow/auto-generation/generate", { requirements });
994
+ return res.data;
995
+ }
996
+ async function getWorkflowPerformance(workflowId, workflowName) {
997
+ const client2 = getClient();
998
+ const res = await client2.get("/api/workflow/performance", {
999
+ params: { workflow_id: workflowId, workflow_name: workflowName }
1000
+ });
1001
+ return res.data;
1002
+ }
1003
+ async function listMcpSessions() {
1004
+ const client2 = getClient();
1005
+ const res = await client2.get("/api/mcp/sessions");
1006
+ return res.data.sessions ?? res.data ?? [];
1007
+ }
1008
+ var init_xgen_extra = __esm({
1009
+ "src/api/xgen-extra.ts"() {
959
1010
  "use strict";
1011
+ init_client();
960
1012
  }
961
1013
  });
962
1014
 
@@ -1056,334 +1108,283 @@ var init_ontology = __esm({
1056
1108
  }
1057
1109
  });
1058
1110
 
1059
- // src/dashboard/tui.ts
1060
- var tui_exports = {};
1061
- __export(tui_exports, {
1062
- startTui: () => startTui
1111
+ // src/dashboard/InkDashboard.tsx
1112
+ var InkDashboard_exports = {};
1113
+ __export(InkDashboard_exports, {
1114
+ startInkDashboard: () => startInkDashboard
1063
1115
  });
1064
- import blessed from "blessed";
1065
- async function startTui() {
1066
- const screen = blessed.screen({ smartCSR: true, title: "OPEN XGEN", fullUnicode: true });
1116
+ import { useState, useEffect } from "react";
1117
+ import { render, Box, Text, useInput, useApp, useStdout } from "ink";
1118
+ import TextInput from "ink-text-input";
1119
+ import { jsx, jsxs } from "react/jsx-runtime";
1120
+ function Header({ tab, serverDisplay, model }) {
1121
+ const tabStr = TABS.map((t) => {
1122
+ const active = tab === t.key;
1123
+ return `[${t.shortcut}]${active ? "\u25B8" : " "}${t.label}`;
1124
+ }).join(" ");
1125
+ return /* @__PURE__ */ jsxs(Box, { paddingX: 1, children: [
1126
+ /* @__PURE__ */ jsx(Text, { bold: true, children: "OPEN XGEN" }),
1127
+ /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
1128
+ " ",
1129
+ model,
1130
+ " ",
1131
+ serverDisplay,
1132
+ " \u2502 ",
1133
+ tabStr
1134
+ ] })
1135
+ ] });
1136
+ }
1137
+ function ListPanel({ items, selected, onSelect }) {
1138
+ const { stdout } = useStdout();
1139
+ const height = (stdout?.rows ?? 24) - 8;
1140
+ const visibleCount = Math.max(1, height);
1141
+ const start = Math.max(0, Math.min(selected - Math.floor(visibleCount / 2), items.length - visibleCount));
1142
+ const visible = items.slice(start, start + visibleCount);
1143
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", width: "50%", borderStyle: "single", borderColor: "gray", paddingX: 1, children: [
1144
+ visible.map((item, i) => {
1145
+ const realIndex = start + i;
1146
+ const isSelected = realIndex === selected;
1147
+ return /* @__PURE__ */ jsxs(Text, { inverse: isSelected, children: [
1148
+ isSelected ? "\u25B8 " : " ",
1149
+ item.label,
1150
+ item.dimLabel ? /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
1151
+ " ",
1152
+ item.dimLabel
1153
+ ] }) : null
1154
+ ] }, `item-${realIndex}`);
1155
+ }),
1156
+ items.length === 0 && /* @__PURE__ */ jsx(Text, { dimColor: true, children: " (\uC5C6\uC74C)" })
1157
+ ] });
1158
+ }
1159
+ function DetailPanel({ lines }) {
1160
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", width: "50%", borderStyle: "single", borderColor: "gray", paddingX: 1, children: lines.map((line, i) => /* @__PURE__ */ jsx(Text, { children: line }, `line-${i}`)) });
1161
+ }
1162
+ function StatusBar({ message }) {
1163
+ return /* @__PURE__ */ jsx(Box, { paddingX: 1, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: message }) });
1164
+ }
1165
+ function InputBar({ value, onChange, onSubmit, placeholder }) {
1166
+ return /* @__PURE__ */ jsxs(Box, { borderStyle: "single", borderColor: "gray", paddingX: 1, children: [
1167
+ /* @__PURE__ */ jsx(Text, { children: "\u276F " }),
1168
+ /* @__PURE__ */ jsx(
1169
+ TextInput,
1170
+ {
1171
+ value,
1172
+ onChange,
1173
+ onSubmit,
1174
+ placeholder: placeholder ?? "\uC785\uB825..."
1175
+ }
1176
+ )
1177
+ ] });
1178
+ }
1179
+ function Dashboard() {
1180
+ const { exit } = useApp();
1067
1181
  const provider = getDefaultProvider();
1068
1182
  const server = getServer();
1069
1183
  const auth = getAuth();
1070
1184
  const serverDisplay = auth && server ? `${auth.username}@${server.replace("https://", "").replace("http://", "")}` : "\uBBF8\uC5F0\uACB0";
1071
- let activeTab = "workflows";
1072
- const header = blessed.box({
1073
- top: 0,
1074
- left: 0,
1075
- width: "100%",
1076
- height: 3,
1077
- tags: true,
1078
- style: { fg: "white", bg: "black" }
1079
- });
1080
- function renderHeader() {
1081
- const wf = activeTab === "workflows" ? "{bold}{underline}\uC6CC\uD06C\uD50C\uB85C\uC6B0{/underline}{/bold}" : "{gray-fg}\uC6CC\uD06C\uD50C\uB85C\uC6B0{/gray-fg}";
1082
- const col = activeTab === "collections" ? "{bold}{underline}\uCEEC\uB809\uC158{/underline}{/bold}" : "{gray-fg}\uCEEC\uB809\uC158{/gray-fg}";
1083
- header.setContent(` OPEN XGEN {gray-fg}${provider?.model ?? ""}{/gray-fg} ${serverDisplay} \u2502 [1]${wf} [2]${col}`);
1084
- screen.render();
1085
- }
1086
- const listPanel = blessed.list({
1087
- top: 3,
1088
- left: 0,
1089
- width: "50%",
1090
- height: "100%-9",
1091
- border: { type: "line" },
1092
- style: {
1093
- border: { fg: "gray" },
1094
- selected: { fg: "black", bg: "white" },
1095
- item: { fg: "white" },
1096
- label: { fg: "white", bold: true }
1097
- },
1098
- keys: true,
1099
- vi: true,
1100
- mouse: true,
1101
- scrollbar: { ch: "\u2502", style: { fg: "gray" } },
1102
- tags: true
1103
- });
1104
- const chatInput = blessed.textbox({
1105
- bottom: 3,
1106
- left: 0,
1107
- width: "50%",
1108
- height: 3,
1109
- label: " \u276F ",
1110
- border: { type: "line" },
1111
- inputOnFocus: true,
1112
- style: {
1113
- border: { fg: "gray" },
1114
- label: { fg: "white", bold: true }
1115
- }
1116
- });
1117
- const detailPanel = blessed.log({
1118
- top: 3,
1119
- left: "50%",
1120
- width: "50%",
1121
- height: "100%-6",
1122
- label: " \uC0C1\uC138 ",
1123
- border: { type: "line" },
1124
- scrollable: true,
1125
- alwaysScroll: true,
1126
- mouse: true,
1127
- tags: true,
1128
- style: {
1129
- border: { fg: "gray" },
1130
- label: { fg: "white", bold: true }
1131
- }
1132
- });
1133
- const statusBar = blessed.box({
1134
- bottom: 0,
1135
- left: 0,
1136
- width: "100%",
1137
- height: 3,
1138
- tags: true,
1139
- style: { fg: "gray", bg: "black" }
1140
- });
1141
- function renderStatusBar(msg) {
1142
- statusBar.setContent(msg ?? " {white-fg}{bold}1/2{/bold}{/white-fg}:\uD0ED {white-fg}{bold}Enter{/bold}{/white-fg}:\uC2E4\uD589 {white-fg}{bold}i{/bold}{/white-fg}:\uC785\uB825 {white-fg}{bold}r{/bold}{/white-fg}:\uC0C8\uB85C\uACE0\uCE68 {white-fg}{bold}Esc{/bold}{/white-fg}:\uBAA9\uB85D {white-fg}{bold}q{/bold}{/white-fg}:\uC885\uB8CC");
1143
- screen.render();
1144
- }
1145
- screen.append(header);
1146
- screen.append(listPanel);
1147
- screen.append(chatInput);
1148
- screen.append(detailPanel);
1149
- screen.append(statusBar);
1150
- let workflows = [];
1151
- let collections = [];
1152
- async function loadWorkflows() {
1153
- if (!server || !auth) return;
1185
+ const [tab, setTab] = useState("workflows");
1186
+ const [selected, setSelected] = useState(0);
1187
+ const [workflows, setWorkflows] = useState([]);
1188
+ const [collections, setCollections] = useState([]);
1189
+ const [nodes, setNodes] = useState([]);
1190
+ const [prompts, setPrompts] = useState([]);
1191
+ const [tools2, setTools] = useState([]);
1192
+ const [detail, setDetail] = useState(["\u2190 \uD56D\uBAA9\uC744 \uC120\uD0DD\uD558\uC138\uC694"]);
1193
+ const [inputValue, setInputValue] = useState("");
1194
+ const [inputMode, setInputMode] = useState(false);
1195
+ const [runTarget, setRunTarget] = useState(null);
1196
+ const [loading, setLoading] = useState(true);
1197
+ const [statusMsg, setStatusMsg] = useState("\uB85C\uB529...");
1198
+ useEffect(() => {
1199
+ loadAll();
1200
+ }, []);
1201
+ async function loadAll() {
1202
+ setLoading(true);
1203
+ setStatusMsg("\uB85C\uB529...");
1154
1204
  try {
1155
- const { getWorkflowListDetail: getWorkflowListDetail2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
1156
- const wfs = await getWorkflowListDetail2();
1157
- workflows = wfs.map((w) => ({
1158
- name: w.workflow_name,
1159
- id: (w.workflow_id ?? w.id ?? "").toString(),
1160
- deployed: !!w.is_deployed
1161
- }));
1205
+ if (server && auth) {
1206
+ const [wfMod, docMod, extraMod] = await Promise.all([
1207
+ Promise.resolve().then(() => (init_workflow(), workflow_exports)),
1208
+ Promise.resolve().then(() => (init_document(), document_exports)),
1209
+ Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports))
1210
+ ]);
1211
+ const [wfs, cols, nodeList, promptList, toolList] = await Promise.allSettled([
1212
+ wfMod.getWorkflowListDetail(),
1213
+ docMod.listCollections(),
1214
+ extraMod.listNodes(),
1215
+ extraMod.listPrompts(),
1216
+ extraMod.listToolStore()
1217
+ ]);
1218
+ if (wfs.status === "fulfilled") {
1219
+ setWorkflows(wfs.value.map((w) => ({
1220
+ name: w.workflow_name,
1221
+ id: w.workflow_id ?? w.id ?? "",
1222
+ deployed: !!w.is_deployed
1223
+ })));
1224
+ }
1225
+ if (cols.status === "fulfilled") {
1226
+ setCollections(cols.value.map((c) => ({
1227
+ name: c.collection_make_name,
1228
+ docs: c.total_documents,
1229
+ chunks: c.total_chunks
1230
+ })));
1231
+ }
1232
+ if (nodeList.status === "fulfilled") setNodes(nodeList.value);
1233
+ if (promptList.status === "fulfilled") setPrompts(promptList.value);
1234
+ if (toolList.status === "fulfilled") setTools(toolList.value);
1235
+ }
1162
1236
  } catch {
1163
- workflows = [];
1164
1237
  }
1165
- }
1166
- async function loadCollections() {
1167
- if (!server || !auth) return;
1168
- try {
1169
- const { listCollections: listCollections2 } = await Promise.resolve().then(() => (init_document(), document_exports));
1170
- const cols = await listCollections2();
1171
- collections = cols.map((c) => ({
1172
- name: c.collection_make_name,
1173
- id: c.id,
1174
- docs: c.total_documents,
1175
- chunks: c.total_chunks,
1176
- shared: c.is_shared,
1177
- group: c.share_group ?? void 0,
1178
- model: c.init_embedding_model ?? void 0
1179
- }));
1180
- } catch {
1181
- collections = [];
1238
+ setLoading(false);
1239
+ setStatusMsg("\u2191\u2193:\uC774\uB3D9 Enter:\uC120\uD0DD 1-5:\uD0ED i:\uC785\uB825 r:\uC0C8\uB85C\uACE0\uCE68 q:\uC885\uB8CC");
1240
+ }
1241
+ function getListItems() {
1242
+ switch (tab) {
1243
+ case "workflows":
1244
+ return workflows.map((w) => ({ label: `${w.deployed ? "\u25CF" : "\u25CB"} ${w.name}`, dimLabel: "" }));
1245
+ case "collections":
1246
+ return collections.map((c) => ({ label: c.name, dimLabel: `${c.docs}\uBB38\uC11C ${c.chunks}\uCCAD\uD06C` }));
1247
+ case "nodes":
1248
+ return nodes.map((n) => ({ label: n.nodeName ?? n.name ?? "?", dimLabel: (n.description ?? "").slice(0, 30) }));
1249
+ case "prompts":
1250
+ return prompts.map((p) => ({ label: p.name ?? p.title ?? "?", dimLabel: `[${p.prompt_type ?? ""}]` }));
1251
+ case "tools":
1252
+ return tools2.map((t) => ({ label: t.name ?? t.tool_name ?? "?", dimLabel: (t.description ?? "").slice(0, 30) }));
1253
+ default:
1254
+ return [];
1255
+ }
1256
+ }
1257
+ function showDetail() {
1258
+ const items = getListItems();
1259
+ if (selected < 0 || selected >= items.length) return;
1260
+ if (tab === "workflows") {
1261
+ const w = workflows[selected];
1262
+ if (w) setDetail([w.name, "", `ID ${w.id}`, `\uBC30\uD3EC ${w.deployed ? "Yes" : "No"}`, "", "Enter \u2192 \uC2E4\uD589"]);
1263
+ } else if (tab === "collections") {
1264
+ const c = collections[selected];
1265
+ if (c) setDetail([c.name, "", `\uBB38\uC11C ${c.docs}\uAC1C`, `\uCCAD\uD06C ${c.chunks}\uAC1C`]);
1266
+ } else if (tab === "nodes") {
1267
+ const n = nodes[selected];
1268
+ if (n) setDetail([n.nodeName ?? n.name ?? "?", "", n.description ?? "", "", `ID: ${n.node_id ?? n.id ?? "?"}`]);
1269
+ } else if (tab === "prompts") {
1270
+ const p = prompts[selected];
1271
+ if (p) setDetail([p.name ?? "?", `[${p.prompt_type ?? ""}]`, "", (p.content ?? "").slice(0, 200)]);
1272
+ } else if (tab === "tools") {
1273
+ const t = tools2[selected];
1274
+ if (t) setDetail([t.name ?? t.tool_name ?? "?", "", t.description ?? ""]);
1275
+ }
1276
+ }
1277
+ useEffect(() => {
1278
+ showDetail();
1279
+ }, [selected, tab]);
1280
+ function switchTab(t) {
1281
+ setTab(t);
1282
+ setSelected(0);
1283
+ setInputMode(false);
1284
+ setRunTarget(null);
1285
+ }
1286
+ async function handleSubmit(value) {
1287
+ if (!value.trim()) {
1288
+ setInputMode(false);
1289
+ setRunTarget(null);
1290
+ return;
1182
1291
  }
1183
- }
1184
- function renderList() {
1185
- if (activeTab === "workflows") {
1186
- listPanel.label = ` \uC6CC\uD06C\uD50C\uB85C\uC6B0 (${workflows.length}) `;
1187
- listPanel.setItems(workflows.map((w, i) => {
1188
- const dot = w.deployed ? "\u25CF" : "\u25CB";
1189
- return ` ${dot} ${String(i + 1).padStart(2)}. ${w.name}`;
1190
- }));
1292
+ if (runTarget) {
1293
+ setDetail([`\uC2E4\uD589 \uC911: ${runTarget.name}`, `\uC785\uB825: ${value}`, "", "..."]);
1294
+ setInputValue("");
1295
+ setInputMode(false);
1296
+ try {
1297
+ const { executeWorkflow: executeWorkflow2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
1298
+ const { randomUUID: randomUUID4 } = await import("crypto");
1299
+ const result = await executeWorkflow2({
1300
+ workflow_id: runTarget.id,
1301
+ workflow_name: runTarget.name,
1302
+ input_data: value,
1303
+ interaction_id: `tui_${randomUUID4().slice(0, 8)}`,
1304
+ user_id: auth?.userId ? parseInt(auth.userId) : 1
1305
+ });
1306
+ const content = result.content ?? result.message ?? JSON.stringify(result).slice(0, 500);
1307
+ setDetail([`${runTarget.name}`, "", `\uC785\uB825: ${value}`, "", `\uACB0\uACFC:`, String(content)]);
1308
+ } catch (err) {
1309
+ setDetail([`\uC2E4\uD589 \uC2E4\uD328: ${err.message}`]);
1310
+ }
1311
+ setRunTarget(null);
1191
1312
  } else {
1192
- listPanel.label = ` \uCEEC\uB809\uC158 (${collections.length}) `;
1193
- listPanel.setItems(collections.map(
1194
- (c, i) => ` ${String(i + 1).padStart(2)}. ${c.name} {gray-fg}${c.docs}\uBB38\uC11C{/gray-fg}`
1195
- ));
1313
+ setInputValue("");
1314
+ setInputMode(false);
1196
1315
  }
1197
- screen.render();
1198
1316
  }
1199
- async function loadAll() {
1200
- renderStatusBar(" \uB85C\uB529...");
1201
- await Promise.all([loadWorkflows(), loadCollections()]);
1202
- renderList();
1203
- renderHeader();
1204
- renderStatusBar();
1205
- }
1206
- listPanel.on("select item", (_item, index) => {
1207
- if (activeTab === "workflows") {
1208
- const w = workflows[index];
1209
- if (!w) return;
1210
- detailPanel.setContent([
1211
- `{bold}${w.name}{/bold}`,
1212
- ``,
1213
- `ID ${w.id}`,
1214
- `\uBC30\uD3EC ${w.deployed ? "Yes" : "No"}`,
1215
- ``,
1216
- `Enter \u2192 \uC2E4\uD589 \uC785\uB825`
1217
- ].join("\n"));
1218
- } else {
1219
- const c = collections[index];
1220
- if (!c) return;
1221
- detailPanel.setContent([
1222
- `{bold}${c.name}{/bold}`,
1223
- ``,
1224
- `\uBB38\uC11C ${c.docs}\uAC1C`,
1225
- `\uCCAD\uD06C ${c.chunks}\uAC1C`,
1226
- `\uACF5\uC720 ${c.shared ? `Yes (${c.group})` : "No"}`,
1227
- `\uBAA8\uB378 ${c.model ?? "-"}`,
1228
- ``,
1229
- `Enter \u2192 \uBB38\uC11C \uBAA9\uB85D`
1230
- ].join("\n"));
1231
- }
1232
- screen.render();
1233
- });
1234
- listPanel.on("select", async (_item, index) => {
1235
- if (activeTab === "workflows") {
1236
- const w = workflows[index];
1237
- if (!w) return;
1238
- chatInput.label = ` ${w.name} \u276F `;
1239
- chatInput.focus();
1240
- screen.render();
1241
- chatInput.once("submit", async (value) => {
1242
- if (!value.trim()) {
1243
- chatInput.label = " \u276F ";
1244
- chatInput.clearValue();
1245
- listPanel.focus();
1246
- screen.render();
1247
- return;
1248
- }
1249
- detailPanel.log(`{gray-fg}\u2500\u2500 ${w.name} \u2500\u2500{/gray-fg}`);
1250
- detailPanel.log(`\uC785\uB825: ${value}`);
1251
- screen.render();
1252
- try {
1253
- const { executeWorkflow: executeWorkflow2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
1254
- const { randomUUID: randomUUID4 } = await import("crypto");
1255
- const result = await executeWorkflow2({
1256
- workflow_id: w.id,
1257
- workflow_name: w.name,
1258
- input_data: value,
1259
- interaction_id: `tui_${randomUUID4().slice(0, 8)}`,
1260
- user_id: auth?.userId ? parseInt(auth.userId) : 1
1261
- });
1262
- if (result.content) {
1263
- detailPanel.log(`${String(result.content)}
1264
- `);
1265
- } else if (result.error || result.message) {
1266
- detailPanel.log(`\uC624\uB958: ${result.error ?? result.message}
1267
- `);
1268
- } else {
1269
- detailPanel.log(JSON.stringify(result, null, 2).slice(0, 800) + "\n");
1270
- }
1271
- } catch (err) {
1272
- detailPanel.log(`\uC2E4\uD328: ${err.message}
1273
- `);
1274
- }
1275
- chatInput.label = " \u276F ";
1276
- chatInput.clearValue();
1277
- listPanel.focus();
1278
- screen.render();
1279
- });
1280
- } else {
1281
- const c = collections[index];
1282
- if (!c) return;
1283
- detailPanel.setContent(`${c.name} \uBB38\uC11C \uB85C\uB529...`);
1284
- screen.render();
1285
- try {
1286
- const { listDocuments: listDocuments2 } = await Promise.resolve().then(() => (init_document(), document_exports));
1287
- const docs = await listDocuments2(c.id?.toString());
1288
- if (!docs.length) {
1289
- detailPanel.setContent(`{bold}${c.name}{/bold}
1290
-
1291
- \uBB38\uC11C \uC5C6\uC74C`);
1292
- } else {
1293
- const docList = docs.map((d, i) => {
1294
- const name = d.name || d.file_name || "\uC774\uB984 \uC5C6\uC74C";
1295
- return ` ${i + 1}. ${name}`;
1296
- }).join("\n");
1297
- detailPanel.setContent(`{bold}${c.name}{/bold} \u2014 ${docs.length}\uAC1C \uBB38\uC11C
1298
-
1299
- ${docList}`);
1300
- }
1301
- } catch (err) {
1302
- detailPanel.setContent(`\uBB38\uC11C \uB85C\uB4DC \uC2E4\uD328: ${err.message}`);
1317
+ useInput((input, key) => {
1318
+ if (inputMode) {
1319
+ if (key.escape) {
1320
+ setInputMode(false);
1321
+ setRunTarget(null);
1303
1322
  }
1304
- screen.render();
1323
+ return;
1305
1324
  }
1306
- });
1307
- chatInput.on("submit", async (value) => {
1308
- if (!value.trim()) {
1309
- chatInput.clearValue();
1310
- listPanel.focus();
1311
- screen.render();
1325
+ if (input === "q" || key.ctrl && input === "c") {
1326
+ exit();
1312
1327
  return;
1313
1328
  }
1314
- detailPanel.log(`{white-fg}\u276F ${value}{/white-fg}`);
1315
- chatInput.clearValue();
1316
- screen.render();
1317
- try {
1318
- const p = getDefaultProvider();
1319
- if (!p) {
1320
- detailPanel.log("\uD504\uB85C\uBC14\uC774\uB354 \uBBF8\uC124\uC815");
1321
- chatInput.focus();
1322
- screen.render();
1323
- return;
1329
+ if (input === "r") {
1330
+ loadAll();
1331
+ return;
1332
+ }
1333
+ if (input === "i") {
1334
+ setInputMode(true);
1335
+ return;
1336
+ }
1337
+ if (input === "1") switchTab("workflows");
1338
+ else if (input === "2") switchTab("collections");
1339
+ else if (input === "3") switchTab("nodes");
1340
+ else if (input === "4") switchTab("prompts");
1341
+ else if (input === "5") switchTab("tools");
1342
+ const items = getListItems();
1343
+ if (key.upArrow) setSelected(Math.max(0, selected - 1));
1344
+ else if (key.downArrow) setSelected(Math.min(items.length - 1, selected + 1));
1345
+ else if (key.tab) switchTab(TABS[(TABS.findIndex((t) => t.key === tab) + 1) % TABS.length].key);
1346
+ if (key.return && items.length > 0) {
1347
+ if (tab === "workflows" && workflows[selected]) {
1348
+ setRunTarget(workflows[selected]);
1349
+ setInputMode(true);
1350
+ setStatusMsg(`${workflows[selected].name} \u2014 \uC785\uB825 \uD6C4 Enter\uB85C \uC2E4\uD589, Esc \uCDE8\uC18C`);
1324
1351
  }
1325
- const { createLLMClient: createLLMClient2, streamChat: streamChat2 } = await Promise.resolve().then(() => (init_llm(), llm_exports));
1326
- const client2 = createLLMClient2(p);
1327
- const result = await streamChat2(client2, p.model, [
1328
- { role: "system", content: "You are OPEN XGEN. Concise. Korean." },
1329
- { role: "user", content: value }
1330
- ]);
1331
- detailPanel.log(`${result.content || "(\uC751\uB2F5 \uC5C6\uC74C)"}
1332
- `);
1333
- } catch (err) {
1334
- detailPanel.log(`\uC624\uB958: ${err.message}
1335
- `);
1336
1352
  }
1337
- chatInput.focus();
1338
- screen.render();
1339
- });
1340
- screen.key(["1"], () => {
1341
- activeTab = "workflows";
1342
- renderList();
1343
- renderHeader();
1344
- listPanel.focus();
1345
- });
1346
- screen.key(["2"], () => {
1347
- activeTab = "collections";
1348
- renderList();
1349
- renderHeader();
1350
- listPanel.focus();
1351
- });
1352
- screen.key(["tab"], () => {
1353
- if (screen.focused === listPanel) chatInput.focus();
1354
- else listPanel.focus();
1355
- screen.render();
1356
- });
1357
- screen.key(["i"], () => {
1358
- chatInput.focus();
1359
- screen.render();
1360
1353
  });
1361
- screen.key(["r"], async () => {
1362
- await loadAll();
1363
- });
1364
- screen.key(["escape"], () => {
1365
- chatInput.label = " \u276F ";
1366
- listPanel.focus();
1367
- screen.render();
1368
- });
1369
- screen.key(["q", "C-c"], () => {
1370
- screen.destroy();
1371
- process.exit(0);
1372
- });
1373
- setInterval(async () => {
1374
- try {
1375
- await loadAll();
1376
- } catch {
1377
- }
1378
- }, 6e4);
1379
- await loadAll();
1380
- listPanel.focus();
1381
- screen.render();
1354
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
1355
+ /* @__PURE__ */ jsx(Header, { tab, serverDisplay, model: provider?.model ?? "" }),
1356
+ /* @__PURE__ */ jsxs(Box, { flexDirection: "row", flexGrow: 1, children: [
1357
+ /* @__PURE__ */ jsx(ListPanel, { items: getListItems(), selected }),
1358
+ /* @__PURE__ */ jsx(DetailPanel, { lines: detail })
1359
+ ] }),
1360
+ inputMode ? /* @__PURE__ */ jsx(
1361
+ InputBar,
1362
+ {
1363
+ value: inputValue,
1364
+ onChange: setInputValue,
1365
+ onSubmit: handleSubmit,
1366
+ placeholder: runTarget ? `${runTarget.name}\uC5D0 \uC785\uB825...` : "\uC785\uB825..."
1367
+ }
1368
+ ) : /* @__PURE__ */ jsx(Box, { borderStyle: "single", borderColor: "gray", paddingX: 1, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u276F i\uB97C \uB20C\uB7EC \uC785\uB825 \xB7 Enter\uB85C \uC2E4\uD589" }) }),
1369
+ /* @__PURE__ */ jsx(StatusBar, { message: loading ? "\uB85C\uB529..." : statusMsg })
1370
+ ] });
1371
+ }
1372
+ async function startInkDashboard() {
1373
+ const { waitUntilExit } = render(/* @__PURE__ */ jsx(Dashboard, {}));
1374
+ await waitUntilExit();
1382
1375
  }
1383
- var init_tui = __esm({
1384
- "src/dashboard/tui.ts"() {
1376
+ var TABS;
1377
+ var init_InkDashboard = __esm({
1378
+ "src/dashboard/InkDashboard.tsx"() {
1385
1379
  "use strict";
1386
1380
  init_store();
1381
+ TABS = [
1382
+ { key: "workflows", label: "\uC6CC\uD06C\uD50C\uB85C\uC6B0", shortcut: "1" },
1383
+ { key: "collections", label: "\uCEEC\uB809\uC158", shortcut: "2" },
1384
+ { key: "nodes", label: "\uB178\uB4DC", shortcut: "3" },
1385
+ { key: "prompts", label: "\uD504\uB86C\uD504\uD2B8", shortcut: "4" },
1386
+ { key: "tools", label: "\uB3C4\uAD6C", shortcut: "5" }
1387
+ ];
1387
1388
  }
1388
1389
  });
1389
1390
 
@@ -2144,13 +2145,71 @@ init_provider();
2144
2145
 
2145
2146
  // src/commands/agent.ts
2146
2147
  init_store();
2147
- init_llm();
2148
2148
  import chalk12 from "chalk";
2149
2149
  import { createInterface as createInterface5 } from "readline";
2150
2150
  import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync5, readdirSync } from "fs";
2151
2151
  import { join as join4 } from "path";
2152
2152
  import { homedir as homedir2 } from "os";
2153
2153
 
2154
+ // src/agent/llm.ts
2155
+ import OpenAI2 from "openai";
2156
+ function createLLMClient(provider) {
2157
+ const opts = {
2158
+ apiKey: provider.apiKey || "ollama"
2159
+ };
2160
+ if (provider.baseUrl) {
2161
+ opts.baseURL = provider.baseUrl;
2162
+ }
2163
+ return new OpenAI2(opts);
2164
+ }
2165
+ async function streamChat(client2, model, messages, tools2, onDelta) {
2166
+ const params = {
2167
+ model,
2168
+ messages,
2169
+ stream: true,
2170
+ stream_options: { include_usage: true }
2171
+ };
2172
+ if (tools2 && tools2.length > 0) {
2173
+ params.tools = tools2;
2174
+ }
2175
+ const stream = await client2.chat.completions.create(params);
2176
+ let content = "";
2177
+ let usage = null;
2178
+ const toolCallMap = /* @__PURE__ */ new Map();
2179
+ for await (const chunk of stream) {
2180
+ if (chunk.usage) {
2181
+ usage = {
2182
+ promptTokens: chunk.usage.prompt_tokens ?? 0,
2183
+ completionTokens: chunk.usage.completion_tokens ?? 0,
2184
+ totalTokens: chunk.usage.total_tokens ?? 0
2185
+ };
2186
+ }
2187
+ const delta = chunk.choices[0]?.delta;
2188
+ if (!delta) continue;
2189
+ if (delta.content) {
2190
+ content += delta.content;
2191
+ onDelta?.(delta.content);
2192
+ }
2193
+ if (delta.tool_calls) {
2194
+ for (const tc of delta.tool_calls) {
2195
+ const idx = tc.index;
2196
+ if (!toolCallMap.has(idx)) {
2197
+ toolCallMap.set(idx, { id: tc.id ?? "", name: tc.function?.name ?? "", arguments: "" });
2198
+ }
2199
+ const entry = toolCallMap.get(idx);
2200
+ if (tc.id) entry.id = tc.id;
2201
+ if (tc.function?.name) entry.name = tc.function.name;
2202
+ if (tc.function?.arguments) entry.arguments += tc.function.arguments;
2203
+ }
2204
+ }
2205
+ }
2206
+ return {
2207
+ content,
2208
+ toolCalls: [...toolCallMap.values()],
2209
+ usage
2210
+ };
2211
+ }
2212
+
2154
2213
  // src/agent/tools/file-read.ts
2155
2214
  var file_read_exports = {};
2156
2215
  __export(file_read_exports, {
@@ -2510,165 +2569,48 @@ function getToolNames() {
2510
2569
  // src/agent/tools/xgen-api.ts
2511
2570
  init_store();
2512
2571
  var definitions = [
2513
- {
2514
- type: "function",
2515
- function: {
2516
- name: "xgen_workflow_list",
2517
- description: "XGEN \uC11C\uBC84\uC5D0\uC11C \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uBAA9\uB85D\uC744 \uAC00\uC838\uC635\uB2C8\uB2E4.",
2518
- parameters: { type: "object", properties: {} }
2519
- }
2520
- },
2521
- {
2522
- type: "function",
2523
- function: {
2524
- name: "xgen_workflow_run",
2525
- description: "XGEN \uC6CC\uD06C\uD50C\uB85C\uC6B0\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4. \uBC30\uD3EC \uC5EC\uBD80\uC640 \uAD00\uACC4\uC5C6\uC774 \uBAA8\uB4E0 \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589 \uAC00\uB2A5.",
2526
- parameters: {
2527
- type: "object",
2528
- properties: {
2529
- workflow_id: { type: "string", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 ID" },
2530
- workflow_name: { type: "string", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC774\uB984" },
2531
- input_data: { type: "string", description: "\uC785\uB825 \uBA54\uC2DC\uC9C0" }
2532
- },
2533
- required: ["workflow_id", "workflow_name", "input_data"]
2534
- }
2535
- }
2536
- },
2537
- {
2538
- type: "function",
2539
- function: {
2540
- name: "xgen_workflow_info",
2541
- description: "\uD2B9\uC815 \uC6CC\uD06C\uD50C\uB85C\uC6B0\uC758 \uC0C1\uC138 \uC815\uBCF4(\uB178\uB4DC, \uC5E3\uC9C0 \uB4F1)\uB97C \uAC00\uC838\uC635\uB2C8\uB2E4.",
2542
- parameters: {
2543
- type: "object",
2544
- properties: {
2545
- workflow_id: { type: "string", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 ID" }
2546
- },
2547
- required: ["workflow_id"]
2548
- }
2549
- }
2550
- },
2551
- {
2552
- type: "function",
2553
- function: {
2554
- name: "xgen_collection_list",
2555
- description: "XGEN \uC11C\uBC84\uC758 \uBB38\uC11C \uCEEC\uB809\uC158(\uC9C0\uC2DD\uBCA0\uC774\uC2A4) \uBAA9\uB85D\uC744 \uAC00\uC838\uC635\uB2C8\uB2E4. \uBB38\uC11C \uC218, \uCCAD\uD06C \uC218, \uACF5\uC720 \uC0C1\uD0DC \uB4F1 \uD3EC\uD568.",
2556
- parameters: { type: "object", properties: {} }
2557
- }
2558
- },
2559
- {
2560
- type: "function",
2561
- function: {
2562
- name: "xgen_server_status",
2563
- description: "XGEN \uC11C\uBC84 \uC0C1\uD0DC\uB97C \uD655\uC778\uD569\uB2C8\uB2E4.",
2564
- parameters: { type: "object", properties: {} }
2565
- }
2566
- },
2567
- {
2568
- type: "function",
2569
- function: {
2570
- name: "xgen_execution_history",
2571
- description: "\uD2B9\uC815 \uC6CC\uD06C\uD50C\uB85C\uC6B0\uC758 \uC2E4\uD589 \uC774\uB825\uC744 \uAC00\uC838\uC635\uB2C8\uB2E4. workflow_id\uC640 workflow_name \uD544\uC218.",
2572
- parameters: {
2573
- type: "object",
2574
- properties: {
2575
- workflow_id: { type: "string", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 ID" },
2576
- workflow_name: { type: "string", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC774\uB984" },
2577
- limit: { type: "number", description: "\uAC00\uC838\uC62C \uC774\uB825 \uC218 (\uAE30\uBCF8 10)" }
2578
- },
2579
- required: ["workflow_id", "workflow_name"]
2580
- }
2581
- }
2582
- },
2583
- {
2584
- type: "function",
2585
- function: {
2586
- name: "xgen_document_list",
2587
- description: "\uD2B9\uC815 \uCEEC\uB809\uC158\uC758 \uBB38\uC11C \uBAA9\uB85D\uC744 \uAC00\uC838\uC635\uB2C8\uB2E4.",
2588
- parameters: {
2589
- type: "object",
2590
- properties: {
2591
- collection_id: { type: "string", description: "\uCEEC\uB809\uC158 ID" }
2592
- }
2593
- }
2594
- }
2595
- },
2596
- {
2597
- type: "function",
2598
- function: {
2599
- name: "xgen_document_upload",
2600
- description: "\uBB38\uC11C\uB97C XGEN \uCEEC\uB809\uC158\uC5D0 \uC5C5\uB85C\uB4DC\uD569\uB2C8\uB2E4.",
2601
- parameters: {
2602
- type: "object",
2603
- properties: {
2604
- file_path: { type: "string", description: "\uC5C5\uB85C\uB4DC\uD560 \uD30C\uC77C \uACBD\uB85C" },
2605
- collection_id: { type: "string", description: "\uB300\uC0C1 \uCEEC\uB809\uC158 ID" }
2606
- },
2607
- required: ["file_path"]
2608
- }
2609
- }
2610
- },
2611
- {
2612
- type: "function",
2613
- function: {
2614
- name: "xgen_graph_rag_query",
2615
- description: "GraphRAG\uB85C \uC628\uD1A8\uB85C\uC9C0 \uC9C0\uC2DD\uADF8\uB798\uD504\uC5D0 \uC9C8\uC758\uD569\uB2C8\uB2E4.",
2616
- parameters: {
2617
- type: "object",
2618
- properties: {
2619
- query: { type: "string", description: "\uC9C8\uC758 \uB0B4\uC6A9" },
2620
- graph_id: { type: "string", description: "\uADF8\uB798\uD504 ID (\uC120\uD0DD)" }
2621
- },
2622
- required: ["query"]
2623
- }
2624
- }
2625
- },
2626
- {
2627
- type: "function",
2628
- function: {
2629
- name: "xgen_graph_stats",
2630
- description: "\uC628\uD1A8\uB85C\uC9C0 \uADF8\uB798\uD504 \uD1B5\uACC4(\uB178\uB4DC, \uC5E3\uC9C0, \uD074\uB798\uC2A4, \uC778\uC2A4\uD134\uC2A4 \uC218)\uB97C \uAC00\uC838\uC635\uB2C8\uB2E4.",
2631
- parameters: {
2632
- type: "object",
2633
- properties: {
2634
- graph_id: { type: "string", description: "\uADF8\uB798\uD504 ID" }
2635
- },
2636
- required: ["graph_id"]
2637
- }
2638
- }
2639
- }
2572
+ // === 워크플로우 ===
2573
+ { type: "function", function: { name: "xgen_workflow_list", description: "XGEN \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC804\uCCB4 \uBAA9\uB85D. \uBC30\uD3EC \uC0C1\uD0DC \uD3EC\uD568.", parameters: { type: "object", properties: {} } } },
2574
+ { type: "function", function: { name: "xgen_workflow_run", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589. \uBC30\uD3EC/\uBE44\uBC30\uD3EC \uBAA8\uB450 \uAC00\uB2A5.", parameters: { type: "object", properties: { workflow_id: { type: "string" }, workflow_name: { type: "string" }, input_data: { type: "string", description: "\uC785\uB825 \uBA54\uC2DC\uC9C0" } }, required: ["workflow_id", "workflow_name", "input_data"] } } },
2575
+ { type: "function", function: { name: "xgen_workflow_info", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC0C1\uC138 (\uB178\uB4DC, \uC5E3\uC9C0 \uAD6C\uC870).", parameters: { type: "object", properties: { workflow_id: { type: "string" } }, required: ["workflow_id"] } } },
2576
+ { type: "function", function: { name: "xgen_execution_history", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589 \uC774\uB825.", parameters: { type: "object", properties: { workflow_id: { type: "string" }, workflow_name: { type: "string" }, limit: { type: "number" } }, required: ["workflow_id", "workflow_name"] } } },
2577
+ { type: "function", function: { name: "xgen_workflow_performance", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC131\uB2A5 \uD1B5\uACC4 (\uB178\uB4DC\uBCC4 \uCC98\uB9AC \uC2DC\uAC04, \uB9AC\uC18C\uC2A4 \uC0AC\uC6A9).", parameters: { type: "object", properties: { workflow_id: { type: "string" }, workflow_name: { type: "string" } }, required: ["workflow_id", "workflow_name"] } } },
2578
+ { type: "function", function: { name: "xgen_workflow_store", description: "\uACF5\uAC1C \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2A4\uD1A0\uC5B4 \uBAA9\uB85D.", parameters: { type: "object", properties: {} } } },
2579
+ { type: "function", function: { name: "xgen_workflow_generate", description: "\uC790\uC5F0\uC5B4 \uC694\uAD6C\uC0AC\uD56D\uC73C\uB85C \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC790\uB3D9 \uC0DD\uC131.", parameters: { type: "object", properties: { requirements: { type: "string", description: "\uC0DD\uC131\uD560 \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC694\uAD6C\uC0AC\uD56D" } }, required: ["requirements"] } } },
2580
+ // === 문서/컬렉션 ===
2581
+ { type: "function", function: { name: "xgen_collection_list", description: "\uBB38\uC11C \uCEEC\uB809\uC158(\uC9C0\uC2DD\uBCA0\uC774\uC2A4) \uBAA9\uB85D.", parameters: { type: "object", properties: {} } } },
2582
+ { type: "function", function: { name: "xgen_document_list", description: "\uCEEC\uB809\uC158\uC758 \uBB38\uC11C \uBAA9\uB85D.", parameters: { type: "object", properties: { collection_id: { type: "string" } } } } },
2583
+ { type: "function", function: { name: "xgen_document_upload", description: "\uBB38\uC11C \uC5C5\uB85C\uB4DC.", parameters: { type: "object", properties: { file_path: { type: "string" }, collection_id: { type: "string" } }, required: ["file_path"] } } },
2584
+ // === 노드 ===
2585
+ { type: "function", function: { name: "xgen_node_list", description: "XGEN \uB178\uB4DC \uC804\uCCB4 \uBAA9\uB85D. \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uBE4C\uB529 \uBE14\uB85D.", parameters: { type: "object", properties: {} } } },
2586
+ { type: "function", function: { name: "xgen_node_search", description: "\uB178\uB4DC \uAC80\uC0C9 (\uC774\uB984, \uC124\uBA85 \uAE30\uBC18).", parameters: { type: "object", properties: { query: { type: "string" } }, required: ["query"] } } },
2587
+ { type: "function", function: { name: "xgen_node_categories", description: "\uB178\uB4DC \uCE74\uD14C\uACE0\uB9AC \uBAA9\uB85D.", parameters: { type: "object", properties: {} } } },
2588
+ // === 프롬프트 ===
2589
+ { type: "function", function: { name: "xgen_prompt_list", description: "\uD504\uB86C\uD504\uD2B8 \uB77C\uC774\uBE0C\uB7EC\uB9AC \uBAA9\uB85D.", parameters: { type: "object", properties: { language: { type: "string", description: "en \uB610\uB294 ko" } } } } },
2590
+ // === 도구/스킬 ===
2591
+ { type: "function", function: { name: "xgen_tool_store", description: "\uACF5\uAC1C \uB3C4\uAD6C \uC2A4\uD1A0\uC5B4 \uBAA9\uB85D.", parameters: { type: "object", properties: {} } } },
2592
+ { type: "function", function: { name: "xgen_user_tools", description: "\uB0B4 \uB3C4\uAD6C \uBAA9\uB85D.", parameters: { type: "object", properties: {} } } },
2593
+ // === 스케줄 ===
2594
+ { type: "function", function: { name: "xgen_schedule_list", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2A4\uCF00\uC904 \uBAA9\uB85D (cron \uC791\uC5C5).", parameters: { type: "object", properties: {} } } },
2595
+ // === 트레이스/인터랙션 ===
2596
+ { type: "function", function: { name: "xgen_trace_list", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589 \uD2B8\uB808\uC774\uC2A4 \uBAA9\uB85D.", parameters: { type: "object", properties: { workflow_id: { type: "string" } } } } },
2597
+ { type: "function", function: { name: "xgen_interaction_list", description: "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC778\uD130\uB799\uC158(\uC2E4\uD589 \uBA54\uD0C0) \uBAA9\uB85D.", parameters: { type: "object", properties: { workflow_id: { type: "string" }, limit: { type: "number" } } } } },
2598
+ // === MCP ===
2599
+ { type: "function", function: { name: "xgen_mcp_sessions", description: "XGEN MCP \uC11C\uBC84 \uC138\uC158 \uBAA9\uB85D.", parameters: { type: "object", properties: {} } } },
2600
+ // === GraphRAG ===
2601
+ { type: "function", function: { name: "xgen_graph_rag_query", description: "GraphRAG \uC628\uD1A8\uB85C\uC9C0 \uC9C8\uC758.", parameters: { type: "object", properties: { query: { type: "string" }, graph_id: { type: "string" } }, required: ["query"] } } },
2602
+ { type: "function", function: { name: "xgen_graph_stats", description: "\uC628\uD1A8\uB85C\uC9C0 \uADF8\uB798\uD504 \uD1B5\uACC4.", parameters: { type: "object", properties: { graph_id: { type: "string" } }, required: ["graph_id"] } } },
2603
+ // === 서버 ===
2604
+ { type: "function", function: { name: "xgen_server_status", description: "XGEN \uC11C\uBC84 \uC5F0\uACB0 \uC0C1\uD0DC.", parameters: { type: "object", properties: {} } } }
2640
2605
  ];
2641
2606
  async function execute8(name, args) {
2642
2607
  const server = getServer();
2643
2608
  const auth = getAuth();
2644
- if (!server || !auth) {
2645
- return "XGEN \uC11C\uBC84\uC5D0 \uC5F0\uACB0\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. /connect \uBA85\uB839\uC73C\uB85C \uC5F0\uACB0\uD558\uC138\uC694.";
2646
- }
2609
+ if (!server || !auth) return "XGEN \uC11C\uBC84\uC5D0 \uC5F0\uACB0\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. /connect \uBA85\uB839\uC73C\uB85C \uC5F0\uACB0\uD558\uC138\uC694.";
2647
2610
  try {
2648
- switch (name) {
2649
- case "xgen_workflow_list":
2650
- return await workflowList2();
2651
- case "xgen_workflow_run":
2652
- return await workflowRun2(args);
2653
- case "xgen_workflow_info":
2654
- return await workflowInfo2(args);
2655
- case "xgen_collection_list":
2656
- return await collectionList();
2657
- case "xgen_server_status":
2658
- return await serverStatus();
2659
- case "xgen_execution_history":
2660
- return await executionHistory(args);
2661
- case "xgen_document_list":
2662
- return await documentList(args);
2663
- case "xgen_document_upload":
2664
- return await documentUpload(args);
2665
- case "xgen_graph_rag_query":
2666
- return await graphRagQuery(args);
2667
- case "xgen_graph_stats":
2668
- return await graphStats(args);
2669
- default:
2670
- return `Unknown XGEN tool: ${name}`;
2671
- }
2611
+ const fn = handlers[name];
2612
+ if (!fn) return `Unknown XGEN tool: ${name}`;
2613
+ return await fn(args);
2672
2614
  } catch (err) {
2673
2615
  return `XGEN API \uC624\uB958: ${err.message}`;
2674
2616
  }
@@ -2676,118 +2618,180 @@ async function execute8(name, args) {
2676
2618
  function isXgenTool(name) {
2677
2619
  return name.startsWith("xgen_");
2678
2620
  }
2679
- async function workflowList2() {
2680
- const { getWorkflowListDetail: getWorkflowListDetail2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
2681
- const wfs = await getWorkflowListDetail2();
2682
- if (!wfs.length) return "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC5C6\uC74C.";
2683
- const header = `\uCD1D ${wfs.length}\uAC1C \uC6CC\uD06C\uD50C\uB85C\uC6B0:
2684
- `;
2685
- const list = wfs.map((w, i) => {
2686
- const deployed = w.is_deployed;
2687
- const tag = deployed ? " \u25CF" : "";
2688
- return `${i + 1}. ${w.workflow_name}${tag} | ${w.workflow_id ?? w.id}`;
2689
- }).join("\n");
2690
- return header + list;
2691
- }
2692
- async function workflowRun2(args) {
2693
- const { executeWorkflow: executeWorkflow2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
2694
- const { randomUUID: randomUUID4 } = await import("crypto");
2695
- const { getAuth: getAuth3 } = await Promise.resolve().then(() => (init_store(), store_exports));
2696
- const auth = getAuth3();
2697
- const result = await executeWorkflow2({
2698
- workflow_id: args.workflow_id,
2699
- workflow_name: args.workflow_name,
2700
- input_data: args.input_data,
2701
- interaction_id: `cli_${randomUUID4().slice(0, 8)}`,
2702
- user_id: auth?.userId ? parseInt(auth.userId) : 1
2703
- });
2704
- if (result.content) return String(result.content);
2705
- if (result.success === false) return `\uC624\uB958: ${result.error ?? result.message}`;
2706
- if (result.message) return String(result.message);
2707
- return JSON.stringify(result, null, 2).slice(0, 2e3);
2708
- }
2709
- async function workflowInfo2(args) {
2710
- const { getWorkflowDetail: getWorkflowDetail2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
2711
- const detail = await getWorkflowDetail2(args.workflow_id);
2712
- const nodes = detail.nodes?.length ?? 0;
2713
- const edges = detail.edges?.length ?? 0;
2714
- return `\uC6CC\uD06C\uD50C\uB85C\uC6B0: ${detail.workflow_name}
2715
- ID: ${detail.id}
2716
- \uB178\uB4DC: ${nodes}\uAC1C
2717
- \uC5E3\uC9C0: ${edges}\uAC1C`;
2718
- }
2719
- async function collectionList() {
2720
- const { listCollections: listCollections2 } = await Promise.resolve().then(() => (init_document(), document_exports));
2721
- const cols = await listCollections2();
2722
- if (!cols.length) return "\uCEEC\uB809\uC158 \uC5C6\uC74C.";
2723
- return cols.map((c, i) => {
2724
- const shared = c.is_shared ? ` [\uACF5\uC720:${c.share_group}]` : "";
2725
- return `${i + 1}. ${c.collection_make_name}${shared}
2726
- \uBB38\uC11C: ${c.total_documents}\uAC1C \xB7 \uCCAD\uD06C: ${c.total_chunks}\uAC1C \xB7 \uBAA8\uB378: ${c.init_embedding_model ?? "-"}`;
2727
- }).join("\n");
2728
- }
2729
- async function serverStatus() {
2730
- const server = getServer();
2731
- const auth = getAuth();
2732
- return `\uC11C\uBC84: ${server}
2733
- \uC0AC\uC6A9\uC790: ${auth?.username}
2734
- User ID: ${auth?.userId}`;
2735
- }
2736
- async function executionHistory(args) {
2737
- const { getIOLogs: getIOLogs2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
2738
- const wfId = args.workflow_id;
2739
- const wfName = args.workflow_name;
2740
- if (!wfId || !wfName) return "workflow_id\uC640 workflow_name\uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \uBA3C\uC800 xgen_workflow_list\uB85C \uBAA9\uB85D\uC744 \uD655\uC778\uD558\uC138\uC694.";
2741
- const limit = args.limit || 10;
2742
- const logs = await getIOLogs2(wfId, wfName, limit);
2743
- if (!logs.length) return "\uC2E4\uD589 \uC774\uB825 \uC5C6\uC74C.";
2744
- return logs.map(
2745
- (l, i) => `${i + 1}. [${l.created_at ?? ""}]
2746
- \uC785\uB825: ${(l.input_data ?? "").slice(0, 80)}
2747
- \uCD9C\uB825: ${(l.output_data ?? "").slice(0, 80)}`
2748
- ).join("\n");
2749
- }
2750
- async function documentList(args) {
2751
- const { listDocuments: listDocuments2 } = await Promise.resolve().then(() => (init_document(), document_exports));
2752
- const docs = await listDocuments2(args.collection_id);
2753
- if (!docs.length) return "\uBB38\uC11C \uC5C6\uC74C.";
2754
- return docs.map((d, i) => {
2755
- const name = d.name || d.file_name || "\uC774\uB984 \uC5C6\uC74C";
2756
- const size = d.file_size ? ` (${(d.file_size / 1024).toFixed(1)}KB)` : "";
2757
- return `${i + 1}. ${name}${size}
2758
- \uC0C1\uD0DC: ${d.status ?? "-"} \xB7 \uD0C0\uC785: ${d.file_type ?? "-"}`;
2759
- }).join("\n");
2760
- }
2761
- async function documentUpload(args) {
2762
- const { uploadDocument: uploadDocument2 } = await Promise.resolve().then(() => (init_document(), document_exports));
2763
- const filePath = args.file_path;
2764
- if (!filePath) return "\uD30C\uC77C \uACBD\uB85C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4.";
2765
- const { existsSync: existsSync5 } = await import("fs");
2766
- if (!existsSync5(filePath)) return `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${filePath}`;
2767
- const result = await uploadDocument2(filePath, args.collection_id);
2768
- return `\uC5C5\uB85C\uB4DC \uC644\uB8CC: ${JSON.stringify(result)}`;
2769
- }
2770
- async function graphRagQuery(args) {
2771
- const { queryGraphRAG: queryGraphRAG2 } = await Promise.resolve().then(() => (init_ontology(), ontology_exports));
2772
- const query = args.query;
2773
- if (!query) return "\uC9C8\uC758 \uB0B4\uC6A9\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.";
2774
- const result = await queryGraphRAG2(query, args.graph_id);
2775
- let output = `\uB2F5\uBCC0: ${result.answer ?? "\uC5C6\uC74C"}`;
2776
- if (result.sources?.length) output += `
2777
-
2778
- \uCD9C\uCC98: ${result.sources.join(", ")}`;
2779
- if (result.triples_used?.length) output += `
2780
- \uD2B8\uB9AC\uD50C: ${result.triples_used.length}\uAC1C \uC0AC\uC6A9`;
2781
- return output;
2782
- }
2783
- async function graphStats(args) {
2784
- const { getGraphStats: getGraphStats2 } = await Promise.resolve().then(() => (init_ontology(), ontology_exports));
2785
- const stats = await getGraphStats2(args.graph_id);
2786
- return `\uB178\uB4DC: ${stats.total_nodes ?? 0}\uAC1C
2787
- \uC5E3\uC9C0: ${stats.total_edges ?? 0}\uAC1C
2788
- \uD074\uB798\uC2A4: ${stats.total_classes ?? 0}\uAC1C
2789
- \uC778\uC2A4\uD134\uC2A4: ${stats.total_instances ?? 0}\uAC1C`;
2790
- }
2621
+ var handlers = {
2622
+ xgen_workflow_list: async () => {
2623
+ const { getWorkflowListDetail: getWorkflowListDetail2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
2624
+ const wfs = await getWorkflowListDetail2();
2625
+ if (!wfs.length) return "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC5C6\uC74C.";
2626
+ return `\uCD1D ${wfs.length}\uAC1C:
2627
+ ` + wfs.map((w, i) => {
2628
+ const d = w.is_deployed ? "\u25CF" : "\u25CB";
2629
+ return `${d} ${i + 1}. ${w.workflow_name} | ${w.workflow_id ?? w.id}`;
2630
+ }).join("\n");
2631
+ },
2632
+ xgen_workflow_run: async (args) => {
2633
+ const { executeWorkflow: executeWorkflow2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
2634
+ const { randomUUID: randomUUID4 } = await import("crypto");
2635
+ const auth = getAuth();
2636
+ const r = await executeWorkflow2({
2637
+ workflow_id: args.workflow_id,
2638
+ workflow_name: args.workflow_name,
2639
+ input_data: args.input_data,
2640
+ interaction_id: `cli_${randomUUID4().slice(0, 8)}`,
2641
+ user_id: auth?.userId ? parseInt(auth.userId) : 1
2642
+ });
2643
+ return r.content ? String(r.content) : r.message ? String(r.message) : JSON.stringify(r, null, 2).slice(0, 2e3);
2644
+ },
2645
+ xgen_workflow_info: async (args) => {
2646
+ const { getWorkflowDetail: getWorkflowDetail2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
2647
+ const d = await getWorkflowDetail2(args.workflow_id);
2648
+ const nodes = d.nodes?.length ?? 0;
2649
+ const edges = d.edges?.length ?? 0;
2650
+ return `${d.workflow_name}
2651
+ ID: ${d.id}
2652
+ \uB178\uB4DC: ${nodes}\uAC1C \xB7 \uC5E3\uC9C0: ${edges}\uAC1C`;
2653
+ },
2654
+ xgen_execution_history: async (args) => {
2655
+ const { getIOLogs: getIOLogs2 } = await Promise.resolve().then(() => (init_workflow(), workflow_exports));
2656
+ if (!args.workflow_id || !args.workflow_name) return "workflow_id, workflow_name \uD544\uC218.";
2657
+ const logs = await getIOLogs2(args.workflow_id, args.workflow_name, args.limit || 10);
2658
+ if (!logs.length) return "\uC2E4\uD589 \uC774\uB825 \uC5C6\uC74C.";
2659
+ return logs.map((l, i) => `${i + 1}. [${l.created_at ?? ""}] \uC785\uB825: ${(l.input_data ?? "").slice(0, 60)} \u2192 \uCD9C\uB825: ${(l.output_data ?? "").slice(0, 60)}`).join("\n");
2660
+ },
2661
+ xgen_workflow_performance: async (args) => {
2662
+ const { getWorkflowPerformance: getWorkflowPerformance2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2663
+ const p = await getWorkflowPerformance2(args.workflow_id, args.workflow_name);
2664
+ return JSON.stringify(p, null, 2).slice(0, 2e3);
2665
+ },
2666
+ xgen_workflow_store: async () => {
2667
+ const { listWorkflowStore: listWorkflowStore2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2668
+ const wfs = await listWorkflowStore2();
2669
+ if (!wfs.length) return "\uACF5\uAC1C \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC5C6\uC74C.";
2670
+ return wfs.map((w, i) => `${i + 1}. ${w.workflow_name ?? w.name ?? "\uC774\uB984\uC5C6\uC74C"}`).join("\n");
2671
+ },
2672
+ xgen_workflow_generate: async (args) => {
2673
+ const { generateWorkflow: generateWorkflow2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2674
+ const r = await generateWorkflow2(args.requirements);
2675
+ return JSON.stringify(r, null, 2).slice(0, 3e3);
2676
+ },
2677
+ xgen_collection_list: async () => {
2678
+ const { listCollections: listCollections2 } = await Promise.resolve().then(() => (init_document(), document_exports));
2679
+ const cols = await listCollections2();
2680
+ if (!cols.length) return "\uCEEC\uB809\uC158 \uC5C6\uC74C.";
2681
+ return `\uCD1D ${cols.length}\uAC1C:
2682
+ ` + cols.map(
2683
+ (c, i) => `${i + 1}. ${c.collection_make_name} | ${c.total_documents}\uBB38\uC11C ${c.total_chunks}\uCCAD\uD06C${c.is_shared ? ` [\uACF5\uC720:${c.share_group}]` : ""}`
2684
+ ).join("\n");
2685
+ },
2686
+ xgen_document_list: async (args) => {
2687
+ const { listDocuments: listDocuments2 } = await Promise.resolve().then(() => (init_document(), document_exports));
2688
+ const docs = await listDocuments2(args.collection_id);
2689
+ if (!docs.length) return "\uBB38\uC11C \uC5C6\uC74C.";
2690
+ return docs.map((d, i) => `${i + 1}. ${d.name || d.file_name || "\uC774\uB984\uC5C6\uC74C"} ${d.file_type ?? ""} ${d.status ?? ""}`).join("\n");
2691
+ },
2692
+ xgen_document_upload: async (args) => {
2693
+ const { uploadDocument: uploadDocument2 } = await Promise.resolve().then(() => (init_document(), document_exports));
2694
+ const { existsSync: existsSync5 } = await import("fs");
2695
+ if (!args.file_path) return "\uD30C\uC77C \uACBD\uB85C \uD544\uC694.";
2696
+ if (!existsSync5(args.file_path)) return `\uD30C\uC77C \uC5C6\uC74C: ${args.file_path}`;
2697
+ const r = await uploadDocument2(args.file_path, args.collection_id);
2698
+ return `\uC5C5\uB85C\uB4DC \uC644\uB8CC: ${JSON.stringify(r)}`;
2699
+ },
2700
+ xgen_node_list: async () => {
2701
+ const { listNodes: listNodes2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2702
+ const nodes = await listNodes2();
2703
+ if (!nodes.length) return "\uB178\uB4DC \uC5C6\uC74C.";
2704
+ return `\uCD1D ${nodes.length}\uAC1C:
2705
+ ` + nodes.slice(0, 50).map(
2706
+ (n, i) => `${i + 1}. ${n.nodeName ?? n.name ?? n.node_id ?? "?"} ${n.description ? "\u2014 " + String(n.description).slice(0, 40) : ""}`
2707
+ ).join("\n") + (nodes.length > 50 ? `
2708
+ ...(+${nodes.length - 50}\uAC1C)` : "");
2709
+ },
2710
+ xgen_node_search: async (args) => {
2711
+ const { searchNodes: searchNodes2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2712
+ const nodes = await searchNodes2(args.query);
2713
+ if (!nodes.length) return "\uAC80\uC0C9 \uACB0\uACFC \uC5C6\uC74C.";
2714
+ return nodes.map(
2715
+ (n, i) => `${i + 1}. ${n.nodeName ?? n.name ?? "?"} \u2014 ${(n.description ?? "").slice(0, 60)}`
2716
+ ).join("\n");
2717
+ },
2718
+ xgen_node_categories: async () => {
2719
+ const { getNodeCategories: getNodeCategories2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2720
+ const cats = await getNodeCategories2();
2721
+ return cats.map((c, i) => `${i + 1}. ${c.name ?? c.category ?? c}`).join("\n") || "\uCE74\uD14C\uACE0\uB9AC \uC5C6\uC74C.";
2722
+ },
2723
+ xgen_prompt_list: async (args) => {
2724
+ const { listPrompts: listPrompts2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2725
+ const prompts = await listPrompts2({ language: args.language });
2726
+ if (!prompts.length) return "\uD504\uB86C\uD504\uD2B8 \uC5C6\uC74C.";
2727
+ return prompts.slice(0, 30).map(
2728
+ (p, i) => `${i + 1}. ${p.name ?? p.title ?? "?"} [${p.prompt_type ?? ""}] ${(p.content ?? "").slice(0, 40)}...`
2729
+ ).join("\n");
2730
+ },
2731
+ xgen_tool_store: async () => {
2732
+ const { listToolStore: listToolStore2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2733
+ const tools2 = await listToolStore2();
2734
+ if (!tools2.length) return "\uACF5\uAC1C \uB3C4\uAD6C \uC5C6\uC74C.";
2735
+ return tools2.map((t, i) => `${i + 1}. ${t.name ?? t.tool_name ?? "?"} \u2014 ${(t.description ?? "").slice(0, 50)}`).join("\n");
2736
+ },
2737
+ xgen_user_tools: async () => {
2738
+ const { listUserTools: listUserTools2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2739
+ const tools2 = await listUserTools2();
2740
+ if (!tools2.length) return "\uB0B4 \uB3C4\uAD6C \uC5C6\uC74C.";
2741
+ return tools2.map((t, i) => `${i + 1}. ${t.name ?? t.tool_name ?? "?"}`).join("\n");
2742
+ },
2743
+ xgen_schedule_list: async () => {
2744
+ const { listSchedules: listSchedules2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2745
+ const sessions = await listSchedules2();
2746
+ if (!sessions.length) return "\uC2A4\uCF00\uC904 \uC5C6\uC74C.";
2747
+ return sessions.map((s, i) => `${i + 1}. ${s.name ?? s.session_id ?? "?"} ${s.cron_expression ?? ""} [${s.status ?? "?"}]`).join("\n");
2748
+ },
2749
+ xgen_trace_list: async (args) => {
2750
+ const { listTraces: listTraces2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2751
+ const data = await listTraces2(args.workflow_id);
2752
+ const traces = data.traces ?? data ?? [];
2753
+ if (!traces.length) return "\uD2B8\uB808\uC774\uC2A4 \uC5C6\uC74C.";
2754
+ return traces.slice(0, 20).map(
2755
+ (t, i) => `${i + 1}. ${t.trace_id ?? t.id ?? "?"} [${t.status ?? "?"}] ${t.created_at ?? ""}`
2756
+ ).join("\n");
2757
+ },
2758
+ xgen_interaction_list: async (args) => {
2759
+ const { listInteractions: listInteractions2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2760
+ const items = await listInteractions2(args.workflow_id, args.limit || 20);
2761
+ if (!items.length) return "\uC778\uD130\uB799\uC158 \uC5C6\uC74C.";
2762
+ return items.slice(0, 20).map(
2763
+ (it, i) => `${i + 1}. ${it.interaction_id ?? "?"} ${it.workflow_name ?? ""} [${it.status ?? "?"}]`
2764
+ ).join("\n");
2765
+ },
2766
+ xgen_mcp_sessions: async () => {
2767
+ const { listMcpSessions: listMcpSessions2 } = await Promise.resolve().then(() => (init_xgen_extra(), xgen_extra_exports));
2768
+ const sessions = await listMcpSessions2();
2769
+ if (!sessions.length) return "MCP \uC138\uC158 \uC5C6\uC74C.";
2770
+ return sessions.map(
2771
+ (s, i) => `${i + 1}. ${s.session_name ?? s.session_id ?? "?"} [${s.server_type ?? "?"}] ${s.status ?? ""}`
2772
+ ).join("\n");
2773
+ },
2774
+ xgen_graph_rag_query: async (args) => {
2775
+ const { queryGraphRAG: queryGraphRAG2 } = await Promise.resolve().then(() => (init_ontology(), ontology_exports));
2776
+ if (!args.query) return "\uC9C8\uC758 \uB0B4\uC6A9 \uD544\uC694.";
2777
+ const r = await queryGraphRAG2(args.query, args.graph_id);
2778
+ let out = `\uB2F5\uBCC0: ${r.answer ?? "\uC5C6\uC74C"}`;
2779
+ if (r.sources?.length) out += `
2780
+ \uCD9C\uCC98: ${r.sources.join(", ")}`;
2781
+ return out;
2782
+ },
2783
+ xgen_graph_stats: async (args) => {
2784
+ const { getGraphStats: getGraphStats2 } = await Promise.resolve().then(() => (init_ontology(), ontology_exports));
2785
+ const s = await getGraphStats2(args.graph_id);
2786
+ return `\uB178\uB4DC: ${s.total_nodes ?? 0} \xB7 \uC5E3\uC9C0: ${s.total_edges ?? 0} \xB7 \uD074\uB798\uC2A4: ${s.total_classes ?? 0} \xB7 \uC778\uC2A4\uD134\uC2A4: ${s.total_instances ?? 0}`;
2787
+ },
2788
+ xgen_server_status: async () => {
2789
+ const server = getServer();
2790
+ const auth = getAuth();
2791
+ return `\uC11C\uBC84: ${server}
2792
+ \uC0AC\uC6A9\uC790: ${auth?.username} (ID: ${auth?.userId})`;
2793
+ }
2794
+ };
2791
2795
 
2792
2796
  // src/mcp/client.ts
2793
2797
  import { spawn } from "child_process";
@@ -2982,24 +2986,22 @@ EXAMPLES OF GOOD RESPONSES:
2982
2986
  if (server && auth) {
2983
2987
  prompt2 += `
2984
2988
 
2985
- XGEN CONNECTED: ${server} as ${auth.username} (${env?.name ?? "default"})
2989
+ XGEN CONNECTED: ${server} as ${auth.username}
2990
+
2991
+ You have full access to XGEN platform. Available tools:
2986
2992
 
2987
- XGEN CAPABILITIES (use these tools naturally):
2988
- - xgen_workflow_list: \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC804\uCCB4 \uBAA9\uB85D. \uBC30\uD3EC \uC0C1\uD0DC, ID \uD3EC\uD568.
2989
- - xgen_workflow_run: \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589. \uBC30\uD3EC \uC5EC\uBD80 \uBB34\uAD00\uD558\uAC8C \uBAA8\uB4E0 \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589 \uAC00\uB2A5. \uC0AC\uC6A9\uC790\uAC00 \uBC88\uD638\uB098 \uC774\uB984 \uB9D0\uD558\uBA74 \uC774\uC804 \uBAA9\uB85D\uC5D0\uC11C \uCC3E\uC544\uC11C \uBC14\uB85C \uC2E4\uD589.
2990
- - xgen_workflow_info: \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC0C1\uC138 (\uB178\uB4DC, \uC5E3\uC9C0 \uC218 \uB4F1).
2991
- - xgen_collection_list: \uBB38\uC11C \uCEEC\uB809\uC158 \uBAA9\uB85D (RAG \uC9C0\uC2DD\uBCA0\uC774\uC2A4). \uBB38\uC11C \uC218, \uCCAD\uD06C \uC218 \uD3EC\uD568.
2992
- - xgen_document_list: \uD2B9\uC815 \uCEEC\uB809\uC158\uC758 \uBB38\uC11C \uBAA9\uB85D \uC870\uD68C.
2993
- - xgen_document_upload: \uD30C\uC77C\uC744 \uCEEC\uB809\uC158\uC5D0 \uC5C5\uB85C\uB4DC.
2994
- - xgen_graph_rag_query: GraphRAG \uC628\uD1A8\uB85C\uC9C0 \uC9C8\uC758. \uC9C0\uC2DD\uADF8\uB798\uD504 \uAE30\uBC18 \uB2F5\uBCC0.
2995
- - xgen_graph_stats: \uADF8\uB798\uD504 \uD1B5\uACC4 (\uB178\uB4DC, \uC5E3\uC9C0, \uD074\uB798\uC2A4, \uC778\uC2A4\uD134\uC2A4 \uC218).
2996
- - xgen_execution_history: \uD2B9\uC815 \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589 \uC774\uB825.
2997
- - xgen_server_status: \uC11C\uBC84 \uC5F0\uACB0 \uC0C1\uD0DC.
2993
+ WORKFLOW: xgen_workflow_list, xgen_workflow_run (\uBAA8\uB4E0 \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589 \uAC00\uB2A5, \uBC30\uD3EC \uBB34\uAD00), xgen_workflow_info, xgen_execution_history, xgen_workflow_performance, xgen_workflow_store, xgen_workflow_generate (\uC790\uC5F0\uC5B4\uB85C \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC790\uB3D9 \uC0DD\uC131)
2994
+ DOCUMENTS: xgen_collection_list, xgen_document_list, xgen_document_upload
2995
+ NODES: xgen_node_list, xgen_node_search, xgen_node_categories
2996
+ PROMPTS: xgen_prompt_list
2997
+ TOOLS: xgen_tool_store, xgen_user_tools
2998
+ SCHEDULE: xgen_schedule_list
2999
+ TRACE: xgen_trace_list, xgen_interaction_list
3000
+ MCP: xgen_mcp_sessions
3001
+ ONTOLOGY: xgen_graph_rag_query, xgen_graph_stats
3002
+ SERVER: xgen_server_status
2998
3003
 
2999
- WORKFLOW EXECUTION NOTES:
3000
- - \uBAA8\uB4E0 \uC6CC\uD06C\uD50C\uB85C\uC6B0 \uC2E4\uD589 \uAC00\uB2A5 (\uBC30\uD3EC/\uBE44\uBC30\uD3EC \uBB34\uAD00). deploy_key \uBD88\uD544\uC694.
3001
- - \uC2E4\uD589 \uC2DC input_data\uC5D0 \uC0AC\uC6A9\uC790 \uBA54\uC2DC\uC9C0\uB97C \uB123\uC74C.
3002
- - \uC2E4\uD589 \uACB0\uACFC\uC758 content\uAC00 \uC751\uB2F5.`;
3004
+ When user says a number \u2192 find it from previous list. "\uC2E4\uD589" \u2192 execute immediately.`;
3003
3005
  } else {
3004
3006
  prompt2 += `
3005
3007
  XGEN: Not connected. User can run /connect to connect.`;
@@ -3310,8 +3312,8 @@ async function agentRepl() {
3310
3312
  mcpManager?.stopAll();
3311
3313
  rl.close();
3312
3314
  if (process.stdin.isTTY) process.stdin.setRawMode?.(false);
3313
- const { startTui: startTui2 } = await Promise.resolve().then(() => (init_tui(), tui_exports));
3314
- await startTui2();
3315
+ const { startInkDashboard: startInkDashboard2 } = await Promise.resolve().then(() => (init_InkDashboard(), InkDashboard_exports));
3316
+ await startInkDashboard2();
3315
3317
  return;
3316
3318
  }
3317
3319
  messages.push({ role: "user", content: input });
@@ -3592,7 +3594,7 @@ ${result.answer}
3592
3594
  }
3593
3595
 
3594
3596
  // src/index.ts
3595
- var VERSION = "1.6.0";
3597
+ var VERSION = "2.0.0";
3596
3598
  var LOGO = chalk15.cyan(`
3597
3599
  \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588
3598
3600
  \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588