feat(core): 자기지식 접지·웹 접근·환경 자가점검 — 할루시네이션 방어 3중화 (v2.2.247)
- Alignment Self-Learning: 자가 조사(질문 전 두뇌 검색)·사용자 답변 두뇌 저장·핵심메시지/프로젝트 컨텍스트 주입 (alignmentResearch.ts 신규)
- 웹 접근: Bridge 폴백 직접 fetch(webFetch.ts 신규)·<fetch_url> 액션 태그·기업 모드 URL/아키텍처 컨텍스트 주입·bare 도메인 인식
- 트리거 버그 수정: startsWith('/') 가 절대경로를 슬래시 명령으로 오인 — 분석 지시·URL 주입 전멸 원인 (회귀 테스트 고정)
- 자기지식 접지: 기능 인벤토리 lazy 재생성·학습 메커니즘 정본 섹션·[인벤토리 대조] 태그 의무화·결정론적 재구현 제안 정정 훅(featureConceptMap.ts 신규)
- 환경 자가점검: HealthCheckMonitor 에 Bridge/두뇌 볼륨/git 자격증명/확장 버전 검사 4종 + readyBar ⚠ 표시
- 두뇌 동기화: 원격 미설정 시 로컬 새로고침 모드·staged 기준 commit 판정·인증 부재 안내
- 기타: outputFormat 기본 markdown(제목 렌더 복구)·레슨/행동제약 truncation 보호 구역 이동·[CONTEXT] 절단 우선순위 재정렬
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { HandlerContext } from './types';
|
||||
import { buildUrlContext } from '../../lib/contextBuilders/urlContext';
|
||||
|
||||
/**
|
||||
* Action 15: Fetch URL (read-only — transaction record 불필요)
|
||||
*
|
||||
* LLM 이 작업 중 웹 페이지의 실제 내용이 필요할 때 emit 하는 태그.
|
||||
* 결과 블록을 chatHistory 에 internal push — read_file 과 동일 패턴이라
|
||||
* 일반 챗의 continuation loop(컨텍스트 주입 → 자동 재호출)가 그대로 작동해
|
||||
* fetch 직후 모델이 내용을 분석한다.
|
||||
*
|
||||
* buildUrlContext 재사용: Bridge 추출 우선 → 직접 fetch 폴백 → 정직 실패
|
||||
* 블록 + 5분 캐시. 실패 블록도 chatHistory 에 push 한다 — 모델이 "가져왔다"고
|
||||
* 지어내지 않고 실패 사실을 사용자에게 전달해야 하므로.
|
||||
*/
|
||||
const FETCH_URL_MAX_PER_TURN = 2;
|
||||
|
||||
export async function applyWebFetchActions(ctx: HandlerContext): Promise<void> {
|
||||
const { aiMessage, report } = ctx;
|
||||
const fetchRegex = /<fetch_url\s+url=['"]?(https?:\/\/[^'">\s]+)['"]?\s*\/?>(?:<\/fetch_url>)?/gi;
|
||||
let match;
|
||||
let handled = 0;
|
||||
const seen = new Set<string>();
|
||||
while ((match = fetchRegex.exec(aiMessage)) !== null) {
|
||||
if (handled >= FETCH_URL_MAX_PER_TURN) {
|
||||
report.push(`⚠️ fetch_url 한도 초과 — 회당 최대 ${FETCH_URL_MAX_PER_TURN}개만 처리합니다.`);
|
||||
break;
|
||||
}
|
||||
const url = match[1].trim();
|
||||
if (seen.has(url)) continue;
|
||||
seen.add(url);
|
||||
handled++;
|
||||
try {
|
||||
const block = await buildUrlContext(url);
|
||||
const ok = block.includes('실데이터');
|
||||
report.push(ok ? `🌐 Fetched: ${url}` : `⚠️ Fetch failed: ${url}`);
|
||||
ctx.chatHistory.push({ role: 'system', content: block, internal: true });
|
||||
} catch (err: any) {
|
||||
// buildUrlContext 는 throw 하지 않지만 방어적으로.
|
||||
report.push(`⚠️ Fetch error: ${url} — ${String(err?.message ?? err).slice(0, 100)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user