@docsagent/docsagent 1.0.1 → 1.0.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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/bin/pdfium.dll ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docsagent/docsagent",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Private Local Documents Search Assistant",
5
5
  "main": "dist/index.mjs",
6
6
  "bin": {
@@ -9,7 +9,9 @@
9
9
  "da": "./dist/cli.mjs"
10
10
  },
11
11
  "files": [
12
- "dist"
12
+ "dist",
13
+ "bin",
14
+ "scripts"
13
15
  ],
14
16
  "scripts": {
15
17
  "build": "tsup src/index.ts src/cli.ts --format esm --tsconfig tsconfig.json --clean --minify",
@@ -0,0 +1,83 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ const getBinaryInfo = () => {
9
+ const platform = process.platform;
10
+ const arch = process.arch;
11
+
12
+ let binaryName = "";
13
+ let libs = [];
14
+
15
+ if (platform === "darwin") {
16
+ libs = ["libawadb.dylib", "libomp.dylib", "libpdfium.dylib"];
17
+ if (arch === "arm64") {
18
+ binaryName = "docsagent-aarch64-apple-darwin";
19
+ } else if (arch === "x64") {
20
+ binaryName = "docsagent-x86_64-apple-darwin";
21
+ } else {
22
+ binaryName = "docsagent-universal-apple-darwin";
23
+ }
24
+ } else if (platform === "win32") {
25
+ binaryName = "docsagent-x86_64-pc-windows-msvc.exe";
26
+ libs = [
27
+ "libawadb.dll",
28
+ "libcrypto-3-x64.dll",
29
+ "libssl-3-x64.dll",
30
+ "libwinpthread-1.dll",
31
+ "pdfium.dll",
32
+ ];
33
+ } else if (platform === "linux") {
34
+ if (arch === "arm64") {
35
+ binaryName = "docsagent-aarch64-unknown-linux-gnu";
36
+ } else {
37
+ binaryName = "docsagent-x86_64-unknown-linux-gnu";
38
+ }
39
+ libs = ["libawadb.so", "libpdfium.so"];
40
+ }
41
+
42
+ return { binaryName, libs };
43
+ };
44
+
45
+ async function install() {
46
+ const binDir = path.join(__dirname, "../bin");
47
+ const { binaryName, libs } = getBinaryInfo();
48
+
49
+ if (!binaryName) {
50
+ console.error(`Unsupported platform: ${process.platform} ${process.arch}`);
51
+ return;
52
+ }
53
+
54
+ const mainBinaryPath = path.join(binDir, binaryName);
55
+
56
+ if (!fs.existsSync(mainBinaryPath)) {
57
+ console.warn(`Warning: Main binary not found at ${mainBinaryPath}.
58
+ This might happen during local development if you haven't built or placed the binaries yet.`);
59
+ return;
60
+ }
61
+
62
+ try {
63
+ // Set executable permissions for the main binary
64
+ if (process.platform !== "win32") {
65
+ fs.chmodSync(mainBinaryPath, 0o755);
66
+ console.log(`Set executable permissions for ${binaryName}`);
67
+ }
68
+
69
+ // Verify libraries exist
70
+ for (const lib of libs) {
71
+ const libPath = path.join(binDir, lib);
72
+ if (!fs.existsSync(libPath)) {
73
+ console.warn(`Warning: Library ${lib} not found at ${libPath}.`);
74
+ }
75
+ }
76
+
77
+ console.log("DocsAgent binaries verified and configured successfully.");
78
+ } catch (err) {
79
+ console.error(`Post-install configuration failed: ${err.message}`);
80
+ }
81
+ }
82
+
83
+ install();