mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 08:35:57 +00:00
feat: vendor permission system source
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { classifyToolKind } from "./access-intent/tool-kind";
|
||||
|
||||
// NOTE: the ask prompts are now payload builders under src/presentation/, and
|
||||
// denial text is a render over the payload (presentation/agent-renderer.ts).
|
||||
// This module retains only the pre-check reasons, refused before any payload
|
||||
// exists to render.
|
||||
|
||||
export function formatMissingToolNameReason(): string {
|
||||
return "Tool call was blocked because no tool name was provided. Use a registered tool name from pi.getAllTools().";
|
||||
}
|
||||
|
||||
export function formatUnknownToolReason(
|
||||
toolName: string,
|
||||
availableToolNames: readonly string[],
|
||||
): string {
|
||||
const preview = availableToolNames.slice(0, 10);
|
||||
const suffix = availableToolNames.length > preview.length ? ", ..." : "";
|
||||
const availableList =
|
||||
preview.length > 0 ? `${preview.join(", ")}${suffix}` : "none";
|
||||
|
||||
const mcpHint =
|
||||
classifyToolKind(toolName) === "mcp"
|
||||
? ""
|
||||
: ' If this was intended as an MCP server tool, call the registered \'mcp\' tool when available (for example: {"tool":"server:tool"}).';
|
||||
|
||||
return `Tool '${toolName}' is not registered in this runtime and was blocked before permission checks.${mcpHint} Registered tools: ${availableList}.`;
|
||||
}
|
||||
Reference in New Issue
Block a user