@shulex/cxclawctl 0.1.11 → 0.1.12

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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "plugin": {
4
- "pluginVersion": "0.1.11",
5
- "cliVersion": "0.1.11",
4
+ "pluginVersion": "0.1.12",
5
+ "cliVersion": "0.1.12",
6
6
  "toolSchemaVersion": "1",
7
7
  "serverApiVersion": "1"
8
8
  },
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ var AUTH_SERVER_URL = "https://ai.solvea.cx/api_v2/ticket";
12
12
  // package.json
13
13
  var package_default = {
14
14
  name: "@shulex/cxclawctl",
15
- version: "0.1.11",
15
+ version: "0.1.12",
16
16
  description: "Solvea CXClaw CLI and Codex plugin runtime",
17
17
  type: "module",
18
18
  bin: {
@@ -75,9 +75,17 @@ var HttpError = class extends Error {
75
75
  this.status = status;
76
76
  this.responseBody = responseBody;
77
77
  this.name = "HttpError";
78
+ try {
79
+ const value = JSON.parse(responseBody);
80
+ const code = Number(value?.code);
81
+ this.responseCode = Number.isFinite(code) ? code : void 0;
82
+ } catch {
83
+ this.responseCode = void 0;
84
+ }
78
85
  }
79
86
  status;
80
87
  responseBody;
88
+ responseCode;
81
89
  };
82
90
  function unwrap(value) {
83
91
  if (value && typeof value === "object" && Object.keys(value).length === 1 && "data" in value) return value.data;
@@ -165,6 +173,9 @@ var loginInFlight;
165
173
  function publicAuthStatus(session) {
166
174
  return { ok: true, loggedIn: true, email: session.email, channel: session.channel, accessExpiresAt: session.accessExpiry };
167
175
  }
176
+ function isAuthorizationPending(error) {
177
+ return error instanceof HttpError && (error.status === 428 || error.responseCode === 428);
178
+ }
168
179
  async function authorizeDevice(channel, runtime) {
169
180
  const session = { channel, accessToken: "", refreshToken: "", accessExpiry: 0, employeeId: "", email: "" };
170
181
  const start = await runtime.start(session);
@@ -187,7 +198,7 @@ ${start.verificationUriComplete}
187
198
  runtime.log("\u9489\u9489\u6388\u6743\u6210\u529F\uFF0C\u7EE7\u7EED\u6267\u884C\u5F53\u524D\u547D\u4EE4\u3002");
188
199
  return session;
189
200
  } catch (error) {
190
- if (!(error instanceof HttpError) || error.status !== 428) throw error;
201
+ if (!isAuthorizationPending(error)) throw error;
191
202
  if (runtime.now() >= nextProgressAt) {
192
203
  runtime.log("\u4ECD\u5728\u7B49\u5F85\u9489\u9489\u6388\u6743\u2026\u2026");
193
204
  nextProgressAt = runtime.now() + 15e3;