@rethinking-studio/clawcontrol 1.0.0 → 1.0.2
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 +12 -9
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -76,12 +76,7 @@ const clawcontrolOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
76
76
|
},
|
|
77
77
|
configure: async ({ cfg, prompter }) => {
|
|
78
78
|
const account = resolveClawControlAccount(cfg);
|
|
79
|
-
const
|
|
80
|
-
const baseUrl = (
|
|
81
|
-
process.env.CLAWCONTROL_BACKEND_URL ||
|
|
82
|
-
(account.backendUrl && !account.backendUrl.includes('localhost') ? account.backendUrl : null) ||
|
|
83
|
-
defaultUrl
|
|
84
|
-
).replace(/\/$/, '');
|
|
79
|
+
const baseUrl = 'https://clawai.rethinkingstudio.com'.replace(/\/$/, '');
|
|
85
80
|
|
|
86
81
|
const proceed = await prompter.confirm({
|
|
87
82
|
message: '是否现在生成配对码?',
|
|
@@ -105,14 +100,22 @@ const clawcontrolOnboardingAdapter: ChannelOnboardingAdapter = {
|
|
|
105
100
|
const msg = code === 'ECONNREFUSED'
|
|
106
101
|
? `Cannot connect to ${baseUrl} - is the backend running? Default: https://clawai.rethinkingstudio.com`
|
|
107
102
|
: code === 'ENOTFOUND'
|
|
108
|
-
? `DNS lookup failed for ${baseUrl} - check network
|
|
103
|
+
? `DNS lookup failed for ${baseUrl} - check network`
|
|
109
104
|
: e?.message || String(e);
|
|
110
105
|
throw new Error(`Fetch failed: ${msg}`);
|
|
111
106
|
}
|
|
112
107
|
|
|
113
108
|
if (!createRes.ok) {
|
|
114
|
-
const
|
|
115
|
-
|
|
109
|
+
const errText = await createRes.text();
|
|
110
|
+
let errMsg = errText;
|
|
111
|
+
try {
|
|
112
|
+
const parsed = JSON.parse(errText);
|
|
113
|
+
if (parsed.details) errMsg = `${parsed.error}: ${parsed.details}`;
|
|
114
|
+
else if (parsed.error) errMsg = parsed.error;
|
|
115
|
+
} catch {
|
|
116
|
+
/* use raw text */
|
|
117
|
+
}
|
|
118
|
+
throw new Error(`Failed to create pairing token: ${errMsg}`);
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
const { pairingToken, expiresIn } = (await createRes.json()) as { pairingToken: string; expiresIn: number };
|