openxgen 1.1.0 → 1.1.1

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
@@ -1243,29 +1243,37 @@ var init_tools = __esm({
1243
1243
  var document_exports = {};
1244
1244
  __export(document_exports, {
1245
1245
  getDocumentInfo: () => getDocumentInfo,
1246
+ listCollections: () => listCollections,
1246
1247
  listDocuments: () => listDocuments,
1247
1248
  uploadDocument: () => uploadDocument
1248
1249
  });
1249
- import { createReadStream, statSync } from "fs";
1250
- import { basename } from "path";
1250
+ async function listCollections() {
1251
+ const client2 = getClient();
1252
+ const res = await client2.get("/api/retrieval/collections");
1253
+ return Array.isArray(res.data) ? res.data : res.data.collections ?? [];
1254
+ }
1251
1255
  async function listDocuments(collectionId) {
1252
1256
  const client2 = getClient();
1253
- const params = {};
1254
- if (collectionId) params.collection_id = collectionId;
1255
- const res = await client2.get("/api/documents/list", { params });
1256
- return res.data.documents ?? res.data ?? [];
1257
+ try {
1258
+ const params = {};
1259
+ if (collectionId) params.collection_id = collectionId;
1260
+ const res = await client2.get("/api/retrieval/documents/list", { params });
1261
+ return res.data.documents ?? res.data ?? [];
1262
+ } catch {
1263
+ return [];
1264
+ }
1257
1265
  }
1258
1266
  async function uploadDocument(filePath, collectionId, name) {
1259
1267
  const client2 = getClient();
1268
+ const { createReadStream, statSync } = await import("fs");
1269
+ const { basename } = await import("path");
1260
1270
  const stat = statSync(filePath);
1261
1271
  const fileName = name || basename(filePath);
1262
- const FormData = (await import("buffer")).Blob ? globalThis.FormData : null;
1263
- if (!FormData) throw new Error("FormData not available");
1264
1272
  const form = new FormData();
1265
1273
  const fileBlob = new Blob([createReadStream(filePath)]);
1266
1274
  form.append("file", fileBlob, fileName);
1267
1275
  if (collectionId) form.append("collection_id", collectionId);
1268
- const res = await client2.post("/api/documents/upload", form, {
1276
+ const res = await client2.post("/api/retrieval/documents/upload", form, {
1269
1277
  headers: { "Content-Type": "multipart/form-data" },
1270
1278
  maxBodyLength: stat.size + 1024 * 1024
1271
1279
  });
@@ -1273,7 +1281,7 @@ async function uploadDocument(filePath, collectionId, name) {
1273
1281
  }
1274
1282
  async function getDocumentInfo(docId) {
1275
1283
  const client2 = getClient();
1276
- const res = await client2.get(`/api/documents/${docId}`);
1284
+ const res = await client2.get(`/api/retrieval/documents/${docId}`);
1277
1285
  return res.data;
1278
1286
  }
1279
1287
  var init_document = __esm({
@@ -1283,50 +1291,6 @@ var init_document = __esm({
1283
1291
  }
1284
1292
  });
1285
1293
 
1286
- // src/api/ontology.ts
1287
- var ontology_exports = {};
1288
- __export(ontology_exports, {
1289
- getGraphStats: () => getGraphStats,
1290
- listGraphs: () => listGraphs,
1291
- queryGraphRAG: () => queryGraphRAG,
1292
- queryGraphRAGMultiTurn: () => queryGraphRAGMultiTurn
1293
- });
1294
- async function queryGraphRAG(query, graphId, opts) {
1295
- const client2 = getClient();
1296
- const res = await client2.post("/api/graph-rag", {
1297
- query,
1298
- graph_id: graphId,
1299
- use_scs: opts?.scs ?? true
1300
- });
1301
- return res.data;
1302
- }
1303
- async function queryGraphRAGMultiTurn(query, sessionId, graphId, opts) {
1304
- const client2 = getClient();
1305
- const res = await client2.post("/api/graph-rag/multi-turn", {
1306
- query,
1307
- session_id: sessionId,
1308
- graph_id: graphId,
1309
- max_turns: opts?.maxTurns ?? 5
1310
- });
1311
- return res.data;
1312
- }
1313
- async function getGraphStats(graphId) {
1314
- const client2 = getClient();
1315
- const res = await client2.get(`/api/graph/${graphId}/stats`);
1316
- return res.data;
1317
- }
1318
- async function listGraphs() {
1319
- const client2 = getClient();
1320
- const res = await client2.get("/api/graph/list");
1321
- return res.data.graphs ?? res.data ?? [];
1322
- }
1323
- var init_ontology = __esm({
1324
- "src/api/ontology.ts"() {
1325
- "use strict";
1326
- init_client();
1327
- }
1328
- });
1329
-
1330
1294
  // src/agent/tools/xgen-api.ts
1331
1295
  async function execute8(name, args) {
1332
1296
  const server = getServer();
@@ -1342,10 +1306,8 @@ async function execute8(name, args) {
1342
1306
  return await workflowRun2(args);
1343
1307
  case "xgen_workflow_info":
1344
1308
  return await workflowInfo2(args);
1345
- case "xgen_doc_list":
1346
- return await docList(args);
1347
- case "xgen_ontology_query":
1348
- return await ontologyQuery(args);
1309
+ case "xgen_collection_list":
1310
+ return await collectionList();
1349
1311
  case "xgen_server_status":
1350
1312
  return await serverStatus();
1351
1313
  case "xgen_execution_history":
@@ -1397,24 +1359,15 @@ ID: ${detail.id}
1397
1359
  \uB178\uB4DC: ${nodes}\uAC1C
1398
1360
  \uC5E3\uC9C0: ${edges}\uAC1C`;
1399
1361
  }
1400
- async function docList(args) {
1401
- const { listDocuments: listDocuments2 } = await Promise.resolve().then(() => (init_document(), document_exports));
1402
- const docs = await listDocuments2(args.collection_id);
1403
- if (!docs.length) return "\uBB38\uC11C \uC5C6\uC74C.";
1404
- return docs.map(
1405
- (d, i) => `${i + 1}. ${d.file_name ?? d.name ?? "-"} (${d.file_type ?? "-"}) \u2014 ${d.status ?? "-"}`
1406
- ).join("\n");
1407
- }
1408
- async function ontologyQuery(args) {
1409
- const { queryGraphRAG: queryGraphRAG2 } = await Promise.resolve().then(() => (init_ontology(), ontology_exports));
1410
- const result = await queryGraphRAG2(args.query, args.graph_id);
1411
- let output = "";
1412
- if (result.answer) output += `\uB2F5\uBCC0: ${result.answer}
1413
- `;
1414
- if (result.sources?.length) output += `\uCD9C\uCC98: ${result.sources.join(", ")}
1415
- `;
1416
- if (result.triples_used?.length) output += `\uD2B8\uB9AC\uD50C: ${result.triples_used.join("; ")}`;
1417
- return output || "\uACB0\uACFC \uC5C6\uC74C.";
1362
+ async function collectionList() {
1363
+ const { listCollections: listCollections2 } = await Promise.resolve().then(() => (init_document(), document_exports));
1364
+ const cols = await listCollections2();
1365
+ if (!cols.length) return "\uCEEC\uB809\uC158 \uC5C6\uC74C.";
1366
+ return cols.map((c, i) => {
1367
+ const shared = c.is_shared ? ` [\uACF5\uC720:${c.share_group}]` : "";
1368
+ return `${i + 1}. ${c.collection_make_name}${shared}
1369
+ \uBB38\uC11C: ${c.total_documents}\uAC1C \xB7 \uCCAD\uD06C: ${c.total_chunks}\uAC1C \xB7 \uBAA8\uB378: ${c.init_embedding_model ?? "-"}`;
1370
+ }).join("\n");
1418
1371
  }
1419
1372
  async function serverStatus() {
1420
1373
  const server = getServer();
@@ -1482,29 +1435,9 @@ var init_xgen_api = __esm({
1482
1435
  {
1483
1436
  type: "function",
1484
1437
  function: {
1485
- name: "xgen_doc_list",
1486
- description: "XGEN \uC11C\uBC84\uC5D0\uC11C \uBB38\uC11C \uBAA9\uB85D\uC744 \uAC00\uC838\uC635\uB2C8\uB2E4.",
1487
- parameters: {
1488
- type: "object",
1489
- properties: {
1490
- collection_id: { type: "string", description: "\uCEEC\uB809\uC158 ID (\uC120\uD0DD)" }
1491
- }
1492
- }
1493
- }
1494
- },
1495
- {
1496
- type: "function",
1497
- function: {
1498
- name: "xgen_ontology_query",
1499
- description: "\uC628\uD1A8\uB85C\uC9C0(GraphRAG)\uC5D0 \uC9C8\uBB38\uD569\uB2C8\uB2E4. \uC9C0\uC2DD \uADF8\uB798\uD504 \uAE30\uBC18 \uAC80\uC0C9.",
1500
- parameters: {
1501
- type: "object",
1502
- properties: {
1503
- query: { type: "string", description: "\uC9C8\uC758 \uB0B4\uC6A9" },
1504
- graph_id: { type: "string", description: "\uADF8\uB798\uD504 ID (\uC120\uD0DD)" }
1505
- },
1506
- required: ["query"]
1507
- }
1438
+ name: "xgen_collection_list",
1439
+ 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.",
1440
+ parameters: { type: "object", properties: {} }
1508
1441
  }
1509
1442
  },
1510
1443
  {
@@ -1703,31 +1636,29 @@ function buildSystemPrompt() {
1703
1636
  const server = getServer();
1704
1637
  const auth = getAuth();
1705
1638
  const env = getActiveEnvironment();
1706
- let prompt2 = `You are OPEN XGEN, an AI assistant in the user's terminal.
1707
- You combine AI coding capabilities with the XGEN workflow platform.
1639
+ let prompt2 = `You are OPEN XGEN. Terminal AI agent.
1708
1640
 
1709
- ## Capabilities
1710
- 1. **Coding**: Read/write files, execute commands, search code, run sandboxed code (JS/TS/Python)
1711
- 2. **XGEN Platform**: List/run workflows, manage documents, query ontology (GraphRAG)
1641
+ CRITICAL RULES:
1642
+ - Be extremely concise. No menus, no numbered lists of options, no "what would you like to do" questions.
1643
+ - Just DO things. If the user says "\uC6CC\uD06C\uD50C\uB85C\uC6B0 \uBAA9\uB85D" \u2192 call xgen_workflow_list immediately, show results.
1644
+ - If the user says a number after seeing a list, treat it as selection and act on it.
1645
+ - If the user says "\uC2E4\uD589" or "run" \u2192 call the tool immediately with the context you have.
1646
+ - Never ask "which option do you prefer" or show menus. Infer intent and act.
1647
+ - Respond in the user's language. Korean if they speak Korean.
1648
+ - Max 2-3 sentences per response unless showing data.
1712
1649
 
1713
- ## Rules
1714
- - Respond in the same language as the user
1715
- - Be concise. Show what you did, not how.
1716
- - When using tools, briefly describe what you're doing
1717
- - For XGEN operations, use the xgen_* tools`;
1650
+ TOOLS:
1651
+ - Coding: file_read, file_write, file_edit, bash, grep, list_files, sandbox_run
1652
+ - XGEN: xgen_workflow_list, xgen_workflow_run, xgen_workflow_info, xgen_doc_list, xgen_ontology_query, xgen_server_status, xgen_execution_history`;
1718
1653
  if (server && auth) {
1719
1654
  prompt2 += `
1720
1655
 
1721
- ## XGEN Server Connected
1722
- - Server: ${server}
1723
- - User: ${auth.username} (ID: ${auth.userId})
1724
- - Environment: ${env?.name ?? "default"}
1725
- You can use xgen_workflow_list, xgen_workflow_run, xgen_doc_list, xgen_ontology_query, etc.`;
1656
+ XGEN CONNECTED: ${server} as ${auth.username} (${env?.name ?? "default"})
1657
+ - Workflow execute uses deploy_key for deployed workflows.
1658
+ - If workflow execution returns 404, it means the Istio routing blocks direct stream access. Use deploy endpoint.`;
1726
1659
  } else {
1727
1660
  prompt2 += `
1728
-
1729
- ## XGEN Server: Not connected
1730
- Tell the user to run /connect to connect to an XGEN server.`;
1661
+ XGEN: Not connected. Tell user to run /connect.`;
1731
1662
  }
1732
1663
  return prompt2;
1733
1664
  }
@@ -3121,10 +3052,38 @@ function registerDocCommand(program2) {
3121
3052
 
3122
3053
  // src/commands/ontology.ts
3123
3054
  init_store();
3124
- init_ontology();
3125
- init_format();
3126
3055
  import chalk14 from "chalk";
3127
3056
  import { createInterface as createInterface6 } from "readline";
3057
+
3058
+ // src/api/ontology.ts
3059
+ init_client();
3060
+ async function queryGraphRAG(query, graphId, opts) {
3061
+ const client2 = getClient();
3062
+ const res = await client2.post("/api/graph-rag", {
3063
+ query,
3064
+ graph_id: graphId,
3065
+ use_scs: opts?.scs ?? true
3066
+ });
3067
+ return res.data;
3068
+ }
3069
+ async function queryGraphRAGMultiTurn(query, sessionId, graphId, opts) {
3070
+ const client2 = getClient();
3071
+ const res = await client2.post("/api/graph-rag/multi-turn", {
3072
+ query,
3073
+ session_id: sessionId,
3074
+ graph_id: graphId,
3075
+ max_turns: opts?.maxTurns ?? 5
3076
+ });
3077
+ return res.data;
3078
+ }
3079
+ async function getGraphStats(graphId) {
3080
+ const client2 = getClient();
3081
+ const res = await client2.get(`/api/graph/${graphId}/stats`);
3082
+ return res.data;
3083
+ }
3084
+
3085
+ // src/commands/ontology.ts
3086
+ init_format();
3128
3087
  import { randomUUID as randomUUID3 } from "crypto";
3129
3088
  function registerOntologyCommand(program2) {
3130
3089
  const ont = program2.command("ontology").alias("ont").description("\uC628\uD1A8\uB85C\uC9C0 GraphRAG \uC9C8\uC758");