@4yi/cli 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4yi/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "4YI command-line launcher for OAuth login and OpenCode runtime",
5
5
  "type": "module",
6
6
  "bin": {
package/src/config.mjs CHANGED
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
 
5
- export const DEFAULT_BASE_URL = "https://4yi.ai";
5
+ export const DEFAULT_BASE_URL = "https://app.4yi.ai";
6
6
 
7
7
  export function normalizeBaseUrl(value) {
8
8
  return String(value || DEFAULT_BASE_URL).replace(/\/+$/, "");
package/src/http.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  export async function requestJson(baseUrl, path, options = {}) {
2
- const res = await fetch(`${baseUrl}${path}`, {
2
+ const url = `${baseUrl}${path}`;
3
+ const res = await fetch(url, {
3
4
  ...options,
4
5
  headers: {
5
6
  "content-type": "application/json",
@@ -8,7 +9,15 @@ export async function requestJson(baseUrl, path, options = {}) {
8
9
  },
9
10
  });
10
11
  const text = await res.text();
11
- const body = text ? JSON.parse(text) : null;
12
+ let body = null;
13
+ if (text) {
14
+ try {
15
+ body = JSON.parse(text);
16
+ } catch {
17
+ const contentType = res.headers.get("content-type") || "unknown content type";
18
+ throw new Error(`Expected JSON from ${url} but received ${contentType} (HTTP ${res.status})`);
19
+ }
20
+ }
12
21
  if (!res.ok) {
13
22
  const message = body?.error?.message || body?.error || `HTTP ${res.status}`;
14
23
  const err = new Error(message);