@rethinking-studio/clawcontrol 1.0.1 → 1.0.3
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/index.ts +9 -8
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -76,8 +76,8 @@ const clawcontrolOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
76
76
|
},
|
|
77
77
|
configure: async ({ cfg, prompter }) => {
|
|
78
78
|
const account = resolveClawControlAccount(cfg);
|
|
79
|
-
const
|
|
80
|
-
|
|
79
|
+
const defaultUrl = 'http://8.140.58.48:3000';
|
|
80
|
+
const baseUrl = defaultUrl
|
|
81
81
|
const proceed = await prompter.confirm({
|
|
82
82
|
message: '是否现在生成配对码?',
|
|
83
83
|
initialValue: true,
|
|
@@ -88,19 +88,18 @@ const clawcontrolOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
88
88
|
|
|
89
89
|
await prompter.note('Creating pairing token...');
|
|
90
90
|
|
|
91
|
+
// 使用 GET + 浏览器 User-Agent(部分 WAF/Nginx 会拦截 curl/Node 请求)
|
|
91
92
|
let createRes: Response;
|
|
92
93
|
try {
|
|
93
94
|
createRes = await fetch(`${baseUrl}/plugin/create-pairing-token`, {
|
|
94
|
-
|
|
95
|
-
headers: { 'Content-Type': 'application/json' },
|
|
96
|
-
body: JSON.stringify({ backendUrl: baseUrl }),
|
|
95
|
+
headers: { 'User-Agent': 'Mozilla/5.0 (compatible; ClawControl/1.0)' },
|
|
97
96
|
});
|
|
98
97
|
} catch (e: any) {
|
|
99
98
|
const code = e?.cause?.code ?? e?.code;
|
|
100
99
|
const msg = code === 'ECONNREFUSED'
|
|
101
100
|
? `Cannot connect to ${baseUrl} - is the backend running? Default: https://clawai.rethinkingstudio.com`
|
|
102
101
|
: code === 'ENOTFOUND'
|
|
103
|
-
? `DNS lookup failed for ${baseUrl} - check network`
|
|
102
|
+
? `DNS lookup failed for ${baseUrl} - check network. Set CLAWCONTROL_BACKEND_URL if using different backend`
|
|
104
103
|
: e?.message || String(e);
|
|
105
104
|
throw new Error(`Fetch failed: ${msg}`);
|
|
106
105
|
}
|
|
@@ -112,7 +111,7 @@ const clawcontrolOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
112
111
|
|
|
113
112
|
const { pairingToken, expiresIn } = (await createRes.json()) as { pairingToken: string; expiresIn: number };
|
|
114
113
|
|
|
115
|
-
const qrContent = JSON.stringify({
|
|
114
|
+
const qrContent = JSON.stringify({ pairingToken });
|
|
116
115
|
|
|
117
116
|
await prompter.note(
|
|
118
117
|
`Scan the QR code below with ClawControl iOS App (expires in ${expiresIn}s):`
|
|
@@ -130,7 +129,9 @@ const clawcontrolOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
130
129
|
|
|
131
130
|
while (Date.now() < deadline) {
|
|
132
131
|
await new Promise((r) => setTimeout(r, pollInterval));
|
|
133
|
-
const statusRes = await fetch(`${baseUrl}/plugin/pairing-status?pairingToken=${encodeURIComponent(pairingToken)}
|
|
132
|
+
const statusRes = await fetch(`${baseUrl}/plugin/pairing-status?pairingToken=${encodeURIComponent(pairingToken)}`, {
|
|
133
|
+
headers: { 'User-Agent': 'Mozilla/5.0 (compatible; ClawControl/1.0)' },
|
|
134
|
+
});
|
|
134
135
|
const status = (await statusRes.json()) as { status: string; claimed?: boolean; apiToken?: string };
|
|
135
136
|
if (status.claimed && status.apiToken) {
|
|
136
137
|
apiToken = status.apiToken;
|