@devness/useai 0.4.8 → 0.4.10

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.
Files changed (2) hide show
  1. package/dist/index.js +26 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -112,7 +112,7 @@ var VERSION;
112
112
  var init_version = __esm({
113
113
  "../shared/dist/constants/version.js"() {
114
114
  "use strict";
115
- VERSION = "0.4.8";
115
+ VERSION = "0.4.10";
116
116
  }
117
117
  });
118
118
 
@@ -2554,7 +2554,15 @@ function getDashboardHtml() {
2554
2554
  section.style.display = 'block';
2555
2555
  var recent = milestones.slice(-20).reverse();
2556
2556
  list.innerHTML = recent.map(function(m) {
2557
- var date = m.created_at ? m.created_at.slice(0, 10) : '';
2557
+ var date = '';
2558
+ if (m.created_at) {
2559
+ var d = new Date(m.created_at);
2560
+ if (!isNaN(d.getTime())) {
2561
+ date = d.getFullYear() + '-' + String(d.getMonth()+1).padStart(2,'0') + '-' + String(d.getDate()).padStart(2,'0') + ' ' + String(d.getHours()).padStart(2,'0') + ':' + String(d.getMinutes()).padStart(2,'0');
2562
+ } else {
2563
+ date = m.created_at.slice(0, 10);
2564
+ }
2565
+ }
2558
2566
  var dur = fmtDuration(m.duration_minutes);
2559
2567
  return '<div class="milestone-item">' +
2560
2568
  '<div class="milestone-title">' + escapeHtml(m.title) + '</div>' +
@@ -3125,9 +3133,14 @@ function sealOrphanedSessions() {
3125
3133
  console.log(`Sealed ${sealed} orphaned session${sealed === 1 ? "" : "s"}`);
3126
3134
  }
3127
3135
  }
3136
+ function isSessionAlreadySealed(session2) {
3137
+ const activePath = join7(ACTIVE_DIR, `${session2.sessionId}.jsonl`);
3138
+ return !existsSync9(activePath);
3139
+ }
3128
3140
  function autoSealSession(active) {
3129
3141
  const { session: session2 } = active;
3130
3142
  if (session2.sessionRecordCount === 0) return;
3143
+ if (isSessionAlreadySealed(session2)) return;
3131
3144
  const duration = session2.getSessionDuration();
3132
3145
  const now = (/* @__PURE__ */ new Date()).toISOString();
3133
3146
  const endRecord = session2.appendToChain("session_end", {
@@ -3188,6 +3201,10 @@ function autoSealSession(active) {
3188
3201
  allSessions.push(seal);
3189
3202
  writeJson(SESSIONS_FILE, allSessions);
3190
3203
  }
3204
+ function sealSessionData(active) {
3205
+ autoSealSession(active);
3206
+ active.session.reset();
3207
+ }
3191
3208
  function resetIdleTimer(sessionId) {
3192
3209
  const active = sessions.get(sessionId);
3193
3210
  if (!active) return;
@@ -3293,15 +3310,18 @@ async function startDaemon(port) {
3293
3310
  return;
3294
3311
  }
3295
3312
  if (url.pathname === "/api/seal-active" && req.method === "POST") {
3296
- const sids = [...sessions.keys()];
3297
- for (const sid of sids) {
3298
- await cleanupSession(sid);
3313
+ let sealed = 0;
3314
+ for (const [, active] of sessions) {
3315
+ if (active.session.sessionRecordCount > 0 && !isSessionAlreadySealed(active.session)) {
3316
+ sealSessionData(active);
3317
+ sealed++;
3318
+ }
3299
3319
  }
3300
3320
  res.writeHead(200, {
3301
3321
  "Content-Type": "application/json",
3302
3322
  "Access-Control-Allow-Origin": "*"
3303
3323
  });
3304
- res.end(JSON.stringify({ sealed: sids.length }));
3324
+ res.end(JSON.stringify({ sealed }));
3305
3325
  return;
3306
3326
  }
3307
3327
  if ((url.pathname.startsWith("/api/local/") || url.pathname === "/api/seal-active") && req.method === "OPTIONS") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devness/useai",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "Track your AI-assisted development workflow. MCP server that records usage metrics across all your AI tools.",
5
5
  "keywords": [
6
6
  "mcp",