@clawchatsai/connector 0.1.0 → 0.1.1
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/dist/index.js +8 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,6 +18,10 @@ import { dispatchRpc } from './shim.js';
|
|
|
18
18
|
import { initAuth, handleAuthMessage, cleanupAuth } from './auth-handler.js';
|
|
19
19
|
import { generateTotpSecret, verifyTotp, generateBackupCodes, buildOtpauthUri } from './totp.js';
|
|
20
20
|
import { generateSessionSecret } from './session-token.js';
|
|
21
|
+
import { fileURLToPath } from 'node:url';
|
|
22
|
+
// ESM __dirname polyfill (package.json has "type":"module")
|
|
23
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
24
|
+
const __dirname = path.dirname(__filename);
|
|
21
25
|
// Inline from shared/api-version.ts to avoid rootDir conflict
|
|
22
26
|
const CURRENT_API_VERSION = 1;
|
|
23
27
|
export const PLUGIN_ID = 'connector';
|
|
@@ -45,7 +49,7 @@ let _uploadsDir = null;
|
|
|
45
49
|
// ---------------------------------------------------------------------------
|
|
46
50
|
// Config helpers
|
|
47
51
|
// ---------------------------------------------------------------------------
|
|
48
|
-
const CONFIG_DIR = path.join(
|
|
52
|
+
const CONFIG_DIR = path.join(os.homedir(), '.openclaw', 'clawchats');
|
|
49
53
|
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
50
54
|
const RUNTIME_FILE = path.join(CONFIG_DIR, 'runtime.json');
|
|
51
55
|
function loadConfig() {
|
|
@@ -267,12 +271,7 @@ async function startClawChats(ctx, api, mediaStash) {
|
|
|
267
271
|
}
|
|
268
272
|
});
|
|
269
273
|
// 5. Connect to signaling server
|
|
270
|
-
const _hostname = (
|
|
271
|
-
return require('os').hostname();
|
|
272
|
-
}
|
|
273
|
-
catch {
|
|
274
|
-
return undefined;
|
|
275
|
-
} })();
|
|
274
|
+
const _hostname = os.hostname();
|
|
276
275
|
signaling = new SignalingClient(config.serverUrl, config.userId, config.apiKey, {
|
|
277
276
|
gatewayId: config.gatewayId,
|
|
278
277
|
hostname: _hostname,
|
|
@@ -811,7 +810,7 @@ async function handleSetup(token, options = {}) {
|
|
|
811
810
|
// Read gateway token from OpenClaw config
|
|
812
811
|
let gatewayToken = '';
|
|
813
812
|
try {
|
|
814
|
-
const openclawConfigPath = path.join(
|
|
813
|
+
const openclawConfigPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
|
|
815
814
|
const openclawConfig = JSON.parse(fs.readFileSync(openclawConfigPath, 'utf8'));
|
|
816
815
|
gatewayToken = openclawConfig.gateway?.auth?.token || openclawConfig.auth?.token || openclawConfig.token || '';
|
|
817
816
|
}
|
|
@@ -833,12 +832,7 @@ async function handleSetup(token, options = {}) {
|
|
|
833
832
|
reject(new Error('Setup timed out'));
|
|
834
833
|
}, 30_000);
|
|
835
834
|
ws.on('open', () => {
|
|
836
|
-
const setupHostname = (
|
|
837
|
-
return require('os').hostname();
|
|
838
|
-
}
|
|
839
|
-
catch {
|
|
840
|
-
return undefined;
|
|
841
|
-
} })();
|
|
835
|
+
const setupHostname = os.hostname();
|
|
842
836
|
ws.send(JSON.stringify({
|
|
843
837
|
type: 'setup',
|
|
844
838
|
setupSecret: tokenData.setupSecret,
|