bluera-knowledge 0.12.7 → 0.12.9
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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +39 -0
- package/dist/{chunk-PFBSZTP3.js → chunk-4ZBK7V54.js} +2 -2
- package/dist/{chunk-QCSFBMYW.js → chunk-6777ULXC.js} +2 -2
- package/dist/{chunk-C4SYGLAI.js → chunk-VTATT3IR.js} +145 -66
- package/dist/chunk-VTATT3IR.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/mcp/server.js +2 -2
- package/dist/workers/background-worker-cli.js +20 -5
- package/dist/workers/background-worker-cli.js.map +1 -1
- package/package.json +1 -1
- package/src/db/embeddings.ts +11 -0
- package/src/db/lance.ts +23 -14
- package/src/services/index.ts +9 -0
- package/src/services/job.service.ts +3 -4
- package/src/services/services.test.ts +21 -0
- package/src/services/store.service.test.ts +24 -0
- package/src/services/store.service.ts +15 -7
- package/src/types/document.ts +25 -1
- package/src/types/job.ts +46 -31
- package/src/workers/background-worker-cli.ts +30 -4
- package/src/workers/background-worker.test.ts +4 -1
- package/dist/chunk-C4SYGLAI.js.map +0 -1
- /package/dist/{chunk-PFBSZTP3.js.map → chunk-4ZBK7V54.js.map} +0 -0
- /package/dist/{chunk-QCSFBMYW.js.map → chunk-6777ULXC.js.map} +0 -0
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { platform } from 'os';
|
|
2
3
|
import { BackgroundWorker } from './background-worker.js';
|
|
3
4
|
import { writePidFile, deletePidFile, buildPidFilePath } from './pid-file.js';
|
|
4
5
|
import { createLogger, shutdownLogger } from '../logging/index.js';
|
|
5
|
-
import { createServices } from '../services/index.js';
|
|
6
|
+
import { createServices, destroyServices } from '../services/index.js';
|
|
6
7
|
import { JobService } from '../services/job.service.js';
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Force exit the process to avoid ONNX runtime mutex crash on macOS.
|
|
11
|
+
*
|
|
12
|
+
* On macOS, the ONNX runtime (used by transformers.js for embeddings) has a known
|
|
13
|
+
* bug where static mutex cleanup fails during process exit, causing a crash with:
|
|
14
|
+
* "mutex lock failed: Invalid argument"
|
|
15
|
+
*
|
|
16
|
+
* This doesn't affect job completion - all work is done and persisted before exit.
|
|
17
|
+
* Using SIGKILL bypasses the problematic cleanup code.
|
|
18
|
+
*
|
|
19
|
+
* See: https://github.com/microsoft/onnxruntime/issues/24579
|
|
20
|
+
*/
|
|
21
|
+
function forceExitOnMacOS(exitCode: number): void {
|
|
22
|
+
if (platform() === 'darwin') {
|
|
23
|
+
// Give time for any pending I/O to flush
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
process.kill(process.pid, 'SIGKILL');
|
|
26
|
+
}, 100);
|
|
27
|
+
} else {
|
|
28
|
+
process.exit(exitCode);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
8
32
|
const logger = createLogger('background-worker-cli');
|
|
9
33
|
|
|
10
34
|
/**
|
|
@@ -90,8 +114,9 @@ async function main(): Promise<void> {
|
|
|
90
114
|
}
|
|
91
115
|
|
|
92
116
|
logger.info({ jobId }, 'Job completed successfully');
|
|
117
|
+
await destroyServices(services);
|
|
93
118
|
await shutdownLogger();
|
|
94
|
-
|
|
119
|
+
forceExitOnMacOS(0);
|
|
95
120
|
} catch (error) {
|
|
96
121
|
// Job service already updated with failure status in BackgroundWorker
|
|
97
122
|
logger.error(
|
|
@@ -108,8 +133,9 @@ async function main(): Promise<void> {
|
|
|
108
133
|
);
|
|
109
134
|
}
|
|
110
135
|
|
|
136
|
+
await destroyServices(services);
|
|
111
137
|
await shutdownLogger();
|
|
112
|
-
|
|
138
|
+
forceExitOnMacOS(1);
|
|
113
139
|
}
|
|
114
140
|
}
|
|
115
141
|
|
|
@@ -119,5 +145,5 @@ main().catch(async (error: unknown) => {
|
|
|
119
145
|
'Fatal error in background worker'
|
|
120
146
|
);
|
|
121
147
|
await shutdownLogger();
|
|
122
|
-
|
|
148
|
+
forceExitOnMacOS(1);
|
|
123
149
|
});
|
|
@@ -59,7 +59,10 @@ describe('BackgroundWorker', () => {
|
|
|
59
59
|
details: { storeId: 'test' },
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
// Zod validation catches invalid job type when reading the job file
|
|
63
|
+
await expect(worker.executeJob(job.id)).rejects.toThrow(
|
|
64
|
+
/Invalid option.*clone.*index.*crawl/
|
|
65
|
+
);
|
|
63
66
|
});
|
|
64
67
|
|
|
65
68
|
it('should set job to running status before execution', async () => {
|