@rag-forge/shared 0.1.0

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.
@@ -0,0 +1,14 @@
1
+ interface PythonBridgeOptions {
2
+ module: string;
3
+ args?: string[];
4
+ cwd?: string;
5
+ }
6
+ interface PythonBridgeResult {
7
+ stdout: string;
8
+ stderr: string;
9
+ exitCode: number;
10
+ }
11
+ declare function runPythonModule(options: PythonBridgeOptions): Promise<PythonBridgeResult>;
12
+ declare function checkPythonAvailable(): Promise<boolean>;
13
+
14
+ export { type PythonBridgeOptions, type PythonBridgeResult, checkPythonAvailable, runPythonModule };
@@ -0,0 +1,38 @@
1
+ // src/python-bridge.ts
2
+ import { execa } from "execa";
3
+ async function runPythonModule(options) {
4
+ const { module, args = [], cwd } = options;
5
+ try {
6
+ const result = await execa("uv", ["run", "python", "-m", module, ...args], {
7
+ cwd,
8
+ reject: false,
9
+ timeout: 3e5
10
+ // 5 minute timeout
11
+ });
12
+ return {
13
+ stdout: result.stdout,
14
+ stderr: result.stderr,
15
+ exitCode: result.exitCode ?? (result.signal ? 1 : 0)
16
+ };
17
+ } catch (error) {
18
+ const message = error instanceof Error ? error.message : "Unknown error";
19
+ return {
20
+ stdout: "",
21
+ stderr: message,
22
+ exitCode: 1
23
+ };
24
+ }
25
+ }
26
+ async function checkPythonAvailable() {
27
+ try {
28
+ const result = await execa("uv", ["run", "python", "--version"], { reject: false });
29
+ return result.exitCode === 0;
30
+ } catch {
31
+ return false;
32
+ }
33
+ }
34
+ export {
35
+ checkPythonAvailable,
36
+ runPythonModule
37
+ };
38
+ //# sourceMappingURL=python-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/python-bridge.ts"],"sourcesContent":["import { execa } from \"execa\";\n\nexport interface PythonBridgeOptions {\n module: string;\n args?: string[];\n cwd?: string;\n}\n\nexport interface PythonBridgeResult {\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\nexport async function runPythonModule(options: PythonBridgeOptions): Promise<PythonBridgeResult> {\n const { module, args = [], cwd } = options;\n\n try {\n const result = await execa(\"uv\", [\"run\", \"python\", \"-m\", module, ...args], {\n cwd,\n reject: false,\n timeout: 300_000, // 5 minute timeout\n });\n\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode ?? (result.signal ? 1 : 0),\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Unknown error\";\n return {\n stdout: \"\",\n stderr: message,\n exitCode: 1,\n };\n }\n}\n\nexport async function checkPythonAvailable(): Promise<boolean> {\n try {\n const result = await execa(\"uv\", [\"run\", \"python\", \"--version\"], { reject: false });\n return result.exitCode === 0;\n } catch {\n return false;\n }\n}\n"],"mappings":";AAAA,SAAS,aAAa;AActB,eAAsB,gBAAgB,SAA2D;AAC/F,QAAM,EAAE,QAAQ,OAAO,CAAC,GAAG,IAAI,IAAI;AAEnC,MAAI;AACF,UAAM,SAAS,MAAM,MAAM,MAAM,CAAC,OAAO,UAAU,MAAM,QAAQ,GAAG,IAAI,GAAG;AAAA,MACzE;AAAA,MACA,QAAQ;AAAA,MACR,SAAS;AAAA;AAAA,IACX,CAAC;AAED,WAAO;AAAA,MACL,QAAQ,OAAO;AAAA,MACf,QAAQ,OAAO;AAAA,MACf,UAAU,OAAO,aAAa,OAAO,SAAS,IAAI;AAAA,IACpD;AAAA,EACF,SAAS,OAAO;AACd,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAEA,eAAsB,uBAAyC;AAC7D,MAAI;AACF,UAAM,SAAS,MAAM,MAAM,MAAM,CAAC,OAAO,UAAU,WAAW,GAAG,EAAE,QAAQ,MAAM,CAAC;AAClF,WAAO,OAAO,aAAa;AAAA,EAC7B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@rag-forge/shared",
3
+ "version": "0.1.0",
4
+ "description": "Internal shared utilities for RAG-Forge packages",
5
+ "author": "Femi Adedayo",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/hallengray/rag-forge.git",
9
+ "directory": "packages/shared"
10
+ },
11
+ "homepage": "https://github.com/hallengray/rag-forge#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/hallengray/rag-forge/issues"
14
+ },
15
+ "keywords": ["rag", "rag-forge", "internal"],
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/python-bridge.js",
20
+ "types": "./dist/python-bridge.d.ts"
21
+ }
22
+ },
23
+ "files": ["dist"],
24
+ "scripts": {
25
+ "build": "tsup",
26
+ "typecheck": "tsc --noEmit"
27
+ },
28
+ "dependencies": {
29
+ "execa": "^9.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^22.0.0",
33
+ "tsup": "^8.0.0",
34
+ "typescript": "^5.5.0"
35
+ },
36
+ "engines": {
37
+ "node": ">=20.0.0"
38
+ },
39
+ "license": "MIT"
40
+ }