@shaykec/bridge 0.4.16 → 0.4.17
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 +1 -1
- package/src/claude-session.js +9 -2
package/package.json
CHANGED
package/src/claude-session.js
CHANGED
|
@@ -21,16 +21,23 @@ import {
|
|
|
21
21
|
} from '@shaykec/shared';
|
|
22
22
|
|
|
23
23
|
import { execSync } from 'child_process';
|
|
24
|
+
import { createRequire } from 'module';
|
|
24
25
|
|
|
25
26
|
// Lazy-load the Agent SDK — auto-installs on first use if missing
|
|
26
27
|
let _sdk = null;
|
|
27
28
|
let _sdkLoadError = null;
|
|
28
29
|
|
|
30
|
+
function tryRequireSDK() {
|
|
31
|
+
// Use createRequire to avoid Node's ESM import cache (which caches failures)
|
|
32
|
+
const require = createRequire(import.meta.url);
|
|
33
|
+
return require('@anthropic-ai/claude-agent-sdk');
|
|
34
|
+
}
|
|
35
|
+
|
|
29
36
|
async function getSDK() {
|
|
30
37
|
if (_sdk) return _sdk;
|
|
31
38
|
if (_sdkLoadError) throw _sdkLoadError;
|
|
32
39
|
try {
|
|
33
|
-
_sdk =
|
|
40
|
+
_sdk = tryRequireSDK();
|
|
34
41
|
return _sdk;
|
|
35
42
|
} catch {
|
|
36
43
|
// SDK not installed — try to install it automatically
|
|
@@ -40,7 +47,7 @@ async function getSDK() {
|
|
|
40
47
|
stdio: 'inherit',
|
|
41
48
|
timeout: 60000,
|
|
42
49
|
});
|
|
43
|
-
_sdk =
|
|
50
|
+
_sdk = tryRequireSDK();
|
|
44
51
|
console.log('[chat] Agent SDK installed successfully.');
|
|
45
52
|
return _sdk;
|
|
46
53
|
} catch (installErr) {
|