@superatomai/sdk-node 0.0.56 → 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 +452 -111
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +452 -111
- 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,26 +6611,48 @@ ${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));
|
|
6501
6645
|
const withProgressHeartbeat = async (operation, progressMessage, intervalMs = 1e3) => {
|
|
6502
6646
|
if (!wrappedStreamCallback) {
|
|
6503
6647
|
return operation();
|
|
6504
6648
|
}
|
|
6505
6649
|
const startTime = Date.now();
|
|
6506
|
-
|
|
6507
|
-
const maxDots = 3;
|
|
6650
|
+
await streamDelay(30);
|
|
6508
6651
|
wrappedStreamCallback(`\u23F3 ${progressMessage}`);
|
|
6509
6652
|
const heartbeatInterval = setInterval(() => {
|
|
6510
6653
|
const elapsedSeconds = Math.floor((Date.now() - startTime) / 1e3);
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
if (elapsedSeconds >= 2) {
|
|
6514
|
-
wrappedStreamCallback(`${dots} (${elapsedSeconds}s)`);
|
|
6515
|
-
} else {
|
|
6516
|
-
wrappedStreamCallback(dots);
|
|
6654
|
+
if (elapsedSeconds >= 1) {
|
|
6655
|
+
wrappedStreamCallback(` (${elapsedSeconds}s)`);
|
|
6517
6656
|
}
|
|
6518
6657
|
}, intervalMs);
|
|
6519
6658
|
try {
|
|
@@ -6558,6 +6697,7 @@ Please try rephrasing your question or simplifying your request.
|
|
|
6558
6697
|
throw new Error(errorMsg);
|
|
6559
6698
|
}
|
|
6560
6699
|
try {
|
|
6700
|
+
flushStream();
|
|
6561
6701
|
if (wrappedStreamCallback) {
|
|
6562
6702
|
const paramsDisplay = Object.keys(params).length > 0 ? `
|
|
6563
6703
|
**Parameters:** ${JSON.stringify(params)}` : "";
|
|
@@ -6567,10 +6707,12 @@ Please try rephrasing your question or simplifying your request.
|
|
|
6567
6707
|
\u{1F50D} **Analyzing your question...**
|
|
6568
6708
|
|
|
6569
6709
|
`);
|
|
6710
|
+
await streamDelay(50);
|
|
6570
6711
|
if (reasoning) {
|
|
6571
6712
|
wrappedStreamCallback(`\u{1F4AD} ${reasoning}
|
|
6572
6713
|
|
|
6573
6714
|
`);
|
|
6715
|
+
await streamDelay(50);
|
|
6574
6716
|
}
|
|
6575
6717
|
wrappedStreamCallback(`\u{1F4DD} **Generated SQL Query:**
|
|
6576
6718
|
\`\`\`sql
|
|
@@ -6578,16 +6720,19 @@ ${sql}
|
|
|
6578
6720
|
\`\`\`${paramsDisplay}
|
|
6579
6721
|
|
|
6580
6722
|
`);
|
|
6723
|
+
await streamDelay(50);
|
|
6581
6724
|
} else {
|
|
6582
6725
|
wrappedStreamCallback(`
|
|
6583
6726
|
|
|
6584
6727
|
\u{1F504} **Retrying with corrected query (attempt ${attempts}/${MAX_QUERY_ATTEMPTS})...**
|
|
6585
6728
|
|
|
6586
6729
|
`);
|
|
6730
|
+
await streamDelay(50);
|
|
6587
6731
|
if (reasoning) {
|
|
6588
6732
|
wrappedStreamCallback(`\u{1F4AD} ${reasoning}
|
|
6589
6733
|
|
|
6590
6734
|
`);
|
|
6735
|
+
await streamDelay(50);
|
|
6591
6736
|
}
|
|
6592
6737
|
wrappedStreamCallback(`\u{1F4DD} **Corrected SQL Query:**
|
|
6593
6738
|
\`\`\`sql
|
|
@@ -6595,6 +6740,7 @@ ${sql}
|
|
|
6595
6740
|
\`\`\`${paramsDisplay}
|
|
6596
6741
|
|
|
6597
6742
|
`);
|
|
6743
|
+
await streamDelay(50);
|
|
6598
6744
|
}
|
|
6599
6745
|
}
|
|
6600
6746
|
logCollector?.logQuery(
|
|
@@ -6621,6 +6767,7 @@ ${sql}
|
|
|
6621
6767
|
\u2705 **Query executed successfully!**
|
|
6622
6768
|
|
|
6623
6769
|
`);
|
|
6770
|
+
await streamDelay(50);
|
|
6624
6771
|
if (Array.isArray(data) && data.length > 0) {
|
|
6625
6772
|
const firstRow = data[0];
|
|
6626
6773
|
const columns = Object.keys(firstRow);
|
|
@@ -6629,18 +6776,22 @@ ${sql}
|
|
|
6629
6776
|
wrappedStreamCallback(`**Result:** ${value}
|
|
6630
6777
|
|
|
6631
6778
|
`);
|
|
6779
|
+
await streamDelay(50);
|
|
6632
6780
|
} else if (data.length > 0) {
|
|
6633
6781
|
wrappedStreamCallback(`**Retrieved ${rowCount} rows**
|
|
6634
6782
|
|
|
6635
6783
|
`);
|
|
6784
|
+
await streamDelay(50);
|
|
6636
6785
|
wrappedStreamCallback(`<DataTable>${JSON.stringify(data)}</DataTable>
|
|
6637
6786
|
|
|
6638
6787
|
`);
|
|
6788
|
+
await streamDelay(50);
|
|
6639
6789
|
}
|
|
6640
6790
|
} else if (Array.isArray(data) && data.length === 0) {
|
|
6641
6791
|
wrappedStreamCallback(`**No rows returned.**
|
|
6642
6792
|
|
|
6643
6793
|
`);
|
|
6794
|
+
await streamDelay(50);
|
|
6644
6795
|
}
|
|
6645
6796
|
wrappedStreamCallback(`\u{1F4CA} **Analyzing results...**
|
|
6646
6797
|
|
|
@@ -6690,6 +6841,7 @@ Please try rephrasing your request or contact support.
|
|
|
6690
6841
|
throw new Error(errorMsg);
|
|
6691
6842
|
}
|
|
6692
6843
|
try {
|
|
6844
|
+
flushStream();
|
|
6693
6845
|
if (wrappedStreamCallback) {
|
|
6694
6846
|
if (attempts === 1) {
|
|
6695
6847
|
wrappedStreamCallback(`
|
|
@@ -6704,6 +6856,7 @@ Please try rephrasing your request or contact support.
|
|
|
6704
6856
|
|
|
6705
6857
|
`);
|
|
6706
6858
|
}
|
|
6859
|
+
await streamDelay(50);
|
|
6707
6860
|
}
|
|
6708
6861
|
const result2 = await withProgressHeartbeat(
|
|
6709
6862
|
() => externalTool.fn(toolInput),
|
|
@@ -6743,6 +6896,7 @@ Please try rephrasing your request or contact support.
|
|
|
6743
6896
|
wrappedStreamCallback(`\u2705 **${externalTool.name} completed successfully**
|
|
6744
6897
|
|
|
6745
6898
|
`);
|
|
6899
|
+
await streamDelay(50);
|
|
6746
6900
|
}
|
|
6747
6901
|
return JSON.stringify(result2, null, 2);
|
|
6748
6902
|
} catch (error) {
|
|
@@ -6811,6 +6965,7 @@ ${errorMsg}
|
|
|
6811
6965
|
textLength: textResponse.length
|
|
6812
6966
|
}
|
|
6813
6967
|
);
|
|
6968
|
+
flushStream();
|
|
6814
6969
|
if (wrappedStreamCallback && components && components.length > 0 && category !== "general") {
|
|
6815
6970
|
wrappedStreamCallback("\n\n\u{1F4CA} **Generating visualization components...**\n\n");
|
|
6816
6971
|
wrappedStreamCallback("__TEXT_COMPLETE__COMPONENT_GENERATION_START__");
|
|
@@ -7122,7 +7277,8 @@ ${errorMsg}
|
|
|
7122
7277
|
collections,
|
|
7123
7278
|
components,
|
|
7124
7279
|
toolsToUse,
|
|
7125
|
-
categoryClassification.category
|
|
7280
|
+
categoryClassification.category,
|
|
7281
|
+
userId
|
|
7126
7282
|
);
|
|
7127
7283
|
const elapsedTime = Date.now() - startTime;
|
|
7128
7284
|
logger.info(`[${this.getProviderName()}] Total time taken: ${elapsedTime}ms (${(elapsedTime / 1e3).toFixed(2)}s)`);
|
|
@@ -10195,6 +10351,182 @@ function sendResponse7(id, res, sendMessage, clientId) {
|
|
|
10195
10351
|
sendMessage(response);
|
|
10196
10352
|
}
|
|
10197
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
|
+
|
|
10198
10530
|
// src/handlers/kb-nodes.ts
|
|
10199
10531
|
init_logger();
|
|
10200
10532
|
async function handleKbNodesRequest(data, collections, sendMessage) {
|
|
@@ -10214,6 +10546,7 @@ async function handleKbNodesRequest(data, collections, sendMessage) {
|
|
|
10214
10546
|
const content = requestData?.content;
|
|
10215
10547
|
const category = requestData?.category;
|
|
10216
10548
|
const tags = requestData?.tags;
|
|
10549
|
+
const type = requestData?.type;
|
|
10217
10550
|
const createdBy = requestData?.createdBy;
|
|
10218
10551
|
const updatedBy = requestData?.updatedBy;
|
|
10219
10552
|
const userId = requestData?.userId;
|
|
@@ -10223,22 +10556,22 @@ async function handleKbNodesRequest(data, collections, sendMessage) {
|
|
|
10223
10556
|
const offset = requestData?.offset;
|
|
10224
10557
|
switch (operation) {
|
|
10225
10558
|
case "create":
|
|
10226
|
-
await
|
|
10559
|
+
await handleCreate7(id, { title, content, category, tags, type, createdBy }, executeCollection, sendMessage, from.id);
|
|
10227
10560
|
break;
|
|
10228
10561
|
case "update":
|
|
10229
|
-
await
|
|
10562
|
+
await handleUpdate7(id, nodeId, { title, content, category, tags, type, updatedBy }, executeCollection, sendMessage, from.id);
|
|
10230
10563
|
break;
|
|
10231
10564
|
case "delete":
|
|
10232
|
-
await
|
|
10565
|
+
await handleDelete7(id, nodeId, executeCollection, sendMessage, from.id);
|
|
10233
10566
|
break;
|
|
10234
10567
|
case "getAll":
|
|
10235
|
-
await
|
|
10568
|
+
await handleGetAll7(id, limit, offset, executeCollection, sendMessage, from.id);
|
|
10236
10569
|
break;
|
|
10237
10570
|
case "getOne":
|
|
10238
|
-
await
|
|
10571
|
+
await handleGetOne7(id, nodeId, executeCollection, sendMessage, from.id);
|
|
10239
10572
|
break;
|
|
10240
10573
|
case "search":
|
|
10241
|
-
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);
|
|
10242
10575
|
break;
|
|
10243
10576
|
case "getByCategory":
|
|
10244
10577
|
await handleGetByCategory(id, category, limit, offset, executeCollection, sendMessage, from.id);
|
|
@@ -10253,37 +10586,37 @@ async function handleKbNodesRequest(data, collections, sendMessage) {
|
|
|
10253
10586
|
await handleGetTags(id, executeCollection, sendMessage, from.id);
|
|
10254
10587
|
break;
|
|
10255
10588
|
default:
|
|
10256
|
-
|
|
10589
|
+
sendResponse9(id, {
|
|
10257
10590
|
success: false,
|
|
10258
10591
|
error: `Unknown operation: ${operation}`
|
|
10259
10592
|
}, sendMessage, from.id);
|
|
10260
10593
|
}
|
|
10261
10594
|
} catch (error) {
|
|
10262
10595
|
logger.error("Failed to handle KB nodes request:", error);
|
|
10263
|
-
|
|
10596
|
+
sendResponse9(null, {
|
|
10264
10597
|
success: false,
|
|
10265
10598
|
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
10266
10599
|
}, sendMessage);
|
|
10267
10600
|
}
|
|
10268
10601
|
}
|
|
10269
|
-
async function
|
|
10270
|
-
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;
|
|
10271
10604
|
if (!title || title.trim().length === 0) {
|
|
10272
|
-
|
|
10605
|
+
sendResponse9(id, {
|
|
10273
10606
|
success: false,
|
|
10274
10607
|
error: "Title is required and cannot be empty"
|
|
10275
10608
|
}, sendMessage, clientId);
|
|
10276
10609
|
return;
|
|
10277
10610
|
}
|
|
10278
10611
|
if (!content || content.trim().length === 0) {
|
|
10279
|
-
|
|
10612
|
+
sendResponse9(id, {
|
|
10280
10613
|
success: false,
|
|
10281
10614
|
error: "Content is required and cannot be empty"
|
|
10282
10615
|
}, sendMessage, clientId);
|
|
10283
10616
|
return;
|
|
10284
10617
|
}
|
|
10285
10618
|
if (!createdBy) {
|
|
10286
|
-
|
|
10619
|
+
sendResponse9(id, {
|
|
10287
10620
|
success: false,
|
|
10288
10621
|
error: "createdBy (user ID) is required"
|
|
10289
10622
|
}, sendMessage, clientId);
|
|
@@ -10295,11 +10628,12 @@ async function handleCreate6(id, nodeData, executeCollection, sendMessage, clien
|
|
|
10295
10628
|
content,
|
|
10296
10629
|
category: category || void 0,
|
|
10297
10630
|
tags: tags || void 0,
|
|
10631
|
+
type: type || "query",
|
|
10298
10632
|
createdBy
|
|
10299
10633
|
});
|
|
10300
10634
|
if (result && result.success) {
|
|
10301
10635
|
logger.info(`[DB] KB node created successfully: ${title}`);
|
|
10302
|
-
|
|
10636
|
+
sendResponse9(id, {
|
|
10303
10637
|
success: true,
|
|
10304
10638
|
data: {
|
|
10305
10639
|
...result.data,
|
|
@@ -10308,29 +10642,29 @@ async function handleCreate6(id, nodeData, executeCollection, sendMessage, clien
|
|
|
10308
10642
|
}, sendMessage, clientId);
|
|
10309
10643
|
return;
|
|
10310
10644
|
}
|
|
10311
|
-
|
|
10645
|
+
sendResponse9(id, {
|
|
10312
10646
|
success: false,
|
|
10313
10647
|
error: "Failed to create knowledge node"
|
|
10314
10648
|
}, sendMessage, clientId);
|
|
10315
10649
|
} catch (error) {
|
|
10316
10650
|
logger.error("[DB] Failed to create KB node:", error);
|
|
10317
|
-
|
|
10651
|
+
sendResponse9(id, {
|
|
10318
10652
|
success: false,
|
|
10319
10653
|
error: error instanceof Error ? error.message : "Failed to create knowledge node"
|
|
10320
10654
|
}, sendMessage, clientId);
|
|
10321
10655
|
}
|
|
10322
10656
|
}
|
|
10323
|
-
async function
|
|
10324
|
-
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;
|
|
10325
10659
|
if (!nodeId) {
|
|
10326
|
-
|
|
10660
|
+
sendResponse9(id, {
|
|
10327
10661
|
success: false,
|
|
10328
10662
|
error: "Knowledge node ID is required"
|
|
10329
10663
|
}, sendMessage, clientId);
|
|
10330
10664
|
return;
|
|
10331
10665
|
}
|
|
10332
10666
|
if (!updatedBy) {
|
|
10333
|
-
|
|
10667
|
+
sendResponse9(id, {
|
|
10334
10668
|
success: false,
|
|
10335
10669
|
error: "updatedBy (user ID) is required"
|
|
10336
10670
|
}, sendMessage, clientId);
|
|
@@ -10343,11 +10677,12 @@ async function handleUpdate6(id, nodeId, nodeData, executeCollection, sendMessag
|
|
|
10343
10677
|
content,
|
|
10344
10678
|
category,
|
|
10345
10679
|
tags,
|
|
10680
|
+
type,
|
|
10346
10681
|
updatedBy
|
|
10347
10682
|
});
|
|
10348
10683
|
if (result && result.success) {
|
|
10349
10684
|
logger.info(`[DB] KB node updated successfully, ID: ${nodeId}`);
|
|
10350
|
-
|
|
10685
|
+
sendResponse9(id, {
|
|
10351
10686
|
success: true,
|
|
10352
10687
|
data: {
|
|
10353
10688
|
...result.data,
|
|
@@ -10356,21 +10691,21 @@ async function handleUpdate6(id, nodeId, nodeData, executeCollection, sendMessag
|
|
|
10356
10691
|
}, sendMessage, clientId);
|
|
10357
10692
|
return;
|
|
10358
10693
|
}
|
|
10359
|
-
|
|
10694
|
+
sendResponse9(id, {
|
|
10360
10695
|
success: false,
|
|
10361
10696
|
error: "Failed to update knowledge node"
|
|
10362
10697
|
}, sendMessage, clientId);
|
|
10363
10698
|
} catch (error) {
|
|
10364
10699
|
logger.error("[DB] Failed to update KB node:", error);
|
|
10365
|
-
|
|
10700
|
+
sendResponse9(id, {
|
|
10366
10701
|
success: false,
|
|
10367
10702
|
error: error instanceof Error ? error.message : "Failed to update knowledge node"
|
|
10368
10703
|
}, sendMessage, clientId);
|
|
10369
10704
|
}
|
|
10370
10705
|
}
|
|
10371
|
-
async function
|
|
10706
|
+
async function handleDelete7(id, nodeId, executeCollection, sendMessage, clientId) {
|
|
10372
10707
|
if (!nodeId) {
|
|
10373
|
-
|
|
10708
|
+
sendResponse9(id, {
|
|
10374
10709
|
success: false,
|
|
10375
10710
|
error: "Knowledge node ID is required"
|
|
10376
10711
|
}, sendMessage, clientId);
|
|
@@ -10380,7 +10715,7 @@ async function handleDelete6(id, nodeId, executeCollection, sendMessage, clientI
|
|
|
10380
10715
|
const result = await executeCollection("kbNodes", "delete", { id: nodeId });
|
|
10381
10716
|
if (result && result.success) {
|
|
10382
10717
|
logger.info(`[DB] KB node deleted successfully, ID: ${nodeId}`);
|
|
10383
|
-
|
|
10718
|
+
sendResponse9(id, {
|
|
10384
10719
|
success: true,
|
|
10385
10720
|
data: {
|
|
10386
10721
|
id: nodeId,
|
|
@@ -10390,19 +10725,19 @@ async function handleDelete6(id, nodeId, executeCollection, sendMessage, clientI
|
|
|
10390
10725
|
}, sendMessage, clientId);
|
|
10391
10726
|
return;
|
|
10392
10727
|
}
|
|
10393
|
-
|
|
10728
|
+
sendResponse9(id, {
|
|
10394
10729
|
success: false,
|
|
10395
10730
|
error: "Failed to delete knowledge node"
|
|
10396
10731
|
}, sendMessage, clientId);
|
|
10397
10732
|
} catch (error) {
|
|
10398
10733
|
logger.error("[DB] Failed to delete KB node:", error);
|
|
10399
|
-
|
|
10734
|
+
sendResponse9(id, {
|
|
10400
10735
|
success: false,
|
|
10401
10736
|
error: error instanceof Error ? error.message : "Failed to delete knowledge node"
|
|
10402
10737
|
}, sendMessage, clientId);
|
|
10403
10738
|
}
|
|
10404
10739
|
}
|
|
10405
|
-
async function
|
|
10740
|
+
async function handleGetAll7(id, limit, offset, executeCollection, sendMessage, clientId) {
|
|
10406
10741
|
try {
|
|
10407
10742
|
const result = await executeCollection("kbNodes", "getAll", {
|
|
10408
10743
|
limit: limit || 100,
|
|
@@ -10410,7 +10745,7 @@ async function handleGetAll6(id, limit, offset, executeCollection, sendMessage,
|
|
|
10410
10745
|
});
|
|
10411
10746
|
if (result && result.success) {
|
|
10412
10747
|
logger.info(`[DB] Retrieved ${result.count} KB nodes`);
|
|
10413
|
-
|
|
10748
|
+
sendResponse9(id, {
|
|
10414
10749
|
success: true,
|
|
10415
10750
|
data: {
|
|
10416
10751
|
nodes: result.data,
|
|
@@ -10420,21 +10755,21 @@ async function handleGetAll6(id, limit, offset, executeCollection, sendMessage,
|
|
|
10420
10755
|
}, sendMessage, clientId);
|
|
10421
10756
|
return;
|
|
10422
10757
|
}
|
|
10423
|
-
|
|
10758
|
+
sendResponse9(id, {
|
|
10424
10759
|
success: false,
|
|
10425
10760
|
error: "Failed to retrieve knowledge nodes"
|
|
10426
10761
|
}, sendMessage, clientId);
|
|
10427
10762
|
} catch (error) {
|
|
10428
10763
|
logger.error("[DB] Failed to get all KB nodes:", error);
|
|
10429
|
-
|
|
10764
|
+
sendResponse9(id, {
|
|
10430
10765
|
success: false,
|
|
10431
10766
|
error: error instanceof Error ? error.message : "Failed to retrieve knowledge nodes"
|
|
10432
10767
|
}, sendMessage, clientId);
|
|
10433
10768
|
}
|
|
10434
10769
|
}
|
|
10435
|
-
async function
|
|
10770
|
+
async function handleGetOne7(id, nodeId, executeCollection, sendMessage, clientId) {
|
|
10436
10771
|
if (!nodeId) {
|
|
10437
|
-
|
|
10772
|
+
sendResponse9(id, {
|
|
10438
10773
|
success: false,
|
|
10439
10774
|
error: "Knowledge node ID is required"
|
|
10440
10775
|
}, sendMessage, clientId);
|
|
@@ -10444,7 +10779,7 @@ async function handleGetOne6(id, nodeId, executeCollection, sendMessage, clientI
|
|
|
10444
10779
|
const result = await executeCollection("kbNodes", "getOne", { id: nodeId });
|
|
10445
10780
|
if (result && result.success) {
|
|
10446
10781
|
logger.info(`[DB] Retrieved KB node ID: ${nodeId}`);
|
|
10447
|
-
|
|
10782
|
+
sendResponse9(id, {
|
|
10448
10783
|
success: true,
|
|
10449
10784
|
data: {
|
|
10450
10785
|
node: result.data,
|
|
@@ -10453,32 +10788,33 @@ async function handleGetOne6(id, nodeId, executeCollection, sendMessage, clientI
|
|
|
10453
10788
|
}, sendMessage, clientId);
|
|
10454
10789
|
return;
|
|
10455
10790
|
}
|
|
10456
|
-
|
|
10791
|
+
sendResponse9(id, {
|
|
10457
10792
|
success: false,
|
|
10458
10793
|
error: "Failed to retrieve knowledge node"
|
|
10459
10794
|
}, sendMessage, clientId);
|
|
10460
10795
|
} catch (error) {
|
|
10461
10796
|
logger.error("[DB] Failed to get KB node:", error);
|
|
10462
|
-
|
|
10797
|
+
sendResponse9(id, {
|
|
10463
10798
|
success: false,
|
|
10464
10799
|
error: error instanceof Error ? error.message : "Failed to retrieve knowledge node"
|
|
10465
10800
|
}, sendMessage, clientId);
|
|
10466
10801
|
}
|
|
10467
10802
|
}
|
|
10468
10803
|
async function handleSearch(id, searchParams, executeCollection, sendMessage, clientId) {
|
|
10469
|
-
const { query, category, tags, createdBy, limit, offset } = searchParams;
|
|
10804
|
+
const { query, category, tags, type, createdBy, limit, offset } = searchParams;
|
|
10470
10805
|
try {
|
|
10471
10806
|
const result = await executeCollection("kbNodes", "search", {
|
|
10472
10807
|
query,
|
|
10473
10808
|
category,
|
|
10474
10809
|
tags,
|
|
10810
|
+
type,
|
|
10475
10811
|
createdBy,
|
|
10476
10812
|
limit: limit || 50,
|
|
10477
10813
|
offset: offset || 0
|
|
10478
10814
|
});
|
|
10479
10815
|
if (result && result.success) {
|
|
10480
10816
|
logger.info(`[DB] Search returned ${result.count} KB nodes`);
|
|
10481
|
-
|
|
10817
|
+
sendResponse9(id, {
|
|
10482
10818
|
success: true,
|
|
10483
10819
|
data: {
|
|
10484
10820
|
nodes: result.data,
|
|
@@ -10488,13 +10824,13 @@ async function handleSearch(id, searchParams, executeCollection, sendMessage, cl
|
|
|
10488
10824
|
}, sendMessage, clientId);
|
|
10489
10825
|
return;
|
|
10490
10826
|
}
|
|
10491
|
-
|
|
10827
|
+
sendResponse9(id, {
|
|
10492
10828
|
success: false,
|
|
10493
10829
|
error: "Failed to search knowledge nodes"
|
|
10494
10830
|
}, sendMessage, clientId);
|
|
10495
10831
|
} catch (error) {
|
|
10496
10832
|
logger.error("[DB] Failed to search KB nodes:", error);
|
|
10497
|
-
|
|
10833
|
+
sendResponse9(id, {
|
|
10498
10834
|
success: false,
|
|
10499
10835
|
error: error instanceof Error ? error.message : "Failed to search knowledge nodes"
|
|
10500
10836
|
}, sendMessage, clientId);
|
|
@@ -10502,7 +10838,7 @@ async function handleSearch(id, searchParams, executeCollection, sendMessage, cl
|
|
|
10502
10838
|
}
|
|
10503
10839
|
async function handleGetByCategory(id, category, limit, offset, executeCollection, sendMessage, clientId) {
|
|
10504
10840
|
if (!category) {
|
|
10505
|
-
|
|
10841
|
+
sendResponse9(id, {
|
|
10506
10842
|
success: false,
|
|
10507
10843
|
error: "Category is required"
|
|
10508
10844
|
}, sendMessage, clientId);
|
|
@@ -10516,7 +10852,7 @@ async function handleGetByCategory(id, category, limit, offset, executeCollectio
|
|
|
10516
10852
|
});
|
|
10517
10853
|
if (result && result.success) {
|
|
10518
10854
|
logger.info(`[DB] Retrieved ${result.count} KB nodes for category: ${category}`);
|
|
10519
|
-
|
|
10855
|
+
sendResponse9(id, {
|
|
10520
10856
|
success: true,
|
|
10521
10857
|
data: {
|
|
10522
10858
|
nodes: result.data,
|
|
@@ -10527,13 +10863,13 @@ async function handleGetByCategory(id, category, limit, offset, executeCollectio
|
|
|
10527
10863
|
}, sendMessage, clientId);
|
|
10528
10864
|
return;
|
|
10529
10865
|
}
|
|
10530
|
-
|
|
10866
|
+
sendResponse9(id, {
|
|
10531
10867
|
success: false,
|
|
10532
10868
|
error: "Failed to retrieve knowledge nodes by category"
|
|
10533
10869
|
}, sendMessage, clientId);
|
|
10534
10870
|
} catch (error) {
|
|
10535
10871
|
logger.error("[DB] Failed to get KB nodes by category:", error);
|
|
10536
|
-
|
|
10872
|
+
sendResponse9(id, {
|
|
10537
10873
|
success: false,
|
|
10538
10874
|
error: error instanceof Error ? error.message : "Failed to retrieve knowledge nodes by category"
|
|
10539
10875
|
}, sendMessage, clientId);
|
|
@@ -10541,7 +10877,7 @@ async function handleGetByCategory(id, category, limit, offset, executeCollectio
|
|
|
10541
10877
|
}
|
|
10542
10878
|
async function handleGetByUser(id, userId, limit, offset, executeCollection, sendMessage, clientId) {
|
|
10543
10879
|
if (!userId) {
|
|
10544
|
-
|
|
10880
|
+
sendResponse9(id, {
|
|
10545
10881
|
success: false,
|
|
10546
10882
|
error: "User ID is required"
|
|
10547
10883
|
}, sendMessage, clientId);
|
|
@@ -10555,7 +10891,7 @@ async function handleGetByUser(id, userId, limit, offset, executeCollection, sen
|
|
|
10555
10891
|
});
|
|
10556
10892
|
if (result && result.success) {
|
|
10557
10893
|
logger.info(`[DB] Retrieved ${result.count} KB nodes for user: ${userId}`);
|
|
10558
|
-
|
|
10894
|
+
sendResponse9(id, {
|
|
10559
10895
|
success: true,
|
|
10560
10896
|
data: {
|
|
10561
10897
|
nodes: result.data,
|
|
@@ -10566,13 +10902,13 @@ async function handleGetByUser(id, userId, limit, offset, executeCollection, sen
|
|
|
10566
10902
|
}, sendMessage, clientId);
|
|
10567
10903
|
return;
|
|
10568
10904
|
}
|
|
10569
|
-
|
|
10905
|
+
sendResponse9(id, {
|
|
10570
10906
|
success: false,
|
|
10571
10907
|
error: "Failed to retrieve knowledge nodes by user"
|
|
10572
10908
|
}, sendMessage, clientId);
|
|
10573
10909
|
} catch (error) {
|
|
10574
10910
|
logger.error("[DB] Failed to get KB nodes by user:", error);
|
|
10575
|
-
|
|
10911
|
+
sendResponse9(id, {
|
|
10576
10912
|
success: false,
|
|
10577
10913
|
error: error instanceof Error ? error.message : "Failed to retrieve knowledge nodes by user"
|
|
10578
10914
|
}, sendMessage, clientId);
|
|
@@ -10583,7 +10919,7 @@ async function handleGetCategories(id, executeCollection, sendMessage, clientId)
|
|
|
10583
10919
|
const result = await executeCollection("kbNodes", "getCategories", {});
|
|
10584
10920
|
if (result && result.success) {
|
|
10585
10921
|
logger.info(`[DB] Retrieved ${result.count} categories`);
|
|
10586
|
-
|
|
10922
|
+
sendResponse9(id, {
|
|
10587
10923
|
success: true,
|
|
10588
10924
|
data: {
|
|
10589
10925
|
categories: result.data,
|
|
@@ -10593,13 +10929,13 @@ async function handleGetCategories(id, executeCollection, sendMessage, clientId)
|
|
|
10593
10929
|
}, sendMessage, clientId);
|
|
10594
10930
|
return;
|
|
10595
10931
|
}
|
|
10596
|
-
|
|
10932
|
+
sendResponse9(id, {
|
|
10597
10933
|
success: false,
|
|
10598
10934
|
error: "Failed to retrieve categories"
|
|
10599
10935
|
}, sendMessage, clientId);
|
|
10600
10936
|
} catch (error) {
|
|
10601
10937
|
logger.error("[DB] Failed to get categories:", error);
|
|
10602
|
-
|
|
10938
|
+
sendResponse9(id, {
|
|
10603
10939
|
success: false,
|
|
10604
10940
|
error: error instanceof Error ? error.message : "Failed to retrieve categories"
|
|
10605
10941
|
}, sendMessage, clientId);
|
|
@@ -10610,7 +10946,7 @@ async function handleGetTags(id, executeCollection, sendMessage, clientId) {
|
|
|
10610
10946
|
const result = await executeCollection("kbNodes", "getTags", {});
|
|
10611
10947
|
if (result && result.success) {
|
|
10612
10948
|
logger.info(`[DB] Retrieved ${result.count} tags`);
|
|
10613
|
-
|
|
10949
|
+
sendResponse9(id, {
|
|
10614
10950
|
success: true,
|
|
10615
10951
|
data: {
|
|
10616
10952
|
tags: result.data,
|
|
@@ -10620,19 +10956,19 @@ async function handleGetTags(id, executeCollection, sendMessage, clientId) {
|
|
|
10620
10956
|
}, sendMessage, clientId);
|
|
10621
10957
|
return;
|
|
10622
10958
|
}
|
|
10623
|
-
|
|
10959
|
+
sendResponse9(id, {
|
|
10624
10960
|
success: false,
|
|
10625
10961
|
error: "Failed to retrieve tags"
|
|
10626
10962
|
}, sendMessage, clientId);
|
|
10627
10963
|
} catch (error) {
|
|
10628
10964
|
logger.error("[DB] Failed to get tags:", error);
|
|
10629
|
-
|
|
10965
|
+
sendResponse9(id, {
|
|
10630
10966
|
success: false,
|
|
10631
10967
|
error: error instanceof Error ? error.message : "Failed to retrieve tags"
|
|
10632
10968
|
}, sendMessage, clientId);
|
|
10633
10969
|
}
|
|
10634
10970
|
}
|
|
10635
|
-
function
|
|
10971
|
+
function sendResponse9(id, res, sendMessage, clientId) {
|
|
10636
10972
|
const response = {
|
|
10637
10973
|
id: id || "unknown",
|
|
10638
10974
|
type: "KB_NODES_RES",
|
|
@@ -10677,19 +11013,19 @@ async function handleMenusRequest(data, collections, sendMessage) {
|
|
|
10677
11013
|
const items = requestData?.items;
|
|
10678
11014
|
switch (operation) {
|
|
10679
11015
|
case "create":
|
|
10680
|
-
await
|
|
11016
|
+
await handleCreate8(id, name, componentName, icon, userMessage, parentId, sortOrder, props, isActive, executeCollection, sendMessage, from.id);
|
|
10681
11017
|
break;
|
|
10682
11018
|
case "update":
|
|
10683
|
-
await
|
|
11019
|
+
await handleUpdate8(id, menuId, name, componentName, icon, userMessage, parentId, sortOrder, props, isActive, executeCollection, sendMessage, from.id);
|
|
10684
11020
|
break;
|
|
10685
11021
|
case "delete":
|
|
10686
|
-
await
|
|
11022
|
+
await handleDelete8(id, menuId, executeCollection, sendMessage, from.id);
|
|
10687
11023
|
break;
|
|
10688
11024
|
case "getAll":
|
|
10689
|
-
await
|
|
11025
|
+
await handleGetAll8(id, executeCollection, sendMessage, from.id);
|
|
10690
11026
|
break;
|
|
10691
11027
|
case "getOne":
|
|
10692
|
-
await
|
|
11028
|
+
await handleGetOne8(id, menuId, executeCollection, sendMessage, from.id);
|
|
10693
11029
|
break;
|
|
10694
11030
|
case "getRootMenus":
|
|
10695
11031
|
await handleGetRootMenus(id, executeCollection, sendMessage, from.id);
|
|
@@ -10707,29 +11043,29 @@ async function handleMenusRequest(data, collections, sendMessage) {
|
|
|
10707
11043
|
await handleReorder(id, items, executeCollection, sendMessage, from.id);
|
|
10708
11044
|
break;
|
|
10709
11045
|
default:
|
|
10710
|
-
|
|
11046
|
+
sendResponse10(id, {
|
|
10711
11047
|
success: false,
|
|
10712
11048
|
error: `Unknown operation: ${operation}`
|
|
10713
11049
|
}, sendMessage, from.id);
|
|
10714
11050
|
}
|
|
10715
11051
|
} catch (error) {
|
|
10716
11052
|
logger.error("Failed to handle menus request:", error);
|
|
10717
|
-
|
|
11053
|
+
sendResponse10(null, {
|
|
10718
11054
|
success: false,
|
|
10719
11055
|
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
10720
11056
|
}, sendMessage);
|
|
10721
11057
|
}
|
|
10722
11058
|
}
|
|
10723
|
-
async function
|
|
11059
|
+
async function handleCreate8(id, name, componentName, icon, userMessage, parentId, sortOrder, props, isActive, executeCollection, sendMessage, clientId) {
|
|
10724
11060
|
if (!name) {
|
|
10725
|
-
|
|
11061
|
+
sendResponse10(id, {
|
|
10726
11062
|
success: false,
|
|
10727
11063
|
error: "name is required"
|
|
10728
11064
|
}, sendMessage, clientId);
|
|
10729
11065
|
return;
|
|
10730
11066
|
}
|
|
10731
11067
|
if (!componentName) {
|
|
10732
|
-
|
|
11068
|
+
sendResponse10(id, {
|
|
10733
11069
|
success: false,
|
|
10734
11070
|
error: "componentName is required"
|
|
10735
11071
|
}, sendMessage, clientId);
|
|
@@ -10746,22 +11082,22 @@ async function handleCreate7(id, name, componentName, icon, userMessage, parentI
|
|
|
10746
11082
|
props,
|
|
10747
11083
|
isActive
|
|
10748
11084
|
});
|
|
10749
|
-
|
|
11085
|
+
sendResponse10(id, {
|
|
10750
11086
|
success: true,
|
|
10751
11087
|
data: result.data,
|
|
10752
11088
|
message: "Menu created successfully"
|
|
10753
11089
|
}, sendMessage, clientId);
|
|
10754
11090
|
logger.info(`Menu created: ID ${result.data?.id}`);
|
|
10755
11091
|
} catch (error) {
|
|
10756
|
-
|
|
11092
|
+
sendResponse10(id, {
|
|
10757
11093
|
success: false,
|
|
10758
11094
|
error: error instanceof Error ? error.message : "Failed to create menu"
|
|
10759
11095
|
}, sendMessage, clientId);
|
|
10760
11096
|
}
|
|
10761
11097
|
}
|
|
10762
|
-
async function
|
|
11098
|
+
async function handleUpdate8(id, menuId, name, componentName, icon, userMessage, parentId, sortOrder, props, isActive, executeCollection, sendMessage, clientId) {
|
|
10763
11099
|
if (!menuId) {
|
|
10764
|
-
|
|
11100
|
+
sendResponse10(id, {
|
|
10765
11101
|
success: false,
|
|
10766
11102
|
error: "Menu ID is required"
|
|
10767
11103
|
}, sendMessage, clientId);
|
|
@@ -10779,22 +11115,22 @@ async function handleUpdate7(id, menuId, name, componentName, icon, userMessage,
|
|
|
10779
11115
|
props,
|
|
10780
11116
|
isActive
|
|
10781
11117
|
});
|
|
10782
|
-
|
|
11118
|
+
sendResponse10(id, {
|
|
10783
11119
|
success: true,
|
|
10784
11120
|
data: result.data,
|
|
10785
11121
|
message: "Menu updated successfully"
|
|
10786
11122
|
}, sendMessage, clientId);
|
|
10787
11123
|
logger.info(`Menu updated: ID ${menuId}`);
|
|
10788
11124
|
} catch (error) {
|
|
10789
|
-
|
|
11125
|
+
sendResponse10(id, {
|
|
10790
11126
|
success: false,
|
|
10791
11127
|
error: error instanceof Error ? error.message : "Failed to update menu"
|
|
10792
11128
|
}, sendMessage, clientId);
|
|
10793
11129
|
}
|
|
10794
11130
|
}
|
|
10795
|
-
async function
|
|
11131
|
+
async function handleDelete8(id, menuId, executeCollection, sendMessage, clientId) {
|
|
10796
11132
|
if (!menuId) {
|
|
10797
|
-
|
|
11133
|
+
sendResponse10(id, {
|
|
10798
11134
|
success: false,
|
|
10799
11135
|
error: "Menu ID is required"
|
|
10800
11136
|
}, sendMessage, clientId);
|
|
@@ -10802,23 +11138,23 @@ async function handleDelete7(id, menuId, executeCollection, sendMessage, clientI
|
|
|
10802
11138
|
}
|
|
10803
11139
|
try {
|
|
10804
11140
|
const result = await executeCollection("menus", "delete", { id: menuId });
|
|
10805
|
-
|
|
11141
|
+
sendResponse10(id, {
|
|
10806
11142
|
success: true,
|
|
10807
11143
|
data: result.data,
|
|
10808
11144
|
message: "Menu deleted successfully"
|
|
10809
11145
|
}, sendMessage, clientId);
|
|
10810
11146
|
logger.info(`Menu deleted: ID ${menuId}`);
|
|
10811
11147
|
} catch (error) {
|
|
10812
|
-
|
|
11148
|
+
sendResponse10(id, {
|
|
10813
11149
|
success: false,
|
|
10814
11150
|
error: error instanceof Error ? error.message : "Failed to delete menu"
|
|
10815
11151
|
}, sendMessage, clientId);
|
|
10816
11152
|
}
|
|
10817
11153
|
}
|
|
10818
|
-
async function
|
|
11154
|
+
async function handleGetAll8(id, executeCollection, sendMessage, clientId) {
|
|
10819
11155
|
try {
|
|
10820
11156
|
const result = await executeCollection("menus", "getAll", {});
|
|
10821
|
-
|
|
11157
|
+
sendResponse10(id, {
|
|
10822
11158
|
success: true,
|
|
10823
11159
|
data: result.data,
|
|
10824
11160
|
count: result.count,
|
|
@@ -10826,15 +11162,15 @@ async function handleGetAll7(id, executeCollection, sendMessage, clientId) {
|
|
|
10826
11162
|
}, sendMessage, clientId);
|
|
10827
11163
|
logger.info(`Retrieved all menus (count: ${result.count})`);
|
|
10828
11164
|
} catch (error) {
|
|
10829
|
-
|
|
11165
|
+
sendResponse10(id, {
|
|
10830
11166
|
success: false,
|
|
10831
11167
|
error: error instanceof Error ? error.message : "Failed to get menus"
|
|
10832
11168
|
}, sendMessage, clientId);
|
|
10833
11169
|
}
|
|
10834
11170
|
}
|
|
10835
|
-
async function
|
|
11171
|
+
async function handleGetOne8(id, menuId, executeCollection, sendMessage, clientId) {
|
|
10836
11172
|
if (!menuId) {
|
|
10837
|
-
|
|
11173
|
+
sendResponse10(id, {
|
|
10838
11174
|
success: false,
|
|
10839
11175
|
error: "Menu ID is required"
|
|
10840
11176
|
}, sendMessage, clientId);
|
|
@@ -10842,14 +11178,14 @@ async function handleGetOne7(id, menuId, executeCollection, sendMessage, clientI
|
|
|
10842
11178
|
}
|
|
10843
11179
|
try {
|
|
10844
11180
|
const result = await executeCollection("menus", "getOne", { id: menuId });
|
|
10845
|
-
|
|
11181
|
+
sendResponse10(id, {
|
|
10846
11182
|
success: true,
|
|
10847
11183
|
data: result.data,
|
|
10848
11184
|
message: `Retrieved menu ID ${menuId}`
|
|
10849
11185
|
}, sendMessage, clientId);
|
|
10850
11186
|
logger.info(`Retrieved menu: ID ${menuId}`);
|
|
10851
11187
|
} catch (error) {
|
|
10852
|
-
|
|
11188
|
+
sendResponse10(id, {
|
|
10853
11189
|
success: false,
|
|
10854
11190
|
error: error instanceof Error ? error.message : "Failed to get menu"
|
|
10855
11191
|
}, sendMessage, clientId);
|
|
@@ -10858,7 +11194,7 @@ async function handleGetOne7(id, menuId, executeCollection, sendMessage, clientI
|
|
|
10858
11194
|
async function handleGetRootMenus(id, executeCollection, sendMessage, clientId) {
|
|
10859
11195
|
try {
|
|
10860
11196
|
const result = await executeCollection("menus", "getRootMenus", {});
|
|
10861
|
-
|
|
11197
|
+
sendResponse10(id, {
|
|
10862
11198
|
success: true,
|
|
10863
11199
|
data: result.data,
|
|
10864
11200
|
count: result.count,
|
|
@@ -10866,7 +11202,7 @@ async function handleGetRootMenus(id, executeCollection, sendMessage, clientId)
|
|
|
10866
11202
|
}, sendMessage, clientId);
|
|
10867
11203
|
logger.info(`Retrieved root menus (count: ${result.count})`);
|
|
10868
11204
|
} catch (error) {
|
|
10869
|
-
|
|
11205
|
+
sendResponse10(id, {
|
|
10870
11206
|
success: false,
|
|
10871
11207
|
error: error instanceof Error ? error.message : "Failed to get root menus"
|
|
10872
11208
|
}, sendMessage, clientId);
|
|
@@ -10874,7 +11210,7 @@ async function handleGetRootMenus(id, executeCollection, sendMessage, clientId)
|
|
|
10874
11210
|
}
|
|
10875
11211
|
async function handleGetChildMenus(id, parentId, executeCollection, sendMessage, clientId) {
|
|
10876
11212
|
if (parentId === void 0 || parentId === null) {
|
|
10877
|
-
|
|
11213
|
+
sendResponse10(id, {
|
|
10878
11214
|
success: false,
|
|
10879
11215
|
error: "parentId is required"
|
|
10880
11216
|
}, sendMessage, clientId);
|
|
@@ -10882,7 +11218,7 @@ async function handleGetChildMenus(id, parentId, executeCollection, sendMessage,
|
|
|
10882
11218
|
}
|
|
10883
11219
|
try {
|
|
10884
11220
|
const result = await executeCollection("menus", "getChildMenus", { parentId });
|
|
10885
|
-
|
|
11221
|
+
sendResponse10(id, {
|
|
10886
11222
|
success: true,
|
|
10887
11223
|
data: result.data,
|
|
10888
11224
|
count: result.count,
|
|
@@ -10890,7 +11226,7 @@ async function handleGetChildMenus(id, parentId, executeCollection, sendMessage,
|
|
|
10890
11226
|
}, sendMessage, clientId);
|
|
10891
11227
|
logger.info(`Retrieved child menus for parent ${parentId} (count: ${result.count})`);
|
|
10892
11228
|
} catch (error) {
|
|
10893
|
-
|
|
11229
|
+
sendResponse10(id, {
|
|
10894
11230
|
success: false,
|
|
10895
11231
|
error: error instanceof Error ? error.message : "Failed to get child menus"
|
|
10896
11232
|
}, sendMessage, clientId);
|
|
@@ -10899,7 +11235,7 @@ async function handleGetChildMenus(id, parentId, executeCollection, sendMessage,
|
|
|
10899
11235
|
async function handleGetHierarchy(id, executeCollection, sendMessage, clientId) {
|
|
10900
11236
|
try {
|
|
10901
11237
|
const result = await executeCollection("menus", "getHierarchy", {});
|
|
10902
|
-
|
|
11238
|
+
sendResponse10(id, {
|
|
10903
11239
|
success: true,
|
|
10904
11240
|
data: result.data,
|
|
10905
11241
|
count: result.count,
|
|
@@ -10907,7 +11243,7 @@ async function handleGetHierarchy(id, executeCollection, sendMessage, clientId)
|
|
|
10907
11243
|
}, sendMessage, clientId);
|
|
10908
11244
|
logger.info(`Retrieved menus hierarchy (root count: ${result.count})`);
|
|
10909
11245
|
} catch (error) {
|
|
10910
|
-
|
|
11246
|
+
sendResponse10(id, {
|
|
10911
11247
|
success: false,
|
|
10912
11248
|
error: error instanceof Error ? error.message : "Failed to get menus hierarchy"
|
|
10913
11249
|
}, sendMessage, clientId);
|
|
@@ -10920,7 +11256,7 @@ async function handleQuery6(id, filters, limit, sort, executeCollection, sendMes
|
|
|
10920
11256
|
limit,
|
|
10921
11257
|
sort
|
|
10922
11258
|
});
|
|
10923
|
-
|
|
11259
|
+
sendResponse10(id, {
|
|
10924
11260
|
success: true,
|
|
10925
11261
|
data: result.data,
|
|
10926
11262
|
count: result.count,
|
|
@@ -10928,7 +11264,7 @@ async function handleQuery6(id, filters, limit, sort, executeCollection, sendMes
|
|
|
10928
11264
|
}, sendMessage, clientId);
|
|
10929
11265
|
logger.info(`Query returned ${result.count} menus`);
|
|
10930
11266
|
} catch (error) {
|
|
10931
|
-
|
|
11267
|
+
sendResponse10(id, {
|
|
10932
11268
|
success: false,
|
|
10933
11269
|
error: error instanceof Error ? error.message : "Failed to query menus"
|
|
10934
11270
|
}, sendMessage, clientId);
|
|
@@ -10936,7 +11272,7 @@ async function handleQuery6(id, filters, limit, sort, executeCollection, sendMes
|
|
|
10936
11272
|
}
|
|
10937
11273
|
async function handleReorder(id, items, executeCollection, sendMessage, clientId) {
|
|
10938
11274
|
if (!items || !Array.isArray(items) || items.length === 0) {
|
|
10939
|
-
|
|
11275
|
+
sendResponse10(id, {
|
|
10940
11276
|
success: false,
|
|
10941
11277
|
error: "items array is required"
|
|
10942
11278
|
}, sendMessage, clientId);
|
|
@@ -10944,20 +11280,20 @@ async function handleReorder(id, items, executeCollection, sendMessage, clientId
|
|
|
10944
11280
|
}
|
|
10945
11281
|
try {
|
|
10946
11282
|
const result = await executeCollection("menus", "reorder", { items });
|
|
10947
|
-
|
|
11283
|
+
sendResponse10(id, {
|
|
10948
11284
|
success: true,
|
|
10949
11285
|
data: result.data,
|
|
10950
11286
|
message: `Reordered ${items.length} menus successfully`
|
|
10951
11287
|
}, sendMessage, clientId);
|
|
10952
11288
|
logger.info(`Reordered ${items.length} menus`);
|
|
10953
11289
|
} catch (error) {
|
|
10954
|
-
|
|
11290
|
+
sendResponse10(id, {
|
|
10955
11291
|
success: false,
|
|
10956
11292
|
error: error instanceof Error ? error.message : "Failed to reorder menus"
|
|
10957
11293
|
}, sendMessage, clientId);
|
|
10958
11294
|
}
|
|
10959
11295
|
}
|
|
10960
|
-
function
|
|
11296
|
+
function sendResponse10(id, res, sendMessage, clientId) {
|
|
10961
11297
|
const response = {
|
|
10962
11298
|
id: id || "unknown",
|
|
10963
11299
|
type: "MENUS_RES",
|
|
@@ -12489,6 +12825,11 @@ var SuperatomSDK = class {
|
|
|
12489
12825
|
logger.error("Failed to handle bookmarks request:", error);
|
|
12490
12826
|
});
|
|
12491
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;
|
|
12492
12833
|
case "KB_NODES":
|
|
12493
12834
|
handleKbNodesRequest(parsed, this.collections, (msg) => this.send(msg)).catch((error) => {
|
|
12494
12835
|
logger.error("Failed to handle KB nodes request:", error);
|