cdsa-harness 0.22.1 → 0.22.3

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": "cdsa-harness",
3
- "version": "0.22.1",
3
+ "version": "0.22.3",
4
4
  "description": "AI 에이전트의 내부 동작을 단계별로 드러내는 교육용 터미널 하네스. 실시간 스트리밍 + OpenAI/Claude/OpenRouter + MCP + npm 플러그인·크로스포맷 스킬.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/builtins.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // 스킬/플러그인/버전을 바꾼 뒤 `node scripts/gen-builtins.mjs` 로 재생성하세요.
3
3
  import p0 from "../plugins/hwpx_read.mjs";
4
4
 
5
- export const VERSION = "0.22.1";
5
+ export const VERSION = "0.22.3";
6
6
 
7
7
  export const BUILTIN_PLUGINS = [p0];
8
8
 
package/src/cli.js CHANGED
@@ -549,6 +549,12 @@ async function runSetup(ask, cfg) {
549
549
  return false;
550
550
  }
551
551
  cfg.provider = provider;
552
+ // ollama 설정이 남긴 base_url 잔재는 다른 provider 의 요청까지 그 주소로 보내버린다.
553
+ // provider 를 새로 고르면 지운다(ollama 는 아래에서 다시 채워진다).
554
+ if (provider !== "ollama" && cfg.base_url) {
555
+ console.log(c.dim(`(이전 설정의 base_url(${cfg.base_url}) 을 지웠어요 — ${provider} 공식 엔드포인트를 사용합니다)`));
556
+ cfg.base_url = "";
557
+ }
552
558
 
