@superatomai/sdk-node 0.0.55 → 0.0.57
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.d.mts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +485 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +485 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2409,10 +2409,30 @@ var BookmarksRequestMessageSchema = import_zod3.z.object({
|
|
|
2409
2409
|
type: import_zod3.z.literal("BOOKMARKS"),
|
|
2410
2410
|
payload: BookmarksRequestPayloadSchema
|
|
2411
2411
|
});
|
|
2412
|
+
var ArtifactsRequestPayloadSchema = import_zod3.z.object({
|
|
2413
|
+
operation: import_zod3.z.enum(["create", "update", "delete", "getAll", "getOne"]),
|
|
2414
|
+
data: import_zod3.z.object({
|
|
2415
|
+
id: import_zod3.z.number().optional(),
|
|
2416
|
+
name: import_zod3.z.string().optional(),
|
|
2417
|
+
createdBy: import_zod3.z.number().optional(),
|
|
2418
|
+
dsl: import_zod3.z.record(import_zod3.z.any()).optional(),
|
|
2419
|
+
status: import_zod3.z.string().optional(),
|
|
2420
|
+
deleted: import_zod3.z.boolean().optional(),
|
|
2421
|
+
limit: import_zod3.z.number().optional()
|
|
2422
|
+
}).optional()
|
|
2423
|
+
});
|
|
2424
|
+
var ArtifactsRequestMessageSchema = import_zod3.z.object({
|
|
2425
|
+
id: import_zod3.z.string(),
|
|
2426
|
+
from: MessageParticipantSchema,
|
|
2427
|
+
type: import_zod3.z.literal("ARTIFACTS"),
|
|
2428
|
+
payload: ArtifactsRequestPayloadSchema
|
|
2429
|
+
});
|
|
2430
|
+
var KbNodeTypeSchema = import_zod3.z.enum(["global", "user", "query"]);
|
|
2412
2431
|
var KbNodesQueryFiltersSchema = import_zod3.z.object({
|
|
2413
2432
|
query: import_zod3.z.string().optional(),
|
|
2414
2433
|
category: import_zod3.z.string().optional(),
|
|
2415
2434
|
tags: import_zod3.z.array(import_zod3.z.string()).optional(),
|
|
2435
|
+
type: KbNodeTypeSchema.optional(),
|
|
2416
2436
|
createdBy: import_zod3.z.number().optional()
|
|
2417
2437
|
});
|
|
2418
2438
|
var KbNodesRequestPayloadSchema = import_zod3.z.object({
|
|
@@ -2423,6 +2443,7 @@ var KbNodesRequestPayloadSchema = import_zod3.z.object({
|
|
|
2423
2443
|
content: import_zod3.z.string().optional(),
|
|
2424
2444
|
category: import_zod3.z.string().optional(),
|
|
2425
2445
|
tags: import_zod3.z.array(import_zod3.z.string()).optional(),
|
|
2446
|
+
type: KbNodeTypeSchema.optional(),
|
|
2426
2447
|
createdBy: import_zod3.z.number().optional(),
|
|
2427
2448
|
updatedBy: import_zod3.z.number().optional(),
|
|
2428
2449
|
userId: import_zod3.z.number().optional(),
|
|
@@ -5436,7 +5457,7 @@ var getKnowledgeBase = async ({
|
|
|
5436
5457
|
topK
|
|
5437
5458
|
});
|
|
5438
5459
|
if (!result || !result.content) {
|
|
5439
|
-
logger.
|
|
5460
|
+
logger.info("[KnowledgeBase] No knowledge base results returned");
|
|
5440
5461
|
return "";
|
|
5441
5462
|
}
|
|
5442
5463
|
logger.info(`[KnowledgeBase] Retrieved knowledge base context (${result.content.length} chars)`);
|
|
@@ -5450,8 +5471,101 @@ var getKnowledgeBase = async ({
|
|
|
5450
5471
|
return "";
|
|
5451
5472
|
}
|
|
5452
5473
|
};
|
|
5474
|
+
var getGlobalKnowledgeBase = async ({
|
|
5475
|
+
collections,
|
|
5476
|
+
limit = 100
|
|
5477
|
+
}) => {
|
|
5478
|
+
try {
|
|
5479
|
+
if (!collections || !collections["knowledge-base"] || !collections["knowledge-base"]["getGlobal"]) {
|
|
5480
|
+
logger.info("[KnowledgeBase] knowledge-base.getGlobal collection not registered, skipping");
|
|
5481
|
+
return "";
|
|
5482
|
+
}
|
|
5483
|
+
logger.info("[KnowledgeBase] Fetching global knowledge base nodes...");
|
|
5484
|
+
const result = await collections["knowledge-base"]["getGlobal"]({ limit });
|
|
5485
|
+
if (!result || !result.content) {
|
|
5486
|
+
logger.info("[KnowledgeBase] No global knowledge base nodes found");
|
|
5487
|
+
return "";
|
|
5488
|
+
}
|
|
5489
|
+
logger.info(`[KnowledgeBase] Retrieved ${result.count || 0} global knowledge base nodes`);
|
|
5490
|
+
return result.content;
|
|
5491
|
+
} catch (error) {
|
|
5492
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
5493
|
+
logger.warn(`[KnowledgeBase] Error fetching global knowledge base: ${errorMsg}`);
|
|
5494
|
+
return "";
|
|
5495
|
+
}
|
|
5496
|
+
};
|
|
5497
|
+
var getUserKnowledgeBase = async ({
|
|
5498
|
+
collections,
|
|
5499
|
+
userId,
|
|
5500
|
+
limit = 100
|
|
5501
|
+
}) => {
|
|
5502
|
+
try {
|
|
5503
|
+
if (!userId) {
|
|
5504
|
+
logger.info("[KnowledgeBase] No userId provided, skipping user knowledge base");
|
|
5505
|
+
return "";
|
|
5506
|
+
}
|
|
5507
|
+
if (!collections || !collections["knowledge-base"] || !collections["knowledge-base"]["getByUser"]) {
|
|
5508
|
+
logger.info("[KnowledgeBase] knowledge-base.getByUser collection not registered, skipping");
|
|
5509
|
+
return "";
|
|
5510
|
+
}
|
|
5511
|
+
logger.info(`[KnowledgeBase] Fetching user knowledge base nodes for userId: ${userId}...`);
|
|
5512
|
+
const result = await collections["knowledge-base"]["getByUser"]({
|
|
5513
|
+
userId: Number(userId),
|
|
5514
|
+
limit
|
|
5515
|
+
});
|
|
5516
|
+
if (!result || !result.content) {
|
|
5517
|
+
logger.info(`[KnowledgeBase] No user knowledge base nodes found for userId: ${userId}`);
|
|
5518
|
+
return "";
|
|
5519
|
+
}
|
|
5520
|
+
logger.info(`[KnowledgeBase] Retrieved ${result.count || 0} user knowledge base nodes for userId: ${userId}`);
|
|
5521
|
+
return result.content;
|
|
5522
|
+
} catch (error) {
|
|
5523
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
5524
|
+
logger.warn(`[KnowledgeBase] Error fetching user knowledge base: ${errorMsg}`);
|
|
5525
|
+
return "";
|
|
5526
|
+
}
|
|
5527
|
+
};
|
|
5528
|
+
var getAllKnowledgeBase = async ({
|
|
5529
|
+
prompt,
|
|
5530
|
+
collections,
|
|
5531
|
+
userId,
|
|
5532
|
+
topK = 3
|
|
5533
|
+
}) => {
|
|
5534
|
+
logger.info("[KnowledgeBase] Fetching all knowledge base contexts...");
|
|
5535
|
+
const [globalContext, userContext, queryContext] = await Promise.all([
|
|
5536
|
+
getGlobalKnowledgeBase({ collections }),
|
|
5537
|
+
getUserKnowledgeBase({ collections, userId }),
|
|
5538
|
+
getKnowledgeBase({ prompt, collections, topK })
|
|
5539
|
+
]);
|
|
5540
|
+
let combinedContext = "";
|
|
5541
|
+
if (globalContext) {
|
|
5542
|
+
combinedContext += "## Global Knowledge Base\n";
|
|
5543
|
+
combinedContext += "The following information applies to all queries:\n\n";
|
|
5544
|
+
combinedContext += globalContext + "\n\n";
|
|
5545
|
+
}
|
|
5546
|
+
if (userContext) {
|
|
5547
|
+
combinedContext += "## User-Specific Knowledge Base\n";
|
|
5548
|
+
combinedContext += "The following information is specific to this user:\n\n";
|
|
5549
|
+
combinedContext += userContext + "\n\n";
|
|
5550
|
+
}
|
|
5551
|
+
if (queryContext) {
|
|
5552
|
+
combinedContext += "## Relevant Knowledge Base (Query-Matched)\n";
|
|
5553
|
+
combinedContext += "The following information is semantically relevant to the current query:\n\n";
|
|
5554
|
+
combinedContext += queryContext + "\n\n";
|
|
5555
|
+
}
|
|
5556
|
+
logger.info(`[KnowledgeBase] Combined knowledge base context: global=${globalContext.length} chars, user=${userContext.length} chars, query=${queryContext.length} chars`);
|
|
5557
|
+
return {
|
|
5558
|
+
globalContext,
|
|
5559
|
+
userContext,
|
|
5560
|
+
queryContext,
|
|
5561
|
+
combinedContext: combinedContext.trim()
|
|
5562
|
+
};
|
|
5563
|
+
};
|
|
5453
5564
|
var KB = {
|
|
5454
|
-
getKnowledgeBase
|
|
5565
|
+
getKnowledgeBase,
|
|
5566
|
+
getGlobalKnowledgeBase,
|
|
5567
|
+
getUserKnowledgeBase,
|
|
5568
|
+
getAllKnowledgeBase
|
|
5455
5569
|
};
|
|
5456
5570
|
var knowledge_base_default = KB;
|
|
5457
5571
|
|
|
@@ -6314,8 +6428,9 @@ ${executedToolsText}`);
|
|
|
6314
6428
|
* @param components - Optional list of available components for matching suggestions
|
|
6315
6429
|
* @param externalTools - Optional array of external tools (email, calendar, etc.) that can be called
|
|
6316
6430
|
* @param category - Question category ('data_analysis' | 'data_modification' | 'general'). For data_modification, answer component streaming is skipped. For general, component generation is skipped entirely.
|
|
6431
|
+
* @param userId - Optional user ID for fetching user-specific knowledge base nodes
|
|
6317
6432
|
*/
|
|
6318
|
-
async generateTextResponse(userPrompt, apiKey, logCollector, conversationHistory, streamCallback, collections, components, externalTools, category) {
|
|
6433
|
+
async generateTextResponse(userPrompt, apiKey, logCollector, conversationHistory, streamCallback, collections, components, externalTools, category, userId) {
|
|
6319
6434
|
const errors = [];
|
|
6320
6435
|
logger.debug(`[${this.getProviderName()}] Starting text response generation`);
|
|
6321
6436
|
logger.debug(`[${this.getProviderName()}] User prompt: "${userPrompt.substring(0, 50)}..."`);
|
|
@@ -6364,11 +6479,13 @@ ${executedToolsText}`);
|
|
|
6364
6479
|
}
|
|
6365
6480
|
const schemaDoc = schema.generateSchemaDocumentation();
|
|
6366
6481
|
const databaseRules = await promptLoader.loadDatabaseRules();
|
|
6367
|
-
const
|
|
6482
|
+
const kbResult = await knowledge_base_default.getAllKnowledgeBase({
|
|
6368
6483
|
prompt: userPrompt,
|
|
6369
6484
|
collections,
|
|
6370
|
-
|
|
6485
|
+
userId,
|
|
6486
|
+
topK: 3
|
|
6371
6487
|
});
|
|
6488
|
+
const knowledgeBaseContext = kbResult.combinedContext;
|
|
6372
6489
|
const prompts = await promptLoader.loadPrompts("text-response", {
|
|
6373
6490
|
USER_PROMPT: userPrompt,
|
|
6374
6491
|
CONVERSATION_HISTORY: conversationHistory || "No previous conversation",
|
|
@@ -6494,10 +6611,58 @@ ${executedToolsText}`);
|
|
|
6494
6611
|
const executedToolsList = [];
|
|
6495
6612
|
let maxAttemptsReached = false;
|
|
6496
6613
|
let fullStreamedText = "";
|
|
6614
|
+
let streamBuffer = "";
|
|
6615
|
+
let flushTimer = null;
|
|
6616
|
+
const FLUSH_INTERVAL = 50;
|
|
6617
|
+
const flushStreamBuffer = () => {
|
|
6618
|
+
if (streamBuffer && streamCallback) {
|
|
6619
|
+
streamCallback(streamBuffer);
|
|
6620
|
+
streamBuffer = "";
|
|
6621
|
+
}
|
|
6622
|
+
flushTimer = null;
|
|
6623
|
+
};
|
|
6497
6624
|
const wrappedStreamCallback = streamCallback ? (chunk) => {
|
|
6498
6625
|
fullStreamedText += chunk;
|
|
6499
|
-
|
|
6626
|
+
streamBuffer += chunk;
|
|
6627
|
+
if (chunk.includes("\n") || chunk.length > 100) {
|
|
6628
|
+
if (flushTimer) {
|
|
6629
|
+
clearTimeout(flushTimer);
|
|
6630
|
+
flushTimer = null;
|
|
6631
|
+
}
|
|
6632
|
+
flushStreamBuffer();
|
|
6633
|
+
} else if (!flushTimer) {
|
|
6634
|
+
flushTimer = setTimeout(flushStreamBuffer, FLUSH_INTERVAL);
|
|
6635
|
+
}
|
|
6500
6636
|
} : void 0;
|
|
6637
|
+
const flushStream = () => {
|
|
6638
|
+
if (flushTimer) {
|
|
6639
|
+
clearTimeout(flushTimer);
|
|
6640
|
+
flushTimer = null;
|
|
6641
|
+
}
|
|
6642
|
+
flushStreamBuffer();
|
|
6643
|
+
};
|
|
6644
|
+
const streamDelay = (ms = 50) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
6645
|
+
const withProgressHeartbeat = async (operation, progressMessage, intervalMs = 1e3) => {
|
|
6646
|
+
if (!wrappedStreamCallback) {
|
|
6647
|
+
return operation();
|
|
6648
|
+
}
|
|
6649
|
+
const startTime = Date.now();
|
|
6650
|
+
await streamDelay(30);
|
|
6651
|
+
wrappedStreamCallback(`\u23F3 ${progressMessage}`);
|
|
6652
|
+
const heartbeatInterval = setInterval(() => {
|
|
6653
|
+
const elapsedSeconds = Math.floor((Date.now() - startTime) / 1e3);
|
|
6654
|
+
if (elapsedSeconds >= 1) {
|
|
6655
|
+
wrappedStreamCallback(` (${elapsedSeconds}s)`);
|
|
6656
|
+
}
|
|
6657
|
+
}, intervalMs);
|
|
6658
|
+
try {
|
|
6659
|
+
const result2 = await operation();
|
|
6660
|
+
return result2;
|
|
6661
|
+
} finally {
|
|
6662
|
+
clearInterval(heartbeatInterval);
|
|
6663
|
+
wrappedStreamCallback("\n\n");
|
|
6664
|
+
}
|
|
6665
|
+
};
|
|
6501
6666
|
const toolHandler = async (toolName, toolInput) => {
|
|
6502
6667
|
if (toolName === "execute_query") {
|
|
6503
6668
|
let sql = toolInput.sql;
|
|
@@ -6532,6 +6697,7 @@ Please try rephrasing your question or simplifying your request.
|
|
|
6532
6697
|
throw new Error(errorMsg);
|
|
6533
6698
|
}
|
|
6534
6699
|
try {
|
|
6700
|
+
flushStream();
|
|
6535
6701
|
if (wrappedStreamCallback) {
|
|
6536
6702
|
const paramsDisplay = Object.keys(params).length > 0 ? `
|
|
6537
6703
|
**Parameters:** ${JSON.stringify(params)}` : "";
|
|
@@ -6541,10 +6707,12 @@ Please try rephrasing your question or simplifying your request.
|
|
|
6541
6707
|
\u{1F50D} **Analyzing your question...**
|
|
6542
6708
|
|
|
6543
6709
|
`);
|
|
6710
|
+
await streamDelay(50);
|
|
6544
6711
|
if (reasoning) {
|
|
6545
6712
|
wrappedStreamCallback(`\u{1F4AD} ${reasoning}
|
|
6546
6713
|
|
|
6547
6714
|
`);
|
|
6715
|
+
await streamDelay(50);
|
|
6548
6716
|
}
|
|
6549
6717
|
wrappedStreamCallback(`\u{1F4DD} **Generated SQL Query:**
|
|
6550
6718
|
\`\`\`sql
|
|
@@ -6552,19 +6720,19 @@ ${sql}
|
|
|
6552
6720
|
\`\`\`${paramsDisplay}
|
|
6553
6721
|
|
|
6554
6722
|
`);
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
`);
|
|
6723
|
+
await streamDelay(50);
|
|
6558
6724
|
} else {
|
|
6559
6725
|
wrappedStreamCallback(`
|
|
6560
6726
|
|
|
6561
6727
|
\u{1F504} **Retrying with corrected query (attempt ${attempts}/${MAX_QUERY_ATTEMPTS})...**
|
|
6562
6728
|
|
|
6563
6729
|
`);
|
|
6730
|
+
await streamDelay(50);
|
|
6564
6731
|
if (reasoning) {
|
|
6565
6732
|
wrappedStreamCallback(`\u{1F4AD} ${reasoning}
|
|
6566
6733
|
|
|
6567
6734
|
`);
|
|
6735
|
+
await streamDelay(50);
|
|
6568
6736
|
}
|
|
6569
6737
|
wrappedStreamCallback(`\u{1F4DD} **Corrected SQL Query:**
|
|
6570
6738
|
\`\`\`sql
|
|
@@ -6572,9 +6740,7 @@ ${sql}
|
|
|
6572
6740
|
\`\`\`${paramsDisplay}
|
|
6573
6741
|
|
|
6574
6742
|
`);
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
`);
|
|
6743
|
+
await streamDelay(50);
|
|
6578
6744
|
}
|
|
6579
6745
|
}
|
|
6580
6746
|
logCollector?.logQuery(
|
|
@@ -6586,15 +6752,22 @@ ${sql}
|
|
|
6586
6752
|
throw new Error("Database collection not registered. Please register database.execute collection to execute queries.");
|
|
6587
6753
|
}
|
|
6588
6754
|
const queryPayload = Object.keys(params).length > 0 ? { sql: JSON.stringify({ sql, values: params }) } : { sql };
|
|
6589
|
-
const result2 = await
|
|
6755
|
+
const result2 = await withProgressHeartbeat(
|
|
6756
|
+
() => collections["database"]["execute"](queryPayload),
|
|
6757
|
+
"Executing database query",
|
|
6758
|
+
800
|
|
6759
|
+
// Send heartbeat every 800ms for responsive feedback
|
|
6760
|
+
);
|
|
6590
6761
|
const data = result2?.data || result2;
|
|
6591
6762
|
const rowCount = result2?.count ?? (Array.isArray(data) ? data.length : "N/A");
|
|
6592
6763
|
logger.info(`[${this.getProviderName()}] Query executed successfully, rows returned: ${rowCount}`);
|
|
6593
6764
|
logCollector?.info(`Query successful, returned ${rowCount} rows`);
|
|
6594
6765
|
if (wrappedStreamCallback) {
|
|
6595
|
-
wrappedStreamCallback(
|
|
6766
|
+
wrappedStreamCallback(`
|
|
6767
|
+
\u2705 **Query executed successfully!**
|
|
6596
6768
|
|
|
6597
6769
|
`);
|
|
6770
|
+
await streamDelay(50);
|
|
6598
6771
|
if (Array.isArray(data) && data.length > 0) {
|
|
6599
6772
|
const firstRow = data[0];
|
|
6600
6773
|
const columns = Object.keys(firstRow);
|
|
@@ -6603,18 +6776,22 @@ ${sql}
|
|
|
6603
6776
|
wrappedStreamCallback(`**Result:** ${value}
|
|
6604
6777
|
|
|
6605
6778
|
`);
|
|
6779
|
+
await streamDelay(50);
|
|
6606
6780
|
} else if (data.length > 0) {
|
|
6607
6781
|
wrappedStreamCallback(`**Retrieved ${rowCount} rows**
|
|
6608
6782
|
|
|
6609
6783
|
`);
|
|
6784
|
+
await streamDelay(50);
|
|
6610
6785
|
wrappedStreamCallback(`<DataTable>${JSON.stringify(data)}</DataTable>
|
|
6611
6786
|
|
|
6612
6787
|
`);
|
|
6788
|
+
await streamDelay(50);
|
|
6613
6789
|
}
|
|
6614
6790
|
} else if (Array.isArray(data) && data.length === 0) {
|
|
6615
6791
|
wrappedStreamCallback(`**No rows returned.**
|
|
6616
6792
|
|
|
6617
6793
|
`);
|
|
6794
|
+
await streamDelay(50);
|
|
6618
6795
|
}
|
|
6619
6796
|
wrappedStreamCallback(`\u{1F4CA} **Analyzing results...**
|
|
6620
6797
|
|
|
@@ -6664,6 +6841,7 @@ Please try rephrasing your request or contact support.
|
|
|
6664
6841
|
throw new Error(errorMsg);
|
|
6665
6842
|
}
|
|
6666
6843
|
try {
|
|
6844
|
+
flushStream();
|
|
6667
6845
|
if (wrappedStreamCallback) {
|
|
6668
6846
|
if (attempts === 1) {
|
|
6669
6847
|
wrappedStreamCallback(`
|
|
@@ -6678,8 +6856,14 @@ Please try rephrasing your request or contact support.
|
|
|
6678
6856
|
|
|
6679
6857
|
`);
|
|
6680
6858
|
}
|
|
6859
|
+
await streamDelay(50);
|
|
6681
6860
|
}
|
|
6682
|
-
const result2 = await
|
|
6861
|
+
const result2 = await withProgressHeartbeat(
|
|
6862
|
+
() => externalTool.fn(toolInput),
|
|
6863
|
+
`Running ${externalTool.name}`,
|
|
6864
|
+
800
|
|
6865
|
+
// Send heartbeat every 800ms
|
|
6866
|
+
);
|
|
6683
6867
|
logger.info(`[${this.getProviderName()}] External tool ${externalTool.name} executed successfully`);
|
|
6684
6868
|
logCollector?.info(`\u2713 ${externalTool.name} executed successfully`);
|
|
6685
6869
|
if (!executedToolsList.find((t) => t.id === externalTool.id)) {
|
|
@@ -6712,6 +6896,7 @@ Please try rephrasing your request or contact support.
|
|
|
6712
6896
|
wrappedStreamCallback(`\u2705 **${externalTool.name} completed successfully**
|
|
6713
6897
|
|
|
6714
6898
|
`);
|
|
6899
|
+
await streamDelay(50);
|
|
6715
6900
|
}
|
|
6716
6901
|
return JSON.stringify(result2, null, 2);
|
|
6717
6902
|
} catch (error) {
|
|
@@ -6780,7 +6965,9 @@ ${errorMsg}
|
|
|
6780
6965
|
textLength: textResponse.length
|
|
6781
6966
|
}
|
|
6782
6967
|
);
|
|
6968
|
+
flushStream();
|
|
6783
6969
|
if (wrappedStreamCallback && components && components.length > 0 && category !== "general") {
|
|
6970
|
+
wrappedStreamCallback("\n\n\u{1F4CA} **Generating visualization components...**\n\n");
|
|
6784
6971
|
wrappedStreamCallback("__TEXT_COMPLETE__COMPONENT_GENERATION_START__");
|
|
6785
6972
|
}
|
|
6786
6973
|
let matchedComponents = [];
|
|
@@ -7090,7 +7277,8 @@ ${errorMsg}
|
|
|
7090
7277
|
collections,
|
|
7091
7278
|
components,
|
|
7092
7279
|
toolsToUse,
|
|
7093
|
-
categoryClassification.category
|
|
7280
|
+
categoryClassification.category,
|
|
7281
|
+
userId
|
|
7094
7282
|
);
|
|
7095
7283
|
const elapsedTime = Date.now() - startTime;
|
|
7096
7284
|
logger.info(`[${this.getProviderName()}] Total time taken: ${elapsedTime}ms (${(elapsedTime / 1e3).toFixed(2)}s)`);
|
|
@@ -10163,6 +10351,182 @@ function sendResponse7(id, res, sendMessage, clientId) {
|
|
|
10163
10351
|
sendMessage(response);
|
|
10164
10352
|
}
|
|
10165
10353
|
|
|
10354
|
+
// src/handlers/artifacts.ts
|
|
10355
|
+
init_logger();
|
|
10356
|
+
async function handleArtifactsRequest(data, collections, sendMessage) {
|
|
10357
|
+
const executeCollection = async (collection, op, params) => {
|
|
10358
|
+
const handler = collections[collection]?.[op];
|
|
10359
|
+
if (!handler) {
|
|
10360
|
+
throw new Error(`Collection operation ${collection}.${op} not found`);
|
|
10361
|
+
}
|
|
10362
|
+
return await handler(params);
|
|
10363
|
+
};
|
|
10364
|
+
try {
|
|
10365
|
+
const request = ArtifactsRequestMessageSchema.parse(data);
|
|
10366
|
+
const { id, payload, from } = request;
|
|
10367
|
+
const { operation, data: requestData } = payload;
|
|
10368
|
+
const artifactId = requestData?.id;
|
|
10369
|
+
const name = requestData?.name;
|
|
10370
|
+
const createdBy = requestData?.createdBy;
|
|
10371
|
+
const dsl = requestData?.dsl;
|
|
10372
|
+
const status = requestData?.status;
|
|
10373
|
+
const deleted = requestData?.deleted;
|
|
10374
|
+
const limit = requestData?.limit;
|
|
10375
|
+
switch (operation) {
|
|
10376
|
+
case "create":
|
|
10377
|
+
await handleCreate6(id, name, createdBy, dsl, status, executeCollection, sendMessage, from.id);
|
|
10378
|
+
break;
|
|
10379
|
+
case "update":
|
|
10380
|
+
await handleUpdate6(id, artifactId, name, dsl, status, deleted, executeCollection, sendMessage, from.id);
|
|
10381
|
+
break;
|
|
10382
|
+
case "delete":
|
|
10383
|
+
await handleDelete6(id, artifactId, executeCollection, sendMessage, from.id);
|
|
10384
|
+
break;
|
|
10385
|
+
case "getAll":
|
|
10386
|
+
await handleGetAll6(id, limit, executeCollection, sendMessage, from.id);
|
|
10387
|
+
break;
|
|
10388
|
+
case "getOne":
|
|
10389
|
+
await handleGetOne6(id, artifactId, executeCollection, sendMessage, from.id);
|
|
10390
|
+
break;
|
|
10391
|
+
default:
|
|
10392
|
+
sendResponse8(id, {
|
|
10393
|
+
success: false,
|
|
10394
|
+
error: `Unknown operation: ${operation}`
|
|
10395
|
+
}, sendMessage, from.id);
|
|
10396
|
+
}
|
|
10397
|
+
} catch (error) {
|
|
10398
|
+
logger.error("Failed to handle artifacts request:", error);
|
|
10399
|
+
sendResponse8(null, {
|
|
10400
|
+
success: false,
|
|
10401
|
+
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
10402
|
+
}, sendMessage);
|
|
10403
|
+
}
|
|
10404
|
+
}
|
|
10405
|
+
async function handleCreate6(id, name, createdBy, dsl, status, executeCollection, sendMessage, clientId) {
|
|
10406
|
+
if (!name) {
|
|
10407
|
+
sendResponse8(id, {
|
|
10408
|
+
success: false,
|
|
10409
|
+
error: "name is required"
|
|
10410
|
+
}, sendMessage, clientId);
|
|
10411
|
+
return;
|
|
10412
|
+
}
|
|
10413
|
+
try {
|
|
10414
|
+
const result = await executeCollection("artifacts", "create", { name, createdBy, dsl, status });
|
|
10415
|
+
sendResponse8(id, {
|
|
10416
|
+
success: true,
|
|
10417
|
+
data: result.data,
|
|
10418
|
+
message: "Artifact created successfully"
|
|
10419
|
+
}, sendMessage, clientId);
|
|
10420
|
+
logger.info(`Artifact created: ID ${result.data.id}`);
|
|
10421
|
+
} catch (error) {
|
|
10422
|
+
sendResponse8(id, {
|
|
10423
|
+
success: false,
|
|
10424
|
+
error: error instanceof Error ? error.message : "Failed to create artifact"
|
|
10425
|
+
}, sendMessage, clientId);
|
|
10426
|
+
}
|
|
10427
|
+
}
|
|
10428
|
+
async function handleUpdate6(id, artifactId, name, dsl, status, deleted, executeCollection, sendMessage, clientId) {
|
|
10429
|
+
if (!artifactId) {
|
|
10430
|
+
sendResponse8(id, {
|
|
10431
|
+
success: false,
|
|
10432
|
+
error: "Artifact ID is required"
|
|
10433
|
+
}, sendMessage, clientId);
|
|
10434
|
+
return;
|
|
10435
|
+
}
|
|
10436
|
+
try {
|
|
10437
|
+
const result = await executeCollection("artifacts", "update", { id: artifactId, name, dsl, status, deleted });
|
|
10438
|
+
sendResponse8(id, {
|
|
10439
|
+
success: true,
|
|
10440
|
+
data: result.data,
|
|
10441
|
+
message: "Artifact updated successfully"
|
|
10442
|
+
}, sendMessage, clientId);
|
|
10443
|
+
logger.info(`Artifact updated: ID ${artifactId}`);
|
|
10444
|
+
} catch (error) {
|
|
10445
|
+
sendResponse8(id, {
|
|
10446
|
+
success: false,
|
|
10447
|
+
error: error instanceof Error ? error.message : "Failed to update artifact"
|
|
10448
|
+
}, sendMessage, clientId);
|
|
10449
|
+
}
|
|
10450
|
+
}
|
|
10451
|
+
async function handleDelete6(id, artifactId, executeCollection, sendMessage, clientId) {
|
|
10452
|
+
if (!artifactId) {
|
|
10453
|
+
sendResponse8(id, {
|
|
10454
|
+
success: false,
|
|
10455
|
+
error: "Artifact ID is required"
|
|
10456
|
+
}, sendMessage, clientId);
|
|
10457
|
+
return;
|
|
10458
|
+
}
|
|
10459
|
+
try {
|
|
10460
|
+
const result = await executeCollection("artifacts", "delete", { id: artifactId });
|
|
10461
|
+
sendResponse8(id, {
|
|
10462
|
+
success: true,
|
|
10463
|
+
data: result.data,
|
|
10464
|
+
message: "Artifact deleted successfully"
|
|
10465
|
+
}, sendMessage, clientId);
|
|
10466
|
+
logger.info(`Artifact deleted: ID ${artifactId}`);
|
|
10467
|
+
} catch (error) {
|
|
10468
|
+
sendResponse8(id, {
|
|
10469
|
+
success: false,
|
|
10470
|
+
error: error instanceof Error ? error.message : "Failed to delete artifact"
|
|
10471
|
+
}, sendMessage, clientId);
|
|
10472
|
+
}
|
|
10473
|
+
}
|
|
10474
|
+
async function handleGetAll6(id, limit, executeCollection, sendMessage, clientId) {
|
|
10475
|
+
try {
|
|
10476
|
+
const result = await executeCollection("artifacts", "getAll", { limit });
|
|
10477
|
+
sendResponse8(id, {
|
|
10478
|
+
success: true,
|
|
10479
|
+
data: result.data,
|
|
10480
|
+
count: result.count,
|
|
10481
|
+
message: `Retrieved ${result.count} artifacts`
|
|
10482
|
+
}, sendMessage, clientId);
|
|
10483
|
+
logger.info(`Retrieved all artifacts (count: ${result.count})`);
|
|
10484
|
+
} catch (error) {
|
|
10485
|
+
sendResponse8(id, {
|
|
10486
|
+
success: false,
|
|
10487
|
+
error: error instanceof Error ? error.message : "Failed to get artifacts"
|
|
10488
|
+
}, sendMessage, clientId);
|
|
10489
|
+
}
|
|
10490
|
+
}
|
|
10491
|
+
async function handleGetOne6(id, artifactId, executeCollection, sendMessage, clientId) {
|
|
10492
|
+
if (!artifactId) {
|
|
10493
|
+
sendResponse8(id, {
|
|
10494
|
+
success: false,
|
|
10495
|
+
error: "Artifact ID is required"
|
|
10496
|
+
}, sendMessage, clientId);
|
|
10497
|
+
return;
|
|
10498
|
+
}
|
|
10499
|
+
try {
|
|
10500
|
+
const result = await executeCollection("artifacts", "getOne", { id: artifactId });
|
|
10501
|
+
sendResponse8(id, {
|
|
10502
|
+
success: true,
|
|
10503
|
+
data: result.data,
|
|
10504
|
+
message: `Retrieved artifact ID ${artifactId}`
|
|
10505
|
+
}, sendMessage, clientId);
|
|
10506
|
+
logger.info(`Retrieved artifact: ID ${artifactId}`);
|
|
10507
|
+
} catch (error) {
|
|
10508
|
+
sendResponse8(id, {
|
|
10509
|
+
success: false,
|
|
10510
|
+
error: error instanceof Error ? error.message : "Failed to get artifact"
|
|
10511
|
+
}, sendMessage, clientId);
|
|
10512
|
+
}
|
|
10513
|
+
}
|
|
10514
|
+
function sendResponse8(id, res, sendMessage, clientId) {
|
|
10515
|
+
const response = {
|
|
10516
|
+
id: id || "unknown",
|
|
10517
|
+
type: "ARTIFACTS_RES",
|
|
10518
|
+
from: { type: "data-agent" },
|
|
10519
|
+
to: {
|
|
10520
|
+
type: "user",
|
|
10521
|
+
id: clientId
|
|
10522
|
+
},
|
|
10523
|
+
payload: {
|
|
10524
|
+
...res
|
|
10525
|
+
}
|
|
10526
|
+
};
|
|
10527
|
+
sendMessage(response);
|
|
10528
|
+
}
|
|
10529
|
+
|
|
10166
10530
|
// src/handlers/kb-nodes.ts
|
|
10167
10531
|
init_logger();
|
|
10168
10532
|
async function handleKbNodesRequest(data, collections, sendMessage) {
|
|
@@ -10182,6 +10546,7 @@ async function handleKbNodesRequest(data, collections, sendMessage) {
|
|
|
10182
10546
|
const content = requestData?.content;
|
|
10183
10547
|
const category = requestData?.category;
|
|
10184
10548
|
const tags = requestData?.tags;
|
|
10549
|
+
const type = requestData?.type;
|
|
10185
10550
|
const createdBy = requestData?.createdBy;
|
|
10186
10551
|
const updatedBy = requestData?.updatedBy;
|
|
10187
10552
|
const userId = requestData?.userId;
|
|
@@ -10191,22 +10556,22 @@ async function handleKbNodesRequest(data, collections, sendMessage) {
|
|
|
10191
10556
|
const offset = requestData?.offset;
|
|
10192
10557
|
switch (operation) {
|
|
10193
10558
|
case "create":
|
|
10194
|
-
await
|
|
10559
|
+
await handleCreate7(id, { title, content, category, tags, type, createdBy }, executeCollection, sendMessage, from.id);
|
|
10195
10560
|
break;
|
|
10196
10561
|
case "update":
|
|
10197
|
-
await
|
|
10562
|
+
await handleUpdate7(id, nodeId, { title, content, category, tags, type, updatedBy }, executeCollection, sendMessage, from.id);
|
|
10198
10563
|
break;
|
|
10199
10564
|
case "delete":
|
|
10200
|
-
await
|
|
10565
|
+
await handleDelete7(id, nodeId, executeCollection, sendMessage, from.id);
|
|
10201
10566
|
break;
|
|
10202
10567
|
case "getAll":
|
|
10203
|
-
await
|
|
10568
|
+
await handleGetAll7(id, limit, offset, executeCollection, sendMessage, from.id);
|
|
10204
10569
|
break;
|
|
10205
10570
|
case "getOne":
|
|
10206
|
-
await
|
|
10571
|
+
await handleGetOne7(id, nodeId, executeCollection, sendMessage, from.id);
|
|
10207
10572
|
break;
|
|
10208
10573
|
case "search":
|
|
10209
|
-
await handleSearch(id, { query, category, tags, createdBy, limit, offset }, executeCollection, sendMessage, from.id);
|
|
10574
|
+
await handleSearch(id, { query, category, tags, type, createdBy, limit, offset }, executeCollection, sendMessage, from.id);
|
|
10210
10575
|
break;
|
|
10211
10576
|
case "getByCategory":
|
|
10212
10577
|
await handleGetByCategory(id, category, limit, offset, executeCollection, sendMessage, from.id);
|
|
@@ -10221,37 +10586,37 @@ async function handleKbNodesRequest(data, collections, sendMessage) {
|
|
|
10221
10586
|
await handleGetTags(id, executeCollection, sendMessage, from.id);
|
|
10222
10587
|
break;
|
|
10223
10588
|
default:
|
|
10224
|
-
|
|
10589
|
+
sendResponse9(id, {
|
|
10225
10590
|
success: false,
|
|
10226
10591
|
error: `Unknown operation: ${operation}`
|
|
10227
10592
|
}, sendMessage, from.id);
|
|
10228
10593
|
}
|
|
10229
10594
|
} catch (error) {
|
|
10230
10595
|
logger.error("Failed to handle KB nodes request:", error);
|
|
10231
|
-
|
|
10596
|
+
sendResponse9(null, {
|
|
10232
10597
|
success: false,
|
|
10233
10598
|
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
10234
10599
|
}, sendMessage);
|
|
10235
10600
|
}
|
|
10236
10601
|
}
|
|
10237
|
-
async function
|
|
10238
|
-
const { title, content, category, tags, createdBy } = nodeData;
|
|
10602
|
+
async function handleCreate7(id, nodeData, executeCollection, sendMessage, clientId) {
|
|
10603
|
+
const { title, content, category, tags, type, createdBy } = nodeData;
|
|
10239
10604
|
if (!title || title.trim().length === 0) {
|
|
10240
|
-
|
|
10605
|
+
sendResponse9(id, {
|
|
10241
10606
|
success: false,
|
|
10242
10607
|
error: "Title is required and cannot be empty"
|
|
10243
10608
|
}, sendMessage, clientId);
|
|
10244
10609
|
return;
|
|
10245
10610
|
}
|
|
10246
10611
|
if (!content || content.trim().length === 0) {
|
|
10247
|
-
|
|
10612
|
+
sendResponse9(id, {
|
|
10248
10613
|
success: false,
|
|
10249
10614
|
error: "Content is required and cannot be empty"
|
|
10250
10615
|
}, sendMessage, clientId);
|
|
10251
10616
|
return;
|
|
10252
10617
|
}
|
|
10253
10618
|
if (!createdBy) {
|
|
10254
|
-
|
|
10619
|
+
sendResponse9(id, {
|
|
10255
10620
|
success: false,
|
|
10256
10621
|
error: "createdBy (user ID) is required"
|
|
10257
10622
|
}, sendMessage, clientId);
|
|
@@ -10263,11 +10628,12 @@ async function handleCreate6(id, nodeData, executeCollection, sendMessage, clien
|
|
|
10263
10628
|
content,
|
|
10264
10629
|
category: category || void 0,
|
|
10265
10630
|
tags: tags || void 0,
|
|
10631
|
+
type: type || "query",
|
|
10266
10632
|
createdBy
|
|
10267
10633
|
});
|
|
10268
10634
|
if (result && result.success) {
|
|
10269
10635
|
logger.info(`[DB] KB node created successfully: ${title}`);
|
|
10270
|
-
|
|
10636
|
+
sendResponse9(id, {
|
|
10271
10637
|
success: true,
|
|
10272
10638
|
data: {
|
|
10273
10639
|
...result.data,
|
|
@@ -10276,29 +10642,29 @@ async function handleCreate6(id, nodeData, executeCollection, sendMessage, clien
|
|
|
10276
10642
|
}, sendMessage, clientId);
|
|
10277
10643
|
return;
|
|
10278
10644
|
}
|
|
10279
|
-
|
|
10645
|
+
sendResponse9(id, {
|
|
10280
10646
|
success: false,
|
|
10281
10647
|
error: "Failed to create knowledge node"
|
|
10282
10648
|
}, sendMessage, clientId);
|
|
10283
10649
|
} catch (error) {
|
|
10284
10650
|
logger.error("[DB] Failed to create KB node:", error);
|
|
10285
|
-
|
|
10651
|
+
sendResponse9(id, {
|
|
10286
10652
|
success: false,
|
|
10287
10653
|
error: error instanceof Error ? error.message : "Failed to create knowledge node"
|
|
10288
10654
|
}, sendMessage, clientId);
|
|
10289
10655
|
}
|
|
10290
10656
|
}
|
|
10291
|
-
async function
|
|
10292
|
-
const { title, content, category, tags, updatedBy } = nodeData;
|
|
10657
|
+
async function handleUpdate7(id, nodeId, nodeData, executeCollection, sendMessage, clientId) {
|
|
10658
|
+
const { title, content, category, tags, type, updatedBy } = nodeData;
|
|
10293
10659
|
if (!nodeId) {
|
|
10294
|
-
|
|
10660
|
+
sendResponse9(id, {
|
|
10295
10661
|
success: false,
|
|
10296
10662
|
error: "Knowledge node ID is required"
|
|
10297
10663
|
}, sendMessage, clientId);
|
|
10298
10664
|
return;
|
|
10299
10665
|
}
|
|
10300
10666
|
if (!updatedBy) {
|
|
10301
|
-
|
|
10667
|
+
sendResponse9(id, {
|
|
10302
10668
|
success: false,
|
|
10303
10669
|
error: "updatedBy (user ID) is required"
|
|
10304
10670
|
}, sendMessage, clientId);
|
|
@@ -10311,11 +10677,12 @@ async function handleUpdate6(id, nodeId, nodeData, executeCollection, sendMessag
|
|
|
10311
10677
|
content,
|
|
10312
10678
|
category,
|
|
10313
10679
|
tags,
|
|
10680
|
+
type,
|
|
10314
10681
|
updatedBy
|
|
10315
10682
|
});
|
|
10316
10683
|
if (result && result.success) {
|
|
10317
10684
|
logger.info(`[DB] KB node updated successfully, ID: ${nodeId}`);
|
|
10318
|
-
|
|
10685
|
+
sendResponse9(id, {
|
|
10319
10686
|
success: true,
|
|
10320
10687
|
data: {
|
|
10321
10688
|
...result.data,
|
|
@@ -10324,21 +10691,21 @@ async function handleUpdate6(id, nodeId, nodeData, executeCollection, sendMessag
|
|
|
10324
10691
|
}, sendMessage, clientId);
|
|
10325
10692
|
return;
|
|
10326
10693
|
}
|
|
10327
|
-
|
|
10694
|
+
sendResponse9(id, {
|
|
10328
10695
|
success: false,
|
|
10329
10696
|
error: "Failed to update knowledge node"
|
|
10330
10697
|
}, sendMessage, clientId);
|
|
10331
10698
|
} catch (error) {
|
|
10332
10699
|
logger.error("[DB] Failed to update KB node:", error);
|
|
10333
|
-
|
|
10700
|
+
sendResponse9(id, {
|
|
10334
10701
|
success: false,
|
|
10335
10702
|
error: error instanceof Error ? error.message : "Failed to update knowledge node"
|
|
10336
10703
|
}, sendMessage, clientId);
|
|
10337
10704
|
}
|
|
10338
10705
|
}
|
|
10339
|
-
async function
|
|
10706
|
+
async function handleDelete7(id, nodeId, executeCollection, sendMessage, clientId) {
|
|
10340
10707
|
if (!nodeId) {
|
|
10341
|
-
|
|
10708
|
+
sendResponse9(id, {
|
|
10342
10709
|
success: false,
|
|
10343
10710
|
error: "Knowledge node ID is required"
|
|
10344
10711
|
}, sendMessage, clientId);
|
|
@@ -10348,7 +10715,7 @@ async function handleDelete6(id, nodeId, executeCollection, sendMessage, clientI
|
|
|
10348
10715
|
const result = await executeCollection("kbNodes", "delete", { id: nodeId });
|
|
10349
10716
|
if (result && result.success) {
|
|
10350
10717
|
logger.info(`[DB] KB node deleted successfully, ID: ${nodeId}`);
|
|
10351
|
-
|
|
10718
|
+
sendResponse9(id, {
|
|
10352
10719
|
success: true,
|
|
10353
10720
|
data: {
|
|
10354
10721
|
id: nodeId,
|
|
@@ -10358,19 +10725,19 @@ async function handleDelete6(id, nodeId, executeCollection, sendMessage, clientI
|
|
|
10358
10725
|
}, sendMessage, clientId);
|
|
10359
10726
|
return;
|
|
10360
10727
|
}
|
|
10361
|
-
|
|
10728
|
+
sendResponse9(id, {
|
|
10362
10729
|
success: false,
|
|
10363
10730
|
error: "Failed to delete knowledge node"
|
|
10364
10731
|
}, sendMessage, clientId);
|
|
10365
10732
|
} catch (error) {
|
|
10366
10733
|
logger.error("[DB] Failed to delete KB node:", error);
|
|
10367
|
-
|
|
10734
|
+
sendResponse9(id, {
|
|
10368
10735
|
success: false,
|
|
10369
10736
|
error: error instanceof Error ? error.message : "Failed to delete knowledge node"
|
|
10370
10737
|
}, sendMessage, clientId);
|
|
10371
10738
|
}
|
|
10372
10739
|
}
|
|
10373
|
-
async function
|
|
10740
|
+
async function handleGetAll7(id, limit, offset, executeCollection, sendMessage, clientId) {
|
|
10374
10741
|
try {
|
|
10375
10742
|
const result = await executeCollection("kbNodes", "getAll", {
|
|
10376
10743
|
limit: limit || 100,
|
|
@@ -10378,7 +10745,7 @@ async function handleGetAll6(id, limit, offset, executeCollection, sendMessage,
|
|
|
10378
10745
|
});
|
|
10379
10746
|
if (result && result.success) {
|
|
10380
10747
|
logger.info(`[DB] Retrieved ${result.count} KB nodes`);
|
|
10381
|
-
|
|
10748
|
+
sendResponse9(id, {
|
|
10382
10749
|
success: true,
|
|
10383
10750
|
data: {
|
|
10384
10751
|
nodes: result.data,
|
|
@@ -10388,21 +10755,21 @@ async function handleGetAll6(id, limit, offset, executeCollection, sendMessage,
|
|
|
10388
10755
|
}, sendMessage, clientId);
|
|
10389
10756
|
return;
|
|
10390
10757
|
}
|
|
10391
|
-
|
|
10758
|
+
sendResponse9(id, {
|
|
10392
10759
|
success: false,
|
|
10393
10760
|
error: "Failed to retrieve knowledge nodes"
|
|
10394
10761
|
}, sendMessage, clientId);
|
|
10395
10762
|
} catch (error) {
|
|
10396
10763
|
logger.error("[DB] Failed to get all KB nodes:", error);
|
|
10397
|
-
|
|
10764
|
+
sendResponse9(id, {
|
|
10398
10765
|
success: false,
|
|
10399
10766
|
error: error instanceof Error ? error.message : "Failed to retrieve knowledge nodes"
|
|
10400
10767
|
}, sendMessage, clientId);
|
|
10401
10768
|
}
|
|
10402
10769
|
}
|
|
10403
|
-
async function
|
|
10770
|
+
async function handleGetOne7(id, nodeId, executeCollection, sendMessage, clientId) {
|
|
10404
10771
|
if (!nodeId) {
|
|
10405
|
-
|
|
10772
|
+
sendResponse9(id, {
|
|
10406
10773
|
success: false,
|
|
10407
10774
|
error: "Knowledge node ID is required"
|
|
10408
10775
|
}, sendMessage, clientId);
|
|
@@ -10412,7 +10779,7 @@ async function handleGetOne6(id, nodeId, executeCollection, sendMessage, clientI
|
|
|
10412
10779
|
const result = await executeCollection("kbNodes", "getOne", { id: nodeId });
|
|
10413
10780
|
if (result && result.success) {
|
|
10414
10781
|
logger.info(`[DB] Retrieved KB node ID: ${nodeId}`);
|
|
10415
|
-
|
|
10782
|
+
sendResponse9(id, {
|
|
10416
10783
|
success: true,
|
|
10417
10784
|
data: {
|
|
10418
10785
|
node: result.data,
|
|
@@ -10421,32 +10788,33 @@ async function handleGetOne6(id, nodeId, executeCollection, sendMessage, clientI
|
|
|
10421
10788
|
}, sendMessage, clientId);
|
|
10422
10789
|
return;
|
|
10423
10790
|
}
|
|
10424
|
-
|
|
10791
|
+
sendResponse9(id, {
|
|
10425
10792
|
success: false,
|
|
10426
10793
|
error: "Failed to retrieve knowledge node"
|
|
10427
10794
|
}, sendMessage, clientId);
|
|
10428
10795
|
} catch (error) {
|
|
10429
10796
|
logger.error("[DB] Failed to get KB node:", error);
|
|
10430
|
-
|
|
10797
|
+
sendResponse9(id, {
|
|
10431
10798
|
success: false,
|
|
10432
10799
|
error: error instanceof Error ? error.message : "Failed to retrieve knowledge node"
|
|
10433
10800
|
}, sendMessage, clientId);
|
|
10434
10801
|
}
|
|
10435
10802
|
}
|
|
10436
10803
|
async function handleSearch(id, searchParams, executeCollection, sendMessage, clientId) {
|
|
10437
|
-
const { query, category, tags, createdBy, limit, offset } = searchParams;
|
|
10804
|
+
const { query, category, tags, type, createdBy, limit, offset } = searchParams;
|
|
10438
10805
|
try {
|
|
10439
10806
|
const result = await executeCollection("kbNodes", "search", {
|
|
10440
10807
|
query,
|
|
10441
10808
|
category,
|
|
10442
10809
|
tags,
|
|
10810
|
+
type,
|
|
10443
10811
|
createdBy,
|
|
10444
10812
|
limit: limit || 50,
|
|
10445
10813
|
offset: offset || 0
|
|
10446
10814
|
});
|
|
10447
10815
|
if (result && result.success) {
|
|
10448
10816
|
logger.info(`[DB] Search returned ${result.count} KB nodes`);
|
|
10449
|
-
|
|
10817
|
+
sendResponse9(id, {
|
|
10450
10818
|
success: true,
|
|
10451
10819
|
data: {
|
|
10452
10820
|
nodes: result.data,
|
|
@@ -10456,13 +10824,13 @@ async function handleSearch(id, searchParams, executeCollection, sendMessage, cl
|
|
|
10456
10824
|
}, sendMessage, clientId);
|
|
10457
10825
|
return;
|
|
10458
10826
|
}
|
|
10459
|
-
|
|
10827
|
+
sendResponse9(id, {
|
|
10460
10828
|
success: false,
|
|
10461
10829
|
error: "Failed to search knowledge nodes"
|
|
10462
10830
|
}, sendMessage, clientId);
|
|
10463
10831
|
} catch (error) {
|
|
10464
10832
|
logger.error("[DB] Failed to search KB nodes:", error);
|
|
10465
|
-
|
|
10833
|
+
sendResponse9(id, {
|
|
10466
10834
|
success: false,
|
|
10467
10835
|
error: error instanceof Error ? error.message : "Failed to search knowledge nodes"
|
|
10468
10836
|
}, sendMessage, clientId);
|
|
@@ -10470,7 +10838,7 @@ async function handleSearch(id, searchParams, executeCollection, sendMessage, cl
|
|
|
10470
10838
|
}
|
|
10471
10839
|
async function handleGetByCategory(id, category, limit, offset, executeCollection, sendMessage, clientId) {
|
|
10472
10840
|
if (!category) {
|
|
10473
|
-
|
|
10841
|
+
sendResponse9(id, {
|
|
10474
10842
|
success: false,
|
|
10475
10843
|
error: "Category is required"
|
|
10476
10844
|
}, sendMessage, clientId);
|
|
@@ -10484,7 +10852,7 @@ async function handleGetByCategory(id, category, limit, offset, executeCollectio
|
|
|
10484
10852
|
});
|
|
10485
10853
|
if (result && result.success) {
|
|
10486
10854
|
logger.info(`[DB] Retrieved ${result.count} KB nodes for category: ${category}`);
|
|
10487
|
-
|
|
10855
|
+
sendResponse9(id, {
|
|
10488
10856
|
success: true,
|
|
10489
10857
|
data: {
|
|
10490
10858
|
nodes: result.data,
|
|
@@ -10495,13 +10863,13 @@ async function handleGetByCategory(id, category, limit, offset, executeCollectio
|
|
|
10495
10863
|
}, sendMessage, clientId);
|
|
10496
10864
|
return;
|
|
10497
10865
|
}
|
|
10498
|
-
|
|
10866
|
+
sendResponse9(id, {
|
|
10499
10867
|
success: false,
|
|
10500
10868
|
error: "Failed to retrieve knowledge nodes by category"
|
|
10501
10869
|
}, sendMessage, clientId);
|
|
10502
10870
|
} catch (error) {
|
|
10503
10871
|
logger.error("[DB] Failed to get KB nodes by category:", error);
|
|
10504
|
-
|
|
10872
|
+
sendResponse9(id, {
|
|
10505
10873
|
success: false,
|
|
10506
10874
|
error: error instanceof Error ? error.message : "Failed to retrieve knowledge nodes by category"
|
|
10507
10875
|
}, sendMessage, clientId);
|
|
@@ -10509,7 +10877,7 @@ async function handleGetByCategory(id, category, limit, offset, executeCollectio
|
|
|
10509
10877
|
}
|
|
10510
10878
|
async function handleGetByUser(id, userId, limit, offset, executeCollection, sendMessage, clientId) {
|
|
10511
10879
|
if (!userId) {
|
|
10512
|
-
|
|
10880
|
+
sendResponse9(id, {
|
|
10513
10881
|
success: false,
|
|
10514
10882
|
error: "User ID is required"
|
|
10515
10883
|
}, sendMessage, clientId);
|
|
@@ -10523,7 +10891,7 @@ async function handleGetByUser(id, userId, limit, offset, executeCollection, sen
|
|
|
10523
10891
|
});
|
|
10524
10892
|
if (result && result.success) {
|
|
10525
10893
|
logger.info(`[DB] Retrieved ${result.count} KB nodes for user: ${userId}`);
|
|
10526
|
-
|
|
10894
|
+
sendResponse9(id, {
|
|
10527
10895
|
success: true,
|
|
10528
10896
|
data: {
|
|
10529
10897
|
nodes: result.data,
|
|
@@ -10534,13 +10902,13 @@ async function handleGetByUser(id, userId, limit, offset, executeCollection, sen
|
|
|
10534
10902
|
}, sendMessage, clientId);
|
|
10535
10903
|
return;
|
|
10536
10904
|
}
|
|
10537
|
-
|
|
10905
|
+
sendResponse9(id, {
|
|
10538
10906
|
success: false,
|
|
10539
10907
|
error: "Failed to retrieve knowledge nodes by user"
|
|
10540
10908
|
}, sendMessage, clientId);
|
|
10541
10909
|
} catch (error) {
|
|
10542
10910
|
logger.error("[DB] Failed to get KB nodes by user:", error);
|
|
10543
|
-
|
|
10911
|
+
sendResponse9(id, {
|
|
10544
10912
|
success: false,
|
|
10545
10913
|
error: error instanceof Error ? error.message : "Failed to retrieve knowledge nodes by user"
|
|
10546
10914
|
}, sendMessage, clientId);
|
|
@@ -10551,7 +10919,7 @@ async function handleGetCategories(id, executeCollection, sendMessage, clientId)
|
|
|
10551
10919
|
const result = await executeCollection("kbNodes", "getCategories", {});
|
|
10552
10920
|
if (result && result.success) {
|
|
10553
10921
|
logger.info(`[DB] Retrieved ${result.count} categories`);
|
|
10554
|
-
|
|
10922
|
+
sendResponse9(id, {
|
|
10555
10923
|
success: true,
|
|
10556
10924
|
data: {
|
|
10557
10925
|
categories: result.data,
|
|
@@ -10561,13 +10929,13 @@ async function handleGetCategories(id, executeCollection, sendMessage, clientId)
|
|
|
10561
10929
|
}, sendMessage, clientId);
|
|
10562
10930
|
return;
|
|
10563
10931
|
}
|
|
10564
|
-
|
|
10932
|
+
sendResponse9(id, {
|
|
10565
10933
|
success: false,
|
|
10566
10934
|
error: "Failed to retrieve categories"
|
|
10567
10935
|
}, sendMessage, clientId);
|
|
10568
10936
|
} catch (error) {
|
|
10569
10937
|
logger.error("[DB] Failed to get categories:", error);
|
|
10570
|
-
|
|
10938
|
+
sendResponse9(id, {
|
|
10571
10939
|
success: false,
|
|
10572
10940
|
error: error instanceof Error ? error.message : "Failed to retrieve categories"
|
|
10573
10941
|
}, sendMessage, clientId);
|
|
@@ -10578,7 +10946,7 @@ async function handleGetTags(id, executeCollection, sendMessage, clientId) {
|
|
|
10578
10946
|
const result = await executeCollection("kbNodes", "getTags", {});
|
|
10579
10947
|
if (result && result.success) {
|
|
10580
10948
|
logger.info(`[DB] Retrieved ${result.count} tags`);
|
|
10581
|
-
|
|
10949
|
+
sendResponse9(id, {
|
|
10582
10950
|
success: true,
|
|
10583
10951
|
data: {
|
|
10584
10952
|
tags: result.data,
|
|
@@ -10588,19 +10956,19 @@ async function handleGetTags(id, executeCollection, sendMessage, clientId) {
|
|
|
10588
10956
|
}, sendMessage, clientId);
|
|
10589
10957
|
return;
|
|
10590
10958
|
}
|
|
10591
|
-
|
|
10959
|
+
sendResponse9(id, {
|
|
10592
10960
|
success: false,
|
|
10593
10961
|
error: "Failed to retrieve tags"
|
|
10594
10962
|
}, sendMessage, clientId);
|
|
10595
10963
|
} catch (error) {
|
|
10596
10964
|
logger.error("[DB] Failed to get tags:", error);
|
|
10597
|
-
|
|
10965
|
+
sendResponse9(id, {
|
|
10598
10966
|
success: false,
|
|
10599
10967
|
error: error instanceof Error ? error.message : "Failed to retrieve tags"
|
|
10600
10968
|
}, sendMessage, clientId);
|
|
10601
10969
|
}
|
|
10602
10970
|
}
|
|
10603
|
-
function
|
|
10971
|
+
function sendResponse9(id, res, sendMessage, clientId) {
|
|
10604
10972
|
const response = {
|
|
10605
10973
|
id: id || "unknown",
|
|
10606
10974
|
type: "KB_NODES_RES",
|
|
@@ -10645,19 +11013,19 @@ async function handleMenusRequest(data, collections, sendMessage) {
|
|
|
10645
11013
|
const items = requestData?.items;
|
|
10646
11014
|
switch (operation) {
|
|
10647
11015
|
case "create":
|
|
10648
|
-
await
|
|
11016
|
+
await handleCreate8(id, name, componentName, icon, userMessage, parentId, sortOrder, props, isActive, executeCollection, sendMessage, from.id);
|
|
10649
11017
|
break;
|
|
10650
11018
|
case "update":
|
|
10651
|
-
await
|
|
11019
|
+
await handleUpdate8(id, menuId, name, componentName, icon, userMessage, parentId, sortOrder, props, isActive, executeCollection, sendMessage, from.id);
|
|
10652
11020
|
break;
|
|
10653
11021
|
case "delete":
|
|
10654
|
-
await
|
|
11022
|
+
await handleDelete8(id, menuId, executeCollection, sendMessage, from.id);
|
|
10655
11023
|
break;
|
|
10656
11024
|
case "getAll":
|
|
10657
|
-
await
|
|
11025
|
+
await handleGetAll8(id, executeCollection, sendMessage, from.id);
|
|
10658
11026
|
break;
|
|
10659
11027
|
case "getOne":
|
|
10660
|
-
await
|
|
11028
|
+
await handleGetOne8(id, menuId, executeCollection, sendMessage, from.id);
|
|
10661
11029
|
break;
|
|
10662
11030
|
case "getRootMenus":
|
|
10663
11031
|
await handleGetRootMenus(id, executeCollection, sendMessage, from.id);
|
|
@@ -10675,29 +11043,29 @@ async function handleMenusRequest(data, collections, sendMessage) {
|
|
|
10675
11043
|
await handleReorder(id, items, executeCollection, sendMessage, from.id);
|
|
10676
11044
|
break;
|
|
10677
11045
|
default:
|
|
10678
|
-
|
|
11046
|
+
sendResponse10(id, {
|
|
10679
11047
|
success: false,
|
|
10680
11048
|
error: `Unknown operation: ${operation}`
|
|
10681
11049
|
}, sendMessage, from.id);
|
|
10682
11050
|
}
|
|
10683
11051
|
} catch (error) {
|
|
10684
11052
|
logger.error("Failed to handle menus request:", error);
|
|
10685
|
-
|
|
11053
|
+
sendResponse10(null, {
|
|
10686
11054
|
success: false,
|
|
10687
11055
|
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
10688
11056
|
}, sendMessage);
|
|
10689
11057
|
}
|
|
10690
11058
|
}
|
|
10691
|
-
async function
|
|
11059
|
+
async function handleCreate8(id, name, componentName, icon, userMessage, parentId, sortOrder, props, isActive, executeCollection, sendMessage, clientId) {
|
|
10692
11060
|
if (!name) {
|
|
10693
|
-
|
|
11061
|
+
sendResponse10(id, {
|
|
10694
11062
|
success: false,
|
|
10695
11063
|
error: "name is required"
|
|
10696
11064
|
}, sendMessage, clientId);
|
|
10697
11065
|
return;
|
|
10698
11066
|
}
|
|
10699
11067
|
if (!componentName) {
|
|
10700
|
-
|
|
11068
|
+
sendResponse10(id, {
|
|
10701
11069
|
success: false,
|
|
10702
11070
|
error: "componentName is required"
|
|
10703
11071
|
}, sendMessage, clientId);
|
|
@@ -10714,22 +11082,22 @@ async function handleCreate7(id, name, componentName, icon, userMessage, parentI
|
|
|
10714
11082
|
props,
|
|
10715
11083
|
isActive
|
|
10716
11084
|
});
|
|
10717
|
-
|
|
11085
|
+
sendResponse10(id, {
|
|
10718
11086
|
success: true,
|
|
10719
11087
|
data: result.data,
|
|
10720
11088
|
message: "Menu created successfully"
|
|
10721
11089
|
}, sendMessage, clientId);
|
|
10722
11090
|
logger.info(`Menu created: ID ${result.data?.id}`);
|
|
10723
11091
|
} catch (error) {
|
|
10724
|
-
|
|
11092
|
+
sendResponse10(id, {
|
|
10725
11093
|
success: false,
|
|
10726
11094
|
error: error instanceof Error ? error.message : "Failed to create menu"
|
|
10727
11095
|
}, sendMessage, clientId);
|
|
10728
11096
|
}
|
|
10729
11097
|
}
|
|
10730
|
-
async function
|
|
11098
|
+
async function handleUpdate8(id, menuId, name, componentName, icon, userMessage, parentId, sortOrder, props, isActive, executeCollection, sendMessage, clientId) {
|
|
10731
11099
|
if (!menuId) {
|
|
10732
|
-
|
|
11100
|
+
sendResponse10(id, {
|
|
10733
11101
|
success: false,
|
|
10734
11102
|
error: "Menu ID is required"
|
|
10735
11103
|
}, sendMessage, clientId);
|
|
@@ -10747,22 +11115,22 @@ async function handleUpdate7(id, menuId, name, componentName, icon, userMessage,
|
|
|
10747
11115
|
props,
|
|
10748
11116
|
isActive
|
|
10749
11117
|
});
|
|
10750
|
-
|
|
11118
|
+
sendResponse10(id, {
|
|
10751
11119
|
success: true,
|
|
10752
11120
|
data: result.data,
|
|
10753
11121
|
message: "Menu updated successfully"
|
|
10754
11122
|
}, sendMessage, clientId);
|
|
10755
11123
|
logger.info(`Menu updated: ID ${menuId}`);
|
|
10756
11124
|
} catch (error) {
|
|
10757
|
-
|
|
11125
|
+
sendResponse10(id, {
|
|
10758
11126
|
success: false,
|
|
10759
11127
|
error: error instanceof Error ? error.message : "Failed to update menu"
|
|
10760
11128
|
}, sendMessage, clientId);
|
|
10761
11129
|
}
|
|
10762
11130
|
}
|
|
10763
|
-
async function
|
|
11131
|
+
async function handleDelete8(id, menuId, executeCollection, sendMessage, clientId) {
|
|
10764
11132
|
if (!menuId) {
|
|
10765
|
-
|
|
11133
|
+
sendResponse10(id, {
|
|
10766
11134
|
success: false,
|
|
10767
11135
|
error: "Menu ID is required"
|
|
10768
11136
|
}, sendMessage, clientId);
|
|
@@ -10770,23 +11138,23 @@ async function handleDelete7(id, menuId, executeCollection, sendMessage, clientI
|
|
|
10770
11138
|
}
|
|
10771
11139
|
try {
|
|
10772
11140
|
const result = await executeCollection("menus", "delete", { id: menuId });
|
|
10773
|
-
|
|
11141
|
+
sendResponse10(id, {
|
|
10774
11142
|
success: true,
|
|
10775
11143
|
data: result.data,
|
|
10776
11144
|
message: "Menu deleted successfully"
|
|
10777
11145
|
}, sendMessage, clientId);
|
|
10778
11146
|
logger.info(`Menu deleted: ID ${menuId}`);
|
|
10779
11147
|
} catch (error) {
|
|
10780
|
-
|
|
11148
|
+
sendResponse10(id, {
|
|
10781
11149
|
success: false,
|
|
10782
11150
|
error: error instanceof Error ? error.message : "Failed to delete menu"
|
|
10783
11151
|
}, sendMessage, clientId);
|
|
10784
11152
|
}
|
|
10785
11153
|
}
|
|
10786
|
-
async function
|
|
11154
|
+
async function handleGetAll8(id, executeCollection, sendMessage, clientId) {
|
|
10787
11155
|
try {
|
|
10788
11156
|
const result = await executeCollection("menus", "getAll", {});
|
|
10789
|
-
|
|
11157
|
+
sendResponse10(id, {
|
|
10790
11158
|
success: true,
|
|
10791
11159
|
data: result.data,
|
|
10792
11160
|
count: result.count,
|
|
@@ -10794,15 +11162,15 @@ async function handleGetAll7(id, executeCollection, sendMessage, clientId) {
|
|
|
10794
11162
|
}, sendMessage, clientId);
|
|
10795
11163
|
logger.info(`Retrieved all menus (count: ${result.count})`);
|
|
10796
11164
|
} catch (error) {
|
|
10797
|
-
|
|
11165
|
+
sendResponse10(id, {
|
|
10798
11166
|
success: false,
|
|
10799
11167
|
error: error instanceof Error ? error.message : "Failed to get menus"
|
|
10800
11168
|
}, sendMessage, clientId);
|
|
10801
11169
|
}
|
|
10802
11170
|
}
|
|
10803
|
-
async function
|
|
11171
|
+
async function handleGetOne8(id, menuId, executeCollection, sendMessage, clientId) {
|
|
10804
11172
|
if (!menuId) {
|
|
10805
|
-
|
|
11173
|
+
sendResponse10(id, {
|
|
10806
11174
|
success: false,
|
|
10807
11175
|
error: "Menu ID is required"
|
|
10808
11176
|
}, sendMessage, clientId);
|
|
@@ -10810,14 +11178,14 @@ async function handleGetOne7(id, menuId, executeCollection, sendMessage, clientI
|
|
|
10810
11178
|
}
|
|
10811
11179
|
try {
|
|
10812
11180
|
const result = await executeCollection("menus", "getOne", { id: menuId });
|
|
10813
|
-
|
|
11181
|
+
sendResponse10(id, {
|
|
10814
11182
|
success: true,
|
|
10815
11183
|
data: result.data,
|
|
10816
11184
|
message: `Retrieved menu ID ${menuId}`
|
|
10817
11185
|
}, sendMessage, clientId);
|
|
10818
11186
|
logger.info(`Retrieved menu: ID ${menuId}`);
|
|
10819
11187
|
} catch (error) {
|
|
10820
|
-
|
|
11188
|
+
sendResponse10(id, {
|
|
10821
11189
|
success: false,
|
|
10822
11190
|
error: error instanceof Error ? error.message : "Failed to get menu"
|
|
10823
11191
|
}, sendMessage, clientId);
|
|
@@ -10826,7 +11194,7 @@ async function handleGetOne7(id, menuId, executeCollection, sendMessage, clientI
|
|
|
10826
11194
|
async function handleGetRootMenus(id, executeCollection, sendMessage, clientId) {
|
|
10827
11195
|
try {
|
|
10828
11196
|
const result = await executeCollection("menus", "getRootMenus", {});
|
|
10829
|
-
|
|
11197
|
+
sendResponse10(id, {
|
|
10830
11198
|
success: true,
|
|
10831
11199
|
data: result.data,
|
|
10832
11200
|
count: result.count,
|
|
@@ -10834,7 +11202,7 @@ async function handleGetRootMenus(id, executeCollection, sendMessage, clientId)
|
|
|
10834
11202
|
}, sendMessage, clientId);
|
|
10835
11203
|
logger.info(`Retrieved root menus (count: ${result.count})`);
|
|
10836
11204
|
} catch (error) {
|
|
10837
|
-
|
|
11205
|
+
sendResponse10(id, {
|
|
10838
11206
|
success: false,
|
|
10839
11207
|
error: error instanceof Error ? error.message : "Failed to get root menus"
|
|
10840
11208
|
}, sendMessage, clientId);
|
|
@@ -10842,7 +11210,7 @@ async function handleGetRootMenus(id, executeCollection, sendMessage, clientId)
|
|
|
10842
11210
|
}
|
|
10843
11211
|
async function handleGetChildMenus(id, parentId, executeCollection, sendMessage, clientId) {
|
|
10844
11212
|
if (parentId === void 0 || parentId === null) {
|
|
10845
|
-
|
|
11213
|
+
sendResponse10(id, {
|
|
10846
11214
|
success: false,
|
|
10847
11215
|
error: "parentId is required"
|
|
10848
11216
|
}, sendMessage, clientId);
|
|
@@ -10850,7 +11218,7 @@ async function handleGetChildMenus(id, parentId, executeCollection, sendMessage,
|
|
|
10850
11218
|
}
|
|
10851
11219
|
try {
|
|
10852
11220
|
const result = await executeCollection("menus", "getChildMenus", { parentId });
|
|
10853
|
-
|
|
11221
|
+
sendResponse10(id, {
|
|
10854
11222
|
success: true,
|
|
10855
11223
|
data: result.data,
|
|
10856
11224
|
count: result.count,
|
|
@@ -10858,7 +11226,7 @@ async function handleGetChildMenus(id, parentId, executeCollection, sendMessage,
|
|
|
10858
11226
|
}, sendMessage, clientId);
|
|
10859
11227
|
logger.info(`Retrieved child menus for parent ${parentId} (count: ${result.count})`);
|
|
10860
11228
|
} catch (error) {
|
|
10861
|
-
|
|
11229
|
+
sendResponse10(id, {
|
|
10862
11230
|
success: false,
|
|
10863
11231
|
error: error instanceof Error ? error.message : "Failed to get child menus"
|
|
10864
11232
|
}, sendMessage, clientId);
|
|
@@ -10867,7 +11235,7 @@ async function handleGetChildMenus(id, parentId, executeCollection, sendMessage,
|
|
|
10867
11235
|
async function handleGetHierarchy(id, executeCollection, sendMessage, clientId) {
|
|
10868
11236
|
try {
|
|
10869
11237
|
const result = await executeCollection("menus", "getHierarchy", {});
|
|
10870
|
-
|
|
11238
|
+
sendResponse10(id, {
|
|
10871
11239
|
success: true,
|
|
10872
11240
|
data: result.data,
|
|
10873
11241
|
count: result.count,
|
|
@@ -10875,7 +11243,7 @@ async function handleGetHierarchy(id, executeCollection, sendMessage, clientId)
|
|
|
10875
11243
|
}, sendMessage, clientId);
|
|
10876
11244
|
logger.info(`Retrieved menus hierarchy (root count: ${result.count})`);
|
|
10877
11245
|
} catch (error) {
|
|
10878
|
-
|
|
11246
|
+
sendResponse10(id, {
|
|
10879
11247
|
success: false,
|
|
10880
11248
|
error: error instanceof Error ? error.message : "Failed to get menus hierarchy"
|
|
10881
11249
|
}, sendMessage, clientId);
|
|
@@ -10888,7 +11256,7 @@ async function handleQuery6(id, filters, limit, sort, executeCollection, sendMes
|
|
|
10888
11256
|
limit,
|
|
10889
11257
|
sort
|
|
10890
11258
|
});
|
|
10891
|
-
|
|
11259
|
+
sendResponse10(id, {
|
|
10892
11260
|
success: true,
|
|
10893
11261
|
data: result.data,
|
|
10894
11262
|
count: result.count,
|
|
@@ -10896,7 +11264,7 @@ async function handleQuery6(id, filters, limit, sort, executeCollection, sendMes
|
|
|
10896
11264
|
}, sendMessage, clientId);
|
|
10897
11265
|
logger.info(`Query returned ${result.count} menus`);
|
|
10898
11266
|
} catch (error) {
|
|
10899
|
-
|
|
11267
|
+
sendResponse10(id, {
|
|
10900
11268
|
success: false,
|
|
10901
11269
|
error: error instanceof Error ? error.message : "Failed to query menus"
|
|
10902
11270
|
}, sendMessage, clientId);
|
|
@@ -10904,7 +11272,7 @@ async function handleQuery6(id, filters, limit, sort, executeCollection, sendMes
|
|
|
10904
11272
|
}
|
|
10905
11273
|
async function handleReorder(id, items, executeCollection, sendMessage, clientId) {
|
|
10906
11274
|
if (!items || !Array.isArray(items) || items.length === 0) {
|
|
10907
|
-
|
|
11275
|
+
sendResponse10(id, {
|
|
10908
11276
|
success: false,
|
|
10909
11277
|
error: "items array is required"
|
|
10910
11278
|
}, sendMessage, clientId);
|
|
@@ -10912,20 +11280,20 @@ async function handleReorder(id, items, executeCollection, sendMessage, clientId
|
|
|
10912
11280
|
}
|
|
10913
11281
|
try {
|
|
10914
11282
|
const result = await executeCollection("menus", "reorder", { items });
|
|
10915
|
-
|
|
11283
|
+
sendResponse10(id, {
|
|
10916
11284
|
success: true,
|
|
10917
11285
|
data: result.data,
|
|
10918
11286
|
message: `Reordered ${items.length} menus successfully`
|
|
10919
11287
|
}, sendMessage, clientId);
|
|
10920
11288
|
logger.info(`Reordered ${items.length} menus`);
|
|
10921
11289
|
} catch (error) {
|
|
10922
|
-
|
|
11290
|
+
sendResponse10(id, {
|
|
10923
11291
|
success: false,
|
|
10924
11292
|
error: error instanceof Error ? error.message : "Failed to reorder menus"
|
|
10925
11293
|
}, sendMessage, clientId);
|
|
10926
11294
|
}
|
|
10927
11295
|
}
|
|
10928
|
-
function
|
|
11296
|
+
function sendResponse10(id, res, sendMessage, clientId) {
|
|
10929
11297
|
const response = {
|
|
10930
11298
|
id: id || "unknown",
|
|
10931
11299
|
type: "MENUS_RES",
|
|
@@ -12457,6 +12825,11 @@ var SuperatomSDK = class {
|
|
|
12457
12825
|
logger.error("Failed to handle bookmarks request:", error);
|
|
12458
12826
|
});
|
|
12459
12827
|
break;
|
|
12828
|
+
case "ARTIFACTS":
|
|
12829
|
+
handleArtifactsRequest(parsed, this.collections, (msg) => this.send(msg)).catch((error) => {
|
|
12830
|
+
logger.error("Failed to handle artifacts request:", error);
|
|
12831
|
+
});
|
|
12832
|
+
break;
|
|
12460
12833
|
case "KB_NODES":
|
|
12461
12834
|
handleKbNodesRequest(parsed, this.collections, (msg) => this.send(msg)).catch((error) => {
|
|
12462
12835
|
logger.error("Failed to handle KB nodes request:", error);
|