@ashx-j/lunr-ai 0.2.25 → 0.2.27

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,16 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ /** External Python needs physical files, including when JavaScript lives in Bun's virtual filesystem. */
5
+ export function getClaudeCodeWorkerPath(worker, runtime = { moduleUrl: import.meta.url, execPath: process.execPath }) {
6
+ const compiled = /\$bunfs|~BUN|%7EBUN/i.test(runtime.moduleUrl);
7
+ const directory = compiled
8
+ ? join(dirname(runtime.execPath), "vendor", "hermes-claude-subscription-directsdk")
9
+ : fileURLToPath(new URL("../../vendor/hermes-claude-subscription-directsdk/", runtime.moduleUrl));
10
+ const path = join(directory, worker);
11
+ if (!existsSync(path)) {
12
+ throw new Error("Claude Code subscription worker is missing. Reinstall the complete lunR package or extract the complete standalone archive.");
13
+ }
14
+ return path;
15
+ }
16
+ //# sourceMappingURL=claude-code-assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-code-assets.js","sourceRoot":"","sources":["../../src/utils/claude-code-assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,yGAAyG;AACzG,MAAM,UAAU,uBAAuB,CACtC,MAAwB,EACxB,OAAO,GAAG,EAAE,SAAS,EAAE,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,EAC3D;IACT,MAAM,QAAQ,GAAG,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,QAAQ;QACzB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,sCAAsC,CAAC;QACnF,CAAC,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,oDAAoD,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IACnG,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACd,6HAA6H,CAC7H,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AAAA,CACZ","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\ntype ClaudeCodeWorker = \"lunr_bridge.py\" | \"lunr_setup_bridge.py\";\n\n/** External Python needs physical files, including when JavaScript lives in Bun's virtual filesystem. */\nexport function getClaudeCodeWorkerPath(\n\tworker: ClaudeCodeWorker,\n\truntime = { moduleUrl: import.meta.url, execPath: process.execPath },\n): string {\n\tconst compiled = /\\$bunfs|~BUN|%7EBUN/i.test(runtime.moduleUrl);\n\tconst directory = compiled\n\t\t? join(dirname(runtime.execPath), \"vendor\", \"hermes-claude-subscription-directsdk\")\n\t\t: fileURLToPath(new URL(\"../../vendor/hermes-claude-subscription-directsdk/\", runtime.moduleUrl));\n\tconst path = join(directory, worker);\n\tif (!existsSync(path)) {\n\t\tthrow new Error(\n\t\t\t\"Claude Code subscription worker is missing. Reinstall the complete lunR package or extract the complete standalone archive.\",\n\t\t);\n\t}\n\treturn path;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ashx-j/lunr-ai",
3
- "version": "0.2.25",
3
+ "version": "0.2.27",
4
4
  "description": "Unified LLM API with automatic model discovery and provider configuration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,6 +18,30 @@ def emit(request_id, kind, **fields):
18
18
  sys.stdout.flush()
19
19
 
20
20
 
21
+ def error_category(error):
22
+ """Retain recovery categories only; native exception text never crosses the bridge."""
23
+ if isinstance(error, (TimeoutError, subprocess.TimeoutExpired)):
24
+ return 'timeout'
25
+ # Only interpret errors emitted by the pinned transport, not arbitrary private text.
26
+ text = str(error).lower()
27
+ if not isinstance(error, RuntimeError) or not text.startswith((
28
+ 'native api error:', 'incomplete upstream response (', 'incomplete native response:')):
29
+ return 'setup'
30
+ if re.search(r'prompt is too long|request_too_large|context[_ ]length[_ ]exceeded|exceeds the context window', text):
31
+ return 'context_overflow'
32
+ if re.search(r'rate[_ ]limit|too many requests|\b429\b', text):
33
+ return 'rate_limit'
34
+ if re.search(r'overloaded|overload|\b529\b', text):
35
+ return 'overloaded'
36
+ if re.search(r'timed? out|timeout', text):
37
+ return 'timeout'
38
+ if re.search(r'\b50[0234]\b|service unavailable|internal server error|network error|connection (?:reset|refused|lost)', text):
39
+ return 'transient'
40
+ if text.startswith('incomplete native response:') or re.search(r'status 200, capture incomplete', text):
41
+ return 'incomplete'
42
+ return 'setup'
43
+
44
+
21
45
  def main():
22
46
  line = sys.stdin.buffer.readline(MAX_RECORD + 1)
23
47
  if not line or len(line) > MAX_RECORD:
@@ -77,9 +101,9 @@ def main():
77
101
  response = chunk._response.model_dump()
78
102
  emit(request_id, 'complete', response=response)
79
103
  return 0
80
- except Exception:
104
+ except Exception as error:
81
105
  emit(request_id, 'cancelled' if cancelled.is_set() else 'error',
82
- message='Claude Code request failed. Check subscription setup and native CLI compatibility.')
106
+ category=error_category(error))
83
107
  return 1
84
108
  finally:
85
109
  client.close()