553
559
  if (provider === "mock") {
554
560
  cfg.model = "mock-agent";
@@ -1263,6 +1269,10 @@ export async function main(argv = []) {
1263
1269
  const p = user.split(/\s+/)[1];
1264
1270
  if (!PROVIDERS.includes(p)) { console.log(c.yellow(`provider 는 ${PROVIDERS.join("/")} 중 하나.`)); continue; }
1265
1271
  cfg.provider = p;
1272
+ if (p !== "ollama" && cfg.base_url) {
1273
+ console.log(c.dim(`(이전 설정의 base_url(${cfg.base_url}) 을 지웠어요 — ${p} 공식 엔드포인트를 사용합니다)`));
1274
+ cfg.base_url = "";
1275
+ }
1266
1276
  if (SUGGESTED_MODELS[p]?.length) cfg.model = SUGGESTED_MODELS[p][0];
1267
1277
  loop.client = makeClient(cfg);
1268
1278
  loop.reset();
package/src/llm.js CHANGED
@@ -57,7 +57,7 @@ export class LLMClient {
57
57
  res = await fetch(url, { method: "POST", headers, body: json, signal: ctrl.signal });
58
58
  } catch (e) {
59
59
  clearTimeout(timer);
60
- throw new LLMError(this._netErrorMessage(e));
60
+ throw new LLMError(this._netErrorMessage(e, url));
61
61
  }
62
62
  if (!res.ok) {
63
63
  clearTimeout(timer);
@@ -67,12 +67,8 @@ export class LLMClient {
67
67
  return { res, started, timer, bodyBytes: Buffer.byteLength(json, "utf8") };
68
68
  }
69
69
 
70
- _netErrorMessage(e) {
71
- let msg = `네트워크 오류: ${e.message}`;
72
- if (this.provider === "ollama") {
73
- msg += "\n ↳ Ollama 가 실행 중인지 확인하세요: `ollama serve` (모델 설치: `ollama pull qwen2.5:7b`)";
74
- }
75
- return msg;
70
+ _netErrorMessage(e, url = "") {
71
+ return describeNetError(e, this.provider, this.timeout, url);
76
72
  }
77
73
 
78
74
  async _post(url, headers, body) {
@@ -84,7 +80,7 @@ export class LLMClient {
84
80
  try {
85
81
  res = await fetch(url, { method: "POST", headers, body: json, signal: ctrl.signal });
86
82
  } catch (e) {
87
- throw new LLMError(this._netErrorMessage(e));
83
+ throw new LLMError(this._netErrorMessage(e, url));
88
84
  } finally {
89
85
  clearTimeout(timer);
90
86
  }
@@ -232,6 +228,81 @@ export class LLMClient {
232
228
  }
233
229
  }
234
230
 
231
+ // Node 내장 fetch(undici)는 실패하면 겉면 메시지가 "fetch failed" 하나뿐이고,
232
+ // 진짜 원인(DNS 실패·프록시·인증서 등)은 e.cause 체인 안에 숨어 있다.
233
+ // 여기서 원인을 끝까지 파고들어 사용자에게 코드와 해결 힌트까지 보여준다.
234
+ export function describeNetError(e, provider = "", timeout = 0, url = "") {
235
+ // 자체 타임아웃(AbortController)에 걸린 경우: fetch 는 AbortError 를 던진다.
236
+ if (e?.name === "AbortError" || e?.name === "TimeoutError") {
237
+ return `네트워크 오류: 응답 시간 초과(${timeout}ms). 네트워크가 느리거나 요청이 너무 클 수 있어요.`;
238
+ }
239
+
240
+ // cause 체인(+AggregateError.errors)을 평탄화해서 원인 오류들을 모두 수집.
241
+ const causes = [];
242
+ const seen = new Set();
243
+ const walk = (err) => {
244
+ if (!err || typeof err !== "object" || seen.has(err)) return;
245
+ seen.add(err);
246
+ causes.push(err);
247
+ if (Array.isArray(err.errors)) err.errors.forEach(walk);
248
+ walk(err.cause);
249
+ };
250
+ walk(e?.cause);
251
+
252
+ const codes = [...new Set(causes.map((c) => c.code).filter(Boolean))];
253
+ const detail = causes.map((c) => c.message).filter(Boolean).slice(-1)[0] || "";
254
+
255
+ let msg = `네트워크 오류: ${e?.message || e}`;
256
+ if (detail && detail !== e?.message) msg += `\n ↳ 원인: ${detail}${codes.length ? ` [${codes.join(", ")}]` : ""}`;
257
+ else if (codes.length) msg += `\n ↳ 원인 코드: ${codes.join(", ")}`;
258
+
259
+ const has = (...cs) => cs.some((c) => codes.includes(c));
260
+
261
+ // provider 는 클라우드(anthropic 등)인데 요청이 로컬 주소로 가는 경우:
262
+ // 이전에 ollama 설정 등이 남긴 config.json 의 base_url 잔재가 원인이다.
263
+ // 이때 방화벽/프록시 힌트는 오답이므로 이 안내만 보여주고 끝낸다.
264
+ const localUrl = /^https?:\/\/(localhost|127\.0\.0\.1|\[?::1\]?)([:/]|$)/i.test(url);
265
+ if (localUrl && provider && provider !== "ollama") {
266
+ msg +=
267
+ `\n ↳ provider 는 '${provider}' 인데 요청이 로컬 주소(${url})로 가고 있어요. ` +
268
+ "설정 파일(config.json)에 이전 ollama 설정의 base_url 이 남아 있을 가능성이 큽니다.\n" +
269
+ " ↳ 해결: /setup 을 다시 실행하거나, config.json 에서 \"base_url\" 값을 지우고 재시작하세요.";
270
+ return msg;
271
+ }
272
+
273
+ if (has("ENOTFOUND", "EAI_AGAIN")) {
274
+ msg += "\n ↳ DNS 조회 실패예요. 인터넷 연결을 확인하세요. 사내망이라면 프록시 뒤일 가능성이 큽니다(아래 프록시 안내 참고).";
275
+ }
276
+ if (has("ECONNREFUSED", "ETIMEDOUT", "ECONNRESET", "EHOSTUNREACH", "ENETUNREACH", "UND_ERR_CONNECT_TIMEOUT")) {
277
+ msg += "\n ↳ 서버까지 연결이 안 돼요. 방화벽·VPN·보안 프로그램이 막고 있거나 프록시가 필요한 환경일 수 있습니다.";
278
+ }
279
+ if (
280
+ has(
281
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
282
+ "SELF_SIGNED_CERT_IN_CHAIN",
283
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
284
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
285
+ "CERT_HAS_EXPIRED",
286
+ "ERR_TLS_CERT_ALTNAME_INVALID",
287
+ )
288
+ ) {
289
+ msg +=
290
+ "\n ↳ TLS 인증서 검증 실패 — 회사 보안 장비가 HTTPS 를 가로채는(SSL 인터셉트) 환경으로 보여요. " +
291
+ "사내 루트 CA 인증서(pem)를 받아 `NODE_EXTRA_CA_CERTS=<CA 파일 경로>` 환경변수를 설정하고 다시 실행하세요.";
292
+ }
293
+ // Node 의 fetch 는 브라우저와 달리 시스템/환경변수 프록시 설정을 기본으로 무시한다.
294
+ // 프록시가 원인일 수 있는 실패라면 사용법을 알려준다.
295
+ if (codes.length === 0 || has("ENOTFOUND", "EAI_AGAIN", "ECONNREFUSED", "ETIMEDOUT", "ECONNRESET", "UND_ERR_CONNECT_TIMEOUT")) {
296
+ msg +=
297
+ "\n ↳ 프록시 환경이라면: Node 의 fetch 는 HTTPS_PROXY 설정을 기본으로 무시해요. " +
298
+ "`NODE_USE_ENV_PROXY=1` 과 `HTTPS_PROXY=http://<프록시주소:포트>` 환경변수를 함께 설정하고 다시 실행하세요(Node 22.18+).";
299
+ }
300
+ if (provider === "ollama") {
301
+ msg += "\n ↳ Ollama 가 실행 중인지 확인하세요: `ollama serve` (모델 설치: `ollama pull qwen2.5:7b`)";
302
+ }
303
+ return msg;
304
+ }
305
+
235
306
  function trim(s) {
236
307
  s = String(s || "");
237
308
  return s.length > 400 ? s.slice(0, 400) + " …" : s;