@superatomai/sdk-node 0.0.16 → 0.0.18
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/README.md +942 -942
- package/dist/index.js +38 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -469,6 +469,8 @@ var ComponentPropsSchema = import_zod3.z.object({
|
|
|
469
469
|
var ComponentSchema = import_zod3.z.object({
|
|
470
470
|
id: import_zod3.z.string(),
|
|
471
471
|
name: import_zod3.z.string(),
|
|
472
|
+
displayName: import_zod3.z.string().optional(),
|
|
473
|
+
isDisplayComp: import_zod3.z.boolean().optional(),
|
|
472
474
|
type: import_zod3.z.string(),
|
|
473
475
|
description: import_zod3.z.string(),
|
|
474
476
|
props: ComponentPropsSchema,
|
|
@@ -3451,6 +3453,26 @@ var BaseLLM = class {
|
|
|
3451
3453
|
getApiKey(apiKey) {
|
|
3452
3454
|
return apiKey || this.apiKey || this.getDefaultApiKey();
|
|
3453
3455
|
}
|
|
3456
|
+
/**
|
|
3457
|
+
* Check if a component contains a Form (data_modification component)
|
|
3458
|
+
* Forms have hardcoded defaultValues that become stale when cached
|
|
3459
|
+
* This checks both single Form components and Forms inside MultiComponentContainer
|
|
3460
|
+
*/
|
|
3461
|
+
containsFormComponent(component) {
|
|
3462
|
+
if (!component) return false;
|
|
3463
|
+
if (component.type === "Form" || component.name === "DynamicForm") {
|
|
3464
|
+
return true;
|
|
3465
|
+
}
|
|
3466
|
+
if (component.type === "Container" || component.name === "MultiComponentContainer") {
|
|
3467
|
+
const nestedComponents = component.props?.config?.components || [];
|
|
3468
|
+
for (const nested of nestedComponents) {
|
|
3469
|
+
if (nested.type === "Form" || nested.name === "DynamicForm") {
|
|
3470
|
+
return true;
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
return false;
|
|
3475
|
+
}
|
|
3454
3476
|
/**
|
|
3455
3477
|
* Match components from text response suggestions and generate follow-up questions
|
|
3456
3478
|
* Takes a text response with component suggestions (c1:type format) and matches with available components
|
|
@@ -4325,9 +4347,15 @@ ${errorMsg}
|
|
|
4325
4347
|
logCollector?.info(
|
|
4326
4348
|
`\u2713 Found similar conversation (${(conversationMatch.similarity * 100).toFixed(2)}% match)`
|
|
4327
4349
|
);
|
|
4328
|
-
const
|
|
4350
|
+
const rawComponent = conversationMatch.uiBlock?.component || conversationMatch.uiBlock?.generatedComponentMetadata;
|
|
4351
|
+
const isValidComponent = rawComponent && typeof rawComponent === "object" && Object.keys(rawComponent).length > 0;
|
|
4352
|
+
const component = isValidComponent ? rawComponent : null;
|
|
4329
4353
|
const cachedTextResponse = conversationMatch.uiBlock?.analysis || conversationMatch.uiBlock?.textResponse || conversationMatch.uiBlock?.text || "";
|
|
4330
|
-
|
|
4354
|
+
logger.debug(`[${this.getProviderName()}] Cached component: ${component ? "present" : "null"}, cachedTextResponse: ${cachedTextResponse ? cachedTextResponse.substring(0, 50) + "..." : "empty"}`);
|
|
4355
|
+
if (this.containsFormComponent(component)) {
|
|
4356
|
+
logger.info(`[${this.getProviderName()}] Skipping cached result - Form components contain stale defaultValues, fetching fresh data`);
|
|
4357
|
+
logCollector?.info("Skipping cache for form - fetching current values from database...");
|
|
4358
|
+
} else if (!component) {
|
|
4331
4359
|
if (conversationMatch.similarity >= 0.99) {
|
|
4332
4360
|
const elapsedTime2 = Date.now() - startTime;
|
|
4333
4361
|
logger.info(`[${this.getProviderName()}] \u2713 Exact match for general question - returning cached text response`);
|
|
@@ -5226,19 +5254,20 @@ async function handleUserPromptSuggestions(data, components, sendMessage) {
|
|
|
5226
5254
|
}, sendMessage, wsId);
|
|
5227
5255
|
return;
|
|
5228
5256
|
}
|
|
5229
|
-
|
|
5257
|
+
const displayComponents = components.filter((c) => c.isDisplayComp === true);
|
|
5258
|
+
if (!displayComponents || displayComponents.length === 0) {
|
|
5230
5259
|
sendResponse(id, {
|
|
5231
5260
|
success: true,
|
|
5232
5261
|
data: {
|
|
5233
5262
|
prompt,
|
|
5234
5263
|
suggestions: [],
|
|
5235
5264
|
count: 0,
|
|
5236
|
-
message: "No components available"
|
|
5265
|
+
message: "No display components available"
|
|
5237
5266
|
}
|
|
5238
5267
|
}, sendMessage, wsId);
|
|
5239
5268
|
return;
|
|
5240
5269
|
}
|
|
5241
|
-
const suggestions = searchComponents(prompt,
|
|
5270
|
+
const suggestions = searchComponents(prompt, displayComponents, limit);
|
|
5242
5271
|
sendResponse(id, {
|
|
5243
5272
|
success: true,
|
|
5244
5273
|
data: {
|
|
@@ -5262,6 +5291,7 @@ function searchComponents(prompt, components, limit) {
|
|
|
5262
5291
|
const scoredComponents = components.map((component) => {
|
|
5263
5292
|
let score = 0;
|
|
5264
5293
|
const componentName = component.name.toLowerCase();
|
|
5294
|
+
const componentDisplayName = (component.displayName || "").toLowerCase();
|
|
5265
5295
|
const componentDesc = component.description.toLowerCase();
|
|
5266
5296
|
const componentKeywords = (component.keywords || []).map((k) => k.toLowerCase());
|
|
5267
5297
|
const componentCategory = (component.category || "").toLowerCase();
|
|
@@ -5271,6 +5301,9 @@ function searchComponents(prompt, components, limit) {
|
|
|
5271
5301
|
} else if (componentName.includes(token)) {
|
|
5272
5302
|
score += 5;
|
|
5273
5303
|
}
|
|
5304
|
+
if (componentDisplayName.includes(token)) {
|
|
5305
|
+
score += 6;
|
|
5306
|
+
}
|
|
5274
5307
|
if (componentKeywords.includes(token)) {
|
|
5275
5308
|
score += 8;
|
|
5276
5309
|
} else if (componentKeywords.some((k) => k.includes(token))) {
|