@agentvalet/register 0.5.1 → 0.5.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.
Files changed (2) hide show
  1. package/dist/index.js +12 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -874,9 +874,18 @@ async function callCliAuth(body) {
874
874
  },
875
875
  body: JSON.stringify(body)
876
876
  });
877
- const json = await res.json();
878
- if (!res.ok) throw new Error(json.error ?? `HTTP ${res.status}`);
879
- return json;
877
+ const text = await res.text();
878
+ let json = null;
879
+ try {
880
+ json = text ? JSON.parse(text) : null;
881
+ } catch {
882
+ }
883
+ if (!res.ok) {
884
+ const err = json?.error ?? text ?? `HTTP ${res.status}`;
885
+ const detail = json?.detail ?? "";
886
+ throw new Error(detail ? `${err}: ${detail}` : err);
887
+ }
888
+ return json ?? {};
880
889
  }
881
890
  async function browserLogin() {
882
891
  const state = crypto.randomUUID();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/register",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {