gpteam 0.1.13 → 0.1.14

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/lib/bench.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import dns from 'node:dns';
2
2
  import https from 'node:https';
3
3
  import { performance } from 'node:perf_hooks';
4
+ import { formatNetworkError } from './errors.js';
4
5
  import { inspectSSEBody } from './sse.js';
5
6
 
6
7
  const MISSING_LATENCY_MS = 999999;
@@ -106,7 +107,7 @@ async function measureHealth(url) {
106
107
  error: response.ok ? '' : `health HTTP ${response.status}`
107
108
  };
108
109
  } catch (error) {
109
- return { ok: false, status: 0, totalMs: performance.now() - started, error: error.message };
110
+ return { ok: false, status: 0, totalMs: performance.now() - started, error: formatNetworkError(error) };
110
111
  }
111
112
  }
112
113
 
@@ -186,7 +187,7 @@ function measureStream(baseUrl, options) {
186
187
  status: 0,
187
188
  ...timings,
188
189
  totalMs: performance.now() - started,
189
- error: error.message
190
+ error: formatNetworkError(error)
190
191
  });
191
192
  });
192
193
  request.end(payload);
package/lib/errors.js ADDED
@@ -0,0 +1,24 @@
1
+ export function formatNetworkError(error) {
2
+ const details = [];
3
+ const message = error && error.message ? String(error.message) : String(error || 'network error');
4
+ if (message) details.push(message);
5
+
6
+ let cause = error && error.cause;
7
+ const seen = new Set();
8
+ while (cause && !seen.has(cause)) {
9
+ seen.add(cause);
10
+ const causeDetails = [
11
+ cause.code,
12
+ cause.errno && cause.errno !== cause.code ? cause.errno : '',
13
+ cause.syscall,
14
+ cause.hostname,
15
+ cause.address,
16
+ cause.port ? `port ${cause.port}` : ''
17
+ ].filter(Boolean);
18
+ if (cause.message && cause.message !== message) causeDetails.push(cause.message);
19
+ if (causeDetails.length) details.push(causeDetails.join(' '));
20
+ cause = cause.cause;
21
+ }
22
+
23
+ return [...new Set(details)].join(',') || 'network error';
24
+ }
package/lib/help.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export const PACKAGE_NAME = 'gpteam';
2
- export const PACKAGE_VERSION = '0.1.13';
2
+ export const PACKAGE_VERSION = '0.1.14';
3
3
 
4
4
  export function getHelpText() {
5
5
  return [
package/lib/models.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { formatNetworkError } from './errors.js';
2
+
1
3
  export const FALLBACK_MODELS = {
2
4
  'gpt-5.2': {
3
5
  id: 'gpt-5.2',
@@ -73,13 +75,18 @@ export function normalizeModels(payload) {
73
75
  }
74
76
 
75
77
  export async function fetchModels(baseUrl, apiKey, options = {}) {
76
- const response = await fetch(`${baseUrl.replace(/\/$/, '')}/models`, {
77
- signal: makeTimeoutSignal(options.timeoutMs || 15000),
78
- headers: {
79
- Authorization: `Bearer ${apiKey}`,
80
- 'User-Agent': 'gpteam-api-config/0.1'
81
- }
82
- });
78
+ let response;
79
+ try {
80
+ response = await fetch(`${baseUrl.replace(/\/$/, '')}/models`, {
81
+ signal: makeTimeoutSignal(options.timeoutMs || 15000),
82
+ headers: {
83
+ Authorization: `Bearer ${apiKey}`,
84
+ 'User-Agent': 'gpteam-api-config/0.1'
85
+ }
86
+ });
87
+ } catch (error) {
88
+ throw new Error(`/v1/models 请求失败:${formatNetworkError(error)}`);
89
+ }
83
90
  if (!response.ok) {
84
91
  const detail = await readResponseError(response);
85
92
  throw new Error(`/v1/models 返回 HTTP ${response.status}${detail ? `:${detail}` : ''}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gpteam",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "GPTeam API interactive client configurator and ingress benchmark CLI.",
5
5
  "type": "module",
6
6
  "bin": {