@eclaw/openclaw-channel 1.0.7 → 1.0.8
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/gateway.js +18 -6
- package/package.json +1 -1
package/dist/gateway.js
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { createServer } from 'node:http';
|
|
2
2
|
import { randomBytes } from 'node:crypto';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
3
6
|
import { resolveAccount } from './config.js';
|
|
4
7
|
import { EClawClient } from './client.js';
|
|
5
8
|
import { setClient } from './outbound.js';
|
|
6
9
|
import { createWebhookHandler } from './webhook-handler.js';
|
|
10
|
+
/** Read full openclaw.json config from disk */
|
|
11
|
+
function readFullConfig() {
|
|
12
|
+
const configPath = process.env.OPENCLAW_CONFIG_PATH
|
|
13
|
+
|| join(homedir(), '.openclaw', 'openclaw.json');
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(readFileSync(configPath, 'utf8'));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
7
21
|
/**
|
|
8
22
|
* Gateway lifecycle: start an E-Claw account.
|
|
9
23
|
*
|
|
@@ -15,12 +29,10 @@ import { createWebhookHandler } from './webhook-handler.js';
|
|
|
15
29
|
*/
|
|
16
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
31
|
export async function startAccount(ctx) {
|
|
18
|
-
const { accountId
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const account = resolveAccount(config, accountId);
|
|
23
|
-
console.log(`[E-Claw] resolved account: enabled=${account.enabled}, apiKey=${account.apiKey ? 'SET' : 'MISSING'}`);
|
|
32
|
+
const { accountId } = ctx;
|
|
33
|
+
// OpenClaw passes an empty config object to the gateway — read config from disk directly
|
|
34
|
+
const fullConfig = readFullConfig();
|
|
35
|
+
const account = resolveAccount(fullConfig, accountId);
|
|
24
36
|
if (!account.enabled || !account.apiKey) {
|
|
25
37
|
console.log(`[E-Claw] Account ${accountId} disabled or missing credentials, skipping`);
|
|
26
38
|
return;
|