示例工程 60-tool-registry-approval

60-tool-registry-approval/app/.tsc/shared/tools.d.ts

typescript · 1.9 KB

export type Risk = "read" | "write" | "exec" | "network";
export type ApprovalDecision = "auto" | "deny" | "allow-once" | "allow-session" | "use-grant";
export type ToolField = {
    name: string;
    type: "string" | "number";
    required: boolean;
};
export type ToolDef = {
    id: string;
    name: string;
    risk: Risk;
    description: string;
    timeoutMs: number;
    maxOutput: number;
    fields: ToolField[];
};
export type ToolCall = {
    scenarioId: string;
    toolId: string;
    args: Record<string, string>;
};
export type Scenario = {
    id: string;
    label: string;
    toolId: string;
    args: Record<string, string>;
    note: string;
    costMs: number;
};
export type ToolStatus = "ok" | "denied" | "approval-required" | "timeout" | "invalid";
export type ToolResult = {
    scenarioId: string;
    toolId: string;
    risk: Risk;
    status: ToolStatus;
    decision: ApprovalDecision | "grant" | "policy";
    durationMs: number;
    summary: string;
    output: string;
};
export type AuditEntry = ToolResult & {
    seq: number;
    at: number;
    approvedBy: "auto" | "user" | "policy" | "none";
};
export declare const TOOLS: ToolDef[];
export declare const SCENARIOS: Scenario[];
export declare function toolById(id: string): ToolDef | undefined;
export declare function scenarioById(id: string): Scenario | undefined;
export declare function validateArgs(tool: ToolDef, args: Record<string, string>): string | null;
export declare function isOutsideWorkspace(path: string): boolean;
export declare function needsApproval(tool: ToolDef): boolean;
export type RunInput = {
    scenarioId: string;
    decision: ApprovalDecision;
};
export type RunContext = {
    grants: Set<string>;
    sleep: (ms: number) => Promise<void>;
};
export declare function runScenario(input: RunInput, context: RunContext): Promise<ToolResult>;
//# sourceMappingURL=tools.d.ts.map