@superatomai/sdk-node 0.0.43 → 0.0.45
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +74 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -92
- package/dist/index.mjs.map +1 -1
- package/package.json +48 -49
package/dist/index.d.mts
CHANGED
|
@@ -2005,10 +2005,12 @@ declare abstract class BaseLLM {
|
|
|
2005
2005
|
/**
|
|
2006
2006
|
* Adapt UI block parameters based on current user question
|
|
2007
2007
|
* Takes a matched UI block from semantic search and modifies its props to answer the new question
|
|
2008
|
+
* Also adapts the cached text response to match the new question
|
|
2008
2009
|
*/
|
|
2009
|
-
adaptUIBlockParameters(currentUserPrompt: string, originalUserPrompt: string, matchedUIBlock: any, apiKey?: string, logCollector?: any): Promise<{
|
|
2010
|
+
adaptUIBlockParameters(currentUserPrompt: string, originalUserPrompt: string, matchedUIBlock: any, apiKey?: string, logCollector?: any, cachedTextResponse?: string): Promise<{
|
|
2010
2011
|
success: boolean;
|
|
2011
2012
|
adaptedComponent?: Component;
|
|
2013
|
+
adaptedTextResponse?: string;
|
|
2012
2014
|
parametersChanged?: Array<{
|
|
2013
2015
|
field: string;
|
|
2014
2016
|
reason: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2005,10 +2005,12 @@ declare abstract class BaseLLM {
|
|
|
2005
2005
|
/**
|
|
2006
2006
|
* Adapt UI block parameters based on current user question
|
|
2007
2007
|
* Takes a matched UI block from semantic search and modifies its props to answer the new question
|
|
2008
|
+
* Also adapts the cached text response to match the new question
|
|
2008
2009
|
*/
|
|
2009
|
-
adaptUIBlockParameters(currentUserPrompt: string, originalUserPrompt: string, matchedUIBlock: any, apiKey?: string, logCollector?: any): Promise<{
|
|
2010
|
+
adaptUIBlockParameters(currentUserPrompt: string, originalUserPrompt: string, matchedUIBlock: any, apiKey?: string, logCollector?: any, cachedTextResponse?: string): Promise<{
|
|
2010
2011
|
success: boolean;
|
|
2011
2012
|
adaptedComponent?: Component;
|
|
2013
|
+
adaptedTextResponse?: string;
|
|
2012
2014
|
parametersChanged?: Array<{
|
|
2013
2015
|
field: string;
|
|
2014
2016
|
reason: string;
|
package/dist/index.js
CHANGED
|
@@ -1196,65 +1196,47 @@ You MUST respond with ONLY a valid JSON object (no markdown, no code blocks):
|
|
|
1196
1196
|
|
|
1197
1197
|
## Your Task
|
|
1198
1198
|
|
|
1199
|
-
1. **Create a filter component** based on the user's request
|
|
1200
|
-
2. **Update
|
|
1199
|
+
1. **Create a filter component** based on the user's request
|
|
1200
|
+
2. **Update existing components** with dynamic title/description interpolation if needed
|
|
1201
|
+
3. **Preserve all existing props** - the filter system handles param merging at runtime
|
|
1201
1202
|
|
|
1202
|
-
## Filter
|
|
1203
|
+
## How The Filter System Works
|
|
1203
1204
|
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
- **MultiSelect**: For multiple value selection
|
|
1209
|
-
- **SearchBox**: For text search filtering
|
|
1210
|
-
- **NumberRange**: For numeric range filtering
|
|
1205
|
+
1. Filter component has a \`filters\` array with preset options, each containing \`label\`, \`value\`, and \`params\`
|
|
1206
|
+
2. When user selects a filter option, those \`params\` are broadcast to all listening components
|
|
1207
|
+
3. Components automatically merge filter params with their existing params (filter values override defaults)
|
|
1208
|
+
4. Component titles/descriptions can use \`{%filterKeyLabel%}\` syntax for dynamic text
|
|
1211
1209
|
|
|
1212
1210
|
## Filter Component Structure
|
|
1213
1211
|
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
"componentType": "DateRangePicker | Dropdown | SearchBox | etc.",
|
|
1219
|
-
"componentName": "Display Name",
|
|
1220
|
-
"props": {
|
|
1221
|
-
"filterId": "unique_filter_id",
|
|
1222
|
-
"label": "Filter Label",
|
|
1223
|
-
"defaultValue": "optional default value",
|
|
1224
|
-
"options": []
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
\`\`\`
|
|
1212
|
+
The filter uses DynamicFilterDropdown with:
|
|
1213
|
+
- **filterKey**: Identifier for label interpolation (e.g., "period", "name", "category")
|
|
1214
|
+
- **filters**: Array of options with label, value, params, and optionally isDefault
|
|
1215
|
+
- **defaultValue**: The value of the initially selected option
|
|
1228
1216
|
|
|
1229
|
-
##
|
|
1217
|
+
## Dynamic Title/Description Interpolation
|
|
1230
1218
|
|
|
1231
|
-
|
|
1219
|
+
Use \`{%filterKeyLabel%}\` syntax for dynamic text:
|
|
1220
|
+
- filterKey "period" \u2192 use \`{%periodLabel%}\` in titles/descriptions
|
|
1221
|
+
- filterKey "name" \u2192 use \`{%nameLabel%}\` in titles/descriptions
|
|
1222
|
+
- Example: \`"{%periodLabel%} Revenue"\` becomes "Q3 2025 Revenue" when user selects "Q3 2025"
|
|
1232
1223
|
|
|
1233
|
-
|
|
1234
|
-
-
|
|
1235
|
-
-
|
|
1224
|
+
**CRITICAL Template Syntax:**
|
|
1225
|
+
- Use \`{%keyLabel%}\` format (percent signs, key + "Label" suffix)
|
|
1226
|
+
- Do NOT use \`{{...}}\` or \`$...\` syntax - these don't work
|
|
1236
1227
|
|
|
1237
|
-
|
|
1238
|
-
- Add filter params to the tool's params object with binding reference
|
|
1239
|
-
|
|
1240
|
-
## Filter Bindings
|
|
1241
|
-
|
|
1242
|
-
Use this binding format to connect filter values to component params:
|
|
1243
|
-
\`\`\`json
|
|
1244
|
-
{
|
|
1245
|
-
"paramName": "$filter.filterId.value"
|
|
1246
|
-
}
|
|
1247
|
-
\`\`\`
|
|
1248
|
-
|
|
1249
|
-
For DateRangePicker:
|
|
1250
|
-
- \`$filter.filterId.startDate\`
|
|
1251
|
-
- \`$filter.filterId.endDate\`
|
|
1228
|
+
## Updating Existing Components
|
|
1252
1229
|
|
|
1253
|
-
|
|
1254
|
-
-
|
|
1230
|
+
**IMPORTANT - Parameter Handling:**
|
|
1231
|
+
- Do NOT change existing parameter values to placeholders
|
|
1232
|
+
- Keep all existing/default parameter values as they are
|
|
1233
|
+
- The filter system MERGES params at runtime: filter params override component defaults
|
|
1255
1234
|
|
|
1256
|
-
|
|
1257
|
-
-
|
|
1235
|
+
**What to modify in existing components:**
|
|
1236
|
+
- Modify \`title\` for \`{%filterKeyLabel%}\` interpolation (only if title exists)
|
|
1237
|
+
- Modify \`description\` for interpolation (only if description exists)
|
|
1238
|
+
- Modify other props only if specifically needed for the filter to function
|
|
1239
|
+
- Copy ALL other props exactly as provided
|
|
1258
1240
|
|
|
1259
1241
|
### Database Query Rules
|
|
1260
1242
|
{{DATABASE_RULES}}
|
|
@@ -1265,53 +1247,48 @@ You MUST respond with ONLY a valid JSON object (no markdown, no code blocks):
|
|
|
1265
1247
|
|
|
1266
1248
|
{
|
|
1267
1249
|
"filterComponent": {
|
|
1268
|
-
"
|
|
1269
|
-
"
|
|
1270
|
-
"
|
|
1250
|
+
"id": "filter-<descriptive-id>",
|
|
1251
|
+
"name": "DynamicFilterDropdown",
|
|
1252
|
+
"type": "FilterDropdown",
|
|
1271
1253
|
"props": {
|
|
1272
|
-
"
|
|
1273
|
-
"
|
|
1274
|
-
"defaultValue":
|
|
1275
|
-
"
|
|
1254
|
+
"title": "<Filter display title>",
|
|
1255
|
+
"filterKey": "<key_for_interpolation>",
|
|
1256
|
+
"defaultValue": "<default_option_value>",
|
|
1257
|
+
"filters": [
|
|
1258
|
+
{
|
|
1259
|
+
"label": "<Display label for option>",
|
|
1260
|
+
"value": "<unique_option_value>",
|
|
1261
|
+
"params": { "<param_key>": "<actual_value>", "...": "..." },
|
|
1262
|
+
"isDefault": true
|
|
1263
|
+
}
|
|
1264
|
+
]
|
|
1276
1265
|
}
|
|
1277
1266
|
},
|
|
1278
1267
|
"updatedComponents": [
|
|
1279
1268
|
{
|
|
1280
|
-
"
|
|
1281
|
-
"
|
|
1282
|
-
"
|
|
1269
|
+
"id": "<existing_component_id>",
|
|
1270
|
+
"name": "<existing_component_name>",
|
|
1271
|
+
"type": "<existing_type>",
|
|
1283
1272
|
"props": {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
"
|
|
1287
|
-
"description": "Existing Description",
|
|
1288
|
-
"config": {},
|
|
1289
|
-
"query": {
|
|
1290
|
-
"sql": "SELECT ... WHERE column BETWEEN $startDate AND $endDate",
|
|
1291
|
-
"params": {
|
|
1292
|
-
"existingParam": "existing_value",
|
|
1293
|
-
"startDate": "$filter.filterId.startDate",
|
|
1294
|
-
"endDate": "$filter.filterId.endDate"
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1273
|
+
"...all existing props preserved...",
|
|
1274
|
+
"title": "{%<filterKey>Label%} <rest of title>",
|
|
1275
|
+
"description": "<updated if needed>"
|
|
1297
1276
|
}
|
|
1298
1277
|
}
|
|
1299
1278
|
],
|
|
1300
1279
|
"filterBindings": {
|
|
1301
|
-
"
|
|
1302
|
-
"endDate": "$filter.filterId.endDate"
|
|
1280
|
+
"<param_key>": "Describes which filter param this binds to"
|
|
1303
1281
|
},
|
|
1304
|
-
"reasoning": "Explanation of filter choice and
|
|
1282
|
+
"reasoning": "Explanation of filter choice and what params it provides"
|
|
1305
1283
|
}
|
|
1306
1284
|
|
|
1307
|
-
**CRITICAL:**
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
- Ensure SQL syntax is valid with the new filter conditions
|
|
1285
|
+
**CRITICAL RULES:**
|
|
1286
|
+
1. Return ONLY valid JSON (no markdown code blocks)
|
|
1287
|
+
2. **COPY ALL existing props** - modify title/description for interpolation only if they exist
|
|
1288
|
+
3. **DO NOT change parameter values** - keep existing defaults, filter merges at runtime
|
|
1289
|
+
4. Use \`{%filterKeyLabel%}\` for dynamic text (NOT \`{{...}}\` or \`$...\`)
|
|
1290
|
+
5. Filter \`params\` must have ACTUAL values (real dates, strings), not placeholders
|
|
1291
|
+
6. Each filter option needs: label, value, params (and optionally isDefault)
|
|
1315
1292
|
|
|
1316
1293
|
## Database Schema
|
|
1317
1294
|
{{SCHEMA_DOC}}
|
|
@@ -5999,8 +5976,9 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
|
|
|
5999
5976
|
/**
|
|
6000
5977
|
* Adapt UI block parameters based on current user question
|
|
6001
5978
|
* Takes a matched UI block from semantic search and modifies its props to answer the new question
|
|
5979
|
+
* Also adapts the cached text response to match the new question
|
|
6002
5980
|
*/
|
|
6003
|
-
async adaptUIBlockParameters(currentUserPrompt, originalUserPrompt, matchedUIBlock, apiKey, logCollector) {
|
|
5981
|
+
async adaptUIBlockParameters(currentUserPrompt, originalUserPrompt, matchedUIBlock, apiKey, logCollector, cachedTextResponse) {
|
|
6004
5982
|
try {
|
|
6005
5983
|
const component = matchedUIBlock?.generatedComponentMetadata || matchedUIBlock?.component;
|
|
6006
5984
|
if (!matchedUIBlock || !component) {
|
|
@@ -6016,6 +5994,7 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
|
|
|
6016
5994
|
CURRENT_USER_PROMPT: currentUserPrompt,
|
|
6017
5995
|
MATCHED_UI_BLOCK_COMPONENT: JSON.stringify(component, null, 2),
|
|
6018
5996
|
COMPONENT_PROPS: JSON.stringify(component.props, null, 2),
|
|
5997
|
+
CACHED_TEXT_RESPONSE: cachedTextResponse || "No cached text response available",
|
|
6019
5998
|
SCHEMA_DOC: schemaDoc || "No schema available",
|
|
6020
5999
|
DATABASE_RULES: databaseRules
|
|
6021
6000
|
});
|
|
@@ -6064,6 +6043,7 @@ ${JSON.stringify(tool.requiredFields || [], null, 2)}`;
|
|
|
6064
6043
|
return {
|
|
6065
6044
|
success: true,
|
|
6066
6045
|
adaptedComponent: result.adaptedComponent,
|
|
6046
|
+
adaptedTextResponse: result.adaptedTextResponse,
|
|
6067
6047
|
parametersChanged: result.parametersChanged,
|
|
6068
6048
|
explanation: result.explanation || "Parameters adapted successfully"
|
|
6069
6049
|
};
|
|
@@ -6759,7 +6739,8 @@ ${errorMsg}
|
|
|
6759
6739
|
originalPrompt,
|
|
6760
6740
|
conversationMatch.uiBlock,
|
|
6761
6741
|
apiKey,
|
|
6762
|
-
logCollector
|
|
6742
|
+
logCollector,
|
|
6743
|
+
cachedTextResponse
|
|
6763
6744
|
);
|
|
6764
6745
|
if (adaptResult.success && adaptResult.adaptedComponent) {
|
|
6765
6746
|
const elapsedTime2 = Date.now() - startTime;
|
|
@@ -6767,15 +6748,16 @@ ${errorMsg}
|
|
|
6767
6748
|
logger.info(`[${this.getProviderName()}] Total time taken: ${elapsedTime2}ms (${(elapsedTime2 / 1e3).toFixed(2)}s)`);
|
|
6768
6749
|
logCollector?.info(`\u2713 UI block adapted successfully`);
|
|
6769
6750
|
logCollector?.info(`Total time taken: ${elapsedTime2}ms (${(elapsedTime2 / 1e3).toFixed(2)}s)`);
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6751
|
+
const textResponseToUse = adaptResult.adaptedTextResponse || cachedTextResponse;
|
|
6752
|
+
if (streamCallback && textResponseToUse) {
|
|
6753
|
+
logger.info(`[${this.getProviderName()}] Streaming ${adaptResult.adaptedTextResponse ? "adapted" : "cached"} text response to frontend`);
|
|
6754
|
+
streamCallback(textResponseToUse);
|
|
6773
6755
|
}
|
|
6774
6756
|
const cachedActions = conversationMatch.uiBlock?.actions || [];
|
|
6775
6757
|
return {
|
|
6776
6758
|
success: true,
|
|
6777
6759
|
data: {
|
|
6778
|
-
text:
|
|
6760
|
+
text: textResponseToUse,
|
|
6779
6761
|
component: adaptResult.adaptedComponent,
|
|
6780
6762
|
matchedComponents: adaptResult.adaptedComponent?.props?.config?.components || [],
|
|
6781
6763
|
actions: cachedActions,
|
|
@@ -10535,13 +10517,13 @@ async function pickComponentWithLLM(prompt, components, anthropicApiKey, groqApi
|
|
|
10535
10517
|
});
|
|
10536
10518
|
return { success: false, errors };
|
|
10537
10519
|
}
|
|
10538
|
-
const originalComponent = components.find((c) => c.
|
|
10520
|
+
const originalComponent = components.find((c) => c.name === result.componentName);
|
|
10539
10521
|
if (!originalComponent) {
|
|
10540
|
-
errors.push(`Component ${result.
|
|
10522
|
+
errors.push(`Component ${result.componentName} not found in available components`);
|
|
10541
10523
|
userPromptErrorLogger.logError("DASH_COMP_REQ", "Component not found", {
|
|
10542
10524
|
prompt,
|
|
10543
|
-
|
|
10544
|
-
|
|
10525
|
+
componentName: result.componentName,
|
|
10526
|
+
availableComponentNames: components.map((c) => c.name)
|
|
10545
10527
|
});
|
|
10546
10528
|
return { success: false, errors };
|
|
10547
10529
|
}
|