From 9d193735255bc46e45f0a7fe77a23e50c2e35101 Mon Sep 17 00:00:00 2001 From: kim Date: Fri, 23 Oct 2026 16:37:27 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B8=B8=EC=B0=BE=EA=B8=B0=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=20=EC=B6=9C=EB=B0=9C=EC=A7=80=EB=A5=BC=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=20=EC=A7=91(=EA=B5=AC=EB=AF=B8=EC=8B=9C=20?= =?UTF-8?q?=ED=98=95=EA=B3=A1=EB=8F=99)=EC=9C=BC=EB=A1=9C=20=E2=80=94=20?= =?UTF-8?q?=EC=9B=90=EB=9E=98=20=EA=B5=AC=EB=AF=B8=EC=8B=9C=20=EC=A4=91?= =?UTF-8?q?=EC=8B=AC.=20=EC=9E=A5=EC=86=8C=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EA=B8=B0=EC=A4=80=20=EC=9C=84=EC=B9=98(=EA=B5=AC=EB=AF=B8?= =?UTF-8?q?=EC=8B=9C)=EB=8A=94=20=EA=B7=B8=EB=8C=80=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- src/gateway/chat/system-prompt.ts | 2 +- src/tools/kakao-route.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gateway/chat/system-prompt.ts b/src/gateway/chat/system-prompt.ts index faaac83..2ca64c9 100644 --- a/src/gateway/chat/system-prompt.ts +++ b/src/gateway/chat/system-prompt.ts @@ -229,7 +229,7 @@ export function buildChatSystemPrompt(input: SystemPromptInput): string { ? '\nPLACE SEARCH: For a specific place, business, or "near X" request in Korea (restaurants, pharmacies, stations, an address or phone number), call place_search FIRST and answer from its results — never write an address or phone number from memory. Default reference point is 구미시; pass location for another area. Put the 카카오맵 `지도:` URL from the result for the top place on its own line so it renders as an inline map, and mention the others by name. Opening hours are not in the result: point to its 상세 link instead of guessing.' : ''; const routeSearchRuleBlock = toolNames.has('route_search') - ? '\nROUTE SEARCH: For driving directions, travel time, distance, or toll questions within Korea, call route_search and answer ONLY from its numbers — never estimate a drive time or toll from memory. Default origin is 구미시; pass origin if the user names one. Put the 길찾기 지도 link from the result alone on its own line, with no label in front — the client shows it as an inline route map. For 대중교통/도보/자전거 say route_search covers driving only and give that link.' + ? '\nROUTE SEARCH: For driving directions, travel time, distance, or toll questions within Korea, call route_search and answer ONLY from its numbers — never estimate a drive time or toll from memory. Default origin is the user\'s home (구미시 형곡동); pass origin if the user names one. Put the 길찾기 지도 link from the result alone on its own line, with no label in front — the client shows it as an inline route map. For 대중교통/도보/자전거 say route_search covers driving only and give that link.' : ''; const mapsRuleBlock = /지도|맵으로|위치(를|가|는)?|주소|어디(에|야|예요|에요|입니까|인가|니|냐|쯤|메)|어디\s*(있|찾|가|계|위치|살|사는|근처)|길\s*찾|가는\s*길|찾아가|찾아오|약도|도로명|지번|좌표|경위도|근처|인근|부근|가까운|\bmap\b|\baddress\b|directions|navigate|where\s+is|how\s+(do\s+i\s+|to\s+)get\s+to|nearby|landmark/i .test(String(input.message || '')) diff --git a/src/tools/kakao-route.ts b/src/tools/kakao-route.ts index fc18e2d..1ebf94e 100644 --- a/src/tools/kakao-route.ts +++ b/src/tools/kakao-route.ts @@ -4,13 +4,16 @@ * "구미에서 현풍까지 얼마나 걸려?", "구미역까지 가는 길" 류. 거리·소요시간·통행료·택시요금과 * 주요 도로 구성, 정체 구간 길이를 돌려주고 카카오맵 길찾기 링크를 붙인다. * 키는 place_search와 같은 REST 키(vault channels.kakao.appKey). 별도 신청 없이 호출된다(2026-10-14 확인). - * 출발지 기본값은 구미시. 지점 해석은 place_search의 resolveCenter(주소 REGION → 키워드 첫 결과)를 쓴다. + * 출발지 기본값은 사용자 집이 있는 구미시 형곡동(2026-10-23, 원래 구미시 중심). 지점 해석은 place_search의 resolveCenter(주소 REGION → 키워드 첫 결과)를 쓴다. */ import { ToolResult } from '../types.js'; import { getConfig } from '../config/config.js'; import { getVault } from '../security/vault.js'; import { resolveCenter, DEFAULT_CENTER } from './kakao-places.js'; +/** 출발지를 말하지 않으면 집에서 출발한다(사용자 거주지, 2026-10-23). place_search의 기준 위치(구미시 중심)와는 별개. */ +export const DEFAULT_ROUTE_ORIGIN = '경북 구미시 형곡동'; + const NAVI_BASE = 'https://apis-navi.kakaomobility.com/v1/directions'; function getRestKey(): string | undefined { @@ -97,7 +100,7 @@ export const routeSearchTool = { name: 'route_search', description: '카카오모빌리티로 국내 자동차 길찾기를 한다: 거리·소요시간·통행료·택시 요금 추정·주요 도로·정체 구간·카카오맵 길찾기 링크를 돌려준다. ' + - '"구미에서 현풍까지 얼마나 걸려?", "OO까지 가는 길", "통행료 얼마야" 같은 요청에 사용. 출발지 기본값은 구미시. ' + + '"구미에서 현풍까지 얼마나 걸려?", "OO까지 가는 길", "통행료 얼마야" 같은 요청에 사용. 출발지 기본값은 사용자 집(구미시 형곡동). ' + '대중교통·도보·자전거는 지원하지 않는다(그럴 땐 돌려주는 카카오맵 링크로 안내). 한국 밖은 불가. 시간·요금은 도구 값만 말할 것.', schema: { destination: 'string', origin: 'string?', waypoints: 'string[]?', priority: 'string?', avoid: 'string[]?' }, jsonSchema: { @@ -105,7 +108,7 @@ export const routeSearchTool = { required: ['destination'], properties: { destination: { type: 'string', description: '도착지 지역·역·건물·장소 이름(예: "현풍", "서울역", "대구 엑스코")' }, - origin: { type: 'string', description: '출발지(선택, 기본 구미시). 예: "구미역", "대구"' }, + origin: { type: 'string', description: '출발지(선택, 기본 집=구미시 형곡동). 예: "구미역", "대구"' }, waypoints: { type: 'array', items: { type: 'string' }, description: '경유지 이름 목록(선택, 최대 5개)' }, priority: { type: 'string', enum: ['RECOMMEND', 'TIME', 'DISTANCE'], description: '경로 기준(기본 RECOMMEND 추천, TIME 최단시간, DISTANCE 최단거리)' }, avoid: { type: 'array', items: { type: 'string', enum: ['toll', 'motorway', 'ferries', 'schoolzone', 'uturn'] }, description: '피할 것(선택): toll 유료도로, motorway 자동차전용도로, ferries, schoolzone, uturn' }, @@ -121,7 +124,7 @@ export const routeSearchTool = { const avoid = (Array.isArray(args?.avoid) ? args.avoid : []).map(String).filter((a: string) => AVOID_OK.has(a)); const viaNames: string[] = (Array.isArray(args?.waypoints) ? args.waypoints : []).map((w: any) => String(w).trim()).filter(Boolean).slice(0, 5); try { - const o = await resolveCenter(String(args?.origin || ''), key); + const o = await resolveCenter(String(args?.origin || '').trim() || DEFAULT_ROUTE_ORIGIN, key); if (!o.found) return { success: false, error: `출발지 "${args.origin}"를 찾지 못했습니다. 더 구체적인 지역·역 이름으로 다시 시도할 것.` }; const d = await resolveCenter(destName, key); if (!d.found) return { success: false, error: `도착지 "${destName}"를 찾지 못했습니다. 더 구체적인 지역·역 이름으로 다시 시도할 것.` };