@devness/useai 0.6.1 → 0.6.3
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.js +33 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -684,7 +684,7 @@ var VERSION;
|
|
|
684
684
|
var init_version = __esm({
|
|
685
685
|
"../shared/dist/constants/version.js"() {
|
|
686
686
|
"use strict";
|
|
687
|
-
VERSION = "0.6.
|
|
687
|
+
VERSION = "0.6.3";
|
|
688
688
|
}
|
|
689
689
|
});
|
|
690
690
|
|
|
@@ -5755,7 +5755,7 @@ async function ensureDaemon(options) {
|
|
|
5755
5755
|
npxArgs.push("--prefer-online");
|
|
5756
5756
|
npxArgs.push("@devness/useai@latest", "daemon", "--port", String(DAEMON_PORT));
|
|
5757
5757
|
const child = spawn(npxPath, npxArgs, {
|
|
5758
|
-
detached:
|
|
5758
|
+
detached: !isWindows2,
|
|
5759
5759
|
stdio: "ignore",
|
|
5760
5760
|
shell: isWindows2,
|
|
5761
5761
|
windowsHide: true
|
|
@@ -35205,18 +35205,44 @@ async function handleLocalSync(req, res) {
|
|
|
35205
35205
|
"Content-Type": "application/json",
|
|
35206
35206
|
"Authorization": `Bearer ${token}`
|
|
35207
35207
|
};
|
|
35208
|
-
const CHUNK_SIZE = 50;
|
|
35209
35208
|
const sessions2 = deduplicateSessions(readJson(SESSIONS_FILE, []));
|
|
35210
|
-
|
|
35211
|
-
|
|
35209
|
+
const byDate = /* @__PURE__ */ new Map();
|
|
35210
|
+
for (const s of sessions2) {
|
|
35211
|
+
const date3 = s.started_at.slice(0, 10);
|
|
35212
|
+
const arr = byDate.get(date3);
|
|
35213
|
+
if (arr) arr.push(s);
|
|
35214
|
+
else byDate.set(date3, [s]);
|
|
35215
|
+
}
|
|
35216
|
+
for (const [date3, daySessions] of byDate) {
|
|
35217
|
+
let totalSeconds = 0;
|
|
35218
|
+
const clients = {};
|
|
35219
|
+
const taskTypes = {};
|
|
35220
|
+
const languages = {};
|
|
35221
|
+
for (const s of daySessions) {
|
|
35222
|
+
totalSeconds += s.duration_seconds;
|
|
35223
|
+
clients[s.client] = (clients[s.client] ?? 0) + s.duration_seconds;
|
|
35224
|
+
taskTypes[s.task_type] = (taskTypes[s.task_type] ?? 0) + s.duration_seconds;
|
|
35225
|
+
for (const lang of s.languages) {
|
|
35226
|
+
languages[lang] = (languages[lang] ?? 0) + s.duration_seconds;
|
|
35227
|
+
}
|
|
35228
|
+
}
|
|
35229
|
+
const payload = {
|
|
35230
|
+
date: date3,
|
|
35231
|
+
total_seconds: totalSeconds,
|
|
35232
|
+
clients,
|
|
35233
|
+
task_types: taskTypes,
|
|
35234
|
+
languages,
|
|
35235
|
+
sessions: daySessions,
|
|
35236
|
+
sync_signature: ""
|
|
35237
|
+
};
|
|
35212
35238
|
const sessionsRes = await fetch(`${USEAI_API}/api/sync`, {
|
|
35213
35239
|
method: "POST",
|
|
35214
35240
|
headers,
|
|
35215
|
-
body: JSON.stringify(
|
|
35241
|
+
body: JSON.stringify(payload)
|
|
35216
35242
|
});
|
|
35217
35243
|
if (!sessionsRes.ok) {
|
|
35218
35244
|
const errBody = await sessionsRes.text();
|
|
35219
|
-
json(res, 502, { success: false, error: `Sessions sync failed (
|
|
35245
|
+
json(res, 502, { success: false, error: `Sessions sync failed (${date3}): ${sessionsRes.status} ${errBody}` });
|
|
35220
35246
|
return;
|
|
35221
35247
|
}
|
|
35222
35248
|
}
|