/** * ToolCategoryRegistry — 외부 도메인 패키지가 LLM tool category 를 동적 등록하는 점. * * 사용 패턴 (외부 패키지의 server bootstrap): * ```ts * import { registerToolCategory } from '@things-factory/board-ai' * * registerToolCategory({ * name: 'board-import', * specs: [ * { kind: 'external', name: 'importBoardAsync', schema: {...}, builder: ... }, * { kind: 'read', name: 'getImportSession', schema: {...}, builder: ... }, * ... * ] * }) * ``` * * board-ai assistant.ts 의 buildBoardEditTools / dispatch / isWriteTool 등이 * 본 registry 에서 자동 도출. * * 정책: * - 카테고리 이름은 unique. 같은 이름으로 재등록하면 덮어쓰기 (외부 패키지의 * hot-reload / dev 환경 대응). console.warn 으로 알림. * - tool name 은 카테고리 간 통틀어 unique. 충돌 시 등록 거부 + 명확한 에러 * (LLM dispatch 가 모호해지지 않도록). * - clear() 는 테스트 전용. 운영 환경에서 호출 금지. */ import type { ToolCategory, ToolSpec } from './types'; /** A registration that was accepted but is not yet what the contract requires. Code + params, not prose. */ export interface ToolRegistryWarning { /** * `tool-doors-undeclared` — nothing said which doors this tool reaches, so the gate leaves it out * of every conversation (`resolveToolScope`) and this names it. * * What those doors require is **not** asked here. Registration runs while modules load, before the * schema stands, so AUTH's field table is still empty; `ai-assistant`'s boot report asks the * schema after it is built (`tool-door-not-in-schema` · `tool-door-has-no-privilege`). */ code: 'tool-doors-undeclared'; params: { category: string; tool: string; kind: ToolSpec['kind']; }; /** For a person reading it; the code and params are what callers act on. */ message: string; } /** * What registered without saying which doors it reaches. A host prints this at boot; the gate has * already left each of these tools out of every conversation. */ export declare function getToolRegistryWarnings(): ReadonlyArray; /** * 카테고리 등록. tool name 충돌 시 throw, 이름 중복 등록 시 덮어쓰기 + warn. */ export declare function registerToolCategory(category: ToolCategory): void; /** * 대화별 도구 노출 제한 — 허용 카테고리 목록. * * `undefined` 는 **제한 없음**(등록된 전부). 호스트가 목록을 주면 그 카테고리에 속한 spec 만 * 정의·실행 대상이 된다. 정의를 숨기는 것만으로는 부족하다 — 모델이 이름을 추측하거나 옛 대화가 * 재생되면 숨긴 도구도 호출되므로 **dispatch 조회(findToolSpec)에도 같은 목록을 넘겨야** 한다. */ export type ToolCategoryFilter = ReadonlyArray | undefined; /** * 등록된 모든 카테고리 (등록 순서 보존). 외부에서 불변 read-only 로 사용. */ export declare function getToolCategories(): ReadonlyArray; /** * 등록된 모든 tool spec 의 평면 view. assistant.ts 의 buildBoardEditTools 가 * LLM tool 정의 합집합으로 사용. */ export declare function getAllToolSpecs(): ReadonlyArray; /** * 허용 카테고리의 spec 평면 view. `undefined` = 전부(= getAllToolSpecs 와 동일). * LLM 도구 정의를 만들 때 이 함수를 쓰면 대화별 노출 제한이 그대로 반영된다. */ export declare function getToolSpecsFor(filter: ToolCategoryFilter): ReadonlyArray; /** * 노출된 카테고리들의 **사용 규율** 모음(등록 순서). 시스템 프롬프트에 붙이는 용도. * * 도구 목록만 보내면 모델은 "무엇이 있는지" 는 알지만 "언제 반드시 불러야 하는지" 는 모른다. * 규율은 도구를 등록한 쪽이 소유하고, 호스트는 노출된 것만 모아 붙인다(도메인 지식이 새지 않는다). */ export declare function getCategoryGuidance(filter: ToolCategoryFilter): string[]; /** * tool name 으로 spec 검색. 없으면 undefined. */ export declare function findToolSpec(name: string, filter?: ToolCategoryFilter): ToolSpec | undefined; /** The name of the category a tool is registered in; undefined for a tool not registered or not allowed. */ export declare function findToolCategory(name: string, filter?: ToolCategoryFilter): string | undefined; /** * tool name 의 카테고리 (read/write/action/external). 미등록 tool 은 undefined. * assistant.ts 의 isReadTool / isWriteTool / isActionTool 이 이 함수에 위임할 수 있다. */ export declare function getToolKind(name: string, filter?: ToolCategoryFilter): ToolSpec['kind'] | undefined; /** * 등록된 tool 인지. dispatch path 가 hardcoded set 와 registry 양쪽 fallback 시 사용. */ export declare function hasTool(name: string, filter?: ToolCategoryFilter): boolean; /** * 카테고리 이름으로 spec 만 추출. */ export declare function getCategorySpecs(categoryName: string): ReadonlyArray; /** * 테스트 전용 — 모든 등록 해제. 운영 환경에서 호출 금지. * * jest 의 setupFilesAfterEach 또는 명시적 afterEach 에서 호출해 테스트 간 격리. * 실제로 STYLING_TOOLS 는 board-ai 자체 부트스트랩에서 다시 등록되므로 clear 후 * 명시 register 가 필요한 것은 동적 카테고리 (board-import 등) 뿐. */ export declare function clearToolRegistry(): void;