@superatomai/sdk-node 0.0.35 → 0.0.37
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +63 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +49 -48
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2028,6 +2028,7 @@ var DashboardsRequestPayloadSchema = import_zod3.z.object({
|
|
|
2028
2028
|
published: import_zod3.z.boolean().optional(),
|
|
2029
2029
|
createdBy: import_zod3.z.number().optional(),
|
|
2030
2030
|
updatedBy: import_zod3.z.number().optional(),
|
|
2031
|
+
allowedUsers: import_zod3.z.array(import_zod3.z.number()).optional(),
|
|
2031
2032
|
dashboard: DSLRendererPropsSchema.optional(),
|
|
2032
2033
|
// Query operation fields
|
|
2033
2034
|
filters: DashboardQueryFiltersSchema.optional(),
|
|
@@ -3585,18 +3586,26 @@ var LLM = class {
|
|
|
3585
3586
|
const client = new import_sdk.default({
|
|
3586
3587
|
apiKey
|
|
3587
3588
|
});
|
|
3589
|
+
const apiMessages = [{
|
|
3590
|
+
role: "user",
|
|
3591
|
+
content: messages.user
|
|
3592
|
+
}];
|
|
3593
|
+
const prefill = messages.prefill || (json ? "{" : void 0);
|
|
3594
|
+
if (prefill) {
|
|
3595
|
+
apiMessages.push({
|
|
3596
|
+
role: "assistant",
|
|
3597
|
+
content: prefill
|
|
3598
|
+
});
|
|
3599
|
+
}
|
|
3588
3600
|
const stream = await client.messages.create({
|
|
3589
3601
|
model: modelName,
|
|
3590
3602
|
max_tokens: options.maxTokens || 1e3,
|
|
3591
3603
|
temperature: options.temperature,
|
|
3592
3604
|
system: this._normalizeSystemPrompt(messages.sys),
|
|
3593
|
-
messages:
|
|
3594
|
-
role: "user",
|
|
3595
|
-
content: messages.user
|
|
3596
|
-
}],
|
|
3605
|
+
messages: apiMessages,
|
|
3597
3606
|
stream: true
|
|
3598
3607
|
});
|
|
3599
|
-
let fullText = "";
|
|
3608
|
+
let fullText = prefill || "";
|
|
3600
3609
|
let usage = null;
|
|
3601
3610
|
for await (const chunk of stream) {
|
|
3602
3611
|
if (chunk.type === "content_block_delta" && chunk.delta.type === "text_delta") {
|
|
@@ -4132,40 +4141,56 @@ var LLM = class {
|
|
|
4132
4141
|
openChar = "[";
|
|
4133
4142
|
closeChar = "]";
|
|
4134
4143
|
}
|
|
4135
|
-
if (startIdx
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4144
|
+
if (startIdx === -1) {
|
|
4145
|
+
const preview = text.length > 500 ? text.substring(0, 500) + "..." : text;
|
|
4146
|
+
throw new Error(`No JSON found in response. LLM returned plain text instead of JSON.
|
|
4147
|
+
|
|
4148
|
+
Full response:
|
|
4149
|
+
${preview}`);
|
|
4150
|
+
}
|
|
4151
|
+
let depth = 0;
|
|
4152
|
+
let inString = false;
|
|
4153
|
+
let endIdx = -1;
|
|
4154
|
+
for (let i = startIdx; i < jsonText.length; i++) {
|
|
4155
|
+
const char = jsonText[i];
|
|
4156
|
+
const prevChar = i > 0 ? jsonText[i - 1] : "";
|
|
4157
|
+
if (char === '"' && prevChar !== "\\") {
|
|
4158
|
+
inString = !inString;
|
|
4159
|
+
continue;
|
|
4160
|
+
}
|
|
4161
|
+
if (!inString) {
|
|
4162
|
+
if (char === openChar) {
|
|
4163
|
+
depth++;
|
|
4164
|
+
} else if (char === closeChar) {
|
|
4165
|
+
depth--;
|
|
4166
|
+
if (depth === 0) {
|
|
4167
|
+
endIdx = i;
|
|
4168
|
+
break;
|
|
4155
4169
|
}
|
|
4156
4170
|
}
|
|
4157
4171
|
}
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4172
|
+
}
|
|
4173
|
+
if (endIdx !== -1) {
|
|
4174
|
+
jsonText = jsonText.substring(startIdx, endIdx + 1);
|
|
4175
|
+
} else {
|
|
4176
|
+
const preview = text.length > 500 ? text.substring(0, 500) + "..." : text;
|
|
4177
|
+
throw new Error(`Incomplete JSON - no matching closing ${closeChar} found.
|
|
4178
|
+
|
|
4179
|
+
Full response:
|
|
4180
|
+
${preview}`);
|
|
4161
4181
|
}
|
|
4162
4182
|
try {
|
|
4163
4183
|
const repairedJson = (0, import_jsonrepair.jsonrepair)(jsonText);
|
|
4164
4184
|
return JSON.parse(repairedJson);
|
|
4165
4185
|
} catch (error) {
|
|
4186
|
+
const preview = text.length > 500 ? text.substring(0, 500) + "..." : text;
|
|
4166
4187
|
throw new Error(`Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}
|
|
4167
4188
|
|
|
4168
|
-
|
|
4189
|
+
Extracted JSON:
|
|
4190
|
+
${jsonText.substring(0, 300)}...
|
|
4191
|
+
|
|
4192
|
+
Full response:
|
|
4193
|
+
${preview}`);
|
|
4169
4194
|
}
|
|
4170
4195
|
}
|
|
4171
4196
|
};
|
|
@@ -7500,6 +7525,7 @@ async function handleDashboardsRequest(data, collections, sendMessage) {
|
|
|
7500
7525
|
const published = requestData?.published;
|
|
7501
7526
|
const createdBy = requestData?.createdBy;
|
|
7502
7527
|
const updatedBy = requestData?.updatedBy;
|
|
7528
|
+
const allowedUsers = requestData?.allowedUsers;
|
|
7503
7529
|
const numericId = requestData?.id;
|
|
7504
7530
|
const filters = requestData?.filters;
|
|
7505
7531
|
const limit = requestData?.limit;
|
|
@@ -7515,10 +7541,10 @@ async function handleDashboardsRequest(data, collections, sendMessage) {
|
|
|
7515
7541
|
const dashboardManager2 = getDashboardManager();
|
|
7516
7542
|
switch (operation) {
|
|
7517
7543
|
case "create":
|
|
7518
|
-
await handleCreate2(id, dashboardId, dashboard, projectId, name, description, published, createdBy, executeCollection, dashboardManager2, sendMessage, from.id);
|
|
7544
|
+
await handleCreate2(id, dashboardId, dashboard, projectId, name, description, published, createdBy, allowedUsers, executeCollection, dashboardManager2, sendMessage, from.id);
|
|
7519
7545
|
break;
|
|
7520
7546
|
case "update":
|
|
7521
|
-
await handleUpdate2(id, numericId, dashboardId, dashboard, name, description, published, updatedBy, executeCollection, dashboardManager2, sendMessage, from.id);
|
|
7547
|
+
await handleUpdate2(id, numericId, dashboardId, dashboard, name, description, published, updatedBy, allowedUsers, executeCollection, dashboardManager2, sendMessage, from.id);
|
|
7522
7548
|
break;
|
|
7523
7549
|
case "delete":
|
|
7524
7550
|
await handleDelete2(id, numericId, dashboardId, executeCollection, dashboardManager2, sendMessage, from.id);
|
|
@@ -7546,7 +7572,7 @@ async function handleDashboardsRequest(data, collections, sendMessage) {
|
|
|
7546
7572
|
}, sendMessage);
|
|
7547
7573
|
}
|
|
7548
7574
|
}
|
|
7549
|
-
async function handleCreate2(id, dashboardId, dashboard, projectId, name, description, published, createdBy, executeCollection, dashboardManager2, sendMessage, clientId) {
|
|
7575
|
+
async function handleCreate2(id, dashboardId, dashboard, projectId, name, description, published, createdBy, allowedUsers, executeCollection, dashboardManager2, sendMessage, clientId) {
|
|
7550
7576
|
if (!dashboardId || dashboardId.trim().length === 0) {
|
|
7551
7577
|
sendResponse4(id, {
|
|
7552
7578
|
success: false,
|
|
@@ -7569,7 +7595,8 @@ async function handleCreate2(id, dashboardId, dashboard, projectId, name, descri
|
|
|
7569
7595
|
description,
|
|
7570
7596
|
dashboard,
|
|
7571
7597
|
published,
|
|
7572
|
-
createdBy
|
|
7598
|
+
createdBy,
|
|
7599
|
+
allowedUsers
|
|
7573
7600
|
});
|
|
7574
7601
|
if (result && result.success) {
|
|
7575
7602
|
logger.info(`[DB] Dashboard created successfully, ID: ${result.data?.id}`);
|
|
@@ -7608,7 +7635,7 @@ async function handleCreate2(id, dashboardId, dashboard, projectId, name, descri
|
|
|
7608
7635
|
}, sendMessage, clientId);
|
|
7609
7636
|
}
|
|
7610
7637
|
}
|
|
7611
|
-
async function handleUpdate2(id, numericId, dashboardId, dashboard, name, description, published, updatedBy, executeCollection, dashboardManager2, sendMessage, clientId) {
|
|
7638
|
+
async function handleUpdate2(id, numericId, dashboardId, dashboard, name, description, published, updatedBy, allowedUsers, executeCollection, dashboardManager2, sendMessage, clientId) {
|
|
7612
7639
|
if (!numericId) {
|
|
7613
7640
|
sendResponse4(id, {
|
|
7614
7641
|
success: false,
|
|
@@ -7623,7 +7650,8 @@ async function handleUpdate2(id, numericId, dashboardId, dashboard, name, descri
|
|
|
7623
7650
|
description,
|
|
7624
7651
|
dashboard,
|
|
7625
7652
|
published,
|
|
7626
|
-
updatedBy
|
|
7653
|
+
updatedBy,
|
|
7654
|
+
allowedUsers
|
|
7627
7655
|
});
|
|
7628
7656
|
if (result && result.success) {
|
|
7629
7657
|
logger.info(`[DB] Dashboard updated successfully, ID: ${numericId}`);
|