- Tool interface declares required permissions via requires field - scoped-context builds a least-privileged ToolContext per call - ToolAuditLogger appends each tool invocation to a Garnet stream - Operations CLI gains tool-audit:list and tool-audit:show commands - All onboarding and moderation tools annotated with explicit requires
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { z } from "zod";
|
|
import { analyzeNicknameIssues } from "@skills/onboarding/onboarding-templates";
|
|
import type { Tool } from "../tool.js";
|
|
|
|
const argsSchema = z.object({
|
|
nickname: z.string().min(1),
|
|
});
|
|
|
|
const nicknameIssueSchema = z.object({
|
|
kind: z.enum([
|
|
"missing-tier",
|
|
"invalid-age",
|
|
"missing-gender",
|
|
"wrong-separator",
|
|
"unknown-tier",
|
|
"other",
|
|
]),
|
|
message: z.string(),
|
|
suggestion: z.string().optional(),
|
|
});
|
|
|
|
const resultSchema = z.object({
|
|
valid: z.boolean(),
|
|
issues: z.array(nicknameIssueSchema),
|
|
normalized: z.string().optional(),
|
|
});
|
|
|
|
export const validateNicknameTool: Tool<
|
|
z.infer<typeof argsSchema>,
|
|
z.infer<typeof resultSchema>
|
|
> = {
|
|
name: "validate-nickname",
|
|
description:
|
|
"새내기 닉네임 형식이 이름/출생 연도/성별/티어 규칙에 맞는지 검사하고, 틀린 부분을 구조화해서 반환한다.",
|
|
requires: [],
|
|
argsSchema,
|
|
resultSchema,
|
|
execute(args) {
|
|
const normalized = args.nickname.trim();
|
|
const issues = analyzeNicknameIssues(normalized);
|
|
|
|
const result: z.infer<typeof resultSchema> = {
|
|
valid: issues.length === 0,
|
|
issues,
|
|
};
|
|
|
|
if (issues.length === 0) {
|
|
result.normalized = normalized;
|
|
}
|
|
|
|
return Promise.resolve(result);
|
|
},
|
|
};
|