@b2y/ai-service 1.0.1 → 1.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b2y/ai-service",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Shared AI assistant (Beya) for B2Y applications: global tenant and role/permission access, one provider and model configuration, read-only data, analytics, search and document capabilities, conversation history, server endpoints and a React chat UI and widget.",
5
5
  "keywords": [
6
6
  "b2y",
@@ -26,7 +26,7 @@ export function createFolderConversationStore({ root }) {
26
26
  try {
27
27
  return JSON.parse(await fs.readFile(file, "utf8"));
28
28
  } catch (error) {
29
- if (error?.code === "ENOENT") return null;
29
+ if (error?.code === "ENOENT" || error instanceof SyntaxError) return null;
30
30
  throw error;
31
31
  }
32
32
  };
@@ -56,7 +56,7 @@ export function createFolderConversationStore({ root }) {
56
56
  for (const entry of entries) {
57
57
  const path = join(dir, entry.name);
58
58
  if (entry.isDirectory() && depth < 3) yield* walk(path, depth + 1);
59
- else if (entry.isFile() && depth === 3 && entry.name.endsWith(".json")) yield path;
59
+ else if (entry.isFile() && depth === 3 && (entry.name.endsWith(".json") || entry.name.endsWith(".tmp"))) yield path;
60
60
  }
61
61
  }
62
62
 
@@ -105,6 +105,11 @@ export function createFolderConversationStore({ root }) {
105
105
  async deleteInactiveSince({ cutoff }) {
106
106
  let deleted = 0;
107
107
  for await (const file of walk(base)) {
108
+ if (file.endsWith(".tmp")) {
109
+ const stat = await fs.stat(file).catch(() => null);
110
+ if (stat && stat.mtime.toISOString() < cutoff && (await fs.unlink(file).then(() => true, () => false))) deleted += 1;
111
+ continue;
112
+ }
108
113
  const removed = await exclusive(file, async () => {
109
114
  const current = await read(file);
110
115
  if (current && typeof current.updatedAt === "string" && current.updatedAt >= cutoff) return false